:root {
  --bg: #0b1016;
  --bg-elev: #121a24;
  --bg-soft: #182232;
  --line: rgba(232, 238, 247, 0.08);
  --text: #e8eef7;
  --muted: #8b98ab;
  --amber: #f5a524;
  --teal: #3ddc97;
  --rose: #ff6b8a;
  --blue: #6aa8ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(245, 165, 36, 0.12), transparent 50%),
    radial-gradient(900px 500px at 90% 0%, rgba(61, 220, 151, 0.08), transparent 45%),
    linear-gradient(180deg, #0d141d 0%, var(--bg) 40%, #090d12 100%);
  color: var(--text);
  font-family: var(--font);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 20, 0.72);
  backdrop-filter: blur(16px);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background:
    linear-gradient(135deg, var(--amber), #ffcf70 45%, transparent 45%),
    linear-gradient(315deg, var(--teal), #1a3b2e);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 10px 30px rgba(245, 165, 36, 0.25);
}

.brand-title {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(245, 165, 36, 0.14), rgba(255, 255, 255, 0.02));
  border-color: rgba(245, 165, 36, 0.28);
  color: var(--text);
}

.nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #445166;
}

.nav-dot.live {
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.6);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.55);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(61, 220, 151, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(61, 220, 151, 0);
  }
}

.side-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat strong {
  font-family: var(--mono);
  font-size: 20px;
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.logout-btn {
  width: 100%;
}

.stream-status {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.main {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.topbar p,
.muted {
  margin: 0;
  color: var(--muted);
}

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

.search {
  width: min(360px, 40vw);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
}

.search:focus {
  border-color: rgba(245, 165, 36, 0.5);
  box-shadow: 0 0 0 3px rgba(245, 165, 36, 0.12);
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
  transition: 150ms ease;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.04);
}

.btn.primary {
  background: linear-gradient(180deg, #ffb84a, var(--amber));
  color: #1a1205;
  font-weight: 600;
}

.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade 220ms ease;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid.session-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  min-height: 70vh;
}

.panel {
  background: rgba(18, 26, 36, 0.88);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.panel.grow {
  min-height: 70vh;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(61, 220, 151, 0.12);
  color: var(--teal);
  border: 1px solid rgba(61, 220, 151, 0.2);
}

.event-list,
.entity-list {
  padding: 10px;
  overflow: auto;
  max-height: calc(100vh - 220px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-card,
.entity-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: 150ms ease;
}

.event-card:hover,
.entity-card:hover,
.entity-card.active {
  border-color: rgba(245, 165, 36, 0.35);
  background: rgba(245, 165, 36, 0.06);
}

.event-top,
.entity-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--blue);
  background: rgba(106, 168, 255, 0.08);
}

.chip.warn {
  color: var(--amber);
  background: rgba(245, 165, 36, 0.1);
}

.chip.rose {
  color: var(--rose);
  background: rgba(255, 107, 138, 0.1);
}

.event-title,
.entity-title {
  font-weight: 600;
  margin: 8px 0 4px;
  word-break: break-word;
}

.event-summary,
.entity-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.meta-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.row {
  display: flex;
  align-items: center;
}

.gap {
  gap: 8px;
}

.drawer,
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.hidden {
  display: none !important;
}

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

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(560px, 100%);
  height: 100%;
  background: #0f1620;
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.drawer-head,
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2,
.modal-head h2 {
  margin: 0 0 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.drawer-body {
  padding: 18px 20px 40px;
  overflow: auto;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px 12px;
  margin-bottom: 18px;
  font-size: 13px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-family: var(--mono);
  word-break: break-word;
}

.pre {
  background: #0a1018;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  max-height: 50vh;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-window {
  position: absolute;
  inset: 4vh 4vw;
  background: #0f1620;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transcript-body {
  padding: 18px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.t-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.02);
}

.t-item .role {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.t-item .content {
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--text);
  font-size: 14px;
}

.shot {
  margin-top: 12px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(245, 165, 36, 0.25);
  background: #000;
}

.shot img {
  display: block;
  width: 100%;
  height: auto;
}

.shot-caption {
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.45);
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(440px, 100%);
}

.login-card {
  background: rgba(18, 26, 36, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.login-copy {
  margin: 0 0 6px;
  color: var(--muted);
  line-height: 1.45;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field input {
  background: #0a1018;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 14px;
  outline: none;
}

.field input:focus {
  border-color: rgba(245, 165, 36, 0.55);
  box-shadow: 0 0 0 3px rgba(245, 165, 36, 0.12);
}

.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 13px 16px;
}

.login-error {
  color: #ffb3c1;
  background: rgba(255, 107, 138, 0.12);
  border: 1px solid rgba(255, 107, 138, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .grid.two,
  .grid.session-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .search {
    width: 100%;
  }
}
