:root {
  --bg-0: #c7cbdd;
  --bg-1: #4f3cff;
  --bg-2: #2a2ad5;
  --ink: #171b41;
  --text: #f8faff;
  --muted: #d8defd;
  --muted-strong: #afbcff;
  --panel: rgba(15, 20, 54, 0.36);
  --panel-border: rgba(227, 233, 255, 0.2);
  --line: rgba(255, 255, 255, 0.12);
  --success: #b8ffd7;
  --warning: #fff0b8;
  --danger: #ffd2d2;
  --shadow: 0 30px 80px rgba(8, 14, 42, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sora", "Avenir Next", "Helvetica Neue", sans-serif;
  color: var(--text);
  background: var(--bg-0);
}

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

.page-bg {
  position: fixed;
  inset: 3vh 2vw;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 88%, rgba(175, 185, 255, 0.96) 0%, rgba(175, 185, 255, 0) 22%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.page-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 88px 88px;
}

.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(18px);
  pointer-events: none;
  z-index: 0;
}

.orb-left {
  width: 240px;
  height: 240px;
  left: 2vw;
  bottom: 6vh;
  background: radial-gradient(circle, rgba(169, 182, 255, 0.68), rgba(169, 182, 255, 0));
}

.orb-right {
  width: 220px;
  height: 220px;
  right: 4vw;
  top: 14vh;
  background: radial-gradient(circle, rgba(146, 176, 255, 0.42), rgba(146, 176, 255, 0));
}

.fixed-nav {
  position: fixed;
  top: 4vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(1320px, 94vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(252, 253, 255, 0.96);
  color: var(--ink);
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: conic-gradient(from 150deg, #4b3eff, #92a6ff, #4b3eff);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.86);
}

.brand-text {
  display: block;
  font-size: 28px;
  font-weight: 700;
}

.brand-tag {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(23, 27, 65, 0.62);
}

.page-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.nav-link {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0.72;
}

.nav-link.active {
  background: linear-gradient(100deg, #5a51ff, #7887ff);
  color: #fff;
  opacity: 1;
}

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.nav-action,
.pill-btn,
.action-btn,
.text-btn,
.segment-btn,
.small-btn,
.favorite-btn {
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.nav-action:hover,
.pill-btn:hover,
.action-btn:hover,
.text-btn:hover,
.segment-btn:hover,
.small-btn:hover,
.favorite-btn:hover {
  transform: translateY(-1px);
}

.nav-action:disabled,
.pill-btn:disabled,
.action-btn:disabled,
.text-btn:disabled,
.segment-btn:disabled,
.small-btn:disabled,
.favorite-btn:disabled,
.nav-action.is-loading,
.pill-btn.is-loading,
.action-btn.is-loading,
.small-btn.is-loading,
.favorite-btn.is-loading {
  cursor: wait;
  opacity: 0.68;
  transform: none;
  box-shadow: none;
}

.nav-action {
  border: 1px solid rgba(77, 84, 138, 0.18);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}

.pill-btn,
.action-btn,
.small-btn,
.favorite-btn {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.pill-btn {
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(100deg, #584fff, #7c8aff);
}

.app-shell {
  position: relative;
  width: min(1320px, 94vw);
  margin: 18vh auto 6vh;
  z-index: 1;
}

.page-view {
  display: none;
  gap: 18px;
}

.page-view.active {
  display: grid;
}

.page-hero {
  display: grid;
  gap: 18px;
}

.page-hero h1 {
  margin: 0;
  font-size: clamp(42px, 7vw, 92px);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.compact-hero h1 {
  font-size: clamp(34px, 4.4vw, 58px);
}

.page-subtitle {
  margin: 10px 0 0;
  max-width: 720px;
  color: #eef2ff;
  font-size: clamp(18px, 2vw, 28px);
  line-height: 1.2;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

.hero-metrics,
.dashboard-grid,
.two-col-grid,
.settings-grid,
.filter-row,
.weight-grid,
.recommendation-grid,
.script-reference-grid,
.must-watch-list,
.trend-compare-grid,
.formula-list,
.insight-list,
.saved-pool,
.topic-history,
.run-history {
  display: grid;
  gap: 18px;
}

.hero-metrics,
.dashboard-grid,
.two-col-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel,
.mini-card,
.inline-chip,
.must-watch-card,
.trend-card,
.recommend-card,
.script-card,
.formula-card,
.insight-card,
.saved-card,
.topic-card,
.history-card,
.history-empty {
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
}

.panel,
.mini-card,
.inline-chip,
.must-watch-card,
.trend-card,
.recommend-card,
.script-card,
.formula-card,
.insight-card,
.saved-card,
.topic-card,
.history-card,
.history-empty {
  background: rgba(15, 20, 54, 0.34);
  border-radius: 22px;
}

.panel {
  padding: 22px;
}

.wide {
  width: 100%;
}

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

.badge-soft {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.mini-card,
.inline-chip {
  padding: 18px;
}

.inline-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.mini-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.mini-card strong,
.inline-chip strong {
  font-size: 28px;
}

.filter-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.filter-item,
.weight-grid label {
  display: grid;
  gap: 8px;
}

.filter-item label,
.weight-grid label,
.toggle-row {
  color: var(--muted);
  font-size: 14px;
}

.weight-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.segment-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.segment-btn {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
}

.segment-btn.active {
  background: #fff;
  color: #282d93;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(9, 12, 35, 0.34);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}

textarea {
  min-height: 140px;
  resize: vertical;
}

textarea:focus,
input:focus,
select:focus {
  border-color: rgba(171, 189, 255, 0.82);
  box-shadow: 0 0 0 4px rgba(146, 176, 255, 0.1);
}

.toggle-row {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}

.action-btn {
  padding: 13px 18px;
  color: #272d93;
  background: #fff;
  font-weight: 700;
}

.action-btn.secondary,
.small-btn,
.favorite-btn {
  background: linear-gradient(100deg, #adbbff, #ffffff);
  color: #272d93;
}

.small-btn,
.favorite-btn {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
}

.text-btn {
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

.table-shell {
  overflow-x: auto;
  border-radius: 18px;
  background: rgba(10, 12, 34, 0.24);
}

.data-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.data-table td {
  color: var(--text);
  line-height: 1.55;
}

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.compact-table {
  min-width: 100%;
}

.trend-compare-grid,
.must-watch-list,
.recommendation-grid,
.script-reference-grid,
.saved-pool,
.topic-history,
.run-history {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.must-watch-card,
.trend-card,
.recommend-card,
.script-card,
.formula-card,
.insight-card,
.saved-card,
.topic-card,
.history-card {
  padding: 18px;
}

.must-watch-card strong,
.recommend-card strong,
.script-card strong,
.formula-card strong,
.saved-card strong,
.topic-card strong,
.history-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.3;
}

.trend-title,
.card-meta,
.recommend-meta,
.topic-meta,
.history-card p,
.formula-card p,
.insight-card p,
.saved-card p,
.script-card p,
.must-watch-card p,
.topic-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.metric-bar-stack {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.metric-row {
  display: grid;
  gap: 6px;
}

.metric-row header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}

.metric-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.metric-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(100deg, #8ea9ff, #ffffff);
}

.card-actions,
.saved-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.history-status {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.history-status.success,
.history-status.active {
  background: rgba(130, 255, 190, 0.14);
  color: var(--success);
}

.history-status.running,
.history-status.pending {
  background: rgba(255, 226, 132, 0.16);
  color: var(--warning);
}

.history-status.failed {
  background: rgba(255, 144, 144, 0.16);
  color: var(--danger);
}

.history-status.history {
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.output-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.output-list li {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.output-list a {
  color: var(--text);
  text-decoration: none;
}

pre {
  margin: 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(8, 10, 30, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.55;
  font-family: "JetBrains Mono", "Menlo", monospace;
}

.detail-drawer {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 40;
}

.detail-drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 20, 0.58);
  backdrop-filter: blur(4px);
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100vw);
  height: 100%;
  padding: 22px;
  background: linear-gradient(180deg, rgba(21, 26, 62, 0.98), rgba(13, 17, 43, 0.98));
  border-left: 1px solid rgba(255, 255, 255, 0.14);
  overflow-y: auto;
}

.drawer-content {
  display: grid;
  gap: 12px;
}

.detail-block {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.detail-block strong {
  display: block;
  margin-bottom: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-block p {
  margin: 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: grid;
  gap: 10px;
  z-index: 60;
  pointer-events: none;
}

.toast {
  min-width: min(360px, 86vw);
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 20, 54, 0.94);
  color: var(--text);
  box-shadow: 0 18px 40px rgba(5, 8, 20, 0.24);
  animation: toast-in 180ms ease;
}

.toast.success {
  border-color: rgba(130, 255, 190, 0.26);
}

.toast.error {
  border-color: rgba(255, 144, 144, 0.28);
}

.toast strong {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
}

.toast p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .fixed-nav {
    border-radius: 26px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .brand {
    min-width: 0;
  }

  .page-tabs {
    order: 3;
    flex-wrap: wrap;
  }

  .hero-metrics,
  .dashboard-grid,
  .two-col-grid,
  .settings-grid,
  .trend-compare-grid,
  .must-watch-list,
  .recommendation-grid,
  .script-reference-grid,
  .saved-pool,
  .topic-history,
  .run-history {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    margin-top: 24vh;
  }

  .hero-metrics,
  .dashboard-grid,
  .two-col-grid,
  .settings-grid,
  .filter-row,
  .weight-grid,
  .trend-compare-grid,
  .must-watch-list,
  .recommendation-grid,
  .script-reference-grid,
  .saved-pool,
  .topic-history,
  .run-history {
    grid-template-columns: 1fr;
  }

  .nav-actions {
    width: 100%;
    justify-content: center;
  }

  .page-hero h1 {
    font-size: clamp(36px, 12vw, 72px);
  }

  .inline-chip {
    width: 100%;
    justify-content: center;
  }

  .drawer-panel {
    width: 100vw;
  }
}
