:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background: #f3f6f8;
  color: #182229;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --line: #dce4e9;
  --line-strong: #c9d4db;
  --text-muted: #65737d;
  --accent: #167c80;
  --accent-dark: #0f5960;
  --accent-soft: #dff3f0;
  --ink: #17242b;
  --warning: #b7791f;
  --info: #2f6f8f;
  --danger: #b54747;
  --shadow: 0 18px 50px rgba(24, 34, 41, 0.07);
  --shadow-soft: 0 8px 24px rgba(24, 34, 41, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  background:
    radial-gradient(circle at top right, rgba(22, 124, 128, 0.09), transparent 32rem),
    linear-gradient(180deg, #f8fafb 0%, var(--bg) 42%);
  margin: 0;
}

.login-screen {
  align-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(22, 124, 128, 0.16), transparent 24rem),
    linear-gradient(135deg, #101d24 0%, #132b32 52%, #17434a 100%);
  display: none;
  min-height: 100vh;
  padding: 22px;
  justify-content: center;
}

.auth-locked .login-screen {
  display: flex;
}

.auth-locked .app-shell {
  display: none;
}

.auth-ready .login-screen {
  display: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
  display: grid;
  gap: 16px;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

.login-mark {
  align-items: center;
  background: #d9f2ef;
  border-radius: 8px;
  color: #123036;
  display: flex;
  font-weight: 900;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.login-error {
  color: var(--danger);
  min-height: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 15px;
  line-height: 1.2;
}

h2 {
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  font-size: 16px;
  line-height: 1.2;
}

p {
  color: var(--text-muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #15252d;
  color: #f7fbfc;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  padding: 4px 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand p {
  color: #9eb0b8;
  margin-top: 4px;
}

.brand-mark {
  align-items: center;
  background: #d9f2ef;
  border-radius: 8px;
  color: #123036;
  display: flex;
  font-size: 13px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #cdd9dd;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.mobile-nav {
  display: none;
}

.workspace {
  display: grid;
  gap: 20px;
  max-width: 1540px;
  min-width: 0;
  padding: 22px;
  width: 100%;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  padding: 18px;
  position: sticky;
  top: 14px;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.eyebrow {
  color: var(--accent-dark);
  font-weight: 800;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.auth,
.actions {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.auth input {
  min-width: 260px;
}

.view {
  display: none;
  gap: 20px;
  min-width: 0;
}

.view.active {
  display: grid;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-hero {
  align-items: end;
  background: linear-gradient(135deg, #112a32 0%, #17434a 55%, #2d6f68 100%);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: white;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 166px;
  overflow: hidden;
  padding: 24px;
  position: relative;
}

.dashboard-hero::after {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.14) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 34px 34px;
  content: "";
  inset: 0;
  opacity: 0.18;
  pointer-events: none;
  position: absolute;
}

.hero-copy,
.hero-actions {
  position: relative;
  z-index: 1;
}

.hero-copy {
  display: grid;
  gap: 8px;
  max-width: 740px;
}

.section-kicker {
  color: #bfe7e1;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-copy h3 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.08;
}

.hero-copy p {
  color: rgba(255, 255, 255, 0.76);
  font-size: 15px;
  line-height: 1.6;
  max-width: 680px;
}

.hero-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.hero-actions .secondary {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  color: white;
}

.status-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  min-width: 0;
}

.command-panel {
  background: linear-gradient(180deg, #ffffff 0%, #f6fbfb 100%);
}

.command-panel textarea {
  border-color: #b9d8d6;
  font-size: 15px;
  line-height: 1.55;
  min-height: 112px;
}

.mode-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.mode-card {
  align-items: start;
  background: #f8fbfc;
  border-color: var(--line);
  color: #22313a;
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 14px;
  text-align: left;
  white-space: normal;
}

.mode-card:hover,
.mode-card.active {
  background: #e5f5f2;
  border-color: var(--accent);
  color: #123036;
}

.mode-card strong {
  font-size: 16px;
}

.mode-card span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.status-pill {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 34, 41, 0.05);
  display: grid;
  gap: 5px;
  min-height: 104px;
  min-width: 0;
  overflow: hidden;
  padding: 15px;
  position: relative;
}

.status-pill::before {
  background: var(--accent);
  border-radius: 999px;
  content: "";
  height: 9px;
  position: absolute;
  right: 15px;
  top: 15px;
  width: 9px;
}

.status-pill span,
.mini-stats span,
.current-state span,
.next-item span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-pill strong {
  color: #12222a;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill small,
.next-item small {
  color: var(--text-muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.home-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(360px, 1.2fr) minmax(320px, 0.85fr);
  min-width: 0;
}

.hero-panel {
  background: linear-gradient(145deg, #ffffff 0%, #f3fbfa 100%);
}

.current-state {
  display: grid;
  gap: 14px;
}

.current-state strong {
  display: block;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.state-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.state-tags span {
  background: #e8f4f2;
  border: 1px solid #cde6e2;
  border-radius: 999px;
  color: #25585b;
  padding: 7px 9px;
  text-transform: none;
  white-space: nowrap;
}

.state-reason {
  border-left: 3px solid var(--accent);
  color: #42525a;
  font-size: 14px;
  line-height: 1.55;
  padding-left: 12px;
}

.mini-stats {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-stats div,
.next-item {
  background: linear-gradient(180deg, #f9fbfc, #f3f7f8);
  border: 1px solid #e2eaee;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 12px;
}

.mini-stats strong {
  font-size: 24px;
}

.chart-panel {
  display: grid;
  gap: 14px;
}

.chart-wrap {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 126px minmax(0, 1fr);
}

.donut-chart {
  align-items: center;
  aspect-ratio: 1;
  background: conic-gradient(#238b8f 0deg var(--ai), #d9a441 var(--ai) 360deg);
  border-radius: 50%;
  display: grid;
  justify-items: center;
  padding: 12px;
}

.donut-chart > div {
  align-items: center;
  background: white;
  border-radius: 50%;
  display: grid;
  height: 100%;
  justify-items: center;
  width: 100%;
}

.donut-chart strong {
  font-size: 26px;
  line-height: 1;
}

.donut-chart span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  margin-top: -18px;
  text-transform: uppercase;
}

.media-progress-panel {
  overflow: hidden;
}

.media-progress-layout {
  align-items: center;
  display: grid;
  gap: 20px;
  grid-template-columns: 150px minmax(0, 1fr);
}

.media-donut {
  background: conic-gradient(#238b8f 0deg var(--done), #d8e2e6 var(--done) 360deg);
  width: 150px;
}

.media-progress-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.media-stat-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
}

.media-stat-grid div {
  background: linear-gradient(180deg, #f9fbfc, #f3f7f8);
  border: 1px solid #e2eaee;
  border-radius: 8px;
  display: grid;
  gap: 5px;
  padding: 12px;
}

.media-stat-grid span,
.media-type-bars span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.media-stat-grid strong {
  font-size: 24px;
}

.media-stack #media-analyzed-bar {
  background: #238b8f;
}

.media-stack #media-unanswered-bar {
  background: #d8e2e6;
}

.media-type-bars {
  display: grid;
  gap: 9px;
}

.media-type-bars div {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 74px minmax(0, 1fr);
}

meter {
  height: 10px;
  width: 100%;
}

meter::-webkit-meter-bar {
  background: #e9eff2;
  border: 0;
  border-radius: 999px;
}

meter::-webkit-meter-optimum-value {
  background: #238b8f;
  border-radius: 999px;
}

.chart-legend {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.chart-legend div {
  align-items: center;
  color: #3d4b54;
  display: grid;
  font-size: 13px;
  gap: 8px;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.legend-dot {
  border-radius: 999px;
  height: 10px;
  width: 10px;
}

.legend-dot.human {
  background: #d9a441;
}

.legend-dot.ai {
  background: #238b8f;
}

.stack-chart {
  display: grid;
  gap: 8px;
}

.stack-bar {
  background: #e9eff2;
  border-radius: 999px;
  display: flex;
  height: 10px;
  overflow: hidden;
}

.stack-bar span {
  display: block;
  min-width: 3px;
  transition: width 180ms ease;
}

#human-bar {
  background: #d9a441;
}

#ai-bar {
  background: #238b8f;
}

.stack-labels {
  color: var(--text-muted);
  display: flex;
  font-size: 11px;
  font-weight: 800;
  justify-content: space-between;
  text-transform: uppercase;
}

.next-stack {
  display: grid;
  gap: 9px;
}

.next-item strong {
  font-size: 18px;
  line-height: 1.25;
}

.attention-list {
  display: grid;
  gap: 9px;
}

.attention {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 11px;
}

.attention strong {
  font-size: 14px;
}

.attention span {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}

.attention.warning {
  background: #fff8eb;
  border-color: #efd39d;
  border-left-color: var(--warning);
}

.attention.info {
  background: #eef6fb;
  border-color: #c9dfeb;
  border-left-color: var(--info);
}

.attention.ok {
  background: #edf8f2;
  border-color: #c9e6d4;
  border-left-color: var(--accent);
}

.message-rail {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  min-width: 0;
}

.message-chip {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  min-height: 86px;
  min-width: 0;
  padding: 11px;
}

.message-chip span {
  color: var(--text-muted);
  font-size: 12px;
}

.message-chip strong {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(24, 34, 41, 0.05);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  font-size: 30px;
  line-height: 1;
}

.panel {
  padding: 16px;
  min-width: 0;
}

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

.panel-head > div {
  min-width: 0;
}

.split {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  min-width: 0;
}

.grid,
.stack,
.inline-form {
  display: grid;
  gap: 10px;
}

.controls,
.state-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.planner-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.inline-form {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

label {
  color: #3d4b54;
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
}

input,
select,
textarea,
button {
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font: inherit;
  font-size: 14px;
  max-width: 100%;
  min-width: 0;
  padding: 10px 11px;
}

input,
select,
textarea {
  background: white;
  color: #182229;
}

textarea {
  min-height: 84px;
  resize: vertical;
  width: 100%;
}

button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: white;
  border-color: var(--line-strong);
  color: #26343c;
}

button[data-persona-delete],
button[data-reject] {
  background: white;
  border-color: #e1b7b7;
  color: var(--danger);
}

.list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
  max-height: 520px;
  min-width: 0;
  overflow: auto;
  padding-right: 2px;
}

.list.compact {
  max-height: 260px;
}

.item,
.empty {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.item {
  line-height: 1.45;
  overflow-wrap: anywhere;
  min-width: 0;
}

.empty {
  color: var(--text-muted);
  font-size: 13px;
}

.meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-bottom: 5px;
}

pre {
  background: #edf3f5;
  border-radius: 7px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
    padding: 16px;
  }

  .nav {
    display: none;
  }

  .mobile-nav {
    color: #cdd9dd;
    display: grid;
    gap: 6px;
  }

  .metric-grid,
  .controls,
  .state-grid,
  .planner-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .home-grid,
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar {
    align-items: stretch;
    display: grid;
    position: static;
  }

  .auth {
    align-items: stretch;
    display: grid;
  }

  .auth input {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 14px;
  }

  .dashboard-hero {
    align-items: stretch;
    display: grid;
    padding: 18px;
  }

  .hero-actions {
    justify-content: stretch;
  }

  .hero-actions button,
  .auth button {
    width: 100%;
  }

  .status-strip,
  .message-rail {
    grid-template-columns: minmax(0, 1fr);
  }

  .chart-wrap {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .media-progress-layout {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
  }

  .media-progress-main {
    width: 100%;
  }

  .donut-chart {
    width: min(170px, 70vw);
  }

  .panel-head {
    align-items: stretch;
    display: grid;
  }
}
