/* =========================================================================
   Luogen Team Studio — Apple Design System
   Tokens + base styles + components.
   No frameworks. No build step. Vanilla CSS only.
   ========================================================================= */

:root {
  /* Backgrounds */
  --bg-light: #f5f5f7;
  --bg-dark: #000000;
  --bg-white: #ffffff;

  /* Text */
  --text-primary: #1d1d1f;
  --text-on-dark: #ffffff;
  --text-secondary: rgba(0, 0, 0, 0.8);
  --text-tertiary: rgba(0, 0, 0, 0.48);

  /* Interactive — THE singular accent */
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-bg: rgba(0, 113, 227, 0.06);
  --accent-bg-hover: rgba(0, 113, 227, 0.08);
  --link-light: #0066cc;
  --link-dark: #2997ff;

  /* Surfaces */
  --surface-1: #272729;
  --surface-2: #28282a;
  --surface-3: #2a2a2d;

  /* States */
  --btn-active: #ededf2;
  --btn-light: #fafafc;

  /* Shadows */
  --shadow-card: rgba(0, 0, 0, 0.22) 3px 5px 30px 0px;

  /* Status colors (badges only, NOT chrome) */
  --status-queued: #8e8e93;
  --status-running: #0071e3;
  --status-complete: #34c759;
  --status-failed: #ff3b30;
  --status-cancelled: #aeaeb2;

  /* Spacing base: 8px grid */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --max-width: 980px;
  --nav-height: 48px;

  /* Easing */
  --ease-press: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-banner: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================== RESET ============================== */

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

html,
body {
  height: 100%;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.374px;
  color: var(--text-primary);
  background: var(--bg-light);
}

img,
video {
  max-width: 100%;
  display: block;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: var(--link-light);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  list-style: none;
}

/* ============================== TYPE SCALE ============================== */

.t-hero {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 56px;
  font-weight: 600;
  line-height: 1.07;
  letter-spacing: -0.28px;
}

.t-section {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 40px;
  font-weight: 600;
  line-height: 1.10;
  letter-spacing: normal;
}

.t-card-title {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.19;
  letter-spacing: 0.231px;
}

.t-subhead {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui,
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 21px;
  font-weight: 400;
  line-height: 1.19;
  letter-spacing: 0.231px;
}

.t-body {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47;
  letter-spacing: -0.374px;
}

.t-body-em {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  letter-spacing: -0.374px;
}

.t-link {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.43;
  letter-spacing: -0.224px;
}

.t-caption {
  font-size: 14px;
  font-weight: 400;
  line-height: 1.29;
  letter-spacing: -0.224px;
  color: var(--text-tertiary);
}

.t-micro {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.33;
  letter-spacing: -0.12px;
  color: var(--text-tertiary);
}

/* ============================== LAYOUT ============================== */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.page {
  min-height: 100vh;
  background: var(--bg-light);
}

main {
  padding: var(--sp-8) 0 var(--sp-16) 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.two-col {
  display: grid;
  /* minmax(0, 1fr) — plain `1fr` lets a column expand past its share when a
     child has long unwrappable content (e.g. a CJK script preview without
     spaces), shoving siblings off-screen. `min-width: 0` on each column
     belt-and-braces the same thing for flex children further down. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-8);
}

.two-col > * {
  min-width: 0;
}

.hidden {
  display: none !important;
}

.spacer {
  flex: 1;
}

/* ============================== NAV GLASS ============================== */

.nav-glass {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  color: var(--text-on-dark);
}

.nav-glass__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.nav-glass__logo {
  color: var(--text-on-dark);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.224px;
  white-space: nowrap;
}

.nav-glass__logo:hover {
  text-decoration: none;
  opacity: 0.9;
}

.nav-glass__links {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex: 1;
  justify-content: center;
}

.nav-glass__link {
  color: var(--text-on-dark);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -0.12px;
  opacity: 0.8;
  transition: opacity 150ms ease-out;
}

.nav-glass__link:hover {
  opacity: 1;
  text-decoration: none;
}

.nav-glass__link.active {
  opacity: 1;
  font-weight: 600;
}

.nav-glass__right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.nav-glass__user {
  color: var(--text-on-dark);
  font-size: 12px;
  opacity: 0.8;
}

.nav-glass__logout {
  color: var(--link-dark);
  font-size: 12px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.nav-glass__logout:hover {
  text-decoration: underline;
}

.nav-glass__menu-btn {
  display: none;
  color: var(--text-on-dark);
  font-size: 12px;
}

/* ============================== BUTTONS ============================== */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: var(--accent);
  color: #ffffff;
  padding: 8px 15px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 400;
  line-height: 1.24;
  border: 1px solid transparent;
  transition: background 150ms ease-out, transform 120ms var(--ease-press);
  text-decoration: none;
  min-height: 32px;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary--large {
  padding: 12px 24px;
  font-size: 17px;
  min-height: 44px;
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  background: transparent;
  color: var(--link-light);
  border: 1px solid var(--link-light);
  border-radius: 980px;
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.24;
  transition: background 150ms ease-out, transform 120ms var(--ease-press);
  text-decoration: none;
  white-space: nowrap;
}

.btn-pill:hover {
  text-decoration: underline;
}

.btn-pill:active {
  transform: scale(0.97);
}

.btn-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-pill--danger {
  color: var(--status-failed);
  border-color: var(--status-failed);
}

/* ============================== CARDS ============================== */

.card {
  background: var(--bg-light);
  border-radius: 8px;
  padding: var(--sp-6);
  border: none;
}

.card--elevated {
  background: var(--bg-white);
  box-shadow: var(--shadow-card);
}

.card--on-white {
  background: var(--bg-white);
  box-shadow: var(--shadow-card);
}

/* ============================== INPUTS ============================== */

.input {
  width: 100%;
  background: var(--btn-light);
  border-radius: 11px;
  border: 3px solid rgba(0, 0, 0, 0.04);
  padding: 12px 16px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.374px;
  transition: border-color 150ms ease-out;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

.input::placeholder {
  color: var(--text-tertiary);
}

.textarea {
  width: 100%;
  background: var(--btn-light);
  border-radius: 11px;
  border: 3px solid rgba(0, 0, 0, 0.04);
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.47;
  letter-spacing: -0.374px;
  font-family: inherit;
  min-height: 240px;
  resize: vertical;
}

.textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: transparent;
}

.select {
  width: 100%;
  background: var(--btn-light);
  border-radius: 11px;
  border: 3px solid rgba(0, 0, 0, 0.04);
  padding: 12px 16px;
  font-size: 17px;
  font-weight: 400;
  color: var(--text-primary);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%231d1d1f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5L6 6.5L11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 42px;
}

.select:focus {
  outline: 2px solid var(--accent);
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  letter-spacing: -0.224px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-error {
  color: var(--status-failed);
  font-size: 14px;
  line-height: 1.43;
  min-height: 20px;
}

/* ============================== STATUS BADGE ============================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 4px 12px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.33;
  letter-spacing: -0.12px;
  text-transform: capitalize;
}

.status-badge--queued {
  color: var(--status-queued);
  background: rgba(142, 142, 147, 0.1);
}

.status-badge--running {
  color: var(--status-running);
  background: rgba(0, 113, 227, 0.1);
}

.status-badge--complete {
  color: var(--status-complete);
  background: rgba(52, 199, 89, 0.1);
}

.status-badge--failed {
  color: var(--status-failed);
  background: rgba(255, 59, 48, 0.1);
}

.status-badge--cancelled {
  color: var(--status-cancelled);
  background: rgba(174, 174, 178, 0.1);
}

/* ============================== PROGRESS BAR ============================== */

.progress {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 980px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 980px;
  transition: width 300ms ease-out;
}

/* ============================== JOB CARD ============================== */

.job-card {
  display: block;
  background: var(--bg-white);
  border-radius: 8px;
  padding: var(--sp-5) var(--sp-6);
  text-decoration: none;
  color: inherit;
  transition: background 150ms ease-out, transform 120ms var(--ease-press);
}

.job-card:hover {
  background: #fbfbfd;
  text-decoration: none;
}

.job-card:active {
  transform: scale(0.995);
}

.job-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}

.job-card__title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.24;
  color: var(--text-primary);
  letter-spacing: -0.374px;
}

.job-card__sub {
  font-size: 14px;
  color: var(--text-tertiary);
  line-height: 1.29;
  margin-top: var(--sp-1);
}

.job-card__body {
  margin-top: var(--sp-3);
}

.job-card__footer {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ============================== VOICE / AVATAR CARDS ============================== */

.picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
}

.pick-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  background: var(--bg-white);
  border-radius: 12px;
  padding: var(--sp-4);
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 150ms ease-out, border-color 150ms ease-out,
    transform 120ms var(--ease-press);
  text-align: left;
  width: 100%;
}

.pick-card:hover {
  background: #fbfbfd;
}

.pick-card:active {
  transform: scale(0.98);
}

.pick-card.selected {
  border-color: var(--accent);
}

.pick-card__media {
  aspect-ratio: 1 / 1;
  background: var(--bg-light);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.pick-card__media img,
.pick-card__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pick-card__media-fallback {
  color: var(--text-tertiary);
  font-size: 12px;
}

/* Compact horizontal voice card */
.voice-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-white);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.voice-card:hover { background: #fbfbfd; }
.voice-card--selected { border-color: var(--accent); }

.voice-card__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.voice-card__play {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.voice-card__play:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.voice-card__play--active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg-hover);
}
.voice-card__icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.voice-card__info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.voice-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-card__dur {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.voice-card__cloud {
  font-size: 12px;
  color: var(--accent);
  opacity: 0.7;
}
.pick-card__cloud {
  font-size: 12px;
  color: var(--accent);
  opacity: 0.7;
  flex-shrink: 0;
}
.voice-card__badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 5px;
  white-space: nowrap;
}
/* Voice cards use a list layout, not a grid */
#teamVoices.picker-grid,
#myVoices.picker-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Avatar video play overlay */
.avatar-play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  border: 2px solid rgba(255,255,255,0.8);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  transition: opacity 0.2s ease;
  padding-left: 2px;
}
.pick-card:hover .avatar-play-overlay {
  opacity: 1;
}
/* Avatar video lightbox */
.avatar-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.pick-card__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.29;
  letter-spacing: -0.224px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pick-card__team-badge {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: rgba(0, 113, 227, 0.9);
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 980px;
  letter-spacing: 0.04em;
}

/* Quality badge — overlays the bottom-right corner of the thumbnail with
   the resolution label + aspect ratio ("1440p · 9:16"). Dark translucent
   pill so it reads on any preview image without being distracting. */
.pick-card__quality-badge {
  position: absolute;
  bottom: var(--sp-2);
  right: var(--sp-2);
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 980px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* Sub-line under the avatar name — shows width×height · fps · bitrate
   only when the probe succeeded. Tertiary color so it doesn't compete
   with the name. */
.pick-card__subline {
  color: var(--text-tertiary);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.pick-card__audio {
  width: 100%;
}

/* Per-card action row (library view — share / unshare / delete). Click
   events on these buttons stopPropagation so they don't also fire the
   card's onSelect. */
.pick-card__actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.pick-card__actions .btn-pill {
  font-size: 11px;
  padding: 3px 10px;
  line-height: 1.4;
}
.pick-card__actions .btn-pill--danger {
  color: var(--status-failed, #ff3b30);
  border-color: var(--status-failed, #ff3b30);
}
.pick-card__actions .btn-pill--danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

/* Admin users table — compact, matches jobs table aesthetics. */
.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-users-table th {
  text-align: left;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid #e5e5ea;
}
.admin-users-table td {
  padding: 10px 8px 10px 0;
  border-bottom: 1px solid #f2f2f7;
  font-variant-numeric: tabular-nums;
}
.admin-users-table td:first-child { color: var(--text); font-weight: 500; }
.admin-users-table td.num { text-align: right; color: var(--text-secondary); }
.admin-users-table tr.admin-users-table__disabled td:first-child {
  color: var(--text-tertiary);
  text-decoration: line-through;
}
.admin-users-table .t-link {
  cursor: pointer;
}

/* Inline form for creating users on the admin page. */
.admin-user-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: var(--sp-3);
  align-items: end;
  padding: var(--sp-4);
  background: var(--bg-light);
  border-radius: 8px;
  margin-bottom: var(--sp-4);
}
@media (max-width: 768px) {
  .admin-user-form { grid-template-columns: 1fr; }
}

/* ============================== SYSTEM BANNER ============================== */

.system-banner {
  width: 100%;
  background: #ff9500;
  color: #ffffff;
  padding: var(--sp-3) var(--sp-6);
  animation: banner-slide 250ms var(--ease-banner);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.224px;
  text-align: center;
}

/* Red — worker dead or hard failure. Highest urgency. */
.system-banner--warn {
  background: #ff3b30;
}

/* Blue — informational (e.g. dry-run mode active). */
.system-banner--info {
  background: #0071e3;
}

.system-banner__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.system-banner__text {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.224px;
}

.system-banner__btn {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 980px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease-out;
}

.system-banner__btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

@keyframes banner-slide {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ============================== TABS ============================== */

.tabs {
  display: flex;
  gap: var(--sp-2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: var(--sp-6);
}

.tab {
  padding: var(--sp-3) var(--sp-4);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 150ms ease-out, border-color 150ms ease-out;
  letter-spacing: -0.224px;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ============================== LOGIN PAGE ============================== */

.login-root {
  min-height: 100vh;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-white);
  border-radius: 16px;
  padding: var(--sp-12) var(--sp-8);
  box-shadow: var(--shadow-card);
}

.login-card__logo {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--sp-8);
  letter-spacing: -0.28px;
}

.login-card__form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-card__footer {
  margin-top: var(--sp-8);
  text-align: center;
}

/* ============================== SPINNER ============================== */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0, 113, 227, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1000ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================== TABLE ============================== */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-white);
  border-radius: 12px;
  overflow: hidden;
}

.table th,
.table td {
  padding: var(--sp-4) var(--sp-5);
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.table th {
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
  background: var(--btn-light);
}

.table tbody tr {
  transition: background 150ms ease-out;
}

.table tbody tr:hover {
  background: #fbfbfd;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================== UTILITIES ============================== */

.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-tertiary {
  color: var(--text-tertiary);
}

.mt-4 {
  margin-top: var(--sp-4);
}
.mt-6 {
  margin-top: var(--sp-6);
}
.mt-8 {
  margin-top: var(--sp-8);
}
.mb-4 {
  margin-bottom: var(--sp-4);
}
.mb-6 {
  margin-bottom: var(--sp-6);
}
.mb-8 {
  margin-bottom: var(--sp-8);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.section-title {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.19;
  letter-spacing: 0.231px;
  color: var(--text-primary);
}

.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
  color: var(--text-tertiary);
}

.empty-state__title {
  font-size: 21px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.inline-error {
  color: var(--status-failed);
  font-size: 14px;
  padding: var(--sp-3) var(--sp-4);
  background: rgba(255, 59, 48, 0.08);
  border-radius: 8px;
  line-height: 1.43;
}

.inline-success {
  color: var(--status-complete);
  font-size: 14px;
  padding: var(--sp-3) var(--sp-4);
  background: rgba(52, 199, 89, 0.08);
  border-radius: 8px;
}

.event-log {
  background: var(--btn-light);
  border-radius: 8px;
  padding: var(--sp-4);
  font-size: 13px;
  line-height: 1.6;
  max-height: 280px;
  overflow-y: auto;
}

.event-log__row {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-1) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.event-log__row:last-child {
  border-bottom: none;
}

.event-log__time {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  font-size: 12px;
}

.event-log__msg {
  color: var(--text-secondary);
  word-break: break-word;
}

/* ============================== RESPONSIVE ============================== */

@media (max-width: 1024px) {
  .picker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .picker-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .t-hero {
    font-size: 40px;
  }

  .t-section {
    font-size: 32px;
  }
}

@media (max-width: 480px) {
  .picker-grid {
    grid-template-columns: 1fr;
  }

  .container {
    padding: 0 var(--sp-4);
  }

  main {
    padding: var(--sp-6) 0 var(--sp-12) 0;
  }

  .t-hero {
    font-size: 32px;
  }

  .nav-glass__links {
    display: none;
  }

  .nav-glass__links.open {
    display: flex;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    flex-direction: column;
    padding: var(--sp-4);
    gap: var(--sp-4);
  }

  .nav-glass__menu-btn {
    display: block;
  }

  .nav-glass__user {
    display: none;
  }

  .login-card {
    padding: var(--sp-8) var(--sp-6);
  }
}

/* === Job cards & timeline — added in Phase 2 === */

/* ---------- new JobCard layout ---------- */

.job-card {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  background: var(--bg-white);
  border-radius: 8px;
  padding: var(--sp-4) var(--sp-5);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background 150ms ease-out, transform 120ms var(--ease-press);
}

.job-card:hover {
  background: #eef1f5;
  text-decoration: none;
}

.job-card:active {
  transform: scale(0.995);
}

.job-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.job-card__preview {
  flex: 0 0 auto;
  width: 64px;
  height: 48px;
  border-radius: 6px;
  overflow: hidden;
  background: #e8e8ed;
  display: flex;
  align-items: center;
  justify-content: center;
}

.job-card__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.job-card__preview--empty {
  background: #e8e8ed;
}

.job-card__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.job-card__script {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.job-card__script--empty {
  color: var(--text-tertiary);
  font-size: 17px;
  font-weight: 400;
}

.job-card__script--audio {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 14px;
}

.job-card__audio-glyph {
  color: var(--accent);
  font-size: 14px;
  line-height: 1;
}

.job-card__meta {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.job-card__progress-track {
  width: 100%;
  height: 2px;
  background: #e5e5ea;
  border-radius: 1px;
  overflow: hidden;
  margin-top: var(--sp-2);
}

.job-card__progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  transition: width 300ms ease-out;
}

.job-card__progress-fill.running {
  animation: jobcard-pulse 1400ms ease-in-out infinite;
}

@keyframes jobcard-pulse {
  0% { opacity: 1; }
  50% { opacity: 0.6; }
  100% { opacity: 1; }
}

.job-card__right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--sp-1);
  min-width: 72px;
}

.job-card__time {
  color: var(--text-tertiary);
}

.job-card__user-badge {
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.04);
  padding: 2px 6px;
  border-radius: 980px;
}

/* Duration badge — shows total gen time on terminal jobs (complete/failed).
   Monospaced digits so "耗时 3m 23s" aligns across the list. */
.job-card__duration {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.job-card__download-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 980px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 150ms ease-out, transform 100ms ease-out;
  margin-top: 4px;
}

.job-card__download-btn:hover {
  background: #0062c1;
  text-decoration: none;
}

.job-card__download-btn:active {
  transform: scale(0.96);
}

/* ============================== ANALYTICS ============================== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-card);
  animation: analytics-card-in 250ms ease-out;
}

.stat-card__label {
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.08px;
}

.stat-card__value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-card__delta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-tertiary);
}
.stat-card__delta--up { color: var(--status-complete, #34c759); }
.stat-card__delta--down { color: var(--status-failed, #ff3b30); }

/* Analytics two-column grid (phases + users stacked responsively) */
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-6);
}
@media (max-width: 768px) {
  .analytics-grid { grid-template-columns: 1fr; }
}

.analytics-section {
  background: var(--bg-white);
  border-radius: 12px;
  padding: var(--sp-5);
  box-shadow: var(--shadow-card);
  min-width: 0;
}

.analytics-section__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--sp-3);
  letter-spacing: -0.12px;
}

.analytics-section__subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-3);
}

/* BarRow — one horizontal row per ranked item */
.bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 6px 0;
}
.bar-row__label {
  flex: 0 0 140px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-row__track {
  flex: 1;
  height: 8px;
  background: #e5e5ea;
  border-radius: 4px;
  overflow: hidden;
  min-width: 0;
}
.bar-row__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 300ms ease-out;
}
.bar-row__value {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}

.phase-sub-caption {
  margin: 0 0 4px 152px;
  font-size: 11px;
}

/* Sparkline SVG */
.sparkline {
  width: 100%;
  height: 48px;
  display: block;
}
.sparkline-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.sparkline-area {
  fill: rgba(0, 113, 227, 0.08);
  stroke: none;
}

/* Quality table — compact, monospaced numbers */
.quality-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.quality-table th {
  text-align: left;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid #e5e5ea;
}
.quality-table td {
  padding: 10px 8px 10px 0;
  border-bottom: 1px solid #f2f2f7;
  font-variant-numeric: tabular-nums;
}
.quality-table td:first-child { color: var(--text); font-weight: 500; }
.quality-table td.num { text-align: right; color: var(--text-secondary); }
.quality-table .quality-err { color: var(--text-tertiary); font-style: italic; }

@keyframes analytics-card-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.analytics-freshness {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: var(--sp-3);
}

@media (max-width: 640px) {
  .job-card {
    flex-wrap: wrap;
    gap: var(--sp-3);
  }
  .job-card__preview {
    width: 48px;
    height: 48px;
  }
  .job-card__body {
    flex-basis: calc(100% - 48px - var(--sp-3));
  }
  .job-card__right {
    flex-direction: row;
    flex-basis: 100%;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--sp-1);
  }
}

/* ---------- Timeline ---------- */

.timeline {
  display: flex;
  flex-direction: column;
}

.timeline__step {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-1) 0;
}

.timeline__gutter {
  flex: 0 0 auto;
  width: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 32px;
}

.timeline__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #c7c7cc;
  background: transparent;
  flex: 0 0 auto;
  margin-top: 4px;
  transition: background 200ms ease-out, border-color 200ms ease-out;
}

.timeline__dot--filled {
  background: var(--accent);
  border-color: var(--accent);
}

.timeline__dot--active {
  animation: jobcard-pulse 1400ms ease-in-out infinite;
}

.timeline__dot--terminal {
  background: var(--status-failed);
  border-color: var(--status-failed);
}

.timeline__line {
  flex: 1 1 auto;
  width: 2px;
  background: #e5e5ea;
  min-height: 14px;
  margin-top: 2px;
}

.timeline__content {
  flex: 1 1 auto;
  padding-bottom: var(--sp-3);
  min-width: 0;
}

.timeline__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.29;
  letter-spacing: -0.224px;
}

.timeline__label--muted {
  color: var(--text-tertiary);
  font-weight: 400;
}

.timeline__label--terminal {
  color: var(--status-failed);
}

.timeline__time {
  color: var(--text-tertiary);
  margin-top: 2px;
}

.timeline__detail {
  color: var(--status-failed);
  margin-top: 2px;
  word-break: break-word;
}

.timeline__step--terminal .timeline__gutter {
  min-height: 24px;
}

/* ---------- Two-column detail layout ---------- */

.two-col-detail {
  display: grid;
  grid-template-columns: minmax(0, 60fr) minmax(0, 40fr);
  gap: var(--sp-6);
  align-items: start;
}

.two-col-detail__left,
.two-col-detail__right {
  min-width: 0;
}

@media (max-width: 1024px) {
  .two-col-detail {
    grid-template-columns: 1fr;
  }
}

/* ---------- Detail cards ---------- */

.detail-card {
  background: #f5f5f7;
  border-radius: 8px;
  padding: var(--sp-6);
}

.detail-card--elevated {
  background: var(--bg-white);
  box-shadow: var(--shadow-card);
}

.detail-card__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.224px;
  margin-bottom: var(--sp-4);
  text-transform: none;
}

.detail-card__script {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-primary);
}

.detail-card__toggle {
  background: none;
  border: none;
  padding: 0;
  margin-top: var(--sp-3);
  color: var(--link-light);
  cursor: pointer;
  font-size: 14px;
}

.detail-card__toggle:hover {
  text-decoration: underline;
}

/* ---------- Detail hero ---------- */

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
}

.detail-hero__left {
  min-width: 0;
  flex: 1 1 auto;
}

.detail-hero__right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.detail-hero__meta {
  margin-bottom: var(--sp-2);
}

/* ---------- Asset rows ---------- */

.detail-asset-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-2) 0;
}

.detail-asset-row + .detail-asset-row {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.detail-asset-row__label {
  flex: 0 0 48px;
  color: var(--text-tertiary);
}

.detail-asset-row__value {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--text-primary);
}

.detail-asset-thumb {
  width: 80px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: #e8e8ed;
  flex: 0 0 auto;
}

.detail-asset-thumb--empty {
  display: inline-block;
}

/* ---------- Metadata rows ---------- */

.detail-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  padding: var(--sp-1) 0;
}

.detail-meta-row + .detail-meta-row {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.detail-meta-row__value {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.detail-error-pre {
  background: rgba(255, 59, 48, 0.06);
  color: var(--status-failed);
  border-radius: 6px;
  padding: var(--sp-3) var(--sp-4);
  font-family: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Admin jobs table extras ---------- */

.admin-jobs-table__preview {
  max-width: 280px;
}

.admin-jobs-table__preview .t-caption {
  display: block;
  white-space: normal;
  word-break: break-word;
}

.admin-jobs-table__assets {
  max-width: 200px;
}

.admin-jobs-table__assets .t-micro {
  display: block;
  white-space: normal;
  word-break: break-word;
}

/* Progress bar — detail page hero (running jobs). Matches the system's
   6px-tall progress track used elsewhere, with a smooth width transition
   so polling-driven increments animate instead of jumping. */
.progress-bar-detail {
  height: 6px;
  background: var(--bg-light);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-detail__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Star/favorite button */
.voice-card__star,
.pick-card__star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-tertiary);
  padding: 0 2px;
  line-height: 1;
  transition: color 150ms ease;
}
.voice-card__star:hover,
.pick-card__star:hover {
  color: #f59e0b;
}
.voice-card__star--active,
.pick-card__star--active {
  color: #f59e0b;
}

/* DRY_RUN warning banner shown on the Job detail page when
   result.dry_run === true. Warm amber Apple-style info surface. */
.dry-run-banner {
  background: #fff4e5;
  border: 1px solid #ffd199;
  border-radius: 8px;
  padding: 16px 20px;
  color: #8a5a00;
}
.dry-run-banner .t-caption {
  color: #6b4500;
  line-height: 1.5;
}

