:root {
  --bg: #f6f4f0;
  --bg-hero: linear-gradient(168deg, #f9f7f3 0%, #ede9e3 48%, #f4f1ec 100%);
  --surface-0: #ffffff;
  --surface-1: #fafaf8;
  --surface-2: #f2f0ec;
  --surface-3: #eae7e2;
  --surface-hover: #f0ede8;
  --surface-code: #2c2a2a;

  --ink: #1a1816;
  --ink-secondary: #5c5650;
  --ink-tertiary: #908880;
  --ink-placeholder: #b8b0a8;
  --ink-inverse: #fafaf8;

  --accent: #1a7a6d;
  --accent-light: #2aa393;
  --accent-soft: rgba(26, 122, 109, 0.08);
  --accent-border: rgba(26, 122, 109, 0.2);

  --coral: #d4654a;
  --coral-soft: rgba(212, 101, 74, 0.08);
  --coral-border: rgba(212, 101, 74, 0.2);

  --success: #2d8f6f;
  --success-soft: rgba(45, 143, 111, 0.1);
  --warn: #c2882a;
  --warn-soft: rgba(194, 136, 42, 0.1);
  --danger: #c44b4b;
  --danger-soft: rgba(196, 75, 75, 0.08);

  --section-drama: #1a7a6d;
  --section-search: #d4654a;
  --section-queue: #3b6bb5;
  --section-files: #7b5ea7;
  --section-episodes: #2d8f6f;
  --section-side: #7a7570;

  --border: #e4e0da;
  --border-strong: #d4cfc8;
  --border-light: #ede9e3;

  --shadow-xs: 0 1px 2px rgba(26, 24, 22, 0.04);
  --shadow-sm: 0 1px 3px rgba(26, 24, 22, 0.05), 0 1px 2px rgba(26, 24, 22, 0.03);
  --shadow-md: 0 4px 16px rgba(26, 24, 22, 0.06), 0 1px 4px rgba(26, 24, 22, 0.04);
  --shadow-lg: 0 8px 32px rgba(26, 24, 22, 0.08), 0 2px 8px rgba(26, 24, 22, 0.04);
  --shadow-xl: 0 16px 48px rgba(26, 24, 22, 0.1), 0 4px 16px rgba(26, 24, 22, 0.05);
  --shadow-card: 0 2px 12px rgba(26, 24, 22, 0.04), 0 0 0 1px rgba(26, 24, 22, 0.03);
  --shadow-focus: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-3xl: 24px;
  --radius-pill: 999px;

  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 16px;
  --gap-lg: 24px;
  --gap-xl: 32px;

  --font-display: "Instrument Serif", "Noto Serif SC", "Source Han Serif SC", "STSong", Georgia, serif;
  --font-body: "DM Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

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

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c4b99a' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

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

button,
input,
select,
textarea {
  font: inherit;
}

code,
pre,
kbd {
  font-family: var(--font-mono);
}

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

a:hover {
  text-decoration: underline;
}

.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;
}

.is-hidden,
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(1840px, calc(100% - 48px));
  margin: 28px auto 40px;
  padding-top: env(safe-area-inset-top);
  animation: fadeIn 420ms ease;
}

.workspace-stack {
  display: grid;
  gap: var(--gap-lg);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--ink);
}

h1 {
  font-size: clamp(40px, 4.4vw, 68px);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.025em;
}

h2 {
  font-size: clamp(24px, 2.3vw, 32px);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: -0.015em;
}

h3 {
  font-size: 19px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 18px 0 0;
  max-width: 58ch;
  color: var(--ink-secondary);
  font-size: 15px;
  line-height: 1.82;
}

.subtitle code,
.hero-foot-card code,
.search-card__id,
.episode-card__id {
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  color: var(--accent);
  font-size: 12px;
}

.eyebrow,
.panel-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.panel-kicker {
  margin-bottom: 10px;
}

.muted {
  margin: 8px 0 0;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 1.72;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(360px, 0.88fr);
  gap: var(--gap-lg);
}

.masthead--secondary .brand-copy {
  padding: 24px 28px 22px;
  gap: 18px;
}

.masthead--secondary h1 {
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.masthead--secondary .subtitle {
  margin-top: 10px;
  max-width: 52ch;
  font-size: 14px;
  line-height: 1.7;
}

.masthead--secondary .hero-footer {
  gap: 12px;
}

.masthead--secondary .hero-foot-card {
  padding: 14px 16px;
}

.masthead--secondary .root-card {
  padding: 20px 22px;
}

.masthead--secondary .overview-head {
  margin-bottom: 14px;
}

.masthead--secondary .progress-panel,
.masthead--secondary .theme-panel,
.masthead--secondary .overview-foot {
  margin-top: 14px;
}

.brand-copy,
.root-card,
.panel,
.module-card,
.summary-card,
.result-card,
.search-card,
.episode-card,
.file-card,
.job-card,
.stat-card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-card);
}

.brand-copy {
  position: relative;
  overflow: hidden;
  padding: 36px 32px 28px;
  display: grid;
  gap: var(--gap-lg);
  background: var(--bg-hero);
  border-color: var(--border-light);
}

.brand-copy::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--coral) 50%, var(--section-files) 100%);
}

.brand-copy::after {
  content: "";
  position: absolute;
  top: -80px;
  right: -60px;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  border: 1px solid var(--border);
  opacity: 0.55;
  pointer-events: none;
}

.eyebrow-row,
.hero-footer,
.stat-grid,
.overview-foot,
.panel-cluster,
.summary-grid {
  display: grid;
}

.eyebrow-row {
  position: relative;
  z-index: 1;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.hero-main,
.hero-copy,
.hero-footer,
.overview-foot,
.panel-head,
.section-head,
.summary-card__title {
  position: relative;
  z-index: 1;
}

.status-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.status-banner[data-state="ok"] {
  color: var(--success);
  border-color: rgba(45, 143, 111, 0.2);
  background: var(--success-soft);
}

.status-banner[data-state="busy"] {
  color: var(--accent);
  border-color: var(--accent-border);
  background: var(--accent-soft);
}

.status-banner[data-state="warn"] {
  color: var(--warn);
  border-color: rgba(194, 136, 42, 0.22);
  background: var(--warn-soft);
}

.status-banner[data-state="danger"] {
  color: var(--danger);
  border-color: rgba(196, 75, 75, 0.2);
  background: var(--danger-soft);
}

.hero-footer {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.hero-foot-card {
  padding: 18px 18px 16px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: var(--shadow-sm);
}

.hero-foot-card > span,
.stat-card > span,
.progress-copy > span,
.theme-panel > span,
.summary-grid__label,
.meta-line > span {
  display: block;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero-foot-card strong,
.hero-foot-card code,
.stat-card strong,
.progress-copy strong,
.meta-line strong {
  display: block;
  margin-top: 10px;
  color: var(--ink);
}

.hero-foot-card strong,
.stat-card strong,
.progress-copy strong {
  font-size: 24px;
  line-height: 1.2;
}

.hero-foot-card code {
  width: fit-content;
}

.hero-footnote,
.stat-footnote,
.meta-note {
  margin: 8px 0 0;
  color: var(--ink-tertiary);
  font-size: 12px;
  line-height: 1.65;
}

.root-card {
  padding: 26px;
}

.overview-head {
  margin-bottom: 18px;
}

.stat-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--surface-1);
}

.progress-panel {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.progress-track {
  position: relative;
  overflow: hidden;
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
}

.progress-track > span,
.progress-bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent) 0%, var(--coral) 100%);
  transition: width 220ms ease;
}

.theme-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.theme-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.theme-switch-btn {
  min-height: 32px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-tertiary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.theme-switch-btn:hover:not(.active) {
  color: var(--ink-secondary);
  background: var(--surface-hover);
}

.theme-switch-btn.active {
  background: var(--surface-0);
  color: var(--ink);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.overview-foot {
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.overview-meta {
  display: grid;
  gap: 12px;
}

.meta-line {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.overview-foot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.86fr);
  gap: var(--gap-lg);
}

.workspace-grid--priority .panel {
  padding-top: 22px;
}

.workspace-grid--priority .panel-head {
  margin-bottom: 16px;
}

.workspace-grid--priority .muted {
  margin-top: 6px;
  font-size: 12px;
}

.panel {
  padding: 26px;
  min-width: 0;
  animation: fadeInUp 380ms ease both;
}

.panel-search {
  grid-column: 1;
}

.panel-side {
  grid-column: 2;
}

.panel-queue,
.panel-episodes,
.panel-files {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-head--split {
  align-items: end;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.compact-head {
  margin-bottom: 12px;
}

.panel-cluster {
  gap: 18px;
}

.panel-cluster--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.module-card,
.result-card,
.summary-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-2xl);
  background: var(--surface-1);
}

.module-card::before,
.result-card::before,
.summary-card::before,
.job-card::before,
.search-card::before,
.episode-card::before,
.file-card::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 3px;
  opacity: 0.94;
}

.accent-teal::before,
.summary-card::before,
.episode-card::before {
  background: linear-gradient(90deg, var(--section-drama) 0%, rgba(26, 122, 109, 0) 100%);
}

.accent-coral::before,
.search-card::before,
.result-card::before {
  background: linear-gradient(90deg, var(--section-search) 0%, rgba(212, 101, 74, 0) 100%);
}

.job-card::before {
  background: linear-gradient(90deg, var(--section-queue) 0%, rgba(59, 107, 181, 0) 100%);
}

.file-card::before {
  background: linear-gradient(90deg, var(--section-files) 0%, rgba(123, 94, 167, 0) 100%);
}

.module-note {
  margin: 12px 0 0;
  color: var(--ink-tertiary);
  font-size: 13px;
  line-height: 1.7;
}

.query-form,
.button-row,
.stack-form,
.action-strip {
  display: flex;
  gap: 12px;
}

.query-form {
  flex-wrap: wrap;
  align-items: end;
}

.stack-form {
  flex-direction: column;
}

.button-row {
  flex-wrap: wrap;
}

.action-strip {
  flex-wrap: wrap;
  align-items: end;
  margin-top: 14px;
}

.field {
  display: grid;
  gap: 8px;
  flex: 1 1 260px;
}

.field--compact {
  flex: 0 0 170px;
}

.field--tiny {
  flex: 0 1 210px;
}

.field--search {
  width: min(340px, 100%);
}

.field span,
.toggle span {
  color: var(--ink-secondary);
  font-size: 13px;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-0);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease, transform 180ms ease;
}

input::placeholder {
  color: var(--ink-placeholder);
}

input:disabled,
select:disabled {
  background: var(--surface-2);
  color: var(--ink-tertiary);
  cursor: not-allowed;
  opacity: 0.72;
}

input:focus-visible,
select:focus-visible,
.button:focus-visible,
.theme-switch-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding-right: 4px;
}

.toggle input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  text-decoration: none;
}

.button[disabled] {
  opacity: 0.62;
  cursor: wait;
  transform: none;
}

.button--primary,
.button.primary {
  color: var(--ink-inverse);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  box-shadow: 0 10px 24px rgba(26, 122, 109, 0.18);
}

.button--secondary,
.button.secondary {
  background: var(--surface-0);
  border-color: var(--border);
  color: var(--ink);
}

.button--ghost,
.button.ghost {
  background: var(--surface-1);
  border-color: var(--border);
  color: var(--ink-secondary);
}

.button--ghost:hover,
.button.ghost:hover,
.button--secondary:hover,
.button.secondary:hover {
  border-color: var(--accent-border);
  color: var(--ink);
}

.status {
  min-height: 24px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.6;
}

.status--muted {
  color: var(--ink-tertiary);
}

.status--success {
  color: var(--success);
}

.status--danger {
  color: var(--danger);
}

.summary-card {
  margin-top: 18px;
}

.summary-card__title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.summary-card__desc {
  margin: 16px 0 0;
  color: var(--ink-secondary);
  line-height: 1.76;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 600;
}

.pill--soft {
  background: var(--accent-soft);
  color: var(--accent);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.32);
  color: var(--ink-tertiary);
  line-height: 1.7;
}

.empty-state code {
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
}

.empty-state--large {
  padding: 24px;
}

.search-grid,
.episodes-grid,
.files-grid,
.jobs-grid,
.result-box,
.job-item-list {
  display: grid;
  gap: 14px;
}

.search-grid {
  margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.episodes-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.files-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.jobs-grid {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.search-card,
.episode-card,
.file-card,
.job-card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius-xl);
  background: var(--surface-0);
}

.search-card::after,
.episode-card::after,
.file-card::after,
.job-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -36px;
  width: 116px;
  height: 116px;
  border-radius: 50%;
  opacity: 0.65;
  pointer-events: none;
}

.search-card::after,
.result-card::after {
  background: radial-gradient(circle, rgba(212, 101, 74, 0.1) 0%, rgba(212, 101, 74, 0) 72%);
}

.episode-card::after {
  background: radial-gradient(circle, rgba(26, 122, 109, 0.1) 0%, rgba(26, 122, 109, 0) 72%);
}

.file-card::after {
  background: radial-gradient(circle, rgba(123, 94, 167, 0.1) 0%, rgba(123, 94, 167, 0) 72%);
}

.job-card::after {
  background: radial-gradient(circle, rgba(59, 107, 181, 0.1) 0%, rgba(59, 107, 181, 0) 72%);
}

.search-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
}

.search-card__media {
  overflow: hidden;
  aspect-ratio: 3 / 4;
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface-0) 0%, var(--surface-2) 100%);
}

.search-card__cover {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.9);
}

.search-card__content {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

.search-card__meta,
.episode-card__meta,
.job-card__header,
.job-item__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.search-card__count,
.search-card__author,
.search-card__desc,
.file-card__meta,
.job-card__sub,
.job-card__meta,
.job-card__footnote,
.job-item__meta {
  margin: 0;
  color: var(--ink-secondary);
  line-height: 1.65;
}

.search-card__count,
.search-card__author {
  font-size: 13px;
}

.search-card__title,
.episode-card__title,
.file-card__name,
.job-card__title {
  font-size: 19px;
}

.search-card__id,
.episode-card__id {
  display: inline-flex;
  width: fit-content;
  word-break: break-all;
}

.search-card__desc {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.episode-card__index {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.episode-card__id {
  margin: 12px 0 14px;
}

.file-card__meta {
  margin-top: 8px;
  word-break: break-word;
}

.result-box__section {
  display: grid;
  gap: 6px;
}

.result-box__label {
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.result-box__value {
  color: var(--ink);
  word-break: break-word;
  line-height: 1.7;
}

.result-box__value a,
.job-item__meta a {
  color: var(--accent);
}

.job-card {
  display: grid;
  gap: 14px;
}

.job-card__metrics {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-chip--small {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
}

.status-chip--queued {
  background: rgba(144, 136, 128, 0.14);
  color: var(--ink-secondary);
}

.status-chip--running {
  background: var(--accent-soft);
  color: var(--accent);
}

.status-chip--completed {
  background: var(--success-soft);
  color: var(--success);
}

.status-chip--warning {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-chip--failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.job-item {
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.job-item__title {
  font-weight: 600;
  color: var(--ink);
}

.toast-stack {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
  z-index: 30;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  padding: 14px 16px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
  line-height: 1.6;
  animation: toastIn 180ms ease;
}

.toast.error {
  background: #fff4f3;
  border-color: rgba(196, 75, 75, 0.18);
  color: var(--danger);
}

body[data-app-mode="standalone"] .page-shell {
  padding-top: calc(8px + env(safe-area-inset-top));
}

html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease !important;
}

html[data-theme="dark"] {
  --bg: #141517;
  --bg-hero: linear-gradient(168deg, #1a1b1e 0%, #16171a 48%, #1c1d20 100%);
  --surface-0: #1e1f23;
  --surface-1: #232428;
  --surface-2: #2a2b30;
  --surface-3: #333439;
  --surface-hover: #2e2f34;
  --surface-code: #f7f6f3;

  --ink: #e8e6e3;
  --ink-secondary: #a8a4a0;
  --ink-tertiary: #787470;
  --ink-placeholder: #5a5753;
  --ink-inverse: #1a1b1e;

  --accent: #3cc9b6;
  --accent-light: #5edac9;
  --accent-soft: rgba(60, 201, 182, 0.12);
  --accent-border: rgba(60, 201, 182, 0.25);

  --coral: #f0845c;
  --coral-soft: rgba(240, 132, 92, 0.12);
  --coral-border: rgba(240, 132, 92, 0.22);

  --success: #4cbb8a;
  --success-soft: rgba(76, 187, 138, 0.12);
  --warn: #e0a840;
  --warn-soft: rgba(224, 168, 64, 0.12);
  --danger: #e86060;
  --danger-soft: rgba(232, 96, 96, 0.1);

  --section-drama: #3cc9b6;
  --section-search: #f0845c;
  --section-queue: #6b9be0;
  --section-files: #a88bd4;
  --section-episodes: #4cbb8a;
  --section-side: #9a9590;

  --border: #2e3035;
  --border-strong: #3a3c42;
  --border-light: #262830;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.24), 0 1px 2px rgba(0, 0, 0, 0.16);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.24);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-focus: 0 0 0 3px var(--accent-soft), 0 0 0 1px var(--accent);
}

html[data-theme="dark"] body::before {
  opacity: 0.08;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

html[data-theme="dark"] .hero-foot-card,
html[data-theme="dark"] .status-banner {
  background: rgba(30, 31, 35, 0.72);
  border-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .toast {
  background: #e8e6e3;
  color: #1a1b1e;
  border-color: rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] .toast.error {
  background: #e86060;
  color: #fff;
  border-color: transparent;
}

/* ======================================================
   Workspace Layout Override
   Mirror the reference project's split-workspace behavior:
   masthead on top, sidebar actions on the left, content on the right,
   and bottom-tabbed navigation on mobile.
   ====================================================== */

.mobile-context,
.mobile-nav {
  display: none;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(360px, 0.9fr);
  gap: var(--gap-lg);
  margin-bottom: var(--gap-lg);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: var(--gap-lg);
  align-items: start;
}

.sidebar,
.editor {
  min-width: 0;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 20px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: calc(100vh - 40px);
  overflow: hidden;
}

.sidebar-tools {
  display: grid;
  gap: 16px;
  overflow: auto;
  padding-right: 4px;
}

.sidebar-tools::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.sidebar-tools::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

.editor {
  background: var(--surface-0);
}

.editor-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--gap-lg);
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.section-chip,
.shortcut-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: all 180ms ease;
}

.section-chip {
  color: var(--ink-secondary);
  border: 1px solid var(--border);
  background: var(--surface-0);
}

.section-chip:hover {
  border-color: var(--accent-border);
  color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

.shortcut-chip {
  color: var(--ink-placeholder);
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
}

.editor-content {
  display: grid;
  gap: 16px;
}

.editor-section {
  display: grid;
  gap: 16px;
  padding: 22px 20px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface-0);
  scroll-margin-top: 80px;
}

.editor-section--queue {
  border-left-color: var(--section-queue);
}

.editor-section--episodes {
  border-left-color: var(--section-episodes);
}

.editor-section--files {
  border-left-color: var(--section-files);
}

.episodes-toolbar {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, var(--accent-soft) 0%, var(--surface-0) 100%);
  box-shadow: var(--shadow-xs);
}

.episodes-toolbar__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.episodes-toolbar__copy {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.episodes-toolbar__label {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.episodes-toolbar__copy strong {
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
}

.episodes-toolbar__meta,
.episodes-toolbar__note {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.7;
}

.episodes-toolbar .action-strip {
  margin-top: 0;
}

.module-card.accent-slate::before,
.result-card--compact::before {
  background: linear-gradient(90deg, var(--section-side) 0%, rgba(122, 117, 112, 0) 100%);
}

.result-card--compact {
  margin-top: 16px;
}

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

  .workspace {
    grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .sidebar-tools {
    overflow: visible;
    padding-right: 0;
  }
}

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

  .sidebar {
    position: static;
    max-height: none;
  }
}

@media (max-width: 768px) {
  .page-shell {
    width: min(100% - 16px, 100%);
    margin-top: 12px;
    margin-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .brand-copy,
  .root-card,
  .panel,
  .module-card,
  .summary-card,
  .result-card,
  .editor-section {
    border-radius: var(--radius-xl);
  }

  .brand-copy {
    padding: 20px 16px;
    gap: 16px;
  }

  .root-card,
  .sidebar,
  .editor {
    padding: 16px;
  }

  .hero-footer,
  .stat-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 32px;
    max-width: none;
  }

  h2 {
    font-size: 22px;
  }

  h3 {
    font-size: 17px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.8;
  }

  .panel-head,
  .section-head,
  .episodes-toolbar__head {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-subnav {
    display: none;
  }

  .workspace {
    display: block;
  }

  .masthead,
  .sidebar,
  .editor {
    display: none;
  }

  body[data-mobile-tab="overview"] .masthead {
    display: grid;
    gap: 12px;
  }

  body[data-mobile-tab="actions"] .workspace,
  body[data-mobile-tab="queue"] .workspace,
  body[data-mobile-tab="episodes"] .workspace,
  body[data-mobile-tab="files"] .workspace {
    display: block;
  }

  body[data-mobile-tab="actions"] .sidebar {
    display: grid;
    gap: 14px;
  }

  body[data-mobile-tab="queue"] .editor,
  body[data-mobile-tab="episodes"] .editor,
  body[data-mobile-tab="files"] .editor {
    display: block;
  }

  body[data-mobile-tab="actions"] .mobile-context,
  body[data-mobile-tab="queue"] .mobile-context,
  body[data-mobile-tab="episodes"] .mobile-context,
  body[data-mobile-tab="files"] .mobile-context {
    display: grid;
  }

  .editor-section {
    display: none;
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .episodes-toolbar {
    padding: 14px;
    border-radius: var(--radius-lg);
  }

  .episodes-toolbar__copy strong {
    font-size: 16px;
  }

  body[data-mobile-tab="queue"] .editor-section--queue {
    display: grid;
  }

  body[data-mobile-tab="episodes"] .editor-section--episodes {
    display: grid;
  }

  body[data-mobile-tab="files"] .editor-section--files {
    display: grid;
  }

  .mobile-context {
    gap: 12px;
    align-items: stretch;
    margin: 0 0 12px;
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface-0);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 8px;
    z-index: 10;
  }

  .mobile-context-copy {
    min-width: 0;
    display: grid;
    gap: 6px;
  }

  .mobile-context-copy-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-context-copy-head span {
    color: var(--ink-tertiary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .mobile-context-copy strong {
    font-size: 14px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--ink);
  }

  .mobile-context-copy-head .button {
    min-height: 40px;
    padding: 6px 12px;
    flex: 0 0 auto;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 20;
    padding: 6px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-xl);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .mobile-nav-button {
    min-height: 42px;
    padding: 0 6px;
    border: 0;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--ink-tertiary);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 150ms ease;
  }

  .mobile-nav-button.active {
    color: var(--ink-inverse);
    background: var(--accent);
    box-shadow: var(--shadow-sm);
  }

  body[data-app-mode="standalone"] .mobile-context {
    top: calc(8px + env(safe-area-inset-top));
  }
}

@media (max-width: 520px) {
  .mobile-nav {
    left: 6px;
    right: 6px;
    gap: 4px;
    padding: 4px;
  }

  .mobile-context {
    padding: 10px 12px;
  }

  .mobile-context-copy-head {
    align-items: start;
    gap: 8px;
  }

  .mobile-context-copy-head .button {
    min-height: 40px;
    padding: 6px 10px;
  }
}

html[data-theme="dark"] .mobile-nav {
  background: rgba(30, 31, 35, 0.92);
  border-color: var(--border);
}

html[data-theme="dark"] .mobile-context {
  background: var(--surface-0);
}

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

  .panel-search,
  .panel-side,
  .panel-queue,
  .panel-episodes,
  .panel-files {
    grid-column: 1;
  }
}

@media (max-width: 1120px) {
  .masthead,
  .panel-cluster--two {
    grid-template-columns: 1fr;
  }

  .hero-footer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 20px, 1840px);
    margin-top: 18px;
    margin-bottom: 28px;
  }

  .brand-copy,
  .root-card,
  .panel,
  .module-card,
  .summary-card,
  .result-card {
    padding: 20px;
  }

  .masthead--secondary .brand-copy,
  .masthead--secondary .root-card {
    padding: 18px;
  }

  .stat-grid,
  .summary-grid,
  .search-grid,
  .episodes-grid,
  .files-grid,
  .jobs-grid {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .query-form,
  .button-row,
  .action-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .field,
  .field--compact,
  .field--tiny,
  .field--search {
    width: 100%;
    flex-basis: auto;
  }

  .search-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .progress-copy {
    flex-direction: column;
    align-items: start;
  }

  .overview-foot-actions {
    flex-direction: column;
  }
}

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