/* MRB Recording Assistant — documentary visual language */
:root {
  --bg: #fafaf7;
  --ink: #141412;
  --accent: #b3261e;
  --accent-hot: #ff6b61;
  --rule: #d8d6cf;
  --panel: #f1f0ea;
  --ok: #3a6b3a;
  --pending: #8a6a1e;
  --header: #0f0f0d;
  --header-ink: #fafaf7;
  --muted: #b9b8b2;
  --danger: #b3261e;
  --font-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-cond: "IBM Plex Sans Condensed", "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --pad: 16px;
  --tap: 48px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  border: 1px solid var(--ink);
  background: var(--bg);
  border-radius: 0;
  min-height: var(--tap);
  padding: 0 16px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--rule);
  background: #fff;
  padding: 0 12px;
  border-radius: 0;
}
.mono { font-family: var(--font-mono); }
.small { font-size: 13px; line-height: 1.4; }

#app-root {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.view { display: flex; flex-direction: column; min-height: 100dvh; }
.view[hidden], [hidden] { display: none !important; }

/* Header band — matches burned-in overlay */
.site-header {
  background: var(--header);
  color: var(--header-ink);
  padding: 14px var(--pad);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  min-height: 85px;
}
.site-header.compact { min-height: 64px; padding: 12px var(--pad); }
.site-header .name {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.site-header .tagline {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-hot);
  margin-top: 4px;
  letter-spacing: 0.04em;
}
.site-header-right {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding-top: 4px;
}

.home-main, .preflight-main, .photos-main, .result-main {
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--rule);
  padding: 14px;
}
.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.status-row:last-child { border-bottom: 0; }
.status-row .label { color: #5c5b55; }
.status-row .value { text-align: right; font-weight: 500; }
.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c5b55;
  margin: 12px 0 6px;
}
.open-entries ul { list-style: none; margin: 0; padding: 0; }
.open-entries li {
  border: 1px solid var(--rule);
  background: #fff;
  padding: 10px 12px;
  margin-bottom: 6px;
  font-size: 14px;
}
.queue-status { margin-top: 8px; }

.chooser-heading {
  font-family: var(--font-cond);
  font-size: 20px;
  font-weight: 700;
  margin: 8px 0 4px;
  letter-spacing: 0.02em;
}
.chooser-intro {
  margin: 0 0 8px;
  font-size: 14px;
  color: #3a3934;
}

.session-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid var(--ink);
  padding: 14px;
  margin-bottom: 10px;
  min-height: auto;
}
.session-card:hover:not(:disabled), .session-card:focus-visible {
  border-color: var(--accent);
  background: #fff8f7;
}
.session-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
}
.session-name {
  font-family: var(--font-cond);
  font-weight: 700;
  font-size: 17px;
}
.session-when { font-size: 11px; color: #5c5b55; white-space: nowrap; }
.session-desc { margin: 0; font-size: 13px; color: #3a3934; line-height: 1.4; }

.settings-toggle {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 40px;
  padding: 0;
}
.settings-body { padding-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field span { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: #5c5b55; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-note { color: #5c5b55; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--ink);
  background: var(--bg);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover:not(:disabled) { background: #2a2a26; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; color: var(--header-ink); border-color: var(--muted); }

/* Preflight */
.preflight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preflight-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--rule);
  font-size: 13px;
}
.preflight-list .check-ok { color: var(--ok); font-weight: 600; }
.preflight-list .check-fail { color: var(--danger); font-weight: 600; }
.preflight-list .check-warn { color: var(--pending); font-weight: 600; }
.preflight-list .check-pending { color: #5c5b55; }

.preflight-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 42vh;
  background: #000;
  border: 1px solid var(--ink);
  overflow: hidden;
}
.preflight-video, .preflight-guide {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.preflight-guide { pointer-events: none; }
.frame-guides { position: absolute; inset: 0; pointer-events: none; }
.guide-line {
  position: absolute;
  left: 8%;
  right: 8%;
  height: 1px;
  background: var(--accent-hot);
  opacity: 0.85;
}
.guide-head { top: 12%; }
.guide-foot { bottom: 10%; }
.preflight-fields { display: flex; flex-direction: column; gap: 10px; }
.preflight-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.preflight-actions .btn-primary { flex: 1; }

.status-line {
  margin: 0;
  min-height: 1.4em;
  font-size: 13px;
  color: #3a3934;
}

/* Session */
.view-session {
  background: #000;
  color: #fff;
  max-width: none;
}
#app-root:has(.view-session:not([hidden])) { max-width: none; }
.session-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 0;
}
.capture-video {
  /* Attached for decode; near-zero opacity, 1px park pattern also used */
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
  left: 0;
  top: 0;
}
.compose-canvas { display: none; }
.preview-canvas {
  width: 100%;
  height: 100%;
  max-height: 100dvh;
  object-fit: contain;
}
.session-chrome {
  padding: 10px var(--pad) calc(12px + env(safe-area-inset-bottom));
  background: var(--header);
  border-top: 1px solid #2a2a26;
}
.session-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.view-session .status-line { color: var(--header-ink); }

/* Photos */
.photo-stage {
  width: 100%;
  aspect-ratio: 9 / 16;
  max-height: 55vh;
  background: #000;
  border: 1px solid var(--ink);
}
.photo-canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.photo-prompt { font-size: 15px; margin: 0; }

/* Result */
.result-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.5;
}
.result-actions { display: flex; gap: 8px; }


/* Error */
.view-error {
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}
.error-panel { max-width: 420px; width: 100%; }
.error-panel h1 {
  font-family: var(--font-cond);
  font-size: 22px;
  margin: 0 0 10px;
}
.error-panel p { margin: 0 0 16px; color: var(--danger); }

/* Parked elements — must decode; not display:none / visibility:hidden */
.parked {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0.01;
  pointer-events: none;
  left: 0;
  top: 0;
  z-index: -1;
}

/* Mobile */
@media (max-width: 390px) {
  .session-when { display: none; }
  .site-header .name { font-size: 18px; }
}

/* Setup phase + downloads */
.setup-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.setup-countdown {
  margin: 0;
  font-size: 14px;
  color: var(--accent-hot);
  letter-spacing: 0.04em;
}
.setup-controls .btn-primary {
  width: 100%;
  background: #fafaf7;
  color: #141412;
  border-color: #fafaf7;
}
.result-downloads {
  border: 1px solid var(--rule);
  background: var(--panel);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.download-row { }
.download-link {
  color: var(--accent);
  text-decoration: underline;
  font-size: 13px;
  word-break: break-all;
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
}

/* Lock */
.lock-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; }
.lock-panel { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.lock-title { margin: 0; font-family: var(--font-cond, 'IBM Plex Sans Condensed', sans-serif); font-size: 24px; letter-spacing: 0.02em; text-transform: uppercase; }
.lock-error { color: #B3261E; margin: 0; font-size: 12px; }
.lock-btn { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
