:root {
  --ink: #1c2430;
  --ink-soft: #4a5563;
  --sage: #5b7f6e;
  --sage-deep: #3f5e50;
  --sage-soft: #e7efe9;
  --sand: #f4f0e8;
  --card: #fffcf7;
  --gold: #b08d57;
  --gold-soft: #f3ead8;
  --line: #e4ded3;
  --danger: #9b4b4b;
  --danger-soft: #f5e8e8;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.06);
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-sans: "PingFang SC", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #e8efe9 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e8d8 0%, transparent 50%),
    var(--sand);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--sage-deep); }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 0 0 88px;
  position: relative;
}

/* Top */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(244, 240, 232, 0.88);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--sage) 0%, var(--sage-deep) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 6px 16px rgba(63, 94, 80, 0.25);
}
.brand-text strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.brand-text span {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.member {
  background: var(--gold-soft);
  color: #7a5d2e;
  border: 1px solid #e2d0a8;
}
.pill.guest {
  background: #efece6;
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.hero {
  padding: 22px 18px 8px;
}
.hero h1 {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0.02em;
}
.hero p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

.hint {
  margin: 12px 18px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid #d5e4da;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 18px;
}
.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-height: 112px;
}
.tile:active { transform: scale(0.98); }
.tile .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  margin-bottom: 12px;
  background: var(--sage-soft);
  color: var(--sage-deep);
}
.tile.gold .ico { background: var(--gold-soft); color: #8a6a32; }
.tile h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 650;
}
.tile p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* 首页四大块 */
.hubs {
  padding: 0 18px 20px;
  display: grid;
  gap: 14px;
}
.hub {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.hub-main,
.hub-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
}
.hub-main:active,
.hub-toggle:active { background: rgba(91, 127, 110, 0.06); }
.hub-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  flex-shrink: 0;
  background: var(--sage);
  color: #fff;
}
.hub-ico.drive { background: linear-gradient(145deg, #4a5d73, #2f3d4d); }
.hub-ico.act { background: linear-gradient(145deg, var(--gold), #8a6a32); }
.hub-ico.svc { background: linear-gradient(145deg, #7a8f84, #4f6358); }
.hub h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.03em;
}
.hub-main p,
.hub-toggle p {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}
.hub-arrow,
.hub-chevron {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 16px;
}
.hub-brain .hub-main {
  background: linear-gradient(120deg, rgba(91,127,110,0.12), rgba(176,141,87,0.08));
}
.hub-links {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 12px 14px;
}
.hub.open .hub-links { display: grid; }
.hub-links .tile {
  min-height: 96px;
  box-shadow: none;
}
.export-bar {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px 14px;
  border-top: 1px dashed var(--line);
}
.hub.open .export-bar { display: flex; }
.export-link {
  display: block;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  color: #1a5fb4;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
}
.export-link:hover { color: #0d47a1; }

.drive-tree {
  display: none;
  padding: 0 12px 14px 14px;
  border-top: 1px dashed var(--line);
}
.hub.open .drive-tree { display: block; }
.drive-root {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 8px;
  font-size: 12px;
  color: var(--ink-soft);
}
.drive-root::before {
  content: "💾";
  font-size: 14px;
}
.drive-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.02em;
}
.folder {
  border-left: 2px solid #d7d0c4;
  margin: 0 0 6px 8px;
  padding-left: 10px;
}
.folder .folder {
  margin-left: 4px;
  border-left-color: #c9c2b4;
}
.folder summary {
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 0;
  color: var(--ink);
}
.folder summary::-webkit-details-marker { display: none; }
.folder-body {
  display: grid;
  gap: 6px;
  padding: 0 0 8px 6px;
}
.folder-body button {
  display: inline;
  width: fit-content;
  max-width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 2px 0;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #1a5fb4;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.folder-body button:hover { color: #0d47a1; }
.folder-body button:active { opacity: 0.75; }
.folder-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.folder-chips span {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage-deep);
}

.panel {
  display: none;
  padding: 8px 18px 24px;
  animation: rise 0.28s ease;
}
.panel.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.back {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
.muted { color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 16px;
  background: var(--sage);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.btn:active { background: var(--sage-deep); }
.btn.secondary {
  background: transparent;
  color: var(--sage-deep);
  border: 1px solid var(--sage);
}
.btn.ghost {
  background: #efece6;
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn.warn {
  background: var(--danger);
}
.btn.block { width: 100%; }

label.field {
  display: block;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-soft);
}
label.field input,
label.field select,
label.field textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.item .tag {
  display: inline-block;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  margin-right: 6px;
}
.item .tag.action-destroy { background: var(--danger-soft); color: var(--danger); }
.item .tag.action-sale { background: var(--gold-soft); color: #7a5d2e; }
.item .tag.action-gift { background: #e6eef7; color: #3d5a80; }
.item strong { display: block; margin: 8px 0 4px; font-size: 15px; }
.stat {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat .box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}
.stat .box b {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  margin-top: 4px;
}
.alert {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid #e8cfcf;
}
.ok {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-size: 13px;
  margin-bottom: 12px;
  border: 1px solid #d5e4da;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 50;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.checks label { display: flex; align-items: center; gap: 8px; }
.progress-bar {
  height: 8px;
  background: #efece6;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.progress-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--sage), var(--sage-deep));
}
.sin-rank {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  margin-right: 8px;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  background: rgba(255, 252, 247, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: stretch;
  gap: 4px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  z-index: 30;
}
.tabbar .step-flow {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 2px;
}
.tabbar button {
  border: none;
  background: transparent;
  padding: 6px 4px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--ink-soft);
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.tabbar .tab-mine {
  flex: 0 0 52px;
  border-left: 1px dashed var(--line);
  padding-left: 6px;
}
.tabbar button.active { color: var(--sage-deep); font-weight: 700; }
.tabbar .step-n {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin: 0 auto 3px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: 12px;
  font-weight: 700;
  font-style: normal;
  background: transparent;
}
.tabbar button.active .step-n {
  background: var(--sage-deep, #2f5d4a);
  border-color: var(--sage-deep, #2f5d4a);
  color: #fff;
}
.tabbar .step-n.soft {
  border-style: dashed;
  font-size: 11px;
}
.tabbar .step-arrow {
  flex: 0 0 auto;
  color: #c45c4a;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0 1px;
  margin-top: -12px;
  pointer-events: none;
  user-select: none;
}
#home.panel.active { display: block; }
.hidden { display: none !important; }

/* 大脑图谱 · 模块内总导航（不在首页展开） */
.brain-hub {
  margin-top: 0;
}
.brain-pin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0 0 8px;
}
.brain-pin-head h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  letter-spacing: 0.04em;
}
.brain-pin-head .muted { margin: 4px 0 0; font-size: 12px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.brain-canvas {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.brain-canvas svg {
  display: block;
  width: 100%;
  height: auto;
  min-width: 320px;
}
.brain-canvas-lg svg { min-width: 360px; }
.brain-node {
  cursor: pointer;
}
.brain-node:hover circle,
.brain-node:hover rect {
  filter: brightness(0.97);
  stroke-width: 2.2;
}
.brain-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 10px;
  font-size: 11px;
}
.brain-edit-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.brain-edit-list .field { margin: 0; }
.brain-edit-list .row-label {
  font-size: 11px;
  color: var(--ink-soft);
  margin-bottom: 2px;
}
.auth-script {
  margin: 0 0 12px;
  padding-left: 1.2em;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}
.auth-script li { margin-bottom: 8px; }
.auth-script b { color: var(--ink); }

@media (min-width: 900px) {
  .app {
    max-width: 980px;
    padding-bottom: 40px;
  }
  .grid { grid-template-columns: repeat(3, 1fr); }
  .hub-links { grid-template-columns: repeat(2, 1fr); }
  .hubs { max-width: 720px; }
  .tabbar { display: none; }
  .desktop-wrap {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 18px;
    padding: 0 18px 24px;
  }
  .brain-canvas svg { min-width: 0; }
}
