/* Callahorn Scribe — dark theme, amber/rose accents */
:root {
  --bg: #0a0810;
  --panel: rgba(214, 178, 148, 0.055);
  --panel-solid: #161020;
  --border: rgba(214, 178, 148, 0.14);
  --border-hot: rgba(251, 191, 36, 0.5);
  --text: #f2ecff;
  --muted: #a396b8;
  --accent-a: #fbbf24; /* amber */
  --accent-b: #fb7185; /* rose */
  --accent-c: #a78bfa; /* violet */
  --grad: linear-gradient(100deg, var(--accent-a), var(--accent-b) 55%, var(--accent-c));
  --danger: #f87171;
  --ok: #34d399;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, sans-serif;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* backdrop */
.bg-grid {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background-image:
    linear-gradient(rgba(214, 178, 148, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 178, 148, 0.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 40%, transparent 100%);
}
.bg-glow {
  position: fixed; z-index: -1; pointer-events: none;
  top: -30vh; left: 50%; transform: translateX(-50%);
  width: 90vw; height: 60vh;
  background: radial-gradient(ellipse, rgba(251, 191, 36, 0.10), rgba(251, 113, 133, 0.05) 55%, transparent 75%);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12.5px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.spacer { flex: 1; }
.grad {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}

button {
  font: inherit; color: var(--text);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
button:hover { border-color: var(--border-hot); }
button.primary {
  background: linear-gradient(100deg, rgba(251, 191, 36, 0.18), rgba(251, 113, 133, 0.18));
  border-color: var(--border-hot);
}
button.danger:hover { border-color: var(--danger); color: var(--danger); }
.icon-btn { padding: 6px 10px; font-size: 16px; line-height: 1; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: rgba(0, 0, 0, 0.25); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 10px; width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--border-hot); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 2px; }
label input, label select, label textarea { margin-top: 4px; }

/* header */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: rgba(10, 8, 16, 0.7); backdrop-filter: blur(10px);
}
.wordmark {
  font-family: var(--mono); font-weight: 700; letter-spacing: 1px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.tagline { color: var(--muted); font-size: 12.5px; letter-spacing: 2px; text-transform: uppercase; }
#sidebarToggle { display: none; }

/* layout */
.app { display: flex; flex-direction: column; height: 100%; }
.layout { display: flex; flex: 1; min-height: 0; }

/* sidebar */
#sidebar {
  width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border-right: 1px solid var(--border);
  overflow-y: auto;
}
.sidebar-actions { display: flex; flex-direction: column; gap: 8px; }
.note-list { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.folder-head {
  font-size: 11.5px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); margin: 10px 4px 2px;
}
.note-item {
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.note-item:hover { background: var(--panel); }
.note-item.active { background: var(--panel); border-color: var(--border-hot); }
.note-item .nt { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-item .nm { font-size: 12px; color: var(--muted); display: flex; gap: 8px; }
.settings summary { cursor: pointer; color: var(--muted); font-size: 13.5px; padding: 4px 0; }

/* main */
#main { flex: 1; min-width: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; }

/* record hero */
#recordView { flex: 1; display: flex; align-items: center; justify-content: center; }
.record-hero {
  max-width: 560px; width: 100%; text-align: center; padding: 42px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.record-hero h1 { margin: 0; font-size: 30px; line-height: 1.25; }
.record-hero p { margin: 0; max-width: 44ch; }
.rec-btn {
  width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid var(--border-hot);
  background: radial-gradient(circle, rgba(251, 113, 133, 0.15), rgba(251, 191, 36, 0.08));
  display: flex; align-items: center; justify-content: center;
  margin-top: 6px;
}
.rec-btn:hover { border-color: var(--accent-a); }
.rec-dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-b);
  transition: border-radius 0.2s, width 0.2s, height 0.2s;
}
.rec-btn.recording { border-color: var(--accent-b); animation: pulse 1.6s infinite; }
.rec-btn.recording .rec-dot { border-radius: 6px; width: 26px; height: 26px; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.35); }
  70% { box-shadow: 0 0 0 18px rgba(251, 113, 133, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0); }
}
.rec-timer { font-family: var(--mono); font-size: 22px; }
#meter { max-width: 100%; opacity: 0.9; }

/* note view */
#noteView { display: flex; flex-direction: column; gap: 12px; max-width: 900px; width: 100%; margin: 0 auto; }
.note-head { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.note-title {
  font-size: 20px; font-weight: 700; background: transparent; border: 1px solid transparent;
  padding: 4px 8px; margin: -4px -8px 0;
}
.note-title:hover, .note-title:focus { border-color: var(--border); background: rgba(0, 0, 0, 0.2); }
.note-meta { display: flex; align-items: center; gap: 14px; font-size: 13px; flex-wrap: wrap; }
.folder-label { display: flex; align-items: center; gap: 6px; margin: 0; }
.folder-label input { width: 140px; padding: 4px 8px; font-size: 13px; }
#player { width: 100%; margin-top: 4px; }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: transparent; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 8px 14px; color: var(--muted);
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent-a); }
.pane { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar select { width: auto; }

/* transcript */
.transcript { display: flex; flex-direction: column; gap: 2px; }
.seg { display: flex; gap: 10px; padding: 6px 8px; border-radius: 8px; align-items: baseline; }
.seg:hover { background: var(--panel); }
.seg.playing { background: rgba(251, 191, 36, 0.08); }
.seg .ts {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  cursor: pointer; flex-shrink: 0; min-width: 46px;
}
.seg .ts:hover { color: var(--accent-a); }
.seg .sp {
  font-size: 12px; font-weight: 700; cursor: pointer; flex-shrink: 0;
  padding: 1px 8px; border-radius: 20px; border: 1px solid var(--border);
  white-space: nowrap;
}
.seg .sp:hover { border-color: var(--border-hot); }
.sp-1 { color: #fbbf24; } .sp-2 { color: #fb7185; } .sp-3 { color: #a78bfa; }
.sp-4 { color: #34d399; } .sp-5 { color: #38bdf8; } .sp-0 { color: #f472b6; }
.seg .tx { flex: 1; }
.live-raw {
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap;
  color: var(--muted); padding: 10px; border: 1px dashed var(--border); border-radius: 10px;
  max-height: 40vh; overflow-y: auto;
}

/* markdown */
.md { line-height: 1.65; }
.md h1, .md h2, .md h3 { line-height: 1.3; margin: 18px 0 8px; }
.md h1 { font-size: 20px; } .md h2 { font-size: 17px; } .md h3 { font-size: 15px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 8px 0; padding-left: 24px; }
.md li { margin: 3px 0; }
.md code {
  font-family: var(--mono); font-size: 13px;
  background: rgba(0, 0, 0, 0.35); padding: 1px 5px; border-radius: 5px;
}
.md pre {
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; overflow-x: auto;
}
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--border-hot); margin: 8px 0; padding: 2px 14px; color: var(--muted); }
.md a { color: var(--accent-a); }
.md strong { color: #fff; }

/* actions */
.actions { display: flex; flex-direction: column; gap: 6px; }
.action-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
}
.action-item input[type="checkbox"] { width: auto; margin-top: 3px; accent-color: var(--accent-a); }
.action-item.done .a-task { text-decoration: line-through; color: var(--muted); }
.a-meta { font-size: 12px; color: var(--muted); }

/* chat */
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 14px; }
.msg.user { align-self: flex-end; background: linear-gradient(100deg, rgba(251, 191, 36, 0.14), rgba(251, 113, 133, 0.14)); border: 1px solid var(--border); }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--border); }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; max-height: 140px; }
.composer button { flex-shrink: 0; }

/* gate */
.gate {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 8, 16, 0.85); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-card { width: 100%; max-width: 380px; padding: 28px; display: flex; flex-direction: column; gap: 6px; }
.gate-tabs { display: flex; gap: 6px; margin: 10px 0; }
.gate-tabs button { flex: 1; padding: 6px; font-size: 13px; }
.gate-tabs button.active { border-color: var(--border-hot); background: var(--panel); }

/* scrim (mobile drawer backdrop) */
#scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0, 0, 0, 0.55);
}

/* ── responsive ── */
@media (max-width: 960px) {
  .tagline { display: none; }
}
@media (max-width: 760px) {
  #sidebarToggle { display: block; }
  #sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0;
    transform: translateX(-105%); transition: transform 0.22s ease;
    background: var(--panel-solid); width: min(320px, 86vw);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
  }
  #sidebar.open { transform: translateX(0); }
  #main { padding: 12px; }
  .record-hero { padding: 30px 18px; }
  .record-hero h1 { font-size: 24px; }
  input, select, textarea { font-size: 16px; } /* stop iOS zoom */
  .msg { max-width: 95%; }
  .note-meta { gap: 8px; }
}
