:root {
  --bg: #0b1220;
  --bg-soft: #121c2e;
  --card: #16203377;
  --line: #ffffff14;
  --text: #e8eefb;
  --muted: #8fa0bd;
  --brand: #4fa8ff;
  --brand-2: #7b6cff;
  --me: #2b6fd6;
  --her: #1a2438;
  --danger: #ff6b6b;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 80% at 50% 0%, #17263f 0%, #0b1220 55%, #070c15 100%);
  color: var(--text);
  font: 16px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 13px; }

.app { height: 100%; display: flex; flex-direction: column; }

/* ---------- 登录 ---------- */
.login {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #1a2740cc, #121a2bcc);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  backdrop-filter: blur(12px);
}
.whale { font-size: 56px; line-height: 1; }
.login-card h1 { margin: 12px 0 4px; font-size: 26px; letter-spacing: 1px; }
.login-card p { margin: 0 0 18px; }
.login-card input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0e1626;
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.login-card input:focus { border-color: var(--brand); }
.msg { min-height: 20px; margin: 10px 0 0; color: var(--danger); font-size: 14px; }

/* ---------- 主界面 ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.topbar {
  padding: calc(var(--safe-t) + 12px) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar-title { font-size: 19px; font-weight: 600; letter-spacing: .5px; }
.topbar-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 8px #3ddc84aa; }
.dot.off { background: #6b7a94; box-shadow: none; }

.pages { flex: 1; min-height: 0; position: relative; }
.page { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 0; }

/* ---------- 聊天 ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.bubble {
  max-width: 82%;
  padding: 11px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
  line-height: 1.62;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(4px); opacity: .4; } to { transform: none; opacity: 1; } }
.bubble.me {
  align-self: flex-end;
  background: linear-gradient(180deg, #3d7fe0, #2a63bd);
  border-bottom-right-radius: 6px;
}
.bubble.her {
  align-self: flex-start;
  background: var(--her);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble.pending { color: var(--muted); font-style: italic; }
.typing { display: inline-flex; gap: 3px; align-items: center; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.2s infinite;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.composer {
  display: flex;
  gap: 8px;
  padding: 8px 12px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: #0a111ccc;
  backdrop-filter: blur(10px);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 132px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #111b2c;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  outline: none;
}
.composer textarea:focus { border-color: #3d7fe088; }
.send {
  width: 46px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #4fa8ff, #3a6fd0);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
}
.send:disabled { opacity: .45; }

/* ---------- 工作台 / 列表 ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 8px; font-size: 13px;
}
.list { flex: 1; overflow-y: auto; padding: 0 14px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; }
.row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.row-top { display: flex; align-items: center; gap: 8px; }
.row-title { font-size: 15px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.live { color: #7ce8a8; border-color: #3ddc8455; background: #3ddc8414; }

/* ---------- 设置 ---------- */
.page[data-page="settings"] { padding: 4px 14px calc(24px + var(--safe-b)); gap: 12px; overflow-y: auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 6px 16px; }
.card-title { font-size: 13px; color: var(--muted); padding: 12px 0 6px; }
.card-row { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.card-row:last-child { border-bottom: 0; }
.modules { display: flex; flex-direction: column; }
.mod-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.mod-item:last-child { border-bottom: 0; }
.mod-note { font-size: 12px; color: var(--muted); }
.switch { width: 44px; height: 26px; border-radius: 999px; background: #24304a; position: relative; transition: .18s; }
.switch.on { background: #2f6fd0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .18s; }
.switch.on::after { left: 21px; }
.switch.soon { opacity: .35; }

/* ---------- 按钮 / 空态 ---------- */
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-size: 15px; font-weight: 600; color: var(--text); background: #1b2740; }
.btn.primary { background: linear-gradient(180deg, #4fa8ff, #3a6fd0); width: 100%; margin-top: 14px; color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); padding: 7px 14px; font-size: 13px; color: var(--muted); }
.btn.small { padding: 6px 12px; }
.btn.danger { background: #3a1720; color: #ff9a9a; margin-top: 6px; }
.btn.wide { display: block; text-align: center; text-decoration: none; margin-top: 6px; }
.empty { flex: 1; display: grid; place-content: center; text-align: center; gap: 8px; padding: 24px; }
.empty-icon { font-size: 46px; }
.empty h2 { margin: 0; font-size: 20px; }

/* ---------- 底部导航 ---------- */
.nav {
  display: flex;
  border-top: 1px solid var(--line);
  background: #0a111cee;
  padding-bottom: var(--safe-b);
  backdrop-filter: blur(10px);
}
.nav button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
}
.nav button .ico { font-size: 19px; line-height: 1.1; }
.nav button.active { color: var(--brand); }
.nav button.soon { opacity: .5; }

/* ---------- 会话详情 ---------- */
.detail {
  position: absolute;
  inset: 0;
  background: #0b1220f2;
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  z-index: 20;
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(12px); opacity: .6; } to { transform: none; opacity: 1; } }
.detail-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.detail-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.detail-title { font-size: 17px; font-weight: 600; line-height: 1.45; }
.detail-meta { font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; }
.detail-sep { height: 1px; background: var(--line); margin: 4px 0; }
.detail-composer { border-top: 1px solid var(--line); }
.detail-actions { display: flex; gap: 8px; margin-top: 6px; }

.queue-hint { padding: 4px 16px 6px; font-size: 12.5px; color: var(--muted); text-align: center; }
