/* 随身秘书 — modern, clean, mobile-first. Light + dark. */
:root {
  --bg: #f4f5f9;
  --bg-2: #ffffff;
  --bg-3: #eceef4;
  --ink: #14161c;
  --muted: #6b7180;
  --line: rgba(20, 22, 28, 0.08);
  --accent: #5b5bf0;
  --accent-2: #8b5cf6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(91, 91, 240, 0.12);
  --ok: #16a34a;
  --ok-soft: rgba(22, 163, 74, 0.12);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, 0.14);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --rec: #ef4444;
  --bubble-ai: #ffffff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow: 0 10px 30px rgba(16, 24, 40, 0.10);
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0f13;
    --bg-2: #181a20;
    --bg-3: #23262e;
    --ink: #eef0f5;
    --muted: #9198a8;
    --line: rgba(255, 255, 255, 0.08);
    --accent: #7c7cff;
    --accent-2: #a78bfa;
    --accent-soft: rgba(124, 124, 255, 0.16);
    --ok: #4ade80; --ok-soft: rgba(74, 222, 128, 0.14);
    --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, 0.14);
    --bubble-ai: #1c1f26;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body { overscroll-behavior: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

.shell, .gate {
  max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) calc(10px + var(--safe-bottom)) calc(16px + var(--safe-left));
}
.shell { height: 100dvh; max-height: 100dvh; overflow: hidden; }
.gate {
  min-height: 100dvh; justify-content: center;
  background: radial-gradient(600px 400px at 50% 0%, var(--accent-soft), transparent 70%);
  max-width: none;
}

.gate-card, dialog {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 28px; box-shadow: var(--shadow); color: var(--ink);
}
.gate-card { width: 100%; max-width: 420px; margin: 0 auto; padding: 32px 24px 24px; }
.gate-card::before {
  content: ""; display: block; width: 56px; height: 56px; border-radius: 18px; margin-bottom: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px var(--accent-soft);
}

.eyebrow {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--accent);
}
h1, h2 { font-weight: 700; letter-spacing: -0.02em; }
h1 { margin: 2px 0 6px; font-size: 24px; line-height: 1.2; }
h2 { margin: 0; font-size: 19px; }
.lede, .hint, .empty { color: var(--muted); margin: 0; }
.lede { font-size: 14px; }

.field, .devices label, .sensitivity {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.field { margin-top: 18px; }

input[type="password"], textarea, select {
  width: 100%; background: var(--bg-3); border: 1px solid transparent;
  border-radius: 14px; padding: 12px 14px; color: var(--ink);
  transition: border-color .15s, background .15s;
}
select { padding: 9px 12px; font-size: 14px; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
textarea { resize: none; min-height: 46px; max-height: 120px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: var(--bg-2); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.primary, .send, .ptt, .toggle, .segment-btn { border-radius: 999px; font-weight: 600; transition: transform .12s, background .2s, box-shadow .2s, opacity .2s; }
.primary, .send { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.primary { margin-top: 18px; width: 100%; padding: 14px; font-size: 16px; box-shadow: 0 8px 20px var(--accent-soft); }
.primary:active, .send:active { transform: scale(0.98); }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 4px 2px 10px; }
.top h1 { font-size: 22px; margin: 0; }
.top-actions, .row, .talk-row, .devices, .dialog-head { display: flex; gap: 8px; align-items: center; }
.top-actions { flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.text-btn {
  background: var(--bg-2); color: var(--ink); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-sm); min-height: 34px;
}
.text-btn:active { background: var(--bg-3); }

/* Chips */
.chips { display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 8px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; padding: 5px 11px; border-radius: 999px;
  background: var(--bg-3); color: var(--muted); white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .6; }
.chip.on { color: var(--ok); background: var(--ok-soft); }
.chip.on::before { opacity: 1; box-shadow: 0 0 0 3px var(--ok-soft); }
.chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.warn::before { opacity: 1; }

.banner {
  margin: 6px 0; padding: 10px 14px; border-radius: 14px; font-size: 14px;
  background: var(--danger-soft); color: var(--danger);
}
.hint { font-size: 12px; }
#ios-hint { padding: 8px 12px; background: var(--accent-soft); color: var(--accent); border-radius: 12px; margin-bottom: 6px; }

/* Transcript */
.transcript {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px; padding: 8px 2px 12px;
  scroll-behavior: smooth;
}
.empty {
  margin: auto 8px; text-align: center; font-size: 14px; padding: 24px 18px;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.bubble {
  max-width: 84%; padding: 10px 14px; border-radius: 20px; font-size: 15.5px;
  word-break: break-word; box-shadow: var(--shadow-sm);
  animation: pop .22s ease-out;
}
.bubble.user {
  align-self: flex-end; border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.bubble.assistant { align-self: flex-start; border-bottom-left-radius: 6px; background: var(--bubble-ai); border: 1px solid var(--line); }
.bubble .meta { display: block; margin-top: 6px; font-size: 11.5px; opacity: .7; }
.badge {
  display: inline-block; margin-bottom: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn);
}
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }

/* Dock */
.dock {
  flex: none; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 26px; padding: 12px; box-shadow: var(--shadow);
}
.preview { position: relative; border-radius: 18px; overflow: hidden; background: #000; margin-bottom: 10px; aspect-ratio: 16 / 9; }
.preview video, .preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-hint {
  position: absolute; left: 8px; bottom: 8px; margin: 0; font-size: 12px; color: #fff;
  background: rgba(0,0,0,.5); padding: 3px 10px; border-radius: 999px; backdrop-filter: blur(6px);
}
.preview-hint:empty { display: none; }

.row { margin-bottom: 10px; justify-content: space-between; }
.row.tight { align-items: flex-end; margin: 10px 0 0; }
.toggle { background: var(--bg-3); padding: 8px 16px; min-height: 38px; font-size: 14px; }
.toggle[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 14px var(--accent-soft); }
.segment { display: flex; padding: 3px; background: var(--bg-3); border-radius: 999px; }
.segment-btn { padding: 6px 14px; min-height: 32px; font-size: 14px; color: var(--muted); }
.segment-btn.on { background: var(--bg-2); color: var(--ink); box-shadow: var(--shadow-sm); }

.devices { align-items: flex-end; margin-bottom: 10px; }
.devices label { flex: 1; min-width: 0; }
.devices .text-btn { flex: none; font-size: 13px; padding: 7px 12px; box-shadow: none; background: var(--bg-3); border: 0; min-height: 38px; }

.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; border-radius: 22px; padding: 11px 16px; }
.send { padding: 0 18px; min-height: 46px; flex: none; }

/* Push to talk */
.talk-row { align-items: center; margin-top: 12px; gap: 14px; }
.ptt {
  position: relative; flex: 1; min-height: 76px; font-size: 18px; letter-spacing: .02em;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 28px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,.25);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  isolation: isolate;
}
.ptt::before { content: "🎙"; margin-right: 8px; }
.ptt.hot {
  background: linear-gradient(135deg, #ef4444, #f97316);
  transform: scale(0.97);
  animation: rec-glow 1.2s ease-in-out infinite;
}
.ptt.hot::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: -1;
  border: 2px solid var(--rec);
  animation: rec-ring 1.2s ease-out infinite;
}
@keyframes rec-glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,.45), 0 10px 28px rgba(239,68,68,.3); }
  50% { box-shadow: 0 0 0 10px rgba(239,68,68,0), 0 10px 28px rgba(239,68,68,.3); }
}
@keyframes rec-ring { from { transform: scale(1); opacity: .8; } to { transform: scale(1.12, 1.35); opacity: 0; } }
.ptt:disabled { opacity: .5; animation: none; }

.side { display: flex; flex-direction: column; gap: 2px; flex: none; }
.switch { display: flex; gap: 8px; align-items: center; font-size: 13px; min-height: 28px; color: var(--muted); cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 34px; height: 20px; border-radius: 999px; background: var(--bg-3);
  border: 1px solid var(--line); position: relative; transition: background .2s; cursor: pointer;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s;
}
.switch input:checked { background: var(--accent); border-color: transparent; }
.switch input:checked::after { transform: translateX(14px); }
.switch input:checked + span { color: var(--ink); }

.meter { height: 4px; border-radius: 999px; background: var(--bg-3); overflow: hidden; margin-top: 12px; }
#meter-bar { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--ok), var(--accent)); border-radius: inherit; transition: width .08s linear; }

.sensitivity { flex: none; width: 104px; }
#talk-hint { flex: 1; text-align: right; line-height: 1.4; }

/* Notes dialog */
dialog { width: min(92vw, 440px); max-height: 80dvh; padding: 20px; }
dialog::backdrop { background: rgba(10, 12, 18, 0.45); backdrop-filter: blur(4px); }
.dialog-head { justify-content: space-between; margin-bottom: 8px; }
.note-list { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 8px; }
.note-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--bg-3); border-radius: 14px; padding: 10px 12px; font-size: 14px;
}
.note-list li .text-btn { flex: none; font-size: 12px; padding: 4px 10px; min-height: 28px; box-shadow: none; }
#notes-empty { margin-top: 12px; text-align: center; }

@media (max-width: 380px) {
  .ptt { min-height: 68px; font-size: 17px; }
  .top h1 { font-size: 20px; }
  .text-btn { padding: 6px 11px; }
}
@media (min-width: 900px) {
  .shell { padding-top: 24px; padding-bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
