/* Scriba — strict black & white. Two themes, one set of tokens.
   The only colour in the app is --alert, used for the live-recording
   indicator and for destructive / error states. */
:root {
  color-scheme: dark light;
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-2: #161616;
  --line: #262626;
  --line-strong: #3d3d3d;
  --text: #ffffff;
  --muted: #a3a3a3;
  --dim: #8a8a8a;
  --on-text: #000000;       /* text on a --text filled shape */
  --alert: #ff453a;
  --font: -apple-system, "SF Pro Text", Inter, Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --surface: #f7f7f7;
    --surface-2: #efefef;
    --line: #e4e4e4;
    --line-strong: #c4c4c4;
    --text: #000000;
    --muted: #595959;
    --dim: #6b6b6b;
    --on-text: #ffffff;
    --alert: #d70015;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--text); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.app {
  max-width: 30rem;
  margin: 0 auto;
  padding: calc(0.6rem + var(--safe-top)) 1.25rem calc(2.5rem + var(--safe-bot));
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0 1.4rem; }
.brand { display: inline-flex; align-items: center; min-height: 44px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.035em; color: var(--text); text-decoration: none; }
.tabs { display: flex; gap: 0.15rem; margin-left: auto; border: 1px solid var(--line-strong); padding: 3px; border-radius: 999px; }
.tabs a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 0.85rem;
  border-radius: 999px; font-size: 0.9rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.tabs a.active { background: var(--text); color: var(--on-text); }
.icon-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--muted); }
.icon-btn.active { color: var(--on-text); background: var(--text); }

.eyebrow { text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.75rem; color: var(--muted); font-weight: 600; margin: 0; }
.view-title { margin: 0.15rem 0 0.4rem; font-size: 2rem; line-height: 1.15; font-weight: 700; letter-spacing: -0.03em; }
.meta { margin: 0; font-size: 0.875rem; color: var(--muted); }

/* ---------- sections: flat, separated by hairlines ---------- */
.card { border-top: 1px solid var(--line); padding: 1.4rem 0 0.4rem; margin-bottom: 1.1rem; }
.card h2 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; min-height: 44px; } /* same height with or without "Actualizar": the record button must not move */
.page-head { margin: 0.2rem 0 0.8rem; }
details.card > summary, .howto summary {
  cursor: pointer; font-weight: 600; list-style: none;
  min-height: 44px; display: flex; align-items: center; justify-content: space-between;
}
details.card > summary::-webkit-details-marker, .howto summary::-webkit-details-marker { display: none; }
details.card > summary::after, .howto summary::after { content: "+"; color: var(--muted); font-size: 1.4rem; font-weight: 400; }
details[open].card > summary::after, .howto[open] summary::after { content: "–"; }
details[open].card > summary { margin-bottom: 0.4rem; }
.mic-panel { padding-top: 1.1rem; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 0.4rem; font-weight: 600; margin-top: 0.9rem; }
.field:first-of-type { margin-top: 0; }
.field span { font-size: 0.875rem; color: var(--muted); }
select, button, input, textarea { font: inherit; }
select, input[type="text"], input[type="url"], input[type="password"], textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* avoids iOS zoom */
  font-weight: 400;
}
textarea { resize: vertical; min-height: 6.5rem; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-color: var(--text); }
code { font-family: ui-monospace, Menlo, monospace; font-size: 0.85em; background: var(--surface-2); padding: 0.05rem 0.35rem; border-radius: 6px; word-break: break-all; }

/* ---------- buttons: pills ---------- */
.btn, .file-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 48px; padding: 0.7rem 1.25rem;
  border-radius: 999px; border: 1px solid var(--text);
  background: var(--text); color: var(--on-text);
  font-weight: 600; font-size: 1rem; cursor: pointer;
  width: 100%; margin-top: 0.8rem; text-align: center; text-decoration: none;
  touch-action: manipulation;
}
.btn:disabled, .rec-btn:disabled, .file-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.btn.secondary, .file-btn { background: transparent; color: var(--text); border-color: var(--line-strong); }
.btn.danger { background: transparent; color: var(--alert); border-color: var(--alert); margin-top: 1.4rem; }
.btn.danger-outline { background: transparent; color: var(--alert); border-color: var(--alert); }
.btn.small { width: auto; min-height: 44px; padding: 0.4rem 1rem; font-size: 0.9rem; margin-top: 0; }
.link-btn {
  background: none; border: 0; color: var(--muted); font-weight: 600; font-size: 0.9rem;
  min-height: 44px; padding: 0 0.2rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}

.hint { font-size: 0.875rem; color: var(--muted); margin: 0.7rem 0 0; font-weight: 400; }
.hint.warn { color: var(--text); font-weight: 600; }
.hint.center { text-align: center; }

/* ---------- mic panel ---------- */
.receiver { display: flex; gap: 0.7rem; align-items: flex-start; padding: 0.15rem 0 0.4rem; }
.receiver .dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 0.4rem; flex: none; border: 2px solid var(--dim); }
.receiver[data-kind="external"] .dot { background: var(--text); border-color: var(--text); }
.receiver[data-kind="builtin"] .dot { border: 2px dashed var(--text); }
.receiver-text { display: flex; flex-direction: column; min-width: 0; }
.receiver-text strong { font-size: 1rem; }
.receiver-text span { font-size: 0.875rem; color: var(--muted); overflow-wrap: anywhere; }

#meters { margin-top: 0.6rem; }
.mic-row { padding: 0.8rem 0 0.2rem; border-top: 1px solid var(--line); margin-top: 0.6rem; }
.mic-row-head { display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.55rem; }
.mic-name { font-weight: 600; }
.chip {
  flex: none; font-size: 0.8rem; font-weight: 600; padding: 0.2rem 0.7rem; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--line-strong);
}
.chip[data-state="active"] { background: var(--text); color: var(--on-text); border-color: var(--text); }       /* filled */
.chip[data-state="quiet"] { color: var(--text); border-color: var(--muted); }                                    /* outlined */
.chip[data-state="dead"] { color: var(--dim); border-style: dashed; border-color: var(--dim); text-decoration: line-through; }  /* dashed + struck */
.mic-hint { font-size: 0.875rem; color: var(--muted); margin: 0.5rem 0 0; }
.record-panel .mic-hint { color: var(--text); font-weight: 600; text-align: center; max-width: 34rem; }
.device-field { margin-top: 1rem !important; }

.meter { width: 100%; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.meter-bar { height: 100%; width: 0%; background: var(--text); border-radius: 99px; }

/* ---------- record ---------- */
.record-panel { display: flex; flex-direction: column; align-items: center; margin: 1.8rem 0 1.4rem; }
.rec-btn {
  width: 112px; height: 112px; border-radius: 50%;
  border: 4px solid var(--text); background: transparent;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  touch-action: manipulation;
}
.rec-dot { width: 76px; height: 76px; border-radius: 50%; background: var(--text); display: block; transition: border-radius 0.15s, width 0.15s, height 0.15s; }
.rec-btn.recording { border-color: var(--alert); }
.rec-btn.recording .rec-dot { width: 38px; height: 38px; border-radius: 8px; background: var(--alert); animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.timer { font-variant-numeric: tabular-nums; font-size: 2.4rem; font-weight: 300; letter-spacing: 0.02em; margin: 1rem 0 0.2rem; }
.status { margin: 0.4rem 0 0; color: var(--muted); text-align: center; min-height: 1.4em; }
.status.left { text-align: left; }
.consent { margin: 0.35rem 0 0; font-size: 0.875rem; color: var(--dim); text-align: center; }

.alert { border: 1px solid var(--alert); color: var(--text); border-radius: 16px; padding: 0.95rem 1.1rem; margin-bottom: 1rem; }
.alert strong { color: var(--alert); font-size: 1.05rem; }
.alert p { margin: 0.3rem 0 0; font-size: 0.95rem; }
.alert .btn { background: var(--alert); border-color: var(--alert); color: #fff; }

.notice { background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 16px; padding: 0.85rem 1.1rem; margin-bottom: 1rem; font-size: 0.9rem; }
.notice strong { display: block; margin-bottom: 0.15rem; color: var(--text); }

.banner { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 0.85rem 1.1rem; margin-bottom: 0.9rem; }
.banner.warn { border-color: var(--text); }
.banner p { margin: 0.2rem 0 0.55rem; font-size: 0.9rem; color: var(--muted); }
.item-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.upload-row { margin: 0.6rem 0 1.2rem; }
.upload-row .file-btn { margin-top: 0; }

.howto { margin: 0 0 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0.4rem 0; }
.howto ol { margin: 0.5rem 0 0.4rem; padding-left: 1.2rem; color: var(--muted); }
.howto li { margin: 0.55rem 0; }

/* ---------- processing ---------- */
.stages { list-style: none; margin: 1.2rem 0 0.6rem; padding: 0; }
.stages li { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0; color: var(--dim); }
.stage-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--dim); flex: none; }
.stage-name { font-weight: 600; }
.stage-extra { margin-left: auto; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.stages li[data-state="active"] { color: var(--text); }
.stages li[data-state="active"] .stage-dot { border-color: var(--text); border-top-color: transparent; animation: spin 0.8s linear infinite; }
.stages li[data-state="done"] { color: var(--muted); }
.stages li[data-state="done"] .stage-dot { background: var(--text); border-color: var(--text); }
.stages li[data-state="error"] { color: var(--alert); }
.stages li[data-state="error"] .stage-dot { background: var(--alert); border-color: var(--alert); }
.stages li:not([data-state="active"]) .stage-extra { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { margin-top: 0.4rem; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--text); transition: width 0.2s ease; }
.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.row-actions .btn { margin-top: 0; }

/* ---------- session ---------- */
#view-session[data-empty] > :not(#s-status) { display: none; } /* only the error message */
.session-head { margin: 0.1rem 0 1rem; }
.title-input {
  font-size: 1.9rem !important; line-height: 1.2; font-weight: 700 !important; letter-spacing: -0.03em;
  background: transparent !important; border: 1px solid transparent !important;
  padding: 0.3rem 0.5rem !important; margin-left: -0.5rem; width: calc(100% + 1rem) !important;
}
.title-input:focus { background: var(--surface) !important; border-color: var(--line-strong) !important; }
.player { margin-bottom: 1rem; }
.player .btn { margin-top: 0; }
.player audio { width: 100%; }

.md { overflow-wrap: anywhere; }
.md h2, .md h3, .md h4 { margin: 1.4rem 0 0.4rem; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }
.md h2 { font-size: 1.15rem; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0.5rem 0; }
.md ul, .md ol { margin: 0.4rem 0; padding-left: 1.25rem; }
.md li { margin: 0.3rem 0; }
.md li.task { list-style: none; margin-left: -1.25rem; }
.md li.task .box { margin-right: 0.4rem; color: var(--text); }
.md blockquote { margin: 0.6rem 0; padding: 0 0 0 1.1rem; font-style: italic; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* transcript: speakers told apart by marker shape/fill, name always bold white */
.transcript { display: flex; flex-direction: column; gap: 1.1rem; }
.turn-head { display: flex; align-items: center; gap: 0.5rem; }
.turn-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.turn-name::before, .swatch {
  content: ""; display: inline-block; width: 0.6rem; height: 0.6rem; margin-right: 0.45rem;
  border: 2px solid var(--text); background: var(--text); border-radius: 50%; box-sizing: border-box; vertical-align: baseline;
}
.swatch { margin: 0; }
.turn[data-sp="1"] .turn-name::before, .speaker-field[data-sp="1"] .swatch { background: transparent; }
.turn[data-sp="2"] .turn-name::before, .speaker-field[data-sp="2"] .swatch { background: var(--dim); border-color: var(--dim); }
.turn[data-sp="3"] .turn-name::before, .speaker-field[data-sp="3"] .swatch { border-radius: 1px; }
.turn[data-sp="4"] .turn-name::before, .speaker-field[data-sp="4"] .swatch { border-radius: 1px; background: transparent; }
.turn[data-sp="5"] .turn-name::before, .speaker-field[data-sp="5"] .swatch { border-radius: 1px; background: var(--dim); border-color: var(--dim); }
.turn[data-sp="6"] .turn-name::before, .speaker-field[data-sp="6"] .swatch { border-radius: 1px; transform: rotate(45deg) scale(0.85); }
.turn[data-sp="7"] .turn-name::before, .speaker-field[data-sp="7"] .swatch { border-radius: 1px; background: transparent; transform: rotate(45deg) scale(0.85); }
.turn-time { font-size: 0.8rem; color: var(--dim); font-variant-numeric: tabular-nums; }
.turn-text { margin: 0.2rem 0 0; color: var(--text); }
.speakers { margin: 0 0 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.speaker-field span { display: flex; align-items: center; gap: 0.5rem; }
.grid-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.grid-actions .btn { margin-top: 0; }

/* ---------- list ---------- */
.session-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.session-item { border-bottom: 1px solid var(--line); }
.session-link { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.8rem; padding: 1rem 0; min-height: 44px; color: var(--text); text-decoration: none; }
.session-title { font-weight: 600; font-size: 1.05rem; overflow-wrap: anywhere; }
.session-meta { grid-column: 1; font-size: 0.875rem; color: var(--muted); }
.badge {
  grid-column: 2; grid-row: 1 / span 2; align-self: center;
  font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.65rem; border-radius: 999px;
  background: transparent; color: var(--muted); border: 1px solid var(--line-strong); white-space: nowrap;
}
.badge[data-status="done"] { background: var(--text); color: var(--on-text); border-color: var(--text); }   /* filled */
.badge[data-status="stopped"] { color: var(--text); border-color: var(--muted); }                          /* outlined */
.badge[data-status="interrupted"] { color: var(--dim); border-style: dashed; border-color: var(--dim); }  /* dashed */
.badge[data-status="error"] { color: var(--alert); border-color: var(--alert); }                            /* error = red */
.session-item .item-actions { padding: 0 0 1rem; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 0; }

.badge[data-status="review"], .badge[data-status="missing"], .badge[data-status="elsewhere"] { color: var(--text); border-style: dashed; border-color: var(--text); } /* dashed, needs attention */
.badge[data-status="recording"] { color: var(--alert); border-color: var(--alert); }                       /* live recording = red */
.badge[data-status="owner"] { background: var(--text); color: var(--on-text); border-color: var(--text); }  /* filled */
.badge[data-status="editor"] { color: var(--text); border-color: var(--muted); }                          /* outlined */
.badge[data-status="viewer"] { color: var(--dim); border-style: dashed; border-color: var(--dim); }       /* dashed */
.badge[data-status="disabled"] { color: var(--dim); border-style: dashed; border-color: var(--dim); text-decoration: line-through; }
.session-item .session-sub { grid-column: 1; font-size: 0.875rem; color: var(--muted); }
.session-item .item-detail { margin: -0.5rem 0 0.7rem; font-size: 0.875rem; color: var(--muted); }

/* rows that are not links (members, users) */
.row-item { display: grid; grid-template-columns: 1fr auto; gap: 0.2rem 0.8rem; padding: 1rem 0 0.6rem; }
.row-item .item-actions { grid-column: 1 / -1; padding: 0.5rem 0 0.4rem; }
.row-item select { width: auto; min-height: 44px; padding: 0.4rem 0.9rem; border-radius: 999px; font-size: 0.9rem; }

/* segmented filter (same shape as the top tabs) */
.segmented { display: flex; gap: 0.15rem; border: 1px solid var(--line-strong); padding: 3px; border-radius: 999px; margin: 0 0 1rem; }
.segmented button {
  flex: 1 1 0; min-height: 44px; padding: 0.2rem 0.5rem; line-height: 1.15; border: 0; border-radius: 999px; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 0.875rem; cursor: pointer; touch-action: manipulation;
}
.segmented button[aria-pressed="true"] { background: var(--text); color: var(--on-text); }

/* checkboxes: share sheet, admin flag */
.check { display: flex; align-items: center; gap: 0.75rem; min-height: 48px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--text); flex: none; }
.check.gone { cursor: default; font-weight: 400; }
.check .check-sub { font-weight: 400; color: var(--muted); font-size: 0.875rem; margin-left: auto; }
.checklist { margin: 0.6rem 0 0.2rem; border-top: 1px solid var(--line); }
.checklist .check { border-bottom: 1px solid var(--line); }
.share-sheet .row-actions { margin-top: 0.8rem; }

.sub-details { margin-top: 1rem; border-top: 1px solid var(--line); }
.sub-details > summary {
  cursor: pointer; font-weight: 600; list-style: none; min-height: 48px;
  display: flex; align-items: center; justify-content: space-between;
}
.sub-details > summary::-webkit-details-marker { display: none; }
.sub-details > summary::after { content: "+"; color: var(--muted); font-size: 1.4rem; font-weight: 400; }
.sub-details[open] > summary::after { content: "–"; }

.session-head .chip { display: inline-block; margin-top: 0.5rem; color: var(--text); border-style: dashed; border-color: var(--text); }
.error-text { color: var(--alert); }
.offline-note { margin-top: 0; }
.view-title + .meta { margin-bottom: 0.4rem; }
#view-settings .row-actions { margin-top: 1rem; }

/* ---------- location ---------- */
.loc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.75rem; }
.loc-line a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); }
.loc-line .link-btn { padding: 0; }
.session-head .loc-line { margin-top: 0.15rem; }
.loc-line .loc-place { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.place-form { margin: 0.4rem 0 0.6rem; }
.place-form .row-actions { margin-top: 0.6rem; }
.session-item .session-place { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- settings: Conexión API ---------- */
.sub-head { margin: 1.4rem 0 0; font-size: 1rem; font-weight: 650; }
.empty-inline { padding: 1rem 0; text-align: left; }
.reveal { margin-top: 1rem; }
.reveal input { margin: 0.5rem 0; font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
#webhook-actions { margin-top: 0.8rem; }
#webhook-secret-line { margin-top: 0.8rem; }

/* recording of another account in this tab: only the notice and the stop button. The mic
   panel above the button keeps its space (invisible) so the stop button does not move. */
#view-record[data-foreign] > :not(.record-panel):not(#rec-foreign):not(.mic-panel) { display: none !important; }
#view-record[data-foreign] > .mic-panel { visibility: hidden; }
#view-record[data-foreign] #rec-location { display: none !important; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + var(--safe-bot)); transform: translateX(-50%);
  background: var(--text); color: var(--on-text); padding: 0.7rem 1.2rem; border-radius: 999px;
  font-size: 0.95rem; font-weight: 500; max-width: calc(100% - 2rem); z-index: 30;
}

@media (prefers-reduced-motion: reduce) {
  .rec-btn.recording .rec-dot, .stages li[data-state="active"] .stage-dot { animation: none; }
  .rec-dot, .progress-bar { transition: none; }
  .stages li[data-state="active"] .stage-dot { border-top-color: var(--text); border-style: dotted; }
}

/* logged out: only the login and settings screens are reachable */
body[data-auth="out"] .tabs, body[data-auth="out"] .icon-btn { visibility: hidden; }
.server-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0 0.75rem; margin-top: 0.8rem; }
#server-card .btn { margin-top: 0.6rem; }
