:root {
  --bg0: #070b14;
  --bg1: #0e1524;
  --ink: #eef2f8;
  --muted: #8b97ad;
  --line: rgba(232, 240, 255, 0.1);
  --panel: rgba(18, 26, 42, 0.72);
  --panel-2: rgba(255, 255, 255, 0.035);
  --accent: #e8b86d;
  --accent-2: #6ec8ff;
  --good: #5ddea0;
  --warn: #f0c56d;
  --bad: #ff8f8f;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font-display: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(920px 540px at 8% -10%, rgba(232, 184, 109, 0.18), transparent 58%),
    radial-gradient(780px 480px at 100% 0%, rgba(110, 200, 255, 0.12), transparent 52%),
    radial-gradient(700px 500px at 50% 110%, rgba(93, 222, 160, 0.08), transparent 55%),
    linear-gradient(165deg, var(--bg0), var(--bg1) 60%, #0a101c);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 40% 20%, black 15%, transparent 70%);
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* Gate */
.gate {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px calc(32px + var(--safe-b));
}
.gate-panel {
  width: min(520px, 100%);
  text-align: left;
  animation: rise 0.7s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 8vw, 3.6rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.05;
}
.brand em {
  font-style: normal;
  background: linear-gradient(120deg, #fff6e8 10%, var(--accent) 55%, #f0d19a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
  max-width: 34em;
}
.gate-form {
  margin-top: 28px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.gate-form input {
  flex: 1 1 220px;
  min-height: 52px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gate-form input:focus {
  border-color: rgba(232,184,109,0.55);
  box-shadow: 0 0 0 3px rgba(232,184,109,0.15);
}
.gate-form button, .btn {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  padding: 0 22px;
  background: linear-gradient(135deg, #f0d19a, var(--accent));
  color: #1a1208;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s;
}
.gate-form button:hover, .btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.gate-form button:disabled { opacity: 0.55; cursor: wait; transform: none; }
.hint, .error {
  margin-top: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}
.error { color: var(--bad); }
.matches {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}
.match {
  text-align: left;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.match:hover {
  background: rgba(232,184,109,0.08);
  border-color: rgba(232,184,109,0.35);
}
.match strong { font-size: 1.05rem; }
.match span { color: var(--muted); font-size: 0.88rem; }

/* App shell — 铺满视口，间距紧凑 */
.app {
  position: relative;
  z-index: 1;
  width: min(1440px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: 12px 14px calc(10px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  animation: rise 0.45s ease both;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.who {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #081018;
  flex: 0 0 auto;
}
.who h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
}
.who p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost {
  min-height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0 14px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.05); }

.nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: thin;
}
.nav button {
  flex: 0 0 auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 14px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav button.active {
  color: var(--ink);
  background: rgba(232,184,109,0.12);
  border-color: rgba(232,184,109,0.28);
}

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.4fr 0.95fr;
  gap: 10px;
  align-items: stretch;
}
.main-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  body { overflow: auto; }
  .app { height: auto; max-height: none; overflow: visible; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}
.main-col > .section.panel {
  flex: 1 1 auto;
  min-height: 0;
  display: none;
  flex-direction: column;
}
.main-col > .section.panel.active {
  display: flex;
}
.scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.panel h2 {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 1.08rem;
  letter-spacing: 0.03em;
}
.panel .sub {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.metric {
  padding: 10px 10px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  border: 1px solid transparent;
}
.metric .k {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.metric .v {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
}
.metric .v.accent { color: var(--accent); }
.metric .v.good { color: var(--good); }
.metric .v.warn { color: var(--warn); }

.next-lesson {
  padding: 14px 16px;
  border-radius: 16px;
  background:
    linear-gradient(120deg, rgba(232,184,109,0.14), rgba(110,200,255,0.08));
  border: 1px solid rgba(232,184,109,0.22);
  margin-bottom: 8px;
}
.next-lesson .label {
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.next-lesson .title {
  margin-top: 6px;
  font-size: 1.12rem;
  font-weight: 650;
}
.next-lesson .meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.list { display: grid; gap: 10px; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row .t { font-weight: 600; }
.row .d { color: var(--muted); font-size: 0.88rem; margin-top: 4px; line-height: 1.5; }
.badge {
  align-self: start;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok { color: var(--good); border-color: rgba(93,222,160,0.35); }
.badge.wait { color: var(--accent-2); border-color: rgba(110,200,255,0.35); }
.badge.due { color: var(--warn); border-color: rgba(240,197,109,0.4); }
.badge.pay { color: var(--bad); border-color: rgba(255,143,143,0.4); }

.bars { display: grid; gap: 12px; }
.bar-item .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
  margin-bottom: 6px;
}
.bar-item .top span:last-child { color: var(--muted); }
.track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ec8ff, #e8b86d);
  width: 0;
  transition: width 0.8s cubic-bezier(.2,.8,.2,1);
}

.notice {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.notice:last-child { border-bottom: 0; }
.notice .t { font-weight: 600; }
.notice .b { margin-top: 4px; color: var(--muted); font-size: 0.9rem; line-height: 1.55; }

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}
.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  margin-bottom: 10px;
}
.bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 0.94rem;
  white-space: pre-wrap;
}
.bubble.bot {
  align-self: flex-start;
  background: rgba(110,200,255,0.1);
  border: 1px solid rgba(110,200,255,0.18);
}
.bubble.me {
  align-self: flex-end;
  background: rgba(232,184,109,0.14);
  border: 1px solid rgba(232,184,109,0.22);
}
.chat-form {
  display: flex;
  gap: 8px;
}
.chat-form input {
  flex: 1;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}
.chat-form button {
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  padding: 0 16px;
  background: linear-gradient(135deg, #8fd0ff, var(--accent-2));
  color: #071018;
  font-weight: 700;
}
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.quick button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
}
.quick button:hover { color: var(--ink); border-color: rgba(255,255,255,0.22); }

.section { display: none; }
.section.active { display: block; animation: rise 0.35s ease both; }

.assistant-panel {
  min-height: 0;
  height: 100%;
}

@media (max-width: 900px) {
  .assistant-panel {
    display: none;
    min-height: 60dvh;
  }
  .assistant-panel.mobile-show {
    display: flex;
  }
  .main-col.chat-mode .section {
    display: none !important;
  }
}

.empty {
  color: var(--muted);
  padding: 8px 0;
  font-size: 0.92rem;
}
