:root {
  color-scheme: dark;
  --bg: #0d100f;
  --surface: #151a17;
  --surface-2: #1d2420;
  --line: #2d3832;
  --text: #f3f5f3;
  --muted: #9caaa2;
  --green: #9ee7bd;
  --green-deep: #193829;
  --gold: #edc77e;
  --red: #ff9e9e;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang HK",
    "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(13,16,15,.9);
  position: sticky; top: 0; backdrop-filter: blur(16px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 18px; letter-spacing: .04em; }
.brand small { color: var(--muted); }
.hana-orb {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e9fff2 0 8%, var(--green) 13%, #3e7d59 52%, #101a14 75%);
  box-shadow: 0 0 22px rgba(158,231,189,.35);
}
.privacy { color: var(--green); background: var(--green-deep); border-radius: 999px; padding: 8px 12px; font-size: 12px; }

main { width: min(960px, calc(100% - 32px)); margin: 0 auto 72px; }
.hero { padding: 56px 0 30px; }
.eyebrow { color: var(--green); font-size: 11px; font-weight: 750; letter-spacing: .18em; margin: 0 0 9px; }
h1 { font-size: clamp(34px, 7vw, 62px); line-height: 1.02; margin: 0; letter-spacing: -.04em; }
.date { color: var(--muted); margin-top: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 34px; }
.stats article { background: var(--surface); border: 1px solid var(--line); padding: 20px; border-radius: 18px; }
.stats strong { display: block; font-size: 28px; color: var(--green); }
.stats span { color: var(--muted); font-size: 13px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.tab { border: 0; color: var(--muted); background: none; padding: 14px 20px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-color: var(--green); }
.panel { display: none; }
.panel.active { display: block; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 18px; gap: 16px; }
h2 { margin: 0; font-size: 24px; }
h3 { font-size: 14px; color: var(--muted); margin: 30px 0 12px; }

.primary, .quiet {
  border: 1px solid var(--green); border-radius: 11px; padding: 10px 14px; color: #092014; background: var(--green); font-weight: 700;
}
.quiet { background: transparent; color: var(--green); }
.full { width: 100%; margin-top: 8px; }
.stack { display: grid; gap: 10px; }
.empty { color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; padding: 16px; }
.task { display: flex; align-items: center; gap: 13px; }
.task button { width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--green); background: transparent; color: var(--green); }
.task.done { opacity: .52; }
.task.done .task-title { text-decoration: line-through; }
.task-main { flex: 1; }
.task-title { font-weight: 700; }
.meta { color: var(--muted); font-size: 12px; margin-top: 5px; }
.priority { font-size: 10px; border-radius: 999px; padding: 5px 8px; border: 1px solid var(--line); color: var(--muted); }
.notice { margin-top: 20px; padding: 18px; border: 1px solid #31483a; background: linear-gradient(135deg, #13251b, #111713); border-radius: 16px; }
.notice strong { color: var(--green); }
.notice p { margin: 7px 0 0; color: var(--muted); line-height: 1.6; }
.quick-capture { display: grid; gap: 12px; padding: 18px; margin-bottom: 24px; border: 1px solid #3a5d49; border-radius: 18px; background: linear-gradient(135deg, #14281d, #111713); }
.quick-capture-copy { display: grid; gap: 3px; }
.quick-capture-copy strong { color: var(--green); font-size: 18px; }
.quick-capture-copy span, .quick-capture small { color: var(--muted); font-size: 12px; }
.quick-capture textarea { min-height: 74px; resize: vertical; }
.quick-capture-actions { display: flex; gap: 9px; }
.quick-capture-actions select { flex: 1; }
.capture-target { display: grid; gap: 4px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #0f1311; }
.capture-target span { color: var(--muted); font-size: 11px; }
#capture-preview { min-height: 110px; margin: 12px 0; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); background: #0f1311; border: 1px solid var(--line); border-radius: 10px; font: inherit; line-height: 1.55; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 9px; }

.memory-guide { display: flex; gap: 16px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.level { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.level-1 { background: var(--green); }
.level-2 { background: var(--gold); }
.level-3 { background: var(--red); }
.memory-card .content { line-height: 1.55; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.card-actions button { border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 8px; padding: 7px 10px; }
.card-actions .approve { color: var(--green); }
.card-actions .danger { color: var(--red); }

dialog { width: min(500px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 20px; color: var(--text); background: var(--surface); padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
dialog form { padding: 24px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 26px; }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; margin-bottom: 16px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #0f1311; color: var(--text); padding: 12px; }
textarea { resize: vertical; }
.form-note { color: var(--muted); font-size: 12px; line-height: 1.55; }
#toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; background: var(--text); color: #111; padding: 10px 16px; border-radius: 10px; transition: .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.brain-controls { display: flex; align-items: end; gap: 8px; }
.provider-label { margin: 0; min-width: 160px; gap: 4px; }
.provider-label select { padding: 9px 10px; }
.gateway-status { color: var(--muted); font-size: 12px; margin: -8px 0 16px; }
.chat-messages {
  min-height: 380px; max-height: 58vh; overflow-y: auto; display: flex; flex-direction: column;
  gap: 13px; padding: 20px; border: 1px solid var(--line); border-radius: 18px;
  background: linear-gradient(180deg, #101411, #0d100f);
}
.bubble { max-width: min(76%, 650px); padding: 13px 15px; border-radius: 16px; line-height: 1.65; white-space: pre-wrap; }
.bubble.user { align-self: flex-end; color: #082013; background: var(--green); border-bottom-right-radius: 5px; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble .bubble-meta { display: block; opacity: .65; font-size: 10px; margin-top: 6px; }
.chat-welcome { margin: auto; text-align: center; color: var(--muted); max-width: 420px; line-height: 1.7; }
.chat-welcome strong { color: var(--green); display: block; font-size: 20px; margin-bottom: 8px; }
.chat-form { display: flex; align-items: stretch; gap: 10px; margin-top: 12px; }
.chat-form textarea { min-height: 54px; resize: none; }
.chat-form button { min-width: 82px; }
.chat-note { color: var(--muted); font-size: 11px; text-align: center; }
.media-actions { display: flex; gap: 6px; }
.icon-button { display: flex; align-items: center; justify-content: center; margin: 0; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 11px; background: var(--surface); color: var(--text); white-space: nowrap; }
.icon-button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button.recording { color: var(--red); border-color: var(--red); }
.attachment-tray { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.attachment-tray span { border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); padding: 7px 9px; border-radius: 999px; font-size: 12px; }
.attachment-tray button { border: 0; color: var(--red); background: transparent; }
.bubble-media { margin-top: 10px; display: grid; gap: 7px; }
.bubble-media img { display: block; max-width: 100%; max-height: 360px; object-fit: contain; border-radius: 11px; }
.bubble-media audio { max-width: 100%; }
.bubble-media button { justify-self: end; border: 0; background: transparent; color: inherit; opacity: .7; font-size: 11px; }
.vault-badge { color: var(--green); border: 1px solid #315641; background: var(--green-deep); border-radius: 999px; padding: 8px 11px; font-size: 12px; }
.vault-badge.offline { color: var(--red); border-color: #6b3838; background: #311b1b; }
.vault-safety { margin-bottom: 14px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; font-size: 12px; }
.vault-search { display: flex; gap: 9px; margin-bottom: 18px; }
.vault-layout { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 16px; align-items: start; }
.vault-note { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; color: var(--text); cursor: pointer; }
.vault-note:hover { border-color: #4e705c; }
.vault-note-main { flex: 1; min-width: 0; display: grid; gap: 5px; }
.vault-note-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vault-note-main small { color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.vault-preview { position: sticky; top: 92px; min-height: 360px; max-height: 68vh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.vault-preview h3 { color: var(--text); font-size: 20px; margin: 0 0 14px; }
.vault-preview pre { font: inherit; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; margin: 0 0 18px; }
.vault-open { display: inline-block; text-decoration: none; }
.vault-open[hidden] { display: none; }

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .privacy { font-size: 0; }
  .privacy::after { content: "本機模式"; font-size: 11px; }
  .hero { padding-top: 38px; }
  .stats article { padding: 15px 12px; }
  .stats strong { font-size: 23px; }
  .stats span { font-size: 11px; }
  .section-heading { align-items: center; }
  .chat-heading { align-items: flex-start; }
  .brain-controls { align-items: stretch; flex-direction: column; }
  .provider-label { min-width: 130px; }
  .bubble { max-width: 88%; }
  .chat-form { flex-wrap: wrap; }
  .media-actions { width: 100%; }
  .chat-form textarea { flex: 1; }
  .tabs { overflow-x: auto; }
  .tab { padding-inline: 14px; white-space: nowrap; }
  .vault-layout { grid-template-columns: 1fr; }
  .vault-preview { position: static; max-height: none; }
  .quick-capture-actions { align-items: stretch; flex-direction: column; }
}
