:root {
  color-scheme: dark;
  --bg: #07070b;
  --bg-2: #0c0c11;
  --sidebar: #0a0a0f;
  --card: #121218;
  --card-2: #16161e;
  --line: rgba(255, 255, 255, 0.08);
  --ink: #f4f4f5;
  --mute: #8b8b98;
  --dim: #5c5c6b;
  --accent: #5ee9a4;
  --accent-2: #3dff9a;
  --accent-ink: #06140c;
  --glow: rgba(94, 233, 164, 0.35);
  --warn: #fbbf24;
  --cyan: #5eead4;
  --violet: #c4b5fd;
  --radius: 14px;
  --sidebar-w: 260px;
  --safe: env(safe-area-inset-top, 0px);
  --display: Syne, Inter, ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: var(--bg); }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.011em;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
img { max-width: 100%; }
.skip {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 80;
  transform: translateY(-160%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  font-weight: 600;
}
.skip:focus { transform: none; }

.logo-h {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #0b0b0f;
  background: linear-gradient(135deg, #5eead4 0%, #a78bfa 100%);
  box-shadow: 0 8px 28px var(--glow);
  flex-shrink: 0;
}
.logo-h.lg {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  font-size: 2.1rem;
  box-shadow: 0 16px 50px rgba(94, 234, 212, 0.35), 0 16px 50px rgba(167, 139, 250, 0.28);
}

/* Splash */
html.entered .splash { display: none; }
html.entered .app { display: flex; }
html.outro-mode .splash,
html.outro-mode .app { display: none; }
html.outro-mode .outro { display: grid; }
.splash {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe)) 24px 24px;
  background:
    radial-gradient(720px 420px at 50% 42%, #161427 0%, transparent 62%),
    radial-gradient(900px 600px at 50% 50%, #101018 0%, var(--bg) 70%);
}
.splash::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 45%, black 20%, transparent 72%);
}
.splash-inner { position: relative; text-align: center; max-width: 40rem; }
.splash h1 {
  margin: 1.35rem 0 0.55rem;
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  text-wrap: balance;
}
.splash .sub { color: var(--mute); font-size: 1.05rem; margin: 0 0 0.4rem; }
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.live-dot i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(94, 233, 164, 0.18);
  animation: pulse 1.8s ease infinite;
}
.enter {
  margin-top: 1.75rem;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: 0.7rem 1.15rem;
  border-radius: 10px;
  cursor: pointer;
}
.splash.closing { animation: fadeOut 0.45s ease forwards; }

.outro {
  display: none;
  min-height: 100dvh;
  place-items: center;
  text-align: center;
  padding: 32px;
  background:
    radial-gradient(680px 380px at 50% 46%, #15122a 0%, transparent 60%),
    var(--bg);
}
.outro.show { display: grid; }
.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.brand-row h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: -0.05em;
}
.outro p { margin: 0; color: var(--mute); font-size: 1.15rem; }
.outro p em { color: var(--accent); font-style: normal; font-weight: 600; }
.glow-rule {
  margin: 1.6rem auto 0;
  width: min(280px, 50vw);
  height: 2px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 18px var(--glow);
}

/* Shell */
.app { display: none; min-height: 100dvh; }
.app.show { display: flex; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow: auto;
  overscroll-behavior: contain;
}
.brand {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  padding: 0.35rem 0.55rem 1rem;
  text-decoration: none;
}
.brand strong { display: block; font-size: 0.98rem; }
.brand span { display: block; color: var(--dim); font-size: 0.68rem; line-height: 1.25; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  text-decoration: none;
  color: #b4b4c0;
  padding: 0.42rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
}
nav a:hover { background: rgba(255,255,255,0.04); color: var(--ink); }
nav a.active { background: #1a1a24; color: #fff; }
.side-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0.45rem 0.2rem;
  color: var(--dim);
  font-size: 0.75rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
}
.badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-ink);
}

.os-hero {
  overflow: hidden;
}
.os-hero-video {
  display: block;
  width: 100%;
  max-height: min(62vh, 640px);
  object-fit: cover;
  background: #08080c;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.splash-video {
  width: min(100%, 42rem);
  max-height: 36vh;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #08080c;
  margin: 1.1rem auto 0;
  display: block;
}

.workspace {
  flex: 1;
  min-width: 0;
  padding: 1.35rem 1.5rem 2.5rem;
  background:
    radial-gradient(900px 300px at 70% -10%, rgba(94, 233, 164, 0.05), transparent 50%),
    var(--bg-2);
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.15rem;
}
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.15rem);
  letter-spacing: -0.045em;
  text-wrap: balance;
  scroll-margin-top: 1rem;
}
.topbar p { margin: 0.25rem 0 0; color: var(--mute); font-size: 0.92rem; }
.actions { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--line);
  background: #15151d;
  color: var(--ink);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
}
.btn:hover { background: #1c1c26; }
.btn:focus-visible,
nav a:focus-visible,
.enter:focus-visible,
.chip:focus-visible,
.cmd-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn:disabled,
.chip:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}
.kbd { font-size: 0.78rem; color: var(--mute); font-weight: 600; }
.live-strip {
  display: grid;
  gap: 0.35rem;
  padding: 0.35rem 0.45rem 0.85rem;
}
.status-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font-size: 0.68rem;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}
.status-chip.ok { border-color: rgba(94, 233, 164, 0.4); color: var(--accent); }
.status-chip.warn { border-color: rgba(251, 191, 36, 0.4); color: var(--warn); }
.os-hero {
  position: relative;
}
.os-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4rem;
  pointer-events: none;
  background: linear-gradient(transparent, var(--card));
  border-radius: 0 0 var(--radius) var(--radius);
}
.walking-slot {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}
.walking-slot img {
  width: min(220px, 36vw);
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #111827;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; }

.grid { display: grid; gap: 0.75rem; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metrics-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { grid-template-columns: 1.35fr 0.9fr; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  min-width: 0;
}
.card.accent {
  border-color: rgba(94, 233, 164, 0.55);
  box-shadow: 0 0 0 1px rgba(94, 233, 164, 0.08), 0 10px 30px rgba(94, 233, 164, 0.06);
}
.lbl {
  display: block;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.val {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.val.green { color: var(--accent); }
.hint { color: var(--mute); font-size: 0.82rem; margin-top: 0.2rem; }
.section-h {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin: 0 0 0.75rem;
}
.section-h h2 { margin: 0; font-size: 1rem; font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.7rem 0; }
.chip {
  border: 1px solid rgba(94, 233, 164, 0.28);
  background: rgba(94, 233, 164, 0.08);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover, .chip.on { background: rgba(94, 233, 164, 0.16); }
.muted { color: var(--mute); font-size: 0.9rem; line-height: 1.45; }
.loop { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.loop button {
  border: 1px solid var(--line);
  background: #15151c;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}
.loop button.on {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 700;
}
.feed { display: grid; gap: 0.85rem; }
.feed-item { min-width: 0; }
.feed-item strong { display: block; font-size: 0.92rem; }
.feed-item span { color: var(--mute); font-size: 0.82rem; }
.feed-item time { float: right; color: var(--dim); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.row:last-child { border-bottom: 0; }
.row h3 { margin: 0; font-size: 0.95rem; }
.stats { color: var(--mute); font-size: 0.78rem; }
.pill {
  background: rgba(94, 233, 164, 0.12);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.22rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-bottom: 0.85rem;
}
.flow span {
  border: 1px solid var(--line);
  background: #17171f;
  border-radius: 8px;
  padding: 0.32rem 0.55rem;
  font-size: 0.78rem;
}
.flow span.end { border-color: rgba(94, 233, 164, 0.5); color: var(--accent); }
.flow i { color: var(--dim); font-style: normal; }
.form { display: grid; gap: 0.7rem; }
label { display: grid; gap: 0.28rem; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); font-weight: 650; }
input, textarea {
  background: #0e0e14;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.92rem;
  color: var(--ink);
}
.toast {
  color: var(--accent);
  font-size: 0.82rem;
  min-height: 1.2em;
}
.empty { color: var(--mute); padding: 0.4rem 0; }
pre.status {
  margin: 0;
  white-space: pre-wrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: #d6d6de;
  line-height: 1.45;
}

.palette {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.55);
  place-items: start center;
  padding: 12vh 16px 16px;
  overscroll-behavior: contain;
}
.palette.open { display: grid; }
.palette-box {
  width: min(560px, 100%);
  background: #121218;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.palette input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0.9rem 1rem;
  background: transparent;
}
.cmd-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.7rem 1rem;
  cursor: pointer;
  color: var(--ink);
}
.cmd-item:hover, .cmd-item[aria-selected="true"] { background: #1b1b24; }
.mobile-nav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 0.65rem 0.85rem;
}

@keyframes pulse {
  50% { opacity: 0.45; transform: scale(0.9); }
}
@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot i, .splash.closing { animation: none; }
  .os-dock a, .studio-beat, .card, .chip { transition: none !important; }
}

.app.os-shell.show {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto auto 1fr auto;
  min-height: 100dvh;
}
.app.os-shell .os-chrome { grid-column: 1 / -1; }
.app.os-shell .mobile-nav { grid-column: 1 / -1; }
.app.os-shell .sidebar {
  grid-row: 3;
  height: auto;
  max-height: none;
  position: static;
}
.app.os-shell .workspace {
  grid-row: 3;
  padding-bottom: 1.25rem;
}
.app.os-shell .os-dock { grid-column: 1 / -1; }
.live-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 0.45rem 0.2rem;
}
.status-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  font-size: 0.68rem;
  color: var(--mute);
}
.status-chip.ok { border-color: rgba(94, 233, 164, 0.45); color: var(--accent); }
.status-chip.warn { border-color: rgba(251, 191, 36, 0.45); color: var(--warn); }
.kg-wrap { position: relative; }
.kg-svg, .analytics-svg {
  display: block;
  width: 100%;
  height: 22rem;
  background: #0b0b10;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.orch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.55rem;
  margin-top: 0.75rem;
}
.orch-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  background: var(--card-2);
}
.orch-card strong { display: block; font-size: 0.85rem; }
.studio-timeline {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding: 0.35rem 0;
}
.studio-beat {
  flex: 1 0 6.5rem;
  min-height: 4.2rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #17171f;
  padding: 0.5rem;
  font-size: 0.78rem;
}
.fly-loop { display: flex; flex-wrap: wrap; gap: 0.4rem; }

@media (max-width: 1100px) {
  .metrics, .metrics-3, .split { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .walking-slot { grid-template-columns: 1fr; }
  .app.show { flex-direction: column; }
  .sidebar {
    display: none;
    width: 100%;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar.open { display: flex; }
  .mobile-nav { display: flex; justify-content: space-between; align-items: center; }
  .metrics, .metrics-3, .split { grid-template-columns: 1fr; }
  .app.os-shell.show {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr auto;
  }
  .app.os-shell .sidebar { grid-row: auto; }
  .app.os-shell .workspace { grid-row: auto; }
}
