/* Hilo styles. See apps/hilo/Documentation/BRAND_ASSETS.md.
 *
 * Signature color: Rojo Marron #942B11 (proposed; from Dale Tranqui palette).
 * Typography: Frank Ruhl Libre (display) / Space Grotesk (body) / Space Mono
 * (data) — system fallbacks below because M1 doesn't ship the webfonts yet.
 */

:root {
  --background:       #FEFBF3;  /* Beige */
  --surface:          #FFFFFF;
  --surface-muted:    #F5F3EE;
  --content:          #3D3D3D;  /* Grafito */
  --content-muted:    #6B6B6B;
  --content-subtle:   #999999;
  --accent:           #942B11;  /* Rojo Marron */
  --accent-soft:      #FEE295;  /* Amarillo */
  --border:           #E0E2E5;  /* Gris */
  --border-subtle:    #F0EEEA;
  --error:            #942B11;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --space-2xl: 4rem;

  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --max-width: 720px;
  --max-width-wide: 1080px;
  --gutter: 1.25rem;

  --motion: 0.15s ease;

  --font-display: "Frank Ruhl Libre", Georgia, "Times New Roman", serif;
  --font-body:    "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono:    "Space Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--background);
  color: var(--content);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--motion);
}
a:hover { opacity: 0.7; }

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
button.link:hover { opacity: 0.7; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--gutter);
  max-width: var(--max-width-wide);
  margin: 0 auto;
  border-bottom: 1px solid var(--border);
}
.topbar .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  color: var(--content);
}
.topbar nav {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}
.topbar nav a { color: var(--content-muted); }
.topbar nav a:hover { color: var(--accent); }
form.inline { display: inline; margin: 0; }

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--gutter);
}

.hero {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  margin: 0;
  font-size: 2rem;
}

.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
  transition: opacity var(--motion);
}
.btn:hover { opacity: 0.85; }
.btn-primary { /* default */ }

.form-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}
.form-card label {
  font-weight: 600;
  color: var(--content);
  font-size: 0.9rem;
}
.form-card input,
.form-card textarea {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font: inherit;
  background: var(--surface);
  color: var(--content);
  width: 100%;
}
.form-card textarea {
  resize: vertical;
  min-height: 12rem;
  font-family: var(--font-body);
}
.form-card .btn { align-self: flex-end; }

.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}
.alert-error { background: #fdecec; color: var(--error); border: 1px solid var(--accent); }
.alert-token { background: var(--accent-soft); color: var(--content); border: 1px solid var(--accent); }
.new-token {
  display: block;
  margin-top: var(--space-sm);
  padding: var(--space-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
}

.episode-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.episode-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--motion);
}
.episode-row:hover { border-color: var(--accent); }
.episode-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  color: var(--content);
}
.episode-title { font-weight: 600; }
.episode-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--content-muted);
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.status {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-muted);
  color: var(--content-muted);
  border: 1px solid var(--border);
}
.status-published { background: var(--accent-soft); color: var(--content); border-color: var(--accent-soft); }
.status-failed    { background: #fdecec; color: var(--error); border-color: var(--accent); }
.status-queued, .status-planning, .status-researching, .status-scripting, .status-rendering {
  background: var(--surface-muted);
}
.status-success { background: var(--surface-muted); }
.status-error   { background: #fdecec; color: var(--error); border-color: var(--accent); }

.meta-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-sm) var(--space-lg);
  margin: 0 0 var(--space-xl);
}
.meta-grid dt { color: var(--content-muted); font-size: 0.9rem; }
.meta-grid dd { margin: 0; }
.meta-grid .prompt { font-family: var(--font-body); line-height: 1.55; }
.meta-grid .error  { color: var(--error); font-family: var(--font-mono); font-size: 0.9rem; }

.runs {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.runs th, .runs td {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}
.runs thead th {
  background: var(--surface-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.7rem;
  color: var(--content-muted);
}

.empty {
  color: var(--content-subtle);
  font-style: italic;
}

.note {
  color: var(--content-muted);
  font-size: 0.9rem;
}

/* TBL-349 post-submit confirmation page. The page should feel like a closed
   door, not a dashboard: low visual energy, no CTAs, the prompt echo
   recessed below the calm-down copy. */
.echo-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--content-muted);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xs);
}
.prompt-echo {
  border-left: 3px solid var(--content-subtle);
  margin: 0 0 var(--space-md);
  padding: var(--space-sm) var(--space-md);
  color: var(--content-muted);
  font-style: italic;
}
.footnote {
  color: var(--content-subtle);
  font-size: 0.85rem;
  margin-top: var(--space-xl);
}

/* TBL-355: episode-detail progress UI. Five-step indicator on top,
   stage heading + body + elapsed/typical below. Audio player only on
   `published`. Designed to look honest (no fake percentage bar) and
   restful (no spinners) while still giving the user real signal. */
.progress {
  margin: var(--space-lg) 0 var(--space-xl);
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-lg);
  display: flex;
  gap: 0;
  justify-content: space-between;
  align-items: flex-start;
  position: relative;
}
.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
  font-size: 0.8rem;
  color: var(--content-subtle);
  text-align: center;
}
.progress-step + .progress-step::before {
  content: "";
  position: absolute;
  top: 7px;
  left: -50%;
  right: 50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.progress-step-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  margin-bottom: var(--space-xs);
  z-index: 1;
  position: relative;
}
.progress-step-label {
  font-weight: 500;
}
.progress-step-done .progress-step-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.progress-step-done + .progress-step::before,
.progress-step-current + .progress-step::before {
  background: var(--accent);
}
.progress-step-done .progress-step-label {
  color: var(--content);
}
.progress-step-current .progress-step-dot {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.progress-step-current .progress-step-label {
  color: var(--accent);
  font-weight: 600;
}
.progress-body {
  text-align: left;
}
.progress-heading {
  margin: 0 0 var(--space-xs);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--content);
}
.progress-text {
  margin: 0 0 var(--space-sm);
  color: var(--content-muted);
  line-height: 1.5;
}
.progress-meta {
  margin: 0;
  color: var(--content-subtle);
  font-size: 0.85rem;
}
.audio-player {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}
.audio-player audio {
  width: 100%;
  display: block;
}
.audio-meta {
  margin: var(--space-sm) 0 0;
  color: var(--content-subtle);
  font-size: 0.85rem;
}

/* TBL-356: relative-time suffix on episode list rows. Matches the
   font-size of the absolute formatTime <time> next to the status pill;
   slightly muted so the status pill remains the dominant signal. */
.episode-relative {
  color: var(--content-muted);
}

/* TBL-358: plan-confirmation page. The plan card shows read-only
   title + outline; the form below lets the user edit/add/remove
   research questions before confirming. Layout is intentionally
   close to the existing form-card so the page feels native rather
   than bolted-on. */
.plan-card {
  margin: var(--space-lg) 0;
  padding: var(--space-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.plan-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 var(--space-lg);
  color: var(--content);
}
.plan-outline {
  padding-left: 1.25rem;
  margin: 0;
  color: var(--content-muted);
  line-height: 1.6;
}
.plan-outline li {
  margin-bottom: var(--space-xs);
}

.question-list {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: var(--space-sm) 0 var(--space-md);
}
.question-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  margin-bottom: var(--space-sm);
}
.question-row textarea {
  flex: 1;
  font: inherit;
  padding: var(--space-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--content);
  resize: vertical;
  min-height: 2.5rem;
}
.question-remove {
  align-self: center;
  background: none;
  border: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: var(--space-xs) var(--space-sm);
}
.question-remove:hover {
  text-decoration: underline;
}

#question-add {
  margin-bottom: var(--space-lg);
}

.confirm-actions {
  margin-top: var(--space-lg);
  display: flex;
  justify-content: flex-end;
}

.regenerate-form {
  margin-top: var(--space-xl);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-md);
  background: transparent;
}

.btn-secondary {
  background: transparent;
  color: var(--content);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  border-color: var(--content);
}

/* TBL-358: prominent CTA inside the progress card when an episode is
   parked at awaiting_confirmation — leads the user straight to the
   plan-review page. */
.confirm-cta {
  margin: var(--space-md) 0;
}

/* TBL-373: cost-summary sparkline next to the Spend-30d stat. Inline
   SVG inherits color via currentColor; sparkline-range is a small
   "peak $X" suffix; empty state is a muted "no cost yet" placeholder. */
.sparkline {
  display: inline-block;
  vertical-align: middle;
  margin-left: var(--space-sm);
  color: var(--accent);
}
.sparkline-range {
  display: inline-block;
  margin-left: var(--space-sm);
  color: var(--content-subtle);
  font-size: 0.85rem;
}
.sparkline-empty {
  display: inline-block;
  margin-left: var(--space-sm);
  color: var(--content-subtle);
  font-style: italic;
  font-size: 0.85rem;
}

/* TBL-365: regenerating-plan flash banner on /episodes/{id}/confirm. */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
}
.alert-info {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  color: var(--content);
}
.alert-error {
  background: #FEE;
  border: 1px solid var(--error);
  color: var(--error);
}

/* TBL-364: per-row action cluster (Purge + Reindex) on the indexed-
   corpus table. Stays inline so the table doesn't grow per row. */
.memory-row-actions {
  white-space: nowrap;
}
.memory-row-actions form.inline {
  display: inline-block;
  margin-right: var(--space-sm);
}

/* TBL-360: per-user confirmation-default toggle on /admin. */
.toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  font-weight: normal;
}
.toggle input[type="checkbox"] {
  width: 1.1em;
  height: 1.1em;
  cursor: pointer;
}

.checklist {
  padding-left: 1.2rem;
  color: var(--content-muted);
}
.checklist li {
  margin-bottom: var(--space-xs);
}

.footer {
  max-width: var(--max-width-wide);
  margin: var(--space-2xl) auto var(--space-md);
  padding: 0 var(--gutter);
  color: var(--content-subtle);
  font-size: 0.85rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-md);
  margin: 0 0 var(--space-xl);
}
.stats-grid dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--content-muted);
}
.stats-grid dd {
  margin: var(--space-xs) 0 0;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--content);
}

.recall-list {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.recall-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}
.recall-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--content-muted);
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-xs);
}
.recall-text {
  margin: 0;
  color: var(--content);
  font-style: italic;
}

.run-debug {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin: var(--space-sm) 0;
}
.run-debug summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--content-muted);
}
.run-debug summary:hover { color: var(--accent); }
.run-debug h4 {
  font-size: 0.9rem;
  color: var(--content-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--space-md) 0 var(--space-xs);
}
.run-blob {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24rem;
  overflow-y: auto;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
