/* JETT portal — light Linear chrome.
   Implements design-system/jett-social-ai-manager/PRODUCT-UI-LIGHT.md.
   One hand-written file: no framework, no build step, no external request.

   ponytail: the addendum names Inter + IBM Plex Mono. We ship the system stack
   instead so the portal makes zero third-party requests and has no webfont
   FOUT. To adopt the named faces, self-host the woff2 files under
   /static/fonts/ and add @font-face here — do not add a CDN <link>. */

:root {
  /* Palette */
  --bg:          #FAFAF8;
  --surface:     #FFFFFF;
  --surface-2:   #F4F4F2;
  --ink:         #111110;
  --ink-2:       #5D5D58;
  --ink-3:       #8A8A84;
  --line:        #E4E4E0;
  --accent:      #FF3B00;
  --accent-ink:  #C42E00;
  --accent-soft: #FFF0EB;
  --ok:          #177245;
  --warn:        #9A6700;
  --err:         #C8321E;
  --demo-ink:    #9A6700;
  --demo-bg:     #FFF8E1;

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --t-xs:  0.75rem;
  --t-sm:  0.8125rem;
  --t-md:  0.875rem;
  --t-lg:  1rem;
  --t-xl:  1.5rem;
  --h1-track: -0.02em;

  /* Space, radii, elevation, motion */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px;
  --r-sm: 6px;
  --r-md: 10px;
  --shadow-float: 0 4px 16px rgba(17, 17, 16, .08);
  /* Elevation is borders (README rule 5). These are the hairline that lifts a
     surface off the page — 1-2px, never a drop shadow. */
  --panel-shadow: 0 1px 2px rgba(17, 17, 16, .04);
  --btn-shadow:   0 1px 2px rgba(255, 59, 0, .25);
  --auth-shadow:  0 2px 12px rgba(17, 17, 16, .06);
  --focus-ring:   rgba(255, 59, 0, .15);
  --nav-active-bg: #FFF1EC;
  --dur: 120ms;
  --ease: ease-out;
  --sidebar-w: 224px;
  --demo-h: 32px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.5;
}

h1, h2, h3, p, dl, dd, ul { margin: 0; }
h1 { font-size: var(--t-xl); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: var(--t-lg); font-weight: 600; }

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-sm);
}
.muted { color: var(--ink-2); }
.bare { list-style: none; padding: 0; margin: 0; }

/* Focus is never removed — 2px accent ring, 2px offset, on everything. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ===== DEMO banner ===================================================== */

.demo-banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  height: var(--demo-h);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  background: var(--demo-bg);
  color: var(--demo-ink);
  border-bottom: 1px solid var(--line);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== Shell =========================================================== */

.app { display: flex; min-height: 100vh; }
.app--demo { padding-top: var(--demo-h); }

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  padding: var(--s5) var(--s3);
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.app--demo .sidebar { height: calc(100vh - var(--demo-h)); top: var(--demo-h); }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 var(--s3);
  color: var(--ink);
  font-weight: 600;
  font-size: var(--t-lg);
  letter-spacing: 0.02em;
}
.wordmark:hover { text-decoration: none; }
.wordmark--lg { font-size: var(--t-xl); padding: 0; }
.dot-brand {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  align-self: flex-end;
  margin-bottom: 4px;
}

.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-section {
  padding: 0 var(--s3);
  margin: var(--s5) 0 var(--s2);
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.nav-item {
  display: block;
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  color: var(--ink-2);
  font-size: var(--t-md);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
a.nav-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-item.is-active {
  background: var(--nav-active-bg);
  border-left-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.nav-item.is-disabled { color: var(--ink-3); cursor: not-allowed; }

.user-chip {
  margin-top: auto;
  padding: var(--s3);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}
.user-chip__id { display: grid; min-width: 0; }
.user-chip__uid {
  font-size: var(--t-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip__role { font-size: var(--t-xs); color: var(--ink-3); }

.content {
  flex: 1 1 auto;
  min-width: 0;
  max-width: calc(1080px + 2 * var(--s6));
  padding: var(--s6);
  display: grid;
  gap: var(--s5);
  align-content: start;
}
.content--centered {
  max-width: none;
  place-content: center;
  justify-items: center;
}

/* ===== Page header ===================================================== */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
}
.page-head h1 { letter-spacing: var(--h1-track); }
.page-head__sub { margin-top: var(--s1); color: var(--ink-2); font-size: var(--t-sm); }

/* ===== Panels ========================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s5);
  display: grid;
  gap: var(--s4);
  align-content: start;
  box-shadow: var(--panel-shadow);
}
.panel__title { font-size: var(--t-lg); }
.grid-2 { display: grid; gap: var(--s5); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.empty { color: var(--ink-2); font-size: var(--t-sm); }

/* ===== Tables ========================================================== */

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th {
  background: var(--surface-2);
  text-align: left;
  font-size: var(--t-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.table th, .table td {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--line);
}
.table tbody tr { transition: background var(--dur) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.row-id { display: block; color: var(--ink-3); font-size: var(--t-xs); }

/* ===== Status ========================================================== */

.status { display: inline-flex; align-items: center; gap: var(--s2); white-space: nowrap; }
.status--lg { font-size: var(--t-lg); font-weight: 500; }
.status__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--ink-3); }
.status__dot--ok   { background: var(--ok); }
.status__dot--warn { background: var(--warn); }
.status__dot--err  { background: var(--err); }
.status__dot--idle { background: var(--ink-3); }

/* ===== Key/value ======================================================= */

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--s2) var(--s4);
  font-size: var(--t-sm);
}
.kv--wide { grid-template-columns: max-content 1fr; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }

/* ===== Meters (quota bars — units only, never euros) =================== */

.meter { display: grid; gap: var(--s2); }
.meter__head { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--t-sm); }
.meter__track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter__fill { height: 100%; background: var(--accent); border-radius: inherit; }

/* ===== Filters ========================================================= */

.filters { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip {
  padding: var(--s1) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-xs);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.chip:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.chip.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 500;
}

/* ===== Buttons ========================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  padding: var(--s2) var(--s4);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--t-md);
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn--primary { background: var(--accent); color: #FFF; font-weight: 600; box-shadow: var(--btn-shadow); }
.btn--primary:hover { background: var(--accent-ink); text-decoration: none; }
.btn--ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-2); text-decoration: none; }
.btn--sm { padding: var(--s1) var(--s2); font-size: var(--t-xs); }
.btn--block { width: 100%; }
.btn.is-disabled,
.btn:disabled {
  color: var(--ink-3);
  background: var(--surface);
  border-color: var(--line);
  cursor: not-allowed;
}
a.btn:hover { text-decoration: none; }

/* Loading: the spinner replaces the label, the button keeps its width. */
.btn.is-loading { color: transparent; position: relative; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  color: var(--ink-2);
  animation: spin 600ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn--danger { background: var(--surface); border-color: var(--err); color: var(--err); }
.btn--danger:hover { background: var(--err); color: #FFF; text-decoration: none; }

/* ===== Forms =========================================================== */

.form { display: grid; gap: var(--s4); }
.form--row {
  grid-template-columns: repeat(auto-fit, minmax(140px, max-content));
  align-items: end;
}
.form--row .field--grow { min-width: 240px; }
.inline-form { display: inline-flex; gap: var(--s1); align-items: center; }
.field { display: grid; gap: var(--s1); }
.field label { font-size: var(--t-sm); font-weight: 500; }
select, textarea,
input[type="text"],
input[type="password"] {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--t-md);
  transition: border-color var(--dur) var(--ease);
}
select:hover, textarea:hover,
input[type="text"]:hover,
input[type="password"]:hover { border-color: var(--ink-3); }
/* The soft ring is the field's own focus affordance. It does NOT replace the
   global :focus-visible outline (README rule 4) — that one still ships. */
select:focus, textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea { resize: vertical; min-height: 4em; }
::placeholder { color: var(--ink-3); }
.check { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); color: var(--ink-2); }
.check input { accent-color: var(--accent); }

.alert {
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  border: 1px solid;
  background: var(--surface);
  font-size: var(--t-sm);
}
.alert--err  { color: var(--err);  border-color: var(--err); }
.alert--ok   { color: var(--ok);   border-color: var(--ok); }
.alert--warn { color: var(--warn); border-color: var(--warn); }

/* Visible to screen readers only — labels for controls the layout can't show. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ===== Approvals ======================================================= */

.panel--warn { border-color: var(--warn); }
.approval__body { display: grid; gap: var(--s5); grid-template-columns: minmax(220px, 300px) 1fr; }
.approval__preview video {
  width: 100%;
  border-radius: var(--r-sm);
  background: #0A0A0A;      /* the dark artifact against light chrome IS the design */
  display: block;
}
/* Stand-in for a reel that hasn't rendered. Same dark frame the video gets —
   the contrast between dark artifact and light chrome is the design, and an
   empty slot should still look like the product. */
.poster {
  aspect-ratio: 9 / 16;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-sm);
  background:
    radial-gradient(120% 80% at 50% 0%, #1A1A19 0%, #0A0A0A 60%);
  color: #FFF;
}
.poster__hook {
  font-size: var(--t-lg);
  font-weight: 500;
  line-height: 1.3;
  text-wrap: balance;
}
.poster__note {
  font-size: var(--t-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8A8A84;
}

.approval__meta { display: grid; gap: var(--s3); align-content: start; }
.approval__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--s5);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.approval__actions .form { flex: 1 1 320px; }

.scorecard { display: grid; gap: var(--s3); }
.signal {
  display: grid;
  gap: var(--s2);
  padding: var(--s3);
  background: var(--surface-2);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
}
.signal__head { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.kv--tight { gap: var(--s1) var(--s3); font-size: var(--t-xs); }

/* ===== Onboarding wizard =============================================== */

.content--wizard { max-width: calc(760px + 2 * var(--s6)); }

/* Nine steps stacked vertically pushed the form itself below the fold. As
   pills they wrap into two lines and read as progress, not as a menu. */
.rail ol {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: var(--s1);
}
.rail__step {
  padding: var(--s1) var(--s3);
  border: 1px solid transparent;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--t-xs);
  white-space: nowrap;
}
.rail__step a { color: var(--ink-2); }
.rail__step.is-done { color: var(--ink-2); }
.rail__step.is-done::before { content: "✓ "; color: var(--ok); }
.rail__step.is-active {
  background: var(--nav-active-bg);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s4); }
.fieldset--stack { flex-direction: column; gap: var(--s2); }
.fieldset legend {
  padding: 0 0 var(--s2);
  font-size: var(--t-sm);
  font-weight: 500;
}
.check input[type="radio"] { accent-color: var(--accent); }

.preview {
  display: grid;
  gap: var(--s2);
  padding: var(--s4);
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.preview audio { width: 100%; }

/* ===== Admin =========================================================== */

.actions-cell { display: flex; flex-wrap: wrap; gap: var(--s1); }
.onetime {
  padding: var(--s2) var(--s3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--t-md);
  user-select: all;
  overflow-wrap: anywhere;
}

/* ===== Auth card ======================================================= */

.auth-card {
  width: min(380px, 100%);
  display: grid;
  gap: var(--s4);
  padding: var(--s6);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--auth-shadow);
}
.auth-card__sub { color: var(--ink-2); font-size: var(--t-sm); margin-top: calc(-1 * var(--s2)); }
.auth-card__demo {
  display: grid;
  gap: var(--s2);
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.auth-card__demo .muted { font-size: var(--t-sm); }

/* ===== Small screens =================================================== */

@media (max-width: 720px) {
  .app { flex-direction: column; }
  .sidebar {
    position: static;
    width: auto;
    height: auto;
    flex-basis: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .app--demo .sidebar { height: auto; top: auto; }
  .nav { grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
  .content { padding: var(--s4); }
  .approval__body { grid-template-columns: 1fr; }
}

/* Tables are the workhorse and some carry six columns — let them scroll inside
   their own panel rather than pushing the page sideways. */
.panel { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Environments (Ambiente) ========================================= */

.envs { display: grid; gap: var(--s5); }
.env {
  display: grid;
  gap: var(--s3);
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.env__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.env__media {
  display: grid;
  gap: var(--s3);
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.env__media li { display: grid; gap: var(--s2); }
.env__media img, .env__media video {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: #0A0A0A;
}

/* ===== Avatar picker (Persona) ========================================= */

/* The person who will present every video is a face, not a radio label. The
   photo sits in the dark frame the reels use (README rule 3) and the whole
   card is the control: the native radio stays in the DOM, visually hidden but
   focusable, so keyboard and screen-reader behaviour is the browser's. */
.avatar-grid {
  display: grid;
  gap: var(--s4);
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  border: 0; margin: 0; padding: 0;
}
.avatar-grid legend { padding: 0 0 var(--s3); font-size: var(--t-sm); font-weight: 500; }
.avatar-card {
  display: grid;
  gap: var(--s2);
  padding: var(--s2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.avatar-card:hover { border-color: var(--ink-3); }
.avatar-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.avatar-card__photo {
  width: 100%;
  /* height:auto is load-bearing: the <img> carries width/height attributes so
     the row reserves space before the file lands, and those attributes are
     presentational hints that beat aspect-ratio unless height is auto. Without
     it every portrait rendered at a literal 480px, stretched. */
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: #0A0A0A;
  display: block;
}
.avatar-card__name { font-weight: 600; font-size: var(--t-md); }
.avatar-card__role { color: var(--ink-2); font-size: var(--t-xs); }
.avatar-card__blurb { color: var(--ink-3); font-size: var(--t-xs); line-height: 1.4; }
.avatar-card__tag {
  justify-self: start;
  padding: 2px var(--s2);
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--t-xs);
}
/* :has() is the whole mechanism — no JS, no click handler. Browsers without it
   still render a working radio group, just without the selected highlight. */
.avatar-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--nav-active-bg);
}
.avatar-card:has(input:checked) .avatar-card__name { color: var(--accent-ink); }
.avatar-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Voice picker with players ======================================= */

.voices { display: grid; gap: var(--s3); }
.voice {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.voice.is-current { border-color: var(--accent); background: var(--nav-active-bg); }
.voice__id { display: grid; gap: 2px; min-width: 0; }
.voice__name { font-weight: 500; }
.voice__meta { color: var(--ink-3); font-size: var(--t-xs); }
/* The player spans the row it belongs to, under the buttons that made it. */
.voice__player { grid-column: 1 / -1; width: 100%; height: 36px; }

/* A second block inside a panel — "presenters you made", "make your own" —
   separated by the same hairline the panel uses, not by another card. */
.panel__aside {
  display: grid;
  gap: var(--s4);
  padding-top: var(--s5);
  border-top: 1px solid var(--line);
}
.mine { display: grid; gap: var(--s4); }
.mine .avatar-chosen { justify-content: start; }
.mine .avatar-chosen > div { flex: 1; min-width: 0; }
.mine .avatar-chosen p { margin: 0; }

/* Palette read-back on Setup → Visual style, and per environment. */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s4); }
.swatches li { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-xs); }
.swatch {
  width: 20px; height: 20px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}

/* The chosen persona, shown back on Setup and in the wizard's review step. */
.avatar-chosen { display: flex; align-items: center; gap: var(--s4); }
.avatar-chosen img {
  width: 72px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: #0A0A0A;
}
