:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #efeee9;
  --text: #1b1a17;
  --muted: #6e6b63;
  --line: #e3e1da;
  --accent: #e5484d;
  --accent-press: #c9373c;
  --link: #2b6cb0;
  --mark: #ffe58a;
  --ok: #2f855a;
  --warn: #b7791f;
  --sp0: #2b6cb0; --sp1: #c05621; --sp2: #2f855a;
  --sp3: #805ad5; --sp4: #b83280; --sp5: #2c7a7b;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --surface: #1c1c1e;
    --surface-2: #2a2a2d;
    --text: #f2f1ee;
    --muted: #9b988f;
    --line: #2f2f33;
    --link: #7ab4f5;
    --mark: #6b5a12;
    --sp0: #7ab4f5; --sp1: #f6ad55; --sp2: #68d391;
    --sp3: #b794f4; --sp4: #f687b3; --sp5: #4fd1c5;
  }
}

* { 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;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.page { max-width: 720px; margin: 0 auto; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 140px); }

/* Cabeçalho */
.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bar h1 { font-size: 30px; line-height: 1.1; letter-spacing: -0.02em; margin: 6px 0; flex: 1; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; color: var(--link); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back { text-decoration: none; display: inline-flex; align-items: center; gap: 2px; color: var(--link); min-height: 44px; font-size: 17px; }
.back svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Busca */
.search { display: block; position: relative; margin: 6px 0 14px; }
.search input {
  width: 100%; height: 40px; border-radius: 11px; border: 0; padding: 0 12px 0 36px;
  background: var(--surface-2); font-size: 16px; outline: none;
}
.search svg { position: absolute; left: 11px; top: 10px; width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }

/* Lista */
.section-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 4px 6px; }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.item { color: inherit; text-decoration: none; display: block; width: 100%; text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item a { color: inherit; text-decoration: none; }
a.item-snippet { padding-top: 4px; }
.item:active { background: var(--surface-2); }
.item-title { font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item-snippet { color: var(--muted); font-size: 15px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-snippet b { color: var(--text); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

.pill { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.pill.busy { color: var(--warn); }
.pill.err { color: var(--accent); }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty svg { width: 56px; height: 56px; stroke: var(--line); fill: none; stroke-width: 1.6; margin-bottom: 8px; }
.empty h2 { color: var(--text); font-size: 20px; margin: 0 0 4px; }

/* Botão de gravar fixo embaixo */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 14px 16px calc(var(--safe-bottom) + 14px);
  background: linear-gradient(to top, var(--bg) 65%, transparent);
  display: flex; justify-content: center; align-items: center; gap: 28px;
}
.btn-rec {
  width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center;
  border: 4px solid var(--text); background: var(--bg);
}
.btn-rec span { width: 58px; height: 58px; border-radius: 50%; background: var(--accent); transition: transform .12s; }
.btn-rec:active span { transform: scale(.9); background: var(--accent-press); }
.dock-side { width: 56px; display: grid; text-decoration: none; justify-items: center; gap: 2px; color: var(--link); font-size: 12px; }
.dock-side svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Gravação */
.recorder {
  position: fixed; inset: 0; z-index: 20; background: #0d0d0d; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 20px) 24px calc(var(--safe-bottom) + 24px);
  text-align: center;
}
.rec-top { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: .02em; color: #ff8a8d; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.recorder.paused .rec-dot { animation: none; background: #888; }
.recorder.paused .rec-top { color: #aaa; }
@keyframes blink { 50% { opacity: .25; } }
.rec-time { font-size: 76px; font-weight: 200; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; margin: 10px 0 16px; }
.rec-level { width: min(100%, 420px); height: 84px; }
.rec-hint { color: #8d8d8d; font-size: 14px; margin: 20px 0 36px; max-width: 300px; }
.rec-actions { display: flex; align-items: center; gap: 36px; }
.btn-stop { width: 84px; height: 84px; border-radius: 50%; border: 4px solid #fff; display: grid; place-items: center; }
.btn-stop span { width: 32px; height: 32px; border-radius: 7px; background: var(--accent); }
.btn-stop:active span { transform: scale(.9); }
.btn-round { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: #262626; }
.btn-round svg { width: 24px; height: 24px; fill: #fff; stroke: #fff; }
.btn-round:active { background: #3a3a3a; }
.rec-legend { display: flex; gap: 36px; color: #8d8d8d; font-size: 12px; margin-top: 10px; }
.rec-legend span { width: 84px; }
.rec-legend span:first-child, .rec-legend span:last-child { width: 56px; }

/* Detalhe */
.title-input {
  width: 100%; font-size: 26px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2;
  border: 0; background: transparent; padding: 4px 0; outline: none;
}
.title-input:focus { border-bottom: 2px solid var(--link); }
.meta { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.player {
  position: sticky; top: calc(var(--safe-top)); z-index: 4; background: var(--bg);
  padding: 8px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.player audio { width: 100%; height: 40px; }
.speakers { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip small { color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; margin: 2px 2px 14px; }

.transcript { background: var(--surface); border-radius: var(--radius); padding: 6px 16px; }
.block { padding: 12px 0; border-bottom: 1px solid var(--line); }
.block:last-child { border-bottom: 0; }
.block-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.block-name { font-weight: 700; font-size: 15px; }
.block-time { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.utt { border-radius: 4px; cursor: pointer; }
.utt.now { background: var(--surface-2); box-shadow: 0 0 0 3px var(--surface-2); }
.utt.flash { background: var(--mark); box-shadow: 0 0 0 3px var(--mark); }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 16px 0; }
.btn {
  min-height: 46px; padding: 0 16px; border-radius: 12px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line); color: var(--link);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--link); color: #fff; border-color: transparent; }
.btn.danger { color: var(--accent); }
.btn[disabled] { opacity: .5; }

.status-box { background: var(--surface); border-radius: var(--radius); padding: 22px 18px; text-align: center; }
.status-box p { margin: 6px 0 14px; color: var(--muted); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--link); animation: spin .9s linear infinite; margin: 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-text { color: var(--accent); font-size: 14px; word-break: break-word; }

/* Ajustes */
.form { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.field { display: block; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field span { display: block; font-size: 13px; color: var(--muted); }
.field input, .field select { width: 100%; border: 0; background: transparent; font-size: 17px; padding: 4px 0; outline: none; }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.row span { font-size: 17px; color: var(--text); }
.switch { appearance: none; -webkit-appearance: none; width: 51px !important; height: 31px; border-radius: 99px; background: var(--line); position: relative; flex: none; transition: background .2s; padding: 0 !important; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.note { color: var(--muted); font-size: 13px; margin: 8px 4px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 110px); transform: translateX(-50%);
  background: rgba(30,30,30,.94); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px;
  z-index: 30; max-width: calc(100% - 32px); text-align: center;
}
