/* AIStore edge PoC — ChatGPT-style shared shell */
:root {
  --bg: #f7f7f8;
  --sidebar: #171717;
  --sidebar-hover: #212121;
  --sidebar-active: #2f2f2f;
  --panel: #ffffff;
  --line: #e5e5e5;
  --text: #0d0d0d;
  --muted: #8e8e8e;
  --accent: #10a37f;
  --accent-hover: #0d8c6d;
  --warn: #ef4444;
  --ok: #16a34a;
  --hover: #f4f4f4;
  --chip: #f4f4f4;
  --opt: #10a37f;
  --partial: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  color-scheme: light;
}

a { color: var(--accent); }

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-brand .name { font-size: 13px; font-weight: 600; }
.sidebar-brand .tag { font-size: 11px; color: #a3a3a3; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section + .sidebar-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8a8a8a;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}

.sidebar-section-toggle:hover {
  color: #c4c4c4;
  background: rgba(255, 255, 255, 0.04);
}

.section-chevron {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.section-chevron svg {
  width: 12px;
  height: 12px;
  display: block;
}

.sidebar-section:not(.collapsed) .section-chevron {
  transform: rotate(90deg);
}

.sidebar-section.collapsed .sidebar-section-items {
  display: none;
}

.sidebar-section-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: #d4d4d4;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.25;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav a:hover .nav-icon {
  opacity: 1;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-nav a.active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
  color: inherit;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 8px;
  position: relative;
}

.sidebar-more-wrap {
  position: relative;
}

.sidebar-more-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #d4d4d4;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-more-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-more-btn[aria-expanded="true"],
.sidebar-more-btn.has-active {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.sidebar-more-btn.has-active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.sidebar-more-btn .more-chevron {
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.sidebar-more-btn[aria-expanded="true"] .more-chevron {
  transform: rotate(90deg);
}

.sidebar-more-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  max-height: min(70vh, 420px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 10px;
  background: #1f1f1f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 50;
}

.sidebar-more-group + .sidebar-more-group {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-more-label {
  padding: 4px 8px 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #737373;
}

.sidebar-more-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #d4d4d4;
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-more-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-more-link.active {
  background: rgba(16, 163, 127, 0.18);
  color: #86efac;
}

.sidebar-more-link.active .nav-icon {
  opacity: 1;
  color: var(--accent);
}

.main-wrap {
  flex: 1;
  margin-left: 200px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.mobile-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}

.mobile-bar button {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}

.page-header {
  padding: 28px 32px 8px;
}

.main-wrap > .toolbar,
.main-wrap > .controls,
.main-wrap > .metrics {
  padding-left: 32px;
  padding-right: 32px;
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.page-header h1 span {
  color: var(--accent);
}

.page-header .sub {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
  max-width: 720px;
}

.page-header .header-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

main, .page-main {
  padding: 12px 32px 40px;
  flex: 1;
}

footer, .page-footer {
  padding: 0 32px 28px;
  color: var(--muted);
  font-size: 12px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--chip);
  color: var(--text);
}

.mono { font-family: "IBM Plex Mono", monospace; font-size: 12px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip);
  border: 1px solid var(--line);
  font-size: 12px;
  margin-right: 4px;
}
.pill.danger, .pill.bad, .pill.warn { border-color: #fecaca; color: var(--warn); background: #fef2f2; }
.pill.ok { border-color: #bbf7d0; color: var(--ok); background: #f0fdf4; }
.pill.skip, .pill.partial { border-color: #fde68a; color: #b45309; background: #fffbeb; }
.pill.blocked, .pill.missing { border-color: #e5e5e5; color: var(--muted); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}
tr:hover td { background: var(--hover); }

.empty, .empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 16px 0;
}

.btn, button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
button:hover, .btn:hover { background: var(--hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary, button.accent, button.ok, .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover, button.accent:hover, button.ok:hover, .btn-primary:hover {
  background: var(--accent-hover);
}
button.warn { background: #fef2f2; border-color: #fecaca; color: var(--warn); }

select, input[type="text"], input[type="password"], input[type="search"], textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}
select:focus, input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,163,127,0.15);
}

.toolbar, .controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.alert {
  border-left: 3px solid var(--warn);
  padding: 12px 14px;
  background: #fef2f2;
  border-radius: 8px;
  margin-bottom: 10px;
}
.alert strong { color: var(--warn); }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tl-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.tl-item .t { color: var(--accent); font-family: "IBM Plex Mono", monospace; }

.timeline { max-height: 320px; overflow: auto; }

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.metric .k { font-size: 12px; color: var(--muted); }
.metric .v { font-size: 22px; font-weight: 650; margin-top: 4px; letter-spacing: -0.02em; }

.note, .hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.verdict {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  margin-bottom: 12px;
}
.note-warn {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  line-height: 1.5;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 35;
}

body.sidebar-open .sidebar-backdrop { display: block; }

/* Boss demo mode */
.demo-mode-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
  font-weight: 600;
}
.demo-hero {
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 8%, var(--panel)), var(--panel));
  margin-bottom: 14px;
}
.demo-hero h2 { margin: 0 0 8px; font-size: 17px; }
.demo-hero p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.demo-hero .chips { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.demo-hero .chip-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.demo-hero .chip-link:hover { border-color: var(--accent); transform: translateY(-1px); }
.demo-hero .chip-link.primary {
  background: color-mix(in srgb, var(--accent) 14%, var(--panel));
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  color: var(--accent);
}
.tech-details {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  margin-bottom: 16px;
  overflow: hidden;
}
.tech-details > summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
  list-style: none;
  color: var(--muted);
}
.tech-details > summary::-webkit-details-marker { display: none; }
.tech-details[open] > summary { border-bottom: 1px solid var(--line); color: var(--text); }
.tech-details .tech-details-body { padding: 0 16px 16px; display: grid; gap: 16px; }
.demo-mode .tech-details[data-demo-collapse] { display: none; }
.demo-mode .scatter-wrap,
.demo-mode [data-boss-hide] { display: none !important; }
.demo-mode #datasetSection,
.demo-mode #fullScheme,
.demo-mode #stageBlock,
.demo-mode #comboBlock,
.demo-mode #kpis,
.demo-mode #rankSection,
.demo-mode #cardsSection,
.demo-mode #promptSection,
.demo-mode #protocolSection,
.demo-mode .boss-hide-split { display: none !important; }
.demo-mode .boss-only { display: block !important; }
.boss-mp4-wrap {
  margin-top: 14px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}
.boss-mp4-wrap video { width: 100%; max-height: 360px; display: block; }
.boss-mp4-caption {
  padding: 10px 14px;
  font-size: 13px;
  background: var(--chip);
  border-top: 1px solid var(--line);
  color: var(--muted);
}
.sidebar[data-view="boss"] .sidebar-nav a.active {
  background: color-mix(in srgb, #86efac 22%, var(--sidebar-active));
}
.story-callout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
@media (max-width: 720px) { .story-callout { grid-template-columns: 1fr 1fr; } }
.story-callout .step {
  text-align: center;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 13px;
}
.story-callout .step strong { display: block; font-size: 20px; color: var(--accent); margin-bottom: 4px; }
.story-callout .arrow { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 18px; }
@media (max-width: 720px) { .story-callout .arrow { display: none; } }
.roadmap-timeline {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.roadmap-timeline .milestone {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--chip);
  font-size: 14px;
}
.roadmap-timeline .when {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

@media (max-width: 900px) {
  .row, .grid2 { grid-template-columns: 1fr; }
}

/* VLM keyframe panel (playback / theft_pretrigger demo) */
.vlm-panel { font-size: 12px; line-height: 1.45; }
.vlm-case-block { margin-top: 4px; }
.vlm-case-meta { margin-bottom: 6px; color: var(--text); }
.vlm-rationale {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
  max-height: 4.5em;
  overflow: auto;
}
.vlm-kf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.vlm-kf {
  margin: 0;
  flex: 0 0 auto;
}
.vlm-kf img {
  display: block;
  height: 72px;
  width: auto;
  max-width: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0b1220;
}
.vlm-kf figcaption {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 2px;
}
.vlm-more-hint { margin-top: 8px; font-size: 11px; color: var(--muted); }
.vlm-panel-empty { padding: 8px 0; }

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
  }
  .main-wrap { margin-left: 0; }
  .mobile-bar { display: flex; }
  .page-header, main, .page-main, footer, .page-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}
