:root {
  --bg: #0e0f13;
  --surface: #171922;
  --surface-2: #20232f;
  --line: #2a2e3c;
  --text: #eceef4;
  --muted: #9097a8;
  --accent: #b9a4ff;
  --rec: #ff4d5e;
  --ok: #4fd18b;
  --warn: #ffb547;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.err { color: var(--rec); margin: 10px 0 0; }
.screen { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; min-height: 100vh; min-height: 100dvh; }

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px;
  padding: 10px 14px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #17121f; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; padding: 14px; }
.btn-big { flex: 1; padding: 18px 12px; font-size: 18px; border-radius: 18px; }
.btn-stop { background: var(--rec); border-color: var(--rec); color: #fff; }
.btn-stop .sq { width: 14px; height: 14px; background: #fff; border-radius: 3px; display: inline-block; }
.btn-dl { padding: 8px 12px; font-size: 14px; min-width: 76px; }
.btn-dl.ready { border-color: var(--accent); color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); padding: 8px 0; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill-warn { background: rgba(255, 181, 71, 0.15); color: var(--warn); }
.pill-ok { background: rgba(79, 209, 139, 0.14); color: var(--ok); }
.pill-err { background: rgba(255, 77, 94, 0.15); color: var(--rec); }
.pill-busy { background: rgba(185, 164, 255, 0.14); color: var(--accent); }

/* login */
#login { display: flex; align-items: center; justify-content: center; }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-icon { width: 72px; height: 72px; border-radius: 18px; }
.login-box h1 { margin-top: 12px; }
.login-box form { margin-top: 24px; display: grid; gap: 12px; }
.login-box input {
  width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 17px;
}

/* home */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; min-height: 60px; }
.rec-hero {
  width: 100%; display: flex; align-items: center; gap: 18px; text-align: left;
  padding: 22px 20px; margin: 4px 0 12px; border-radius: 22px; border: 1px solid #3a2530;
  background: linear-gradient(135deg, #2a1820, #1b1520);
}
.rec-hero:active { transform: scale(0.985); }
.rec-hero strong { display: block; font-size: 21px; }
.rec-hero small { color: var(--muted); font-size: 14px; }
.rec-dot { width: 54px; height: 54px; flex: none; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 7px rgba(255, 77, 94, 0.18); }
.rec-dot.small { width: 10px; height: 10px; box-shadow: none; display: inline-block; }
.tip { font-size: 14px; color: var(--muted); background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.search-row input {
  width: 100%; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 16px; margin: 4px 0 12px;
}
.list { display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card-main { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-title { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-preview { color: #c3c7d3; font-size: 14px; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-err { color: var(--rec); font-size: 13px; margin-top: 8px; }
.card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.foot { text-align: center; margin-top: 28px; }
.foot .link { color: var(--muted); font-size: 14px; }

/* recording */
#recording { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 24px; }
.rec-top { min-height: 32px; }
.rec-badge { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.08em; color: var(--rec); }
.rec-badge.paused { color: var(--warn); }
.rec-badge.paused .rec-dot { background: var(--warn); animation: none; }
.rec-badge .rec-dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.rec-time { font-size: 76px; font-weight: 250; font-variant-numeric: tabular-nums; letter-spacing: -0.03em; margin: 18px 0 8px; }
.meter { width: 100%; max-width: 420px; height: 64px; }
.rec-sync { color: var(--muted); font-size: 14px; margin: 14px 0 0; min-height: 20px; }
.rec-sync.ok { color: var(--ok); }
.rec-sync.warn { color: var(--warn); }
.rec-alert { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 181, 71, 0.12); color: var(--warn); font-size: 15px; }
.rec-alert .btn { margin-top: 10px; }
.rec-note { color: var(--muted); font-size: 14px; margin: auto 0 18px; padding-top: 28px; }
.rec-actions { display: flex; gap: 12px; width: 100%; max-width: 440px; }

/* detail */
.back { font-size: 17px; }
.d-title {
  width: 100%; font-size: 24px; font-weight: 700; background: transparent; color: var(--text);
  border: 0; border-bottom: 1px dashed transparent; padding: 2px 0; letter-spacing: -0.01em;
}
.d-title:focus { outline: none; border-bottom-color: var(--line); }
.d-sub { color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
audio { width: 100%; margin: 4px 0 12px; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.d-actions .btn { flex: 1; min-width: 92px; }
.speakers { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 16px; align-items: center; }
.speakers .label { color: var(--muted); font-size: 13px; width: 100%; }
.chip { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: 6px 12px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.chip i { font-style: normal; width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.utt { padding: 10px 0; border-top: 1px solid var(--line); }
.utt-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.utt-who { font-weight: 650; font-size: 14px; }
.utt-time { background: none; border: 0; padding: 0; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.utt-text { font-size: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.d-status { background: var(--surface); border-radius: 12px; padding: 14px; color: var(--muted); margin-bottom: 14px; }
.danger { color: var(--rec); margin-top: 26px; }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  width: 100%; max-width: 640px; background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px;
}
.sheet h3 { margin: 0; }
.sheet input { width: 100%; padding: 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 17px; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions .btn { flex: 1; padding: 13px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2c3040; color: var(--text); padding: 11px 16px; border-radius: 12px; font-size: 15px;
  max-width: calc(100% - 32px); z-index: 30; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
