:root {
  --paper: #f7f4ef;
  --ink: #1a1f24;
  --ink-soft: #5f6770;
  --seal: #c45c3e;
  --moss: #2f6f57;
  --line: #e6dfd4;
  --card: #fffcf8;
  --rail: #f3eee6;
  --shadow: 0 8px 24px rgba(26, 31, 36, .06);
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: #ece7e0;
}
.shell {
  display: flex;
  height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background: var(--paper);
  position: relative;
  overflow: hidden;
}
.rail {
  width: 220px;
  flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 12px 10px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rail-item {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.rail-item:hover, .rail-item.on { background: #fff; }
.rail-item.add { margin-top: 8px; border: 1px dashed var(--line); }
.rail-item.icon { text-align: center; font-size: 16px; letter-spacing: 0; }
.rail-out { margin-top: auto; color: var(--ink-soft); }
.logout-link {
  border: 1.5px solid #0a2156;
  background: #123a7a;
  color: #fff;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 8px;
  line-height: 1.2;
}
.rail-label {
  margin: 14px 12px 4px;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: .12em;
}
.conv-list { display: flex; flex-direction: column; gap: 2px; flex: 1; min-height: 40px; }
.conv-list button {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conv-list button.on { background: #fff; }
.stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage-bar {
  height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.menu-btn {
  width: 36px; height: 36px; padding: 0;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: none;
  overflow: hidden;
}
.menu-btn img { width: 36px; height: 36px; display: block; border-radius: 8px; }
.stage-title { flex: 1; font-family: var(--serif); font-size: 18px; min-width: 0; }
.stage-title button {
  border: 0; background: none; font: inherit; cursor: pointer; color: inherit;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stage-meta { font-size: 11px; color: var(--ink-soft); text-align: right; }
.quiet-clock { font-size: 12px; color: #9aa1a8; font-variant-numeric: tabular-nums; margin-left: 8px; }
.quiet-clock.urgent { color: var(--seal); }
#app { flex: 1; overflow: auto; padding: 16px 16px 20px; }
#app.chat-page {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.shell.auth .rail, .shell.auth .stage-bar { display: none; }
.shell.auth #app { padding: 36px 22px 40px; }
.scrim {
  position: absolute; inset: 0; background: rgba(26,31,36,.28); z-index: 4;
}
.scrim.hidden { display: none; }

.login-hero { text-align: center; margin: 12px 0 28px; }
.login-brand, .auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.login-brand h2, .auth-brand h1 { margin: 0; }
.login-hero .seal {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border: 1.5px solid var(--seal); color: var(--seal);
  display: none;
  place-items: center; font-family: var(--serif); font-size: 28px;
}
.login-hero h2 { margin: 0; font-family: var(--serif); font-size: 32px; letter-spacing: .18em; }
.login-hero p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.code-row { display: flex; gap: 8px; }
.code-row .input { flex: 1; }
.code-row .btn { flex-shrink: 0; padding: 0 12px; min-width: 108px; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.grades button {
  min-height: 40px; border: 1px solid var(--line); background: #fffdf8;
  border-radius: 10px; font-family: inherit; cursor: pointer;
}
.grades button.on { border-color: var(--ink); background: var(--ink); color: #f7f0e4; }
.login-foot { margin-top: 18px; text-align: center; font-size: 11px; color: var(--ink-soft); line-height: 1.6; }
.err { color: var(--seal); font-size: 12px; margin: 0 0 10px; min-height: 18px; }
.search-miss { color: #c62828; font-size: 13px; margin: 12px 0; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.auth-tabs a {
  text-align: center; text-decoration: none; color: var(--ink-soft);
  border-bottom: 2px solid transparent; padding: 8px 0; font-size: 15px;
}
.auth-tabs a.on { color: var(--ink); border-color: var(--seal); font-weight: 600; }

h2.page { margin: 0 0 4px; font-family: var(--serif); font-size: 24px; }
.lede { margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; font-family: var(--serif); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--ink); background: var(--ink); color: #f7f0e4;
  font-size: 14px; cursor: pointer; font-family: inherit;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
.input {
  width: 100%; min-height: 44px; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-family: inherit; font-size: 14px; background: #fff;
}
.input.area { min-height: 72px; resize: vertical; }
.search-row { display: flex; gap: 8px; margin-bottom: 14px; }
.search-row .input { flex: 1; }
.muted { color: var(--ink-soft); font-size: 12px; }
.empty { text-align: center; padding: 28px 10px; color: var(--ink-soft); font-size: 13px; }
.list-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; font: inherit; cursor: pointer; text-align: left;
}
.pill { font-size: 11px; border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; color: var(--moss); white-space: nowrap; }
.tabs3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 12px; }
.tabs3 button {
  border: 1px solid var(--line); background: transparent; border-radius: 999px;
  padding: 8px 0; font: inherit; cursor: pointer;
}
.tabs3 button.on { background: var(--ink); color: #f7f0e4; border-color: var(--ink); }

.thread { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow: auto; padding: 16px; }
.bubble { max-width: 86%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; }
.bubble.bot.play { max-width: 100%; }
.play-q { margin: 12px 0 6px; font-weight: 600; font-size: 13px; }
.play-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.play-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink);
}
.play-chip.on { background: var(--ink); color: #f7f0e4; border-color: var(--ink); }
.play-log { margin: 0 0 8px 18px; padding: 0; font-size: 13px; }
.play-hints { background: #f7f4ef; border-radius: 10px; padding: 8px 10px; margin-bottom: 8px; }
.play-hints p { margin: 0 0 6px; }
.play-hints p:last-child { margin: 0; }
.bubble.bot.play .btn { margin-top: 8px; }
.style-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.style-card {
  text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 14px; padding: 12px; font: inherit; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; gap: 4px;
}
.style-card b { font-size: 14px; }
.style-card span { font-size: 12px; color: var(--ink-soft); }
.style-card.on { border-color: var(--seal); box-shadow: 0 0 0 2px rgba(196,92,62,.18); }
.relic-map { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.relic-bead {
  text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 14px; padding: 12px 14px; font: inherit; cursor: pointer; color: var(--ink);
  display: flex; flex-direction: column; gap: 4px;
}
.relic-bead.locked { opacity: .4; cursor: not-allowed; }
.relic-bead.next { border-color: var(--seal); box-shadow: 0 0 0 2px rgba(196,92,62,.2); }
.relic-bead.open { background: var(--ink); color: #f7f0e4; }
.relic-lv { font-size: 11px; opacity: .7; }
.relic-body { font-size: 13px; line-height: 1.45; }
.composer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 10px 16px 16px;
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.cam-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 18px; flex-shrink: 0;
}
.choice {
  width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 8px;
  border-radius: 12px; border: 1px solid var(--line); background: #fffdf8;
  cursor: pointer; font-family: inherit; font-size: 14px;
}
.choice.selected { border-color: var(--moss); background: #eef5f0; }
.tree { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; padding-left: 12px; border-left: 2px solid var(--line); }
.tree-arm { font-size: 13px; color: var(--ink-soft); }
.tree-arm.now { color: var(--ink); font-weight: 600; }
.tree-arm.dead { text-decoration: line-through; opacity: .5; }
.coach-q { font-family: var(--serif); font-size: 20px; line-height: 1.45; margin: 8px 0 12px; }
.me-page { padding-bottom: 12px; }
.me-cover {
  height: 168px;
  background:
    linear-gradient(160deg, rgba(196,92,62,.18), rgba(47,111,87,.12)),
    #cfc6b8 center/cover no-repeat;
  border-radius: 18px;
  position: relative;
  margin-bottom: 8px;
  cursor: pointer;
  overflow: hidden;
}
.me-cover-hint {
  position: absolute; right: 12px; bottom: 12px;
  font-size: 11px; color: #fff; background: rgba(26,31,36,.42);
  padding: 4px 10px; border-radius: 999px; pointer-events: none;
}
.me-avatar {
  width: 76px; height: 76px; border-radius: 50%; border: 3px solid var(--paper);
  background: #d8d0c4 center/cover no-repeat;
  position: absolute; left: 16px; bottom: -22px; cursor: pointer;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 28px; color: #7a7268;
  box-shadow: var(--shadow);
}
.me-avatar.has-img { color: transparent; }
.me-id {
  margin: 28px 4px 16px 4px;
}
.me-id h3 {
  margin: 0 0 4px; font-family: var(--serif); font-size: 24px; font-weight: 600;
}
.me-id p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.me-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.me-chips span {
  font-size: 11px; padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
}
.me-chips span.on { border-color: #cde3d8; background: #eef5f0; color: var(--moss); }
.me-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 18px;
}
.me-stat {
  border: 1px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 12px 8px 10px; text-align: center; cursor: pointer; font: inherit; color: inherit;
}
.me-stat:hover { border-color: #d4cbbd; background: #fff; }
.me-stat b { display: block; font-family: var(--serif); font-size: 22px; line-height: 1.1; }
.me-stat small { color: var(--ink-soft); font-size: 11px; }
.me-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 4px 14px; margin-bottom: 12px;
}
.me-group h4 {
  margin: 12px 2px 4px; font-size: 11px; color: var(--ink-soft);
  letter-spacing: .14em; font-weight: 500;
}
.me-group .list-row:last-child { border-bottom: 0; }
.me-actions { display: none; }
.kp-block { padding: 8px 0; border-top: 1px dashed var(--line); }
.rail-badge {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--seal); color: #fff; font-size: 11px; line-height: 18px; text-align: center;
}
.rail-badge.hidden { display: none; }
#app.chat-page .thread { min-height: 0; }
.due-banner {
  flex-shrink: 0;
  margin: 12px 16px 0; padding: 10px 12px; border-radius: 12px;
  background: #f8e8e4; color: var(--seal); font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.due-banner button { border: 0; background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 12px; cursor: pointer; font: inherit; }
.onboard {
  position: absolute; inset: 0; z-index: 6; background: rgba(26,31,36,.45);
  display: grid; place-items: end center; padding: 20px;
}
.onboard .card { width: min(420px, 100%); margin: 0; }
.onboard.hidden { display: none; }
.thumb { width: 100%; max-height: 180px; object-fit: contain; border-radius: 8px; background: #111; }

.auth-pane { display: none; }
.rail-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: .22em;
  padding: 8px 12px 16px;
}
.rail-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  display: block;
  letter-spacing: 0;
}

@media (max-width: 900px) {
  .menu-btn { display: grid; place-items: center; }
  .rail {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 5;
    transform: translateX(-102%);
    transition: transform .2s ease;
    width: 78%;
    max-width: 280px;
  }
  .shell.rail-open .rail { transform: none; }
  .shell { max-width: none; }
  .bubble { max-width: 88%; }
}

@media (min-width: 901px) {
  .menu-btn, .logout-link { display: none; }
  body.is-desktop {
    background:
      radial-gradient(1200px 500px at 10% -10%, rgba(196,92,62,.08), transparent 50%),
      #e4ddd3;
  }
  .shell {
    max-width: 1440px;
    height: calc(100% - 28px);
    margin: 14px auto;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(26, 31, 36, .1);
    border: 1px solid var(--line);
  }
  .rail {
    width: 248px;
    padding: 18px 12px 20px;
  }
  .stage-bar {
    height: 58px;
    padding: 0 28px;
  }
  .stage-title { font-size: 22px; }
  #app { padding: 28px 40px 32px; }
  #app.chat-page {
    background: linear-gradient(#f3eee6, var(--paper));
  }
  .thread {
    padding: 24px 0 16px;
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
  }
  .bubble { max-width: 76%; font-size: 15px; }
  .composer {
    max-width: 760px;
    width: 100%;
    margin: 0 auto;
    padding: 14px 0 22px;
    background: transparent;
    border-top: 0;
  }
  .due-banner { max-width: 760px; width: calc(100% - 0px); margin: 16px auto 0; }
  h2.page { font-size: 30px; }
  .me-page {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
    max-width: 980px;
    margin: 0 auto;
  }
  .me-cover, .me-id, .me-stats { grid-column: 1 / -1; }
  .me-cover { height: 220px; }
  .library-desk, .page-wrap { max-width: 980px; margin: 0 auto; }
  .shell.auth {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    max-width: 880px;
    height: auto;
    min-height: 560px;
    margin: 8vh auto;
  }
  .shell.auth .rail, .shell.auth .stage-bar, .shell.auth .scrim { display: none !important; }
  .shell.auth .auth-pane {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 36px;
    background: linear-gradient(165deg, #f3eee6, #e8dfd2);
    border-right: 1px solid var(--line);
  }
  .shell.auth .auth-pane .auth-brand {
    margin-bottom: 16px;
    justify-content: flex-start;
  }
  .shell.auth .auth-pane .rail-logo { width: 48px; height: 48px; border-radius: 12px; }
  .shell.auth .auth-pane h1 {
    margin: 0; font-family: var(--serif); font-size: 40px; letter-spacing: .2em; font-weight: 600;
  }
  .shell.auth .auth-pane p { color: var(--ink-soft); line-height: 1.7; font-size: 14px; }
  .shell.auth .stage { background: var(--paper); }
  .shell.auth #app { padding: 40px 36px 36px; }
  .is-desktop .login-hero .login-brand { justify-content: flex-start; }
  .is-desktop .login-hero h2 { font-size: 22px; letter-spacing: .12em; }
  .is-desktop .login-hero { text-align: left; margin: 0 0 18px; }
}
