/* ============================================================================
   Stream Studio — design system
   Native-feeling on Windows 11: Segoe UI Variable, Fluent-ish surfaces,
   GPU-friendly transitions, custom scrollbars. Light/dark via [data-theme].
   ========================================================================= */

:root {
  --accent: #6d5efc;
  --accent-2: #8b7bff;
  --accent-ink: #ffffff;

  --bg: #f4f5fb;
  --bg-grad-1: #eef0fb;
  --bg-grad-2: #f7f5ff;
  --surface: #ffffff;
  --surface-2: #f6f7fc;
  --surface-hover: #eef0fa;
  --border: #e4e6f0;
  --border-strong: #d3d6e6;

  --text: #1b1c28;
  --text-dim: #5a5d70;
  --text-faint: #8b8fa6;

  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #e11d48;

  --shadow-sm: 0 1px 2px rgba(20, 22, 50, 0.06), 0 1px 3px rgba(20, 22, 50, 0.05);
  --shadow-md: 0 4px 16px rgba(20, 22, 50, 0.08), 0 2px 6px rgba(20, 22, 50, 0.05);
  --shadow-lg: 0 18px 50px rgba(20, 22, 50, 0.16);

  --radius: 12px;
  --radius-lg: 16px;
  --radius-sm: 8px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --accent: #8b7bff;
  --accent-2: #a594ff;
  --accent-ink: #14121f;

  --bg: #0e0f17;
  --bg-grad-1: #11111d;
  --bg-grad-2: #161427;
  --surface: #1a1b27;
  --surface-2: #20212f;
  --surface-hover: #262838;
  --border: #2a2c3c;
  --border-strong: #383b50;

  --text: #eceefb;
  --text-dim: #a6a9bf;
  --text-faint: #71748c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.55);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: radial-gradient(1200px 600px at 80% -10%, var(--bg-grad-2), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, var(--bg-grad-1), transparent 55%),
              var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  user-select: none;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Scrollbars ───────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

/* ── App shell ────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

.titlebar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  -webkit-app-region: drag;
}
.titlebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 16px; letter-spacing: 0.2px;
}
.titlebar .logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center; color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
}
.titlebar .spacer { flex: 1; }
.icon-btn {
  -webkit-app-region: no-drag;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer;
  display: grid; place-items: center; font-size: 16px;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }

/* ── Tabs ─────────────────────────────────────────────────────────────── */
.tabs {
  -webkit-app-region: no-drag;
  display: flex; gap: 4px;
  margin: 0 22px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: fit-content;
}
.tab {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: 9px;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-dim); font-weight: 550;
  transition: color .18s var(--ease), background .18s var(--ease);
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* ── Content area ─────────────────────────────────────────────────────── */
.content { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.view { display: flex; flex-direction: column; gap: 16px; max-width: 880px; margin: 0 auto; }
.view[hidden] { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.card h2 {
  font-size: 13px; font-weight: 650; letter-spacing: .2px;
  color: var(--text); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.card h2 .step {
  width: 20px; height: 20px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 11px; color: var(--text-dim);
}
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); font-size: 12px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  -webkit-app-region: no-drag;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 550; cursor: pointer;
  transition: transform .12s var(--ease), background .18s var(--ease),
              border-color .18s var(--ease), box-shadow .18s var(--ease), opacity .18s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.btn.primary:hover { filter: brightness(1.05); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.btn.accent-soft {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--accent);
}

/* ── Inputs ───────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-dim); font-weight: 550; }
.input, select.input {
  -webkit-app-region: no-drag;
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); transition: border-color .18s var(--ease), background .18s var(--ease);
  user-select: text;
}
.input:focus { border-color: var(--accent); background: var(--surface); }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ── Dropzone ─────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  padding: 22px; text-align: center; color: var(--text-dim);
  background: var(--surface-2);
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
}
.dropzone.hot {
  border-color: var(--accent); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

/* ── File list ────────────────────────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; padding-right: 4px; }
.list-head, .list-row {
  display: grid; grid-template-columns: 30px 26px 1fr 72px 32px;
  align-items: center; gap: 6px;
}
.list-head { padding: 4px 10px; font-size: 11px; color: var(--text-faint); font-weight: 650; }
.list-row {
  padding: 9px 10px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.list-row:hover { background: var(--surface-hover); }
.list-row.active { border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.list-row .idx { color: var(--text-faint); font-size: 12px; text-align: center; }
.list-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .dur { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.list-row .x {
  width: 24px; height: 24px; border-radius: 7px; border: none; cursor: pointer;
  background: transparent; color: var(--text-faint);
  transition: background .15s, color .15s;
}
.list-row .x:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.checkbox { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Progress ─────────────────────────────────────────────────────────── */
.progress-wrap { display: flex; flex-direction: column; gap: 8px; }
.bar { height: 10px; border-radius: 99px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--border); }
.bar > i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 99px; transition: width .25s var(--ease);
}
.bar.indeterminate > i {
  width: 35% !important; border-radius: 99px;
  animation: slide 1.1s var(--ease) infinite;
}
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.progress-meta { display: flex; justify-content: space-between; font-size: 12px; }
.progress-meta .status { color: var(--text); font-weight: 550; }
.progress-meta .timing { color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ── Log ──────────────────────────────────────────────────────────────── */
.log {
  margin-top: 10px; max-height: 150px; overflow-y: auto;
  font-family: "Cascadia Code", "Consolas", monospace; font-size: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px; color: var(--text-dim);
  white-space: pre-wrap; user-select: text;
}
.log:empty { display: none; }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast-host { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; font-weight: 550;
  animation: rise .3s var(--ease);
}
.toast.ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--border)); }
.toast.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.banner {
  padding: 10px 14px; border-radius: 10px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  color: var(--text);
}
.hint { font-size: 12px; color: var(--text-faint); }
.rename-preview { font-size: 12px; color: var(--accent); min-height: 16px; }
