/* The component drawer is a visual index: dense enough for comparison, calm enough for inspection. */
.component-stories { width:calc(100vw - 24px); height:calc(100dvh - 24px); max-width:1720px; max-height:none; padding:0; overflow:hidden; border:1px solid #2b4565; border-radius:18px; color:var(--ink); background:#06101d; box-shadow:0 32px 100px #000c; }
.component-stories[open] { display:flex; flex-direction:column; }
.component-stories::backdrop { background:#010610dc; backdrop-filter:blur(8px); }
.story-heading { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:18px 22px 16px; border-bottom:1px solid #203650; background:#071322; }
.story-heading h2 { margin:0 0 2px; font-size:clamp(1.35rem,2.4vw,2rem); font-weight:650; letter-spacing:-.035em; }
.story-heading p { margin:0; color:var(--ink-faint); font-size:.92rem; }
.component-stories button { min-height:40px; padding:8px 13px; border:1px solid var(--line); border-radius:8px; background:#0a1727; color:var(--ink); cursor:pointer; }
.component-stories button:hover:not(:disabled) { border-color:#6288b5; background:#10233a; }
.component-stories button:disabled { opacity:.55; cursor:default; }
.component-stories :focus-visible { outline:3px solid #7de4ff; outline-offset:2px; }
.story-close { flex:none; min-width:76px; }
.story-toolbar { padding:12px 14px 10px; border-bottom:1px solid #172b42; background:#081421; }
.story-search { display:grid; grid-template-columns:22px minmax(0,1fr) auto; align-items:center; gap:9px; min-height:46px; padding:0 12px; border:1px solid #2d435d; border-radius:9px; background:#0b1724; }
.story-search:focus-within { border-color:#62d9ff; box-shadow:0 0 0 1px #62d9ff; }
.story-search svg { width:20px; fill:none; stroke:#8fa3bb; stroke-width:1.8; stroke-linecap:round; }
.story-search input { width:100%; min-width:0; padding:10px 0; border:0; outline:0; background:transparent; color:var(--ink); font:inherit; }
.story-search kbd { padding:2px 7px; border:1px solid #314861; border-radius:5px; color:#94a8bf; background:#0d1b2b; font:500 .75rem/1.5 var(--sans); }
.story-filters { display:flex; align-items:end; gap:8px; margin-top:10px; }
.story-filters label { position:relative; display:block; }
.story-filters label > span { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.story-filters select { min-height:38px; max-width:190px; padding:7px 32px 7px 11px; border:1px solid #2b4059; border-radius:8px; background:#0c1928; color:#dce7f5; font:500 .82rem/1.3 var(--sans); }
.story-filters .story-sort { margin-left:auto; }
.story-load-status { margin:0; padding:7px 15px; border-bottom:1px solid #172b42; color:#9db0c7; background:#07111e; font-size:.8rem; line-height:1.4; }
.story-catalog-layout { display:grid; grid-template-columns:minmax(350px,.82fr) minmax(650px,1.62fr); min-height:0; flex:1; }
.story-browser { min-width:0; min-height:0; overflow:auto; padding:12px; border-right:1px solid #203650; scrollbar-color:#3b526d transparent; }
.story-card-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(118px,1fr)); gap:9px; align-content:start; }
.story-component-card { position:relative; display:block; width:100%; min-height:0!important; padding:0!important; overflow:hidden; border-color:#172a40!important; border-radius:10px!important; text-align:left; background:#0b1725!important; }
.story-component-card:hover { transform:translateY(-1px); border-color:#4c6b8e!important; }
.story-component-card[aria-pressed="true"] { border-color:#3d8cff!important; box-shadow:inset 0 0 0 1px #3d8cff,0 0 20px #1b69ff24; background:#0d1c2d!important; }
.story-thumb { position:relative; aspect-ratio:4/3; display:grid; place-items:center; overflow:hidden; background:radial-gradient(circle at 50% 42%,#263447 0,#101a27 55%,#09121e 100%); }
.story-thumb::before { content:""; width:32%; aspect-ratio:1; border:2px solid #263c54; border-radius:50%; }
.story-thumb img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.story-component-card strong,.story-component-card small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.story-card-copy { padding:9px 10px 10px; }
.story-component-card strong { color:#edf4fd; font-size:.78rem; line-height:1.35; }
.story-component-card small { margin-top:2px; color:#8499b1; font-size:.68rem; line-height:1.35; }
.story-card-status { position:absolute; top:7px; right:7px; width:8px; height:8px; border-radius:50%; background:#5ee3c0; box-shadow:0 0 0 3px #06101d99; }
.story-card-status.partial { background:#ffd184; }
.story-empty { max-width:360px; margin:48px auto; text-align:center; }
.story-empty h3 { font-size:1.2rem; }.story-empty p { color:var(--ink-faint); }
.story-inspector { min-width:0; min-height:0; display:flex; flex-direction:column; background:#07121f; }
.story-component-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; min-height:70px; padding:13px 16px; border-bottom:1px solid #203650; }
.story-component-heading h3 { font-size:1.35rem; letter-spacing:-.025em; }
.story-component-heading p { margin:3px 0 0; color:#9db0c8; font-size:.8rem; }
.story-copy { flex:none; }
.story-inspector-layout { display:grid; grid-template-columns:minmax(360px,1.25fr) minmax(290px,.85fr); min-height:0; flex:1; }
.story-visual-column { min-width:0; min-height:0; display:flex; flex-direction:column; padding:10px; border-right:1px solid #203650; }
.story-stage { position:relative; min-height:260px; flex:1; overflow:hidden; border:1px solid #16283d; border-radius:10px; background:radial-gradient(ellipse at 52% 44%,#1a2a3c 0,#0a121d 67%); }
.story-stage canvas { display:block; width:100%; height:100%; min-height:260px; }
.story-fallback { position:absolute; inset:0; display:grid; place-items:center; margin:0; padding:30px; color:var(--ink-soft); text-align:center; }
.story-view-strip { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; margin-top:8px; }
.story-view-strip button { min-width:0; font-size:.78rem; }
.story-view-strip button[aria-pressed="true"],.story-model-controls button[aria-pressed="true"] { border-color:#3c8eff; background:#122c4d; box-shadow:inset 0 0 0 1px #3c8eff; }
.story-model-controls { display:flex; align-items:center; gap:10px; min-height:54px; margin-top:8px; padding:7px 10px; border:1px solid #1d3149; border-radius:9px; background:#091625; }
.story-model-controls > span { color:#c6d3e3; font-size:.78rem; }
.story-model-controls > div { display:flex; gap:4px; }
.story-model-controls button { min-width:36px; min-height:34px; padding:4px 9px; }
.story-model-controls p { margin:0 0 0 auto; color:#8298b2; font-size:.7rem; text-align:right; }
.story-detail-column { min-width:0; min-height:0; display:flex; flex-direction:column; }
.story-tabs { display:flex; overflow-x:auto; overflow-y:hidden; padding:8px 10px 0; border-bottom:1px solid #203650; scrollbar-width:thin; scrollbar-color:#3b526d transparent; }
/* Labels stay whole: buttons keep their text width and the row scrolls when it cannot fit them. */
.story-tabs button { flex:0 0 auto; min-height:38px; padding:7px 10px; border:0; border-bottom:2px solid transparent; border-radius:6px 6px 0 0; color:#91a5bd; background:transparent; font-size:.76rem; white-space:nowrap; overflow-wrap:normal; }
.story-tabs button[aria-selected="true"] { border-bottom-color:#54d9ff; color:#eef6ff; background:#102138; }
@media (min-width:1201px) and (max-width:1440px) { .story-tabs { padding-inline:6px; } .story-tabs button { padding-inline:7px; } }
.story-details { min-height:0; overflow:auto; overscroll-behavior:contain; overflow-wrap:anywhere; padding:16px; scrollbar-color:#3b526d transparent; }
.story-details h4 { margin:0 0 12px; font-size:.92rem; }
.story-details p,.story-details li { color:#b5c5d8; font-size:.79rem; line-height:1.55; }
.story-details ul { padding-left:18px; }
.story-details dl { display:grid; gap:0; margin:0; }
.story-details dl > div { display:grid; grid-template-columns:minmax(95px,.75fr) minmax(0,1fr); gap:12px; padding:7px 0; border-bottom:1px solid #172a40; }
.story-details dt { color:#849ab3; font-size:.75rem; }.story-details dd { margin:0; color:#e2eaf5; font-size:.77rem; }
.story-details table { width:100%; border-collapse:collapse; font-size:.72rem; }
.story-details th,.story-details td { padding:7px 5px; border-bottom:1px solid #1d3046; text-align:left; vertical-align:top; }
.story-details th { color:#8197b1; font-weight:600; }.story-details td { color:#d5e1ef; }
.story-details details { margin-top:14px; color:#9eb2ca; font-size:.76rem; }
.story-details summary { color:#a9dfff; cursor:pointer; }
.story-source-badge { display:inline-flex; align-items:center; gap:7px; margin:0 0 14px!important; padding:6px 9px; border:1px solid #2b644f; border-radius:7px; color:#7de9c6!important; background:#0a2a25; }
.story-source-badge.partial { border-color:#705c32; color:#ffd184!important; background:#2c2416; }
.story-source-badge::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }
.story-caveat { margin-top:15px!important; padding:10px; border:1px solid #2b4059; border-radius:8px; background:#0a1727; }
.story-dimension-list dd { font-variant-numeric:tabular-nums; }
.sr-only { position:absolute!important; width:1px!important; height:1px!important; padding:0!important; margin:-1px!important; overflow:hidden!important; clip:rect(0,0,0,0)!important; white-space:nowrap!important; border:0!important; }
@media(max-width:1200px) {
    .story-catalog-layout { grid-template-columns:minmax(315px,.72fr) minmax(540px,1.28fr); }
    .story-inspector-layout { grid-template-columns:1fr; overflow:auto; }
    .story-visual-column { min-height:460px; border-right:0; border-bottom:1px solid #203650; }
    .story-detail-column { min-height:360px; }
}
@media(max-width:820px) {
    .component-stories { width:100vw; height:100dvh; border:0; border-radius:0; }
    .story-heading { padding:13px 14px; }.story-heading p { display:none; }
    .story-toolbar { padding:10px; }.story-search kbd { display:none; }
    .story-filters { overflow-x:auto; padding-bottom:3px; }.story-filters .story-sort { margin-left:0; }
    .story-filters select { max-width:155px; }
    .story-catalog-layout { display:block; overflow:auto; }
    .story-browser { max-height:45dvh; overflow:auto; border-right:0; border-bottom:1px solid #203650; }
    .story-card-grid { grid-template-columns:repeat(auto-fill,minmax(118px,1fr)); }
    .story-inspector { min-height:720px; }.story-inspector-layout { overflow:visible; }
    .story-stage canvas { min-height:310px; }.story-visual-column { min-height:500px; }
}
@media(max-width:520px) {
    .story-heading h2 { font-size:1.2rem; }.story-close { min-width:64px; }
    .story-component-heading { align-items:flex-start; }.story-component-heading h3 { font-size:1.12rem; }
    .story-view-strip button { padding:7px 3px; font-size:.7rem; }
    .story-model-controls p { display:none; }
}
@media(prefers-reduced-motion:reduce) { .component-stories * { scroll-behavior:auto; transition:none; animation:none; } }

.component-sandbox { width: min(1280px,96vw); max-width: none; max-height: 95dvh; padding: 22px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--paper); }
.component-sandbox::backdrop { background: rgb(20 44 58 / 65%); }
.component-sandbox button { min-height: 44px; padding: 8px 12px; background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.component-sandbox button:disabled { opacity: .55; cursor: default; }
.component-sandbox :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sandbox-warning { padding: 12px; background: var(--warn-surface); color: var(--warn); line-height: 1.5; }
.sandbox-layout { display: grid; grid-template-columns: 180px minmax(300px,1.25fr) minmax(240px,1fr); gap: 20px; }
.sandbox-layout > * { min-width: 0; }
.sandbox-layout h3 { margin: 6px 0 10px; }
.sandbox-layout p { color: var(--ink-soft); font-size: 1rem; line-height: 1.5; }
.sandbox-inventory { max-height: 440px; overflow: auto; display: grid; grid-template-columns: minmax(0,1fr); gap: 6px; }
.sandbox-inventory button { min-width: 0; width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; touch-action: none; }
.sandbox-layout svg { display: block; width: 100%; aspect-ratio: 80 / 55; border: 2px solid var(--line-bright); touch-action: none; }
.sandbox-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sandbox-controls input { width: 75px; padding: 8px; font: inherit; }
.sandbox-controls select { padding: 8px; font: inherit; }
.sandbox-placed { max-height: 170px; overflow: auto; }
.sandbox-placed > div { display: flex; gap: 6px; margin-bottom: 6px; }
.sandbox-canvas { position: relative; border-radius: 10px; overflow: hidden; background: var(--panel-2); }
.sandbox-canvas canvas { width: 100%; height: 310px; display: block; }
.component-sandbox .story-navigation { flex-wrap: wrap; bottom: -22px; }
@media (max-width: 900px) {
    .sandbox-layout { grid-template-columns: 150px minmax(0,1fr); }
    .sandbox-preview { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    .component-sandbox { width: 100vw; padding: 14px; max-height: 100dvh; border-radius: 0; }
    .sandbox-layout { display: block; }
    .sandbox-inventory { max-height: 145px; grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
    .sandbox-canvas canvas { height: 230px; }
    .component-sandbox .story-navigation { position: static; }
}

.behavior-reference { font-weight:600; color:#edf6ff!important; }
.behavior-badges { display:flex; flex-wrap:wrap; gap:6px; margin:10px 0; }
.behavior-badges span { padding:5px 8px; border:1px solid #36516d; border-radius:6px; color:#cde4fa; font-size:.72rem; }
.behavior-blocked { margin:12px 0; padding:12px; background:#2a2115; border:1px solid #705c32; border-radius:8px; color:#ffdc9e; }
#component-stories .story-details button.behavior-run { min-height:44px; padding:10px 14px; color:#04182a; background:#7dd9ff; border:1px solid #a1e5ff; border-radius:7px; font-weight:650; cursor:pointer; }
#component-stories .story-details button.behavior-run:disabled { background:#15263a; color:#93a7bb; border-color:#32475c; cursor:default; }
.story-tabs { flex-shrink:0; }
.behavior-run-status { margin-top:10px!important; color:#d9edff!important; }
.behavior-result { padding-top:10px; border-top:1px solid #36516d; overflow-wrap:anywhere; }
.behavior-result.has-violation { border-color:#ee907b; }
.behavior-result.has-violation h4 { color:#ffac97; }
.behavior-result h5 { font-size:.78rem; margin:16px 0 7px; color:#dceeff; }
.behavior-result pre { white-space:pre-wrap; overflow-wrap:anywhere; font-size:.65rem; }
.behavior-result li { margin-bottom:8px; }
.behavior-traces figure { margin:12px 0; padding:8px; border:1px solid #294663; border-radius:6px; }
.behavior-traces figcaption { font-size:.7rem; color:#b9d6f0; }
.behavior-traces svg { width:100%; color:#75d9ff; background:#06101b; }
.story-card-sim { display:inline-block; margin-top:4px; padding:1px 7px; border-radius:999px; font-size:11px; font-weight:600; color:#06101d; background:#5ee3c0; }
.story-card-sim-reference { color:#e8eef7; background:#3a4f6e; }
.story-behavior-line { margin:12px 0 0; padding:9px 12px; border-radius:8px; border:1px solid #2a3b55; background:#0d1a2c; }
.story-behavior-line.simulated { border-color:#2f7d68; background:#0c2420; }
