/* DeVide Studio — Editorial Dark/Light Production UI */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root,
html[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #12151e;
  --surface-2: #181c28;
  --surface-3: #1f2433;
  --ink: #f3f4f6;
  --muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.11);
  --accent: #f59e0b;
  --accent-ink: #0b0d12;
  --accent-soft: rgba(245, 158, 11, 0.14);
  --ok: #10b981;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.16);
}

html[data-theme="light"] {
  --bg: #f1f3f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e2e8f0;
  --ink: #0f172a;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --accent: #d97706;
  --accent-ink: #ffffff;
  --accent-soft: rgba(217, 119, 6, 0.12);
  --ok: #059669;
  --ok-bg: rgba(5, 150, 105, 0.12);
  --warn: #d97706;
  --warn-bg: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.12);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Host Grotesk", system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.sm { font-size: 0.875rem; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex-1 { flex: 1; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Login Screen */
.login-screen {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 490px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.brand-title {
  display: block;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}
.brand-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
}
.owner-code {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.86rem;
}
.google-auth-box {
  margin: 20px 0;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.security-pill-box {
  margin-top: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sec-row { display: flex; align-items: center; gap: 8px; }
.sec-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); flex-shrink: 0;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 265px 1fr;
  min-height: 100svh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100svh;
}
.sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar__close { display: none; }
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.nav-group__label {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 10px 6px;
  font-weight: 600;
}
.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(245, 158, 11, 0.35);
  font-weight: 600;
}
.sidebar__foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.owner-pill {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.77rem;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ok);
}
.sidebar__foot-row { display: flex; gap: 8px; }

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 15;
}
.topbar__left, .topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.topbar__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
}
.mobile-nav-trigger { display: none; }
.room-picker {
  height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.88rem;
  min-width: 220px;
}

.content {
  padding: 24px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* Cards & Grids */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.card__head h2, .card__head h3 {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat__label { font-size: 0.82rem; color: var(--muted); }
.stat__val { font-size: 1.55rem; font-weight: 700; }
.stat__sub { font-size: 0.8rem; color: var(--muted); }

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: transform 0.1s, opacity 0.15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--sm { height: 34px; padding: 0 12px; font-size: 0.83rem; }
.btn--full { width: 100%; }
.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.btn--secondary {
  background: var(--surface-2);
  color: var(--ink);
}
.btn--ghost {
  background: transparent;
  color: var(--muted);
}
.btn--danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sidebar__close,
.mobile-nav-trigger {
  display: none;
}

.badge, .mono-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.mono-badge { font-family: "JetBrains Mono", monospace; }
.badge--running {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: rgba(16, 185, 129, 0.35);
}
.badge--starting {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.35);
}
.badge--error {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.form-inline {
  display: flex;
  gap: 10px;
  align-items: center;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.92rem;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Rooms Grid */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.room-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.room-card__title {
  margin: 6px 0 4px;
  font-size: 1.08rem;
  font-weight: 700;
}
.room-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.81rem;
  color: var(--muted);
}
.room-card__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Progress Bar */
.bar {
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}
.progress-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.83rem;
  margin-bottom: 6px;
}

/* Workspace Hero & Download Hub */
.room-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.rm-main-title {
  margin: 4px 0;
  font-size: 1.45rem;
}
.rm-status-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.pipeline-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.download-hub-card {
  background: linear-gradient(135deg, var(--surface-2), var(--accent-soft));
  border-color: rgba(245, 158, 11, 0.4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.download-hub-left h3 { margin: 0 0 4px; }
.download-hub-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
.dl-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Subtabs */
.subtabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  flex-wrap: wrap;
}
.subtab {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 9px 15px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.subtab.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Ordered Parts Cards */
.parts-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.part-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}
.part-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.part-num-pill {
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 4px 10px;
  border-radius: 6px;
}
.part-card__grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}
.part-narration-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.94rem;
  margin-bottom: 10px;
}
.part-meta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--muted);
}
.part-media-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.part-media-col audio,
.media-preview-slot audio,
.sfx-item audio {
  width: 100%;
  height: 36px;
}
.part-media-col video,
.media-preview-slot video {
  width: 100%;
  max-height: 220px;
  border-radius: 6px;
  background: #000;
}

.sub-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.sfx-stack, .stack, .audit-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sfx-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Tables & Code */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.code-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.84rem;
  white-space: pre-wrap;
  max-height: 460px;
  overflow-y: auto;
}

/* Credentials & Tools */
.cred-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.cred-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.cred-label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.cred-val-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cred-val-row code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}
.tool-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

/* Alerts & Toasts */
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.alert--err {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}
.toast--ok { border-left-color: var(--ok); }
.toast--err { border-left-color: var(--danger); }

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .part-card__grid, .cred-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2, .field.span-3 { grid-column: span 1; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 270px;
    z-index: 50;
    transition: left 0.2s ease;
  }
  .sidebar.is-open { left: 0; }
  .sidebar__close, .mobile-nav-trigger { display: inline-flex; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 40;
  }
}
