:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --line: #e7e7ea;
  --line-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  font-family: InterVariable, Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.5; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; padding: 0 20px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--text);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 8px; top: 6px;
  border-left: 8px solid #fff; border-top: 5px solid transparent; border-bottom: 5px solid transparent;
}
.brand-sub { color: var(--muted); font-weight: 500; padding-left: 8px; border-left: 1px solid var(--line); }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a:not(.btn) { padding: 6px 10px; color: var(--muted); border-radius: 6px; }
.topnav a:not(.btn):hover { color: var(--text); background: #f4f4f5; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--panel);
  font-weight: 500; cursor: pointer; box-shadow: var(--shadow);
}
.btn:hover { background: #f4f4f5; }
.btn-primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn-primary:hover { background: #27272a; }

/* App shell: sidebar + content */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 56px); background: linear-gradient(90deg, var(--panel) 232px, var(--bg) 232px); }
.sidebar {
  position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); overflow-y: auto;
  padding: 16px 12px; border-right: 1px solid var(--line); background: var(--panel);
}
.side-label { margin: 16px 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
.side-label:first-child { margin-top: 0; }
.side-item {
  display: flex; width: 100%; align-items: center; justify-content: space-between;
  padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; color: #3f3f46;
}
.side-item:hover { background: #f4f4f5; }
.side-item[aria-pressed="true"] { background: #f4f4f5; color: var(--text); font-weight: 500; }
.side-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }

.content { padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 640px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.search {
  flex: 1; max-width: 360px; height: 34px; padding: 0 12px 0 32px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--panel)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%2371717a' stroke-width='2'%3E%3Ccircle cx='6' cy='6' r='4.5'/%3E%3Cpath d='m9.5 9.5 3 3'/%3E%3C/svg%3E") no-repeat 11px center;
  font: inherit; box-shadow: var(--shadow);
}
.search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.result-count { color: var(--muted); font-size: 13px; }

/* Card grid */
.card-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s;
}
.card:hover { border-color: var(--line-strong); box-shadow: 0 4px 12px rgba(16, 24, 40, .08); }
.card[hidden] { display: none; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: #f4f4f5; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.duration { position: absolute; right: 8px; bottom: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(9, 9, 11, .78); color: #fff; font-size: 12px; font-variant-numeric: tabular-nums; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; flex: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.35; }
.card-question { margin: 0; color: var(--muted); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: #f4f4f5; color: #3f3f46; font-size: 12px; font-weight: 500; }
.tag-tool { background: var(--panel); border: 1px solid var(--line); font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; font-weight: 400; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-miss { background: var(--text); color: #fff; }
.empty { padding: 48px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* Card page */
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.crumbs a:hover { color: var(--text); }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.detail-head h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.detail-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; }
.panel-body { padding: 16px; }
.player { display: block; width: 100%; aspect-ratio: 16 / 9; background: #09090b; border-radius: var(--radius) var(--radius) 0 0; }
.player-foot { display: flex; justify-content: space-between; padding: 10px 16px; color: var(--muted); font-size: 13px; }

.qa dt { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.qa dd { margin: 0 0 16px; }
.qa dd:last-child { margin-bottom: 0; }
.answer { font-size: 15px; font-weight: 500; }
.check-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 8px; background: var(--ok-soft); color: #14532d; font-size: 13px; }
.check-row strong { display: block; color: var(--ok); }
.check-row-miss { background: #f4f4f5; color: #3f3f46; }
.check-row-miss strong { color: var(--text); }
.miss-compare { margin-bottom: 12px; }

.proof-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.proof-frame { display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; text-align: left; cursor: pointer; }
.proof-frame:hover { border-color: var(--accent); }
.proof-frame img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.proof-frame span { display: block; padding: 8px 10px; font-size: 12.5px; color: #3f3f46; }
.proof-time { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent) !important; padding-bottom: 0 !important; }

.call { border-top: 1px solid var(--line); }
.call:first-child { border-top: 0; }
.call summary { display: flex; justify-content: space-between; padding: 10px 16px; cursor: pointer; list-style: none; }
.call summary::-webkit-details-marker { display: none; }
.call summary:hover { background: #fafafa; }
.tool-name { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.call-meta { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.call-body { padding: 0 16px 14px; }
.call-body h3 { margin: 8px 0 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); }
.call-body pre, .prompt { margin: 0; padding: 12px; max-height: 280px; overflow: auto; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; white-space: pre-wrap; word-break: break-word; }
.prompt { font-family: inherit; font-size: 13px; max-height: none; margin-bottom: 12px; }

.kv { margin: 0; display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv a { color: var(--accent); }
.licence-quote { margin: 12px 0 0; padding-left: 10px; border-left: 2px solid var(--line-strong); color: var(--muted); font-size: 12.5px; }
.install-steps { margin: 0; padding-left: 18px; font-size: 13px; }
.install-steps li + li { margin-top: 6px; }
.install-steps a, .try a { color: var(--accent); }
.limits { color: var(--muted); font-size: 13px; }
.how { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: #3f3f46; }
.btn { white-space: nowrap; }
.player-foot span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 16px; }

.try { margin: 0 0 24px; }
.try-text { margin: 0 0 8px; font-size: 13px; color: #3f3f46; }
.try-links { margin: 10px 0 0; }
.install-code { margin: 0; padding: 10px 12px; overflow-x: auto; white-space: pre; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; }
  .side-label { display: none; }
  .sidebar { scrollbar-width: none; }
  .sidebar::-webkit-scrollbar { display: none; }
  .side-item { width: auto; white-space: nowrap; gap: 6px; }
  .content { padding: 20px 16px 48px; }
  .shell { background: none; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-head .btn { display: none; }
  .stat { padding: 10px 12px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }
  .detail { grid-template-columns: 1fr; }
  .detail { display: flex; flex-direction: column; gap: 16px; }
  .detail-main, .detail-side { display: contents; }
  .detail .panel { order: 3; margin-top: 0; width: 100%; min-width: 0; }
  .detail .panel:first-child { order: 1; }
  .detail #question { order: 2; }
  .detail-head { flex-direction: column; }
  .detail-head .btn { align-self: flex-start; }
  .topnav a:not(.btn) { display: none; }
}
