/* Tokens mirrored from frontend/src/styles/tokens.css — that file is the source
   of truth; keep in sync by hand. Dark-only, like /app. */

/* ============================================================ */
/* 1. Tokens                                                    */
/* ============================================================ */
:root {
  color-scheme: dark;
  /* chrome */
  --bg-app: #0d0f13; /* app background */
  --bg-panel: #14171c; /* panels */
  --bg-elevated: #1b1f26; /* cards, inputs, hover */
  --border: #262b33;
  --fg: #e6e8eb; /* primary text */
  --fg-muted: #8b93a1;
  --fg-faint: #5c6470;
  --accent: #4f8ff7; /* selection, playhead handle, primary buttons */
  --accent-fg: #ffffff;
  --danger: #e5484d;
  --warn: #f0a13b;
  --ok: #46a758;
  /* track/element colors (element kind = color, matches old viewer semantics) */
  --el-clip: #2f5db3;
  --el-clip-border: #4f8ff7;
  --el-text: #8a6d1f;
  --el-text-border: #d4a72c;
  --el-audio: #1f7a55;
  --el-audio-border: #34d399;
  --el-overlay: #6b4fa0;
  --el-overlay-border: #a78bfa;
  /* annotations (same palette as annotate.html today) */
  --pin-blocker: #dc2626;
  --pin-major: #d97706;
  --pin-minor: #2563eb;
  /* type & spacing */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-md: 13px;
  --radius: 6px;
  --radius-sm: 4px;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
}

/* ============================================================ */
/* 2. Base (ported from base.html's inline <style>)             */
/* ============================================================ */
* { box-sizing: border-box; }
body {
  font-family: var(--font-ui);
  background: var(--bg-app);
  color: var(--fg);
  margin: 0;
  padding: 0;
}
header {
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--bg-panel);
}
header a { color: var(--fg); text-decoration: none; }
.nav-left, .nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-left .brand { font-weight: 600; }
.nav-left a:not(.brand) { color: var(--fg-muted); font-size: var(--fs-sm); }
.nav-left a:not(.brand):hover { color: var(--fg); }
header .tag {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}
header .editor-link { color: var(--accent); }
.logout-form { display: inline; margin: 0; }
.logout-form button {
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
  background: transparent; color: var(--fg-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 4px 10px;
}
.logout-form button:hover { color: var(--fg); border-color: var(--fg-faint); }
main { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }
h1, h2, h3 { line-height: 1.3; }
a { color: var(--accent); }
table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
th { color: var(--fg-muted); font-weight: 600; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: var(--bg-elevated); }
.empty { color: var(--fg-faint); font-style: italic; padding: 2rem 0; }
.scroll-x { overflow-x: auto; }
code, pre { font-family: var(--font-mono); font-size: 0.85rem; }
pre { background: var(--bg-elevated); padding: 0.75rem; border-radius: 6px; overflow-x: auto; }
details > summary { cursor: pointer; color: var(--fg-muted); }
details { margin-bottom: 0.5rem; border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.6rem; }

.track { margin-bottom: 0.9rem; }
.track-label { font-size: 0.75rem; color: var(--fg-muted); margin-bottom: 0.25rem; text-transform: uppercase; letter-spacing: 0.05em; }
.track-lane { position: relative; height: 2.25rem; background: var(--bg-elevated); border-radius: 4px; }
.el {
  position: absolute; top: 2px; bottom: 2px; border-radius: 4px;
  padding: 0 0.4rem; font-size: var(--fs-xs); line-height: 2rem;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  color: var(--fg);
}
.el-clip { background: var(--el-clip); border: 1px solid var(--el-clip-border); }
.el-text { background: var(--el-text); border: 1px solid var(--el-text-border); }
.el-audio { background: var(--el-audio); border: 1px solid var(--el-audio-border); }
.el-overlay { background: var(--el-overlay); border: 1px solid var(--el-overlay-border); }
video, img.preview-frame { max-width: 360px; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }

/* ============================================================ */
/* 3. Components (new for the redesign)                         */
/* ============================================================ */

/* Status — the enum value (draft/exporting/exported) is the class suffix,
   so no Python mapping is needed. A leading dot inherits the status color. */
.status { display: inline-flex; align-items: center; gap: 6px; }
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-draft { color: var(--fg-muted); }
.status-exporting { color: var(--warn); }
.status-exported { color: var(--ok); }

/* Metadata chips — human-readable `niche 3` instead of raw `niche_id=3`. */
.meta-chip {
  font-size: var(--fs-xs);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--fg-muted);
  white-space: nowrap;
}
.meta-chip b { color: var(--fg); font-weight: 600; }

/* Count next to a heading (e.g. "Projects  12"). */
.count { color: var(--fg-faint); font-size: 0.6em; }

/* Two-column work zone: player | timeline+details, collapses < 960px. */
.two-col { display: grid; gap: var(--sp-4); }
@media (min-width: 960px) {
  .two-col { grid-template-columns: minmax(280px, 400px) 1fr; align-items: start; }
  .two-col > .col-player { position: sticky; top: var(--sp-4); }
}

/* --- annotate page (ported from annotate.html's inline <style>) --- */
.note-rule { border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 4px; padding: 0.5rem 0.75rem; color: var(--fg-muted); }
.annotate-bar { cursor: crosshair; margin: 0.5rem 0 1.5rem; }
.pin { position: absolute; top: -4px; transform: translateX(-50%); font-size: 0.9rem; line-height: 1; color: var(--accent); }
.pin-blocker { color: var(--pin-blocker); }
.pin-major { color: var(--pin-major); }
.pin-minor { color: var(--pin-minor); }
.pin-resolved { opacity: 0.35; }
.sev { font-size: 0.7rem; border-radius: 4px; padding: 0.05rem 0.4rem; border: 1px solid var(--border); text-transform: uppercase; }
.sev-blocker { color: var(--pin-blocker); }
.sev-major { color: var(--pin-major); }
.sev-minor { color: var(--pin-minor); }
.row-resolved td { opacity: 0.5; }
.inline-form { display: inline; margin: 0; }
.add-form { display: grid; gap: 0.6rem; max-width: 560px; margin-top: 0.5rem; }
.add-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.8rem; color: var(--fg-muted); }
.add-form input, .add-form select, .add-form textarea { font: inherit; padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-elevated); color: var(--fg); }
.add-form button, .inline-form button { font: inherit; cursor: pointer; padding: 0.35rem 0.8rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-elevated); color: var(--fg); }
.add-form button[type="submit"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.hint { font-size: 0.8rem; color: var(--fg-muted); }

/* Editor cross-link styled as an accent button (shared /ui ↔ /app chrome). */
.editor-link { border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 4px 10px; text-decoration: none; }

/* --- inline form banners (project create, and anywhere /ui reports a
   rejected form) --- */
.form-error { border: 1px solid var(--danger); border-left: 4px solid var(--danger); border-radius: 4px; padding: 0.5rem 0.75rem; color: var(--danger); margin-bottom: 1rem; }
.form-success { border: 1px solid var(--ok); border-left: 4px solid var(--ok); border-radius: 4px; padding: 0.5rem 0.75rem; color: var(--ok); margin-bottom: 1rem; }

/* ============================================================ */
/* 4. The four-kind timeline strip                              */
/* ============================================================ */
/* The brand signature: one color per element kind (clip / text / audio /
   overlay), the same semantics as the real editor. The auth pages carry
   their own copy of this rule in auth.css — auth_base.html is standalone
   and never loads this stylesheet. */
.empty-strip { display: flex; height: 3px; }
.empty-strip > span { flex: 1; }
.empty-strip > :nth-child(1) { background: var(--el-clip-border); }
.empty-strip > :nth-child(2) { background: var(--el-text-border); }
.empty-strip > :nth-child(3) { background: var(--el-audio-border); }
.empty-strip > :nth-child(4) { background: var(--el-overlay-border); }

/* ============================================================ */
/* 5. Projects surface — page header, panel, empty state        */
/* ============================================================ */

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { margin: 0 0 0.3rem; }
.page-sub { margin: 0; color: var(--fg-muted); font-size: var(--fs-sm); max-width: 60ch; }

/* Wraps the dense project table so it reads as one bordered surface. */
.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel table { margin: 0; }
.panel tbody tr:last-child td { border-bottom: none; }

.empty-state { max-width: 420px; margin: 2rem auto; text-align: center; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.empty-state > p { margin: 0.4rem 1.5rem; color: var(--fg-muted); font-size: var(--fs-sm); }
.empty-state > p:last-child { padding-bottom: 1.6rem; }
.empty-state-title { margin-top: 1.5rem !important; color: var(--fg) !important; font-size: var(--fs-md); font-weight: 600; }

/* ============================================================ */
/* 6. Shared chrome: footer alignment, buttons, new-project,    */
/*    onboarding card, and the /ui/connect docs page            */
/* ============================================================ */

/* Footer sits in the same content column as <main> instead of jamming
   against the viewport's left edge. */
.legal-footer { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem; color: var(--fg-muted); font-size: var(--fs-sm); }
.legal-footer a { color: var(--fg-muted); }
.legal-footer a:hover { color: var(--accent); }

.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.btn-primary, .btn-secondary {
  display: inline-block; font: inherit; font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; text-decoration: none; border-radius: var(--radius-sm);
  padding: 0.4rem 0.85rem; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--bg-elevated); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--fg-faint); }

/* "New project" disclosure — native <details>, no JS. summary is the button. */
.new-project { position: relative; }
.new-project > summary { list-style: none; }
.new-project > summary::-webkit-details-marker { display: none; }
.new-project[open] > summary { filter: brightness(1.08); }
.new-project-form { margin-top: 0.75rem; gap: 0.75rem; max-width: 520px; }
.new-project-lead { margin: 0; color: var(--fg-muted); font-size: var(--fs-sm); }
.new-project-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.new-project-form button[type="submit"] { justify-self: start; background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; padding: 0.45rem 1rem; }
@media (max-width: 520px) { .new-project-grid { grid-template-columns: 1fr; } }
/* On wider screens float the form so opening it never shoves the table. */
@media (min-width: 700px) {
  .new-project[open] > .new-project-form {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 5;
    width: 360px; max-width: none; background: var(--bg-panel);
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem; box-shadow: 0 18px 48px -24px rgba(0, 0, 0, 0.8);
  }
}

/* Projects table: cap width so columns don't sprawl on wide screens. */
.panel { max-width: 960px; }

/* Empty-state onboarding — left-aligned in the content flow, actionable. */
.onboarding { max-width: 560px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-panel); }
.onboarding-strip { display: flex; height: 3px; }
.onboarding-strip > span { flex: 1; }
.onboarding-strip > :nth-child(1) { background: var(--el-clip-border); }
.onboarding-strip > :nth-child(2) { background: var(--el-text-border); }
.onboarding-strip > :nth-child(3) { background: var(--el-audio-border); }
.onboarding-strip > :nth-child(4) { background: var(--el-overlay-border); }
.onboarding-body { padding: 1.25rem 1.5rem 1.5rem; }
.onboarding-title { margin: 0 0 0.4rem; font-weight: 600; color: var(--fg); }
.onboarding-body > p { margin: 0 0 1rem; color: var(--fg-muted); font-size: var(--fs-sm); }

/* /ui/connect — MCP onboarding docs. */
.doc-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: var(--sp-3); max-width: 960px; }
.doc-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.doc-card h2 { margin: 0 0 0.6rem; font-size: var(--fs-md); display: flex; align-items: center; gap: 0.5rem; }
.doc-card p { margin: 0 0 0.75rem; color: var(--fg-muted); font-size: var(--fs-sm); }
.doc-card pre { margin: 0 0 0.75rem; }
.doc-card p code, .doc-list code { color: var(--fg); }
.doc-step { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--radius-sm); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--accent); font-size: var(--fs-xs); font-weight: 700; }
.doc-wide { max-width: 960px; margin-bottom: var(--sp-3); }
.doc-list { margin: 0 0 0.75rem; padding-left: 1.1rem; color: var(--fg-muted); font-size: var(--fs-sm); }
.doc-list li { margin-bottom: 0.3rem; }
