/* Academy v2 prototype: tokens, base, shell and shared components (zinc, shadcn/ui look) */
@font-face {
  font-family: "Inter";
  src: url("../vendor/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --primary: 240 9% 17.5%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 71% 36%;
  --warning: 38 92% 42%;
  --info: 217 91% 45%;
  --live: 0 72% 46%;
  --rating: 45 93% 47%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 10% 3.9%;
  --sidebar-background: 0 0% 98%;
  --sidebar-foreground: 240 5.3% 26.1%;
  --sidebar-accent: 240 4.8% 95.9%;
  --sidebar-border: 220 13% 91%;
  --chart-1: #2a78d6;
  --chart-2: #eb6834;
  --chart-3: #1baf7a;
  --chart-4: #eda100;
  --chart-5: #e87ba4;
  --chart-6: #008300;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.16);
  --sidebar-w: 16rem;
  --sidebar-w-collapsed: 3.5rem;
  --topbar-h: 3.5rem;
  color-scheme: light;
}

.dark {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 3.9%;
  --card-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --secondary: 240 3.7% 15.9%;
  --secondary-foreground: 0 0% 98%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 72% 55%;
  --destructive-foreground: 0 0% 98%;
  --success: 142 69% 58%;
  --warning: 43 96% 56%;
  --info: 213 94% 68%;
  --live: 0 72% 55%;
  --rating: 45 93% 55%;
  --border: 240 3.7% 15.9%;
  --input: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --sidebar-background: 240 5.9% 10%;
  --sidebar-foreground: 240 4.8% 95.9%;
  --sidebar-accent: 240 3.7% 15.9%;
  --sidebar-border: 240 3.7% 15.9%;
  --chart-1: #3987e5;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-6: #008300;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; border-color: hsl(var(--border)); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h1 { font-size: 24px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
ul, ol { margin: 0; padding: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid hsl(var(--border)); margin: 16px 0; }
:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; }
::selection { background: hsl(var(--primary) / 0.15); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.muted { color: hsl(var(--muted-foreground)); }
.small { font-size: 12px; }
.sep { height: 1px; border: 0; background: hsl(var(--border)); margin: 16px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.icon { width: 16px; height: 16px; stroke-width: 2; flex: none; vertical-align: middle; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 24px; height: 24px; }

/* ---------- Layout helpers ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px; }
.page-header { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-header > div:first-child { flex: 1; min-width: 240px; }
.page-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { margin-top: 4px; color: hsl(var(--muted-foreground)); font-size: 14px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1023px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .page { padding: 16px; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: transparent; color: inherit; transition: background-color .15s, color .15s, border-color .15s, opacity .15s;
  user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: hsl(var(--primary) / 0.9); }
.btn-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.btn-secondary:hover { background: hsl(var(--secondary) / 0.8); }
.btn-outline { border-color: hsl(var(--input)); background: hsl(var(--background)); box-shadow: var(--shadow-sm); }
.btn-outline:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.btn-destructive { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); box-shadow: var(--shadow-sm); }
.btn-destructive:hover { background: hsl(var(--destructive) / 0.9); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 40px; padding: 0 32px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-lg { width: 40px; }

/* ---------- Cards ---------- */
.card {
  background: hsl(var(--card)); color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-sm);
}
.card-header { padding: 24px 24px 0; display: flex; flex-direction: column; gap: 4px; }
.card-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.card-desc { font-size: 13px; color: hsl(var(--muted-foreground)); }
.card-body { padding: 24px; }
.card-header + .card-body { padding-top: 16px; }
.card-footer { padding: 0 24px 24px; display: flex; align-items: center; gap: 8px; }
.card.compact .card-header { padding: 12px 12px 0; }
.card.compact .card-body { padding: 12px; }
.card.compact .card-footer { padding: 0 12px 12px; }
.card-hover { transition: border-color .15s, box-shadow .15s; }
.card-hover:hover { border-color: hsl(var(--foreground) / 0.25); box-shadow: var(--shadow-md); }

/* ---------- Badge, tag, chip, dot ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid transparent; padding: 2px 8px; font-size: 12px; font-weight: 600; line-height: 16px; white-space: nowrap;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
}
.badge .icon { width: 12px; height: 12px; }
.badge-outline { background: transparent; color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.badge-secondary { background: hsl(var(--secondary)); color: hsl(var(--secondary-foreground)); }
.badge-success { background: hsl(var(--success) / 0.12); color: hsl(var(--success)); border-color: hsl(var(--success) / 0.3); }
.badge-warning { background: hsl(var(--warning) / 0.12); color: hsl(var(--warning)); border-color: hsl(var(--warning) / 0.3); }
.badge-info { background: hsl(var(--info) / 0.12); color: hsl(var(--info)); border-color: hsl(var(--info) / 0.3); }
.badge-destructive { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); border-color: hsl(var(--destructive) / 0.3); }
.badge-live { background: hsl(var(--live)); color: #fff; }
.tag {
  display: inline-flex; align-items: center; border: 1px solid hsl(var(--border)); border-radius: 999px;
  padding: 0 8px; font-size: 11px; line-height: 18px; color: hsl(var(--muted-foreground)); white-space: nowrap;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid hsl(var(--input)); background: hsl(var(--background)); font-size: 13px; font-weight: 500;
}
.chip:hover { background: hsl(var(--accent)); }
.chip.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-color: hsl(var(--primary)); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: hsl(var(--muted-foreground)); flex: none; }
.dot-success { background: hsl(var(--success)); }
.dot-warning { background: hsl(var(--warning)); }
.dot-destructive { background: hsl(var(--destructive)); }
.dot-info { background: hsl(var(--info)); }
.dot-muted { background: hsl(var(--muted-foreground) / 0.5); }

/* ---------- Forms ---------- */
.label { display: block; font-size: 14px; font-weight: 500; line-height: 1; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; margin-bottom: 16px; }
.field > .label { margin-bottom: 8px; }
.field .hint { margin-top: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); }
.input, .select, .textarea {
  display: block; width: 100%; height: 36px; padding: 4px 12px; border-radius: calc(var(--radius) - 2px);
  border: 1px solid hsl(var(--input)); background: transparent; font-size: 14px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: hsl(var(--muted-foreground)); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: none; border-color: hsl(var(--ring)); box-shadow: 0 0 0 1px hsl(var(--ring)); }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.select option { background: hsl(var(--background)); color: hsl(var(--foreground)); }
.textarea { height: auto; min-height: 80px; padding: 8px 12px; resize: vertical; line-height: 1.5; }
.checkbox, .switch { appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer; flex: none; }
.checkbox { width: 16px; height: 16px; border: 1px solid hsl(var(--primary)); border-radius: 4px; background: transparent; display: inline-grid; place-content: center; box-shadow: var(--shadow-sm); }
.checkbox:checked { background: hsl(var(--primary)); }
.checkbox:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid hsl(var(--primary-foreground)); border-bottom: 2px solid hsl(var(--primary-foreground)); transform: rotate(-45deg) translate(1px, -1px); }
.switch { width: 36px; height: 20px; border-radius: 999px; background: hsl(var(--input)); position: relative; transition: background-color .15s; box-shadow: inset 0 0 0 1px hsl(var(--border)); }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: hsl(var(--background)); box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch:checked { background: hsl(var(--primary)); }
.switch:checked::after { transform: translateX(16px); background: hsl(var(--primary-foreground)); }
.switch:disabled, .checkbox:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--radius); background: hsl(var(--muted)); color: hsl(var(--muted-foreground)); max-width: 100%; overflow-x: auto; }
.tab { height: 28px; padding: 0 12px; border: 0; border-radius: calc(var(--radius) - 2px); background: transparent; font-size: 13px; font-weight: 500; white-space: nowrap; color: inherit; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: hsl(var(--foreground)); }
.tab.active { background: hsl(var(--background)); color: hsl(var(--foreground)); box-shadow: var(--shadow-sm); }

/* ---------- Table ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 2px); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; font-size: 13px; color: hsl(var(--muted-foreground)); padding: 10px 16px; height: 40px; border-bottom: 1px solid hsl(var(--border)); white-space: nowrap; background: hsl(var(--muted) / 0.4); }
.table td { padding: 12px 16px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: hsl(var(--muted) / 0.5); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Progress, avatar, stat ---------- */
.progress { height: 8px; width: 100%; border-radius: 999px; background: hsl(var(--secondary)); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: hsl(var(--primary)); transition: width .4s ease; }
.progress-success > span { background: hsl(var(--success)); }
.progress-warning > span { background: hsl(var(--warning)); }
.progress-info > span { background: hsl(var(--info)); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: hsl(var(--muted)); color: hsl(var(--foreground)); font-size: 12px; font-weight: 600; flex: none; border: 1px solid hsl(var(--border)); }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 13px; color: hsl(var(--muted-foreground)); }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 12px; font-weight: 500; color: hsl(var(--muted-foreground)); }
.stat-delta.up { color: hsl(var(--success)); }
.stat-delta.down { color: hsl(var(--destructive)); }

/* ---------- Empty, callout, kbd ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 48px 24px; border: 1px dashed hsl(var(--border)); border-radius: calc(var(--radius) + 2px); color: hsl(var(--muted-foreground)); }
.empty .icon { width: 32px; height: 32px; opacity: .6; }
.empty h3 { color: hsl(var(--foreground)); }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 2px); background: hsl(var(--muted) / 0.5); font-size: 13px; }
.callout > .icon { margin-top: 2px; }
.callout > div, .callout > details { flex: 1; min-width: 0; }
.callout-info { background: hsl(var(--info) / 0.07); border-color: hsl(var(--info) / 0.25); }
.callout-info > .icon, .callout-info summary .icon { color: hsl(var(--info)); }
.callout-warning { background: hsl(var(--warning) / 0.08); border-color: hsl(var(--warning) / 0.3); }
.callout-warning > .icon { color: hsl(var(--warning)); }
.callout-success { background: hsl(var(--success) / 0.08); border-color: hsl(var(--success) / 0.3); }
.callout-success > .icon { color: hsl(var(--success)); }
.callout-destructive { background: hsl(var(--destructive) / 0.07); border-color: hsl(var(--destructive) / 0.3); }
.callout-destructive > .icon { color: hsl(var(--destructive)); }
.callout details > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.callout details > summary::-webkit-details-marker { display: none; }
.callout details > summary::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; opacity: .6; }
.callout details[open] > summary::after { transform: rotate(-135deg); }
.callout details > :not(summary) { margin-top: 8px; color: hsl(var(--muted-foreground)); }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border: 1px solid hsl(var(--border)); border-bottom-width: 2px; border-radius: 4px; background: hsl(var(--muted)); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: hsl(var(--muted-foreground)); }

/* ---------- List, stepper, timeline ---------- */
.list { display: flex; flex-direction: column; border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 2px); overflow: hidden; background: hsl(var(--card)); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border: 0; border-bottom: 1px solid hsl(var(--border)); background: transparent; width: 100%; text-align: left; color: inherit; }
.list-item:last-child { border-bottom: 0; }
button.list-item:hover, a.list-item:hover, .list-item.clickable:hover { background: hsl(var(--accent)); text-decoration: none; }
.list-item.clickable { cursor: pointer; }
.stepper { display: flex; gap: 8px; counter-reset: step; list-style: none; flex-wrap: wrap; }
.step { flex: 1; min-width: 100px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: hsl(var(--muted-foreground)); counter-increment: step; }
.step::before { content: counter(step); display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; border: 1px solid hsl(var(--border)); font-size: 12px; font-weight: 600; flex: none; background: hsl(var(--background)); }
.step.active { color: hsl(var(--foreground)); font-weight: 600; }
.step.active::before { border-color: hsl(var(--primary)); background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.step.done { color: hsl(var(--foreground)); }
.step.done::before { content: "\2713"; border-color: hsl(var(--success)); background: hsl(var(--success)); color: #fff; }
.timeline { position: relative; list-style: none; padding-left: 24px; display: flex; flex-direction: column; gap: 16px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 1px; background: hsl(var(--border)); }
.tl-item { position: relative; }
.tl-item::before { content: ""; position: absolute; left: -24px; top: 4px; width: 15px; height: 15px; border-radius: 50%; background: hsl(var(--background)); border: 2px solid hsl(var(--border)); }
.tl-item.done::before { border-color: hsl(var(--success)); background: hsl(var(--success)); }
.tl-item.active::before { border-color: hsl(var(--primary)); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban-col { background: hsl(var(--muted) / 0.6); border-radius: calc(var(--radius) + 2px); padding: 8px; display: flex; flex-direction: column; gap: 8px; min-height: 160px; }
.kanban-col > h4, .kanban-col > .kanban-title { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 13px; font-weight: 600; }
.kanban-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.kanban-card.clickable { cursor: pointer; }
.kanban-card.clickable:hover { border-color: hsl(var(--foreground) / 0.3); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: calc(var(--radius) + 4px); font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.msg-user { align-self: flex-end; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); border-bottom-right-radius: 4px; }
.msg-ai { align-self: flex-start; background: hsl(var(--muted)); border-bottom-left-radius: 4px; }
.msg-system { align-self: center; max-width: 100%; font-size: 12px; color: hsl(var(--muted-foreground)); padding: 4px 12px; background: transparent; border: 1px dashed hsl(var(--border)); border-radius: 999px; }
.chat-input { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.chat-input .input { flex: 1; }

/* ---------- Tooltip, skeleton ---------- */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: 4px 8px; border-radius: 6px;
  font-size: 12px; font-weight: 500; line-height: 1.3; white-space: nowrap; z-index: 80; pointer-events: none; box-shadow: var(--shadow-md);
}
.skeleton { background: hsl(var(--muted)); border-radius: calc(var(--radius) - 2px); animation: proto-pulse 1.5s ease-in-out infinite; min-height: 14px; }
.skeleton-line { height: 12px; margin: 6px 0; }

/* ---------- Animations ---------- */
@keyframes proto-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes proto-pop { 0% { transform: scale(.9); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes proto-shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes proto-spin { to { transform: rotate(360deg); } }
@keyframes proto-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
@keyframes proto-slide-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes proto-scale-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.fade-in { animation: proto-fade .3s ease both; }
.pop { animation: proto-pop .4s ease; }
.shake { animation: proto-shake .4s ease; }
.spin { animation: proto-spin 1s linear infinite; }
.pulse { animation: proto-pulse 1.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--sidebar-w); z-index: 50; display: flex; flex-direction: column;
  background: hsl(var(--sidebar-background)); color: hsl(var(--sidebar-foreground)); border-right: 1px solid hsl(var(--sidebar-border));
  transition: width .2s ease, transform .2s ease;
}
.sidebar-head { height: var(--topbar-h); display: flex; align-items: center; padding: 0 16px; flex: none; border-bottom: 1px solid hsl(var(--sidebar-border)); }
.sidebar-head a { display: flex; align-items: center; }
.logo { height: 56px; width: auto; display: block; margin: -10px 0 -10px -10px; }
.logo-dark { display: none; }
.dark .logo-light { display: none; }
.dark .logo-dark { display: block; }
.logo-mark { display: none; width: 24px; height: 24px; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; }
.nav-group { margin-bottom: 8px; }
.nav-group-label { padding: 8px 8px 4px; font-size: 12px; font-weight: 500; color: hsl(var(--sidebar-foreground) / 0.6); white-space: nowrap; overflow: hidden; }
.nav-link {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; border-radius: calc(var(--radius) - 2px);
  font-size: 14px; color: hsl(var(--sidebar-foreground)); white-space: nowrap; overflow: hidden;
}
.nav-link:hover { background: hsl(var(--sidebar-accent)); text-decoration: none; }
.nav-link.active { background: hsl(var(--sidebar-accent)); font-weight: 600; color: hsl(var(--foreground)); }
.nav-link .icon { opacity: .85; }
.nav-sub { padding-left: 16px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid hsl(var(--sidebar-border)); font-size: 12px; color: hsl(var(--sidebar-foreground) / 0.6); white-space: nowrap; overflow: hidden; }
.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: 45; display: none; }
.main-wrap { margin-left: var(--sidebar-w); flex: 1; min-width: 0; height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 16px;
  border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--background) / 0.9); backdrop-filter: blur(8px); position: relative; z-index: 30;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 14px; min-width: 0; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.breadcrumb .crumb-cur { color: hsl(var(--foreground)); font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb .icon { width: 14px; height: 14px; opacity: .6; }
.top-search { position: relative; width: 240px; }
.top-search .icon { position: absolute; left: 10px; top: 9px; width: 14px; height: 14px; color: hsl(var(--muted-foreground)); pointer-events: none; }
.top-search .input { padding-left: 32px; height: 32px; box-shadow: none; }
.lang-chip { display: inline-flex; align-items: center; height: 28px; padding: 0 8px; border-radius: 6px; border: 1px solid hsl(var(--border)); font-size: 12px; font-weight: 600; color: hsl(var(--muted-foreground)); }
.persona-btn { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 4px; border-radius: 999px; border: 1px solid hsl(var(--border)); background: hsl(var(--background)); }
.persona-btn:hover { background: hsl(var(--accent)); }
.persona-btn .persona-text { display: flex; flex-direction: column; text-align: left; line-height: 1.15; }
.persona-btn .persona-name { font-size: 13px; font-weight: 600; }
.persona-btn .persona-role { font-size: 11px; color: hsl(var(--muted-foreground)); }
.menu-anchor { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 280px; z-index: 70; padding: 4px;
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow-lg);
  animation: proto-scale-in .12s ease both;
}
.menu[hidden] { display: none; }
.menu-label { padding: 6px 8px; font-size: 12px; font-weight: 600; color: hsl(var(--muted-foreground)); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; background: transparent; border-radius: calc(var(--radius) - 2px); text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: hsl(var(--accent)); outline: none; }
.menu-item .menu-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.menu-item .menu-title { font-size: 13px; font-weight: 500; }
.menu-item .menu-sub { font-size: 12px; color: hsl(var(--muted-foreground)); }
.menu-sep { height: 1px; background: hsl(var(--border)); margin: 4px -4px; }
.content { flex: 1; overflow-y: auto; min-height: 0; }
.theme-icon-moon { display: none; }
.dark .theme-icon-sun { display: none; }
.dark .theme-icon-moon { display: inline-block; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main-wrap { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .sidebar-head { padding: 0; justify-content: center; }
body.sidebar-collapsed .sidebar-head .logo { display: none; }
body.sidebar-collapsed .logo-mark { display: block; }
body.sidebar-collapsed .nav-label, body.sidebar-collapsed .sidebar-foot { display: none; }
body.sidebar-collapsed .nav-group-label { height: 1px; padding: 0; margin: 8px 8px; background: hsl(var(--sidebar-border)); font-size: 0; }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-sub { padding-left: 0; }

@media (max-width: 1023px) { .top-search { display: none; } .persona-btn .persona-text { display: none; } .persona-btn { padding-right: 4px; } }
@media (max-width: 767px) {
  .sidebar, body.sidebar-collapsed .sidebar { width: var(--sidebar-w); transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.sidebar-open .backdrop { display: block; }
  .main-wrap, body.sidebar-collapsed .main-wrap { margin-left: 0; }
  body.sidebar-collapsed .logo-mark { display: none; }
  body.sidebar-collapsed .sidebar-head .logo { display: block; }
  body.sidebar-collapsed .sidebar-head .logo-dark { display: none; }
  body.dark.sidebar-collapsed .sidebar-head .logo-light { display: none; }
  body.dark.sidebar-collapsed .sidebar-head .logo-dark { display: block; }
  body.sidebar-collapsed .sidebar-head { padding: 0 16px; justify-content: flex-start; }
  body.sidebar-collapsed .nav-label { display: inline; }
  body.sidebar-collapsed .sidebar-foot { display: block; }
  body.sidebar-collapsed .nav-group-label { height: auto; padding: 8px 8px 4px; margin: 0; background: none; font-size: 12px; }
  body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 0 8px; }
  .topbar { padding: 0 12px; }
  .lang-chip { display: none; }
  .proto-badge { display: none; }
}

/* ---------- Toasts and modal ---------- */
.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: calc(var(--radius) + 2px);
  background: hsl(var(--card)); border: 1px solid hsl(var(--border)); box-shadow: var(--shadow-lg); font-size: 13px; animation: proto-slide-in .2s ease both;
}
.toast .icon { margin-top: 1px; }
.toast .toast-msg { flex: 1; }
.toast-success { border-color: hsl(var(--success) / 0.5); } .toast-success > .icon { color: hsl(var(--success)); }
.toast-warning { border-color: hsl(var(--warning) / 0.5); } .toast-warning > .icon { color: hsl(var(--warning)); }
.toast-destructive { border-color: hsl(var(--destructive) / 0.5); } .toast-destructive > .icon { color: hsl(var(--destructive)); }
.toast.leaving { opacity: 0; transform: translateX(16px); transition: opacity .2s, transform .2s; }
.modal-overlay { position: fixed; inset: 0; z-index: 90; background: rgb(0 0 0 / 0.55); display: flex; align-items: center; justify-content: center; padding: 16px; animation: proto-fade .15s ease both; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); border-radius: calc(var(--radius) + 4px); box-shadow: var(--shadow-lg); animation: proto-scale-in .15s ease both; }
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 24px 0; }
.modal-head h2 { flex: 1; font-size: 18px; }
.modal-body { padding: 12px 24px 20px; overflow-y: auto; font-size: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 24px 20px; flex-wrap: wrap; }

/* ---------- Charts ---------- */
.chart-svg { display: block; margin: 0 auto; max-width: 100%; height: auto; overflow: visible; }
.chart-grid { fill: none; stroke: hsl(var(--border)); stroke-width: 1; }
.chart-axis { stroke: hsl(var(--border)); stroke-width: 1; }
.chart-label { fill: hsl(var(--muted-foreground)); font-size: 11px; font-family: inherit; }
.chart-value { fill: hsl(var(--foreground)); font-weight: 700; font-family: inherit; }
.chart-ring-track { fill: none; stroke: hsl(var(--secondary)); }
.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.chart-bar-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 12px; font-size: 13px; }
.chart-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track { height: 8px; border-radius: 999px; background: hsl(var(--secondary)); overflow: hidden; }
.chart-bar-fill { display: block; height: 100%; border-radius: 999px; transition: width .5s ease; }
.chart-bar-value { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 36px; text-align: right; }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 8px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- Prototype-only helpers ---------- */
.proto-badge { text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }
.notfound { max-width: 480px; margin: 64px auto; text-align: center; }

/* ---------- Home screen ---------- */
.home-hero { padding: 40px 32px; border-radius: calc(var(--radius) + 4px); border: 1px solid hsl(var(--border)); background: linear-gradient(135deg, hsl(var(--muted)) 0%, hsl(var(--background)) 70%); }
.home-hero h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; max-width: 720px; }
.home-hero p { max-width: 640px; margin-top: 12px; font-size: 15px; color: hsl(var(--muted-foreground)); }
.home-chain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 24px; }
.home-chain-step { display: inline-flex; flex-direction: column; padding: 10px 14px; border-radius: var(--radius); border: 1px solid hsl(var(--border)); background: hsl(var(--background)); box-shadow: var(--shadow-sm); min-width: 150px; }
.home-chain-step strong { font-size: 14px; }
.home-chain-step span { font-size: 12px; color: hsl(var(--muted-foreground)); }
.home-chain > .icon { color: hsl(var(--muted-foreground)); }
.home-pillar-icon { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: var(--radius); background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); margin-bottom: 8px; }
.home-pillar ul { list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.home-pillar li { display: flex; gap: 8px; align-items: flex-start; }
.home-pillar li .icon { color: hsl(var(--success)); margin-top: 3px; width: 14px; height: 14px; }
.home-demo-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 12px; font-weight: 600; flex: none; }
.home-demo-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.home-demo-text strong { font-size: 14px; font-weight: 500; }
.home-demo-text span { font-size: 12px; color: hsl(var(--muted-foreground)); }
.home-principle { display: flex; gap: 12px; align-items: flex-start; }
.home-principle .icon { margin-top: 2px; }
@media (max-width: 767px) { .home-hero { padding: 24px 16px; } .home-hero h1 { font-size: 24px; } .home-chain > .icon { transform: rotate(90deg); } }
