/* ============================================================
   Toolbox workspace.
   Full-bleed work area per the UX kit: fixed tool rail, 1px
   structural borders, 0px corners, mono caps labels — on the
   site's own palette so light/dark keep working.
   On wide screens the shell owns the viewport and the panels
   scroll internally; below 900px it falls back to page flow.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@400;600;800&family=Archivo+Narrow:wght@600;700&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
    --lab-gap: 1px;          /* gutter is a hairline, not whitespace */
    --lab-radius: 0;
    --ws-icons: 76px;
    --ws-rail: 178px;
    --ws-nav: 56px;
    --ws-bar: 30px;
}

/* ============================================================
   The workspace runs on the UX kit's own palette and type —
   Electric Indigo, Hanken Grotesk / Archivo Narrow / Geist Mono.
   Scoped to the tools pages so home and blog keep their teal.
   ============================================================ */
body[data-page="tools"] {
    --color-bg:        #0b0f10;
    --color-bg2:       #101415;
    --color-surface:   #191c1e;
    --color-border:    #2f3336;
    --color-text:      #e0e3e5;
    --color-muted:     #8b8794;
    --color-heading:   #ffffff;
    --color-accent:    #d2bbff;   /* light lavender: text, borders, indicators */
    --ux-solid:        #7c3aed;   /* electric indigo: filled actions */
    --ux-on-solid:     #ffffff;
    --ux-ok:           #34d399;
    --ux-warn:         #f59e0b;
    --ux-err:          #ff6b6b;

    --font-sans:  'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    --font-mono:  'Geist Mono', 'JetBrains Mono', 'Fira Code', monospace;
    --font-label: 'Archivo Narrow', 'Hanken Grotesk', sans-serif;

    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
}

/* The kit is dark-first; this keeps the theme toggle honest. */
[data-theme="light"] body[data-page="tools"] {
    --color-bg:        #f6f4fb;
    --color-bg2:       #ffffff;
    --color-surface:   #efeaf8;
    --color-border:    #d8d0e6;
    --color-text:      #241f2e;
    --color-muted:     #6b6478;
    --color-heading:   #14101c;
    --color-accent:    #6d28d9;
    --ux-solid:        #7c3aed;
    --ux-on-solid:     #ffffff;
    --ux-ok:           #047857;
    --ux-warn:         #b45309;
    --ux-err:          #b91c1c;
}

/* Machine labels use the condensed face, always caps. */
body[data-page="tools"] .mod__title,
body[data-page="tools"] .ws__rail-cat,
body[data-page="tools"] .ws__dock-tab,
body[data-page="tools"] .lab__stat dt,
body[data-page="tools"] .lab__opt label,
body[data-page="tools"] .ws__icon-label {
    font-family: var(--font-label);
    font-weight: 700;
}

body[data-page="tools"] { min-height: 100vh; }

.ws {
    display: grid;
    grid-template-columns: var(--ws-icons) var(--ws-rail) 1fr;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg);
}

/* ===== Category icon rail ===== */
.ws__icons {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--color-border);
    background: var(--color-bg2);
}

.ws__icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.85rem 0.3rem;
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: none;
    color: var(--color-muted);
    text-decoration: none !important;
    transition: background var(--transition), color var(--transition);
}
.ws__icon:hover { background: var(--color-surface); color: var(--color-text); }

/* Active category is a solid indigo block, per the kit's nav spec. */
.ws__icon.is-active {
    background: var(--ux-solid);
    color: var(--ux-on-solid);
}

.ws__icon-glyph {
    width: 20px;
    height: 20px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

.ws__icon-label {
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    line-height: 1;
}

.ws__icon-chip {
    font-family: var(--font-mono);
    font-size: 0.48rem;
    letter-spacing: 0.06em;
    color: var(--ux-warn);
}
.ws__icon.is-active .ws__icon-chip { color: var(--ux-on-solid); opacity: 0.75; }

.ws__icons-spacer { flex: 1; border-bottom: 1px solid var(--color-border); }
.ws__icons .ws__icon--foot { border-bottom: none; border-top: 1px solid var(--color-border); }

/* ===== Tool rail ===== */
.ws__rail {
    border-right: 1px solid var(--color-border);
    background: var(--color-bg2);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ws__rail-cat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin: 0;
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--color-accent);
}

.ws__rail-count {
    font-size: 0.62rem;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    padding: 0 0.35rem;
}

.ws__rail-list {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.ws__tool {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid var(--color-border);
    border-left: 3px solid transparent;
    border-radius: var(--lab-radius);
    padding: 0.7rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    cursor: pointer;
    text-align: left;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.ws__tool:hover { color: var(--color-text); background: var(--color-surface); }

.ws__tool.is-active {
    color: var(--color-accent);
    background: var(--color-bg);
    border-left-color: var(--color-accent);
}

.ws__tool-idx {
    font-size: 0.62rem;
    color: var(--color-muted);
    opacity: 0.7;
    flex-shrink: 0;
}
.ws__tool.is-active .ws__tool-idx { color: var(--color-accent); opacity: 1; }

.ws__tool-name { overflow: hidden; text-overflow: ellipsis; }

.ws__rail-empty {
    flex: 1;
    padding: 1.25rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1.6;
    color: var(--color-muted);
}

.ws__rail-foot {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.6rem 0.9rem;
    border-top: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    line-height: 1.4;
    color: var(--color-muted);
}

.ws__shield {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23d2bbff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
}
[data-theme="light"] .ws__shield {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236d28d9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z'/%3E%3C/svg%3E");
}

/* ===== Work area ===== */
.ws__main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.9rem;
    gap: 0.9rem;
}

.ws__head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.ws__title {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--color-heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.ws__title::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--color-accent);
}

.ws__desc {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--color-muted);
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.ws__warn {
    margin: 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-left: 2px solid var(--ux-warn);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    line-height: 1.55;
    color: var(--color-muted);
    background: var(--color-bg2);
    flex-shrink: 0;
}
.ws__warn[hidden] { display: none; }

/* ===== Grid ===== */
.ws__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    align-items: stretch;
    flex: 1;
    min-height: 0;
}

/* Generators (uuid, lorem) take no input, so the empty textarea would
   just be dead space — give the room to the output instead. */
.ws__grid.is-generator { grid-template-columns: minmax(260px, 340px) 1fr; }
.ws__grid.is-generator .mod__body--input { display: none; }
.ws__grid.is-generator .lab__opts { flex: 1; }
/* Three mode blocks won't fit side by side in the narrow column. */
.ws__grid.is-generator .mod__modes { flex-direction: column; }

/* ===== Bottom dock ===== */
.ws__dock { flex-shrink: 0; }

.ws__dock-tabs { display: flex; gap: 1px; }

.ws__dock-tab {
    background: none;
    border: none;
    border-radius: var(--lab-radius);
    padding: 0.2rem 0.6rem 0.2rem 0;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-muted);
    cursor: pointer;
    transition: color var(--transition);
}
.ws__dock-tab:hover { color: var(--color-text); }
.ws__dock-tab.is-active { color: var(--color-heading); }
.ws__dock-tab.is-active::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    background: var(--color-accent);
    margin-right: 0.5rem;
}

.ws__dock-body {
    height: 168px;
    overflow: auto;
}
.ws__dock-body[hidden] { display: none; }

.ws__dock.is-collapsed .ws__dock-body { display: none; }
.ws__dock.is-collapsed .lab__icon[data-icon="chevron"] { transform: rotate(180deg); }

.ws__params { padding: 0.9rem; font-size: 0.85rem; color: var(--color-muted); }
.ws__params > p:first-child { margin-top: 0; }

/* ===== Empty category ===== */
.ws__empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
}

.ws__empty-box {
    border: 1px solid var(--color-border);
    background: var(--color-bg2);
    padding: 2rem;
    max-width: 460px;
    text-align: center;
}

.ws__empty-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.16em;
    color: var(--ux-warn);
    margin-bottom: 1rem;
}

.ws__dog {
    display: block;
    width: 150px;
    height: auto;
    margin: 0.25rem auto 1rem;
    color: var(--color-muted);
}
.ws__dog-q { color: var(--color-accent); stroke: currentColor; }

@media (prefers-reduced-motion: no-preference) {
    .ws__dog-q { animation: ws-dog-wonder 2.6s ease-in-out infinite; transform-origin: center; }
}
@keyframes ws-dog-wonder {
    0%, 100% { opacity: 0.35; transform: translateY(2px); }
    50%      { opacity: 1;    transform: translateY(-3px); }
}

.ws__dog-line {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    color: var(--color-text);
    margin-bottom: 0.75rem;
}

.ws__empty-text { color: var(--color-muted); font-size: 0.92rem; margin-bottom: 1.5rem; }

.ws__empty-cta { display: inline-flex; text-decoration: none !important; }
.ws__empty-cta::after { display: none; }   /* no lightning bolt on a plain link */

/* ===== Status bar ===== */
.ws__statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--ws-bar);
    padding: 0 1rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-bg2);
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    white-space: nowrap;
    overflow: hidden;
}

.ws__statusbar-mid { color: var(--color-heading); }

.ws__statusbar-ok { display: flex; align-items: center; gap: 0.4rem; color: var(--ux-ok); }
.ws__statusbar-ok::before { content: ''; width: 6px; height: 6px; background: var(--ux-ok); }

.ws__statusbar-wip { color: var(--ux-warn); }

/* Desktop: the shell owns the viewport, panels scroll inside. */
@media (min-width: 900px) {
    body[data-page="tools"] { height: 100vh; overflow: hidden; }
    .ws { height: calc(100vh - var(--ws-nav) - var(--ws-bar)); }
    .ws__main { overflow: hidden; }
}

/* On short screens the dock would eat most of the work area. */
@media (min-width: 900px) and (max-height: 820px) {
    .ws__dock-body { height: 120px; }
}

/* ===== Module ===== */
.mod {
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    background: var(--color-bg2);
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.mod__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
}

.mod__title {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-heading);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.mod__title::before {
    content: '';
    width: 7px;
    height: 7px;
    background: var(--color-accent);
    flex-shrink: 0;
}

.mod__meta {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    white-space: nowrap;
}

.mod__act {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    padding: 0.25rem 0.6rem;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}
.mod__act:hover { border-color: var(--color-accent); color: var(--color-accent); }

.mod__head-right {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* Flex body + auto-height fields so the two columns stay the same height
   even though only the output panel carries a stats strip. */
.mod__body { display: flex; padding: 0.9rem; flex: 1; min-height: 0; }
.mod__body--flush { display: block; padding: 0; overflow-x: auto; }

.mod__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.9rem;
    border-top: 1px solid var(--color-border);
    min-height: 48px;
}

/* ===== Mode switch ===== */
.mod__modes {
    display: flex;
    gap: var(--lab-gap);
    background: var(--color-border);
    border-bottom: 1px solid var(--color-border);
}
.mod__modes:empty { display: none; }

/* Mock spec: full-width mode blocks, active one filled with lavender. */
.lab__mode {
    flex: 1;
    background: var(--color-bg2);
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    padding: 0.8rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.lab__mode:hover { color: var(--color-text); border-color: var(--color-accent); }
.lab__mode.is-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #1a1030;
    font-weight: 600;
}
[data-theme="light"] .lab__mode.is-active { color: #ffffff; }

/* ===== Textarea / output ===== */
.lab__ta,
.lab__out {
    width: 100%;
    flex: 1;
    /* min-height:0 lets the field shrink to the shell inside a flex column;
       the 900px breakpoint puts a real floor back for page-flow mode. */
    min-height: 0;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    padding: 0.85rem 0.9rem;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.65;
    color: var(--color-text);
    resize: vertical;
    overflow: auto;
    tab-size: 2;
}

.lab__ta::placeholder { color: var(--color-muted); opacity: 0.7; }

/* No blur — a 1px inner ring, per the kit's "no shadows" rule. */
.lab__ta:focus,
.lab__out:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: inset 0 0 0 1px var(--color-accent);
}

.lab__ta:disabled {
    color: var(--color-muted);
    cursor: not-allowed;
}

.lab__out {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    resize: none;
}
.lab__out.is-empty { color: var(--color-muted); opacity: 0.7; }
.lab__out.is-error { color: var(--ux-err); border-color: var(--ux-err); }

/* Inline highlights inside decoded JWT / JSON output */
.lab__out .k  { color: var(--color-accent); }
.lab__out .hl { color: var(--color-heading); font-weight: 600; }
.lab__out .dim { color: var(--color-muted); }

.lab__icon {
    width: 24px;
    height: 24px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    cursor: pointer;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 13px 13px;
    opacity: 0.65;
    transition: opacity var(--transition), border-color var(--transition);
}
.lab__icon:hover { opacity: 1; border-color: var(--color-accent); }

.lab__icon[data-icon="trash"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18M8 6V4h8v2M19 6l-1 14H6L5 6'/%3E%3C/svg%3E");
}
.lab__icon[data-icon="chevron"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
.lab__icon[data-icon="link"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.5.5l3-3a5 5 0 0 0-7-7l-1.7 1.7'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.5-.5l-3 3a5 5 0 0 0 7 7l1.7-1.7'/%3E%3C/svg%3E");
}
.lab__icon[data-icon="paste"] {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='8' y='2' width='8' height='4'/%3E%3Cpath d='M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2'/%3E%3C/svg%3E");
}

/* ===== Options row ===== */
.lab__opts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.lab__opt {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.lab__opt label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    text-transform: uppercase;
}

.lab__opt select,
.lab__opt input {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    padding: 0.25rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--color-text);
    cursor: pointer;
}
.lab__opt select:focus,
.lab__opt input:focus { outline: none; border-color: var(--color-accent); }
.lab__opt input { width: 68px; cursor: text; }

/* ===== Execute ===== */
/* The one solid Electric Indigo action on the page. */
.lab__exec {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--ux-solid);
    color: var(--ux-on-solid);
    border: 1px solid var(--ux-solid);
    border-radius: var(--lab-radius);
    padding: 0.7rem 1.6rem;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}
.lab__exec::after {
    content: '';
    width: 12px;
    height: 12px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M13 2L4.09 12.97h6.14L11 22l8.91-10.97h-6.14z'/%3E%3C/svg%3E");
}
.lab__exec:hover { background: transparent; color: var(--color-accent); }

/* ===== Stats strip ===== */
.lab__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: var(--lab-gap);
    background: var(--color-border);
}
.lab__stats:empty { display: none; }
.lab__stats + .mod__body { border-top: 1px solid var(--color-border); }

.lab__stat {
    background: var(--color-bg2);
    padding: 0.55rem 0.9rem;
    min-width: 0;
}

.lab__stat dt {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    text-transform: uppercase;
    margin-bottom: 0.15rem;
}

.lab__stat dd {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-heading);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lab__stat dd.is-good { color: var(--ux-ok); }
.lab__stat dd.is-bad  { color: var(--ux-err); }

/* ===== Status line ===== */
.lab__status {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--color-muted);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}
.lab__status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--color-muted);
    flex-shrink: 0;
}
.lab__status[data-state="ok"]    { color: var(--ux-ok); }
.lab__status[data-state="ok"]::before    { background: var(--ux-ok); }
.lab__status[data-state="error"] { color: var(--ux-err); }
.lab__status[data-state="error"]::before { background: var(--ux-err); }

/* ===== History table ===== */
.lab__log { margin-top: 1.25rem; }

.lab__table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.lab__table th {
    text-align: left;
    font-weight: 500;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    color: var(--color-muted);
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.lab__table td {
    padding: 0.6rem 0.9rem;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    vertical-align: middle;
}
.lab__table tr:last-child td { border-bottom: none; }

.lab__table .col-src {
    max-width: 1px;      /* let the ellipsis do the work in a table layout */
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-muted);
}

.lab__chip {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    border: 1px solid var(--color-border);
    color: var(--color-accent);
    white-space: nowrap;
}

.lab__table .st-ok  { color: var(--ux-ok); }
.lab__table .st-err { color: var(--ux-err); }

.lab__restore {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--lab-radius);
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color var(--transition), color var(--transition);
}
.lab__restore:hover { border-color: var(--color-accent); color: var(--color-accent); }

.lab__empty {
    padding: 1.5rem 0.9rem;
    color: var(--color-muted);
    font-family: var(--font-mono);
    font-size: 0.74rem;
}

.lab__log-note {
    padding: 0.6rem 0.9rem;
    margin: 0;
    border-top: 1px solid var(--color-border);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    color: var(--color-muted);
}

/* ===== URL parameter reference (dock tab) ===== */
.lab__help-code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 0.6rem 0.75rem;
    margin: 0.75rem 0;
    overflow-x: auto;
    color: var(--color-text);
    word-break: break-all;
    white-space: pre-wrap;
}

.lab__help-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.lab__help-table td { padding: 0.4rem 0; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.lab__help-table td:first-child { width: 34%; padding-right: 1rem; }
.lab__help-table tr:last-child td { border-bottom: none; }
.lab__help-table code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-accent);
    white-space: nowrap;
}

.lab__help-note { margin: 0.75rem 0 0; font-size: 0.78rem; }

@media (max-width: 640px) {
    .lab__help-table td:first-child { width: 40%; }
}

.lab__sr {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ===== Responsive =====
   Below 900px the app shell would trap content in unusable slivers,
   so the rail moves on top and the page scrolls normally again. */
@media (max-width: 900px) {
    .ws { grid-template-columns: 1fr; }

    /* Category rail becomes a horizontal strip above the tool list. */
    .ws__icons {
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .ws__icon {
        flex: 1;
        flex-direction: row;
        gap: 0.4rem;
        border-bottom: none;
        border-right: 1px solid var(--color-border);
        padding: 0.6rem 0.3rem;
    }
    .ws__icons-spacer { display: none; }
    .ws__icons .ws__icon--foot { border-top: none; border-right: none; }

    .ws__rail {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    .ws__rail-list { flex-direction: row; flex-wrap: wrap; overflow: visible; }
    .ws__tool {
        flex: 1 1 33%;
        border-left: none;
        border-top: 3px solid transparent;
        border-right: 1px solid var(--color-border);
        justify-content: center;
        padding: 0.6rem 0.4rem;
        font-size: 0.72rem;
    }
    .ws__tool.is-active { border-left-color: transparent; border-top-color: var(--color-accent); }
    .ws__tool-idx { display: none; }
    .ws__rail-foot { justify-content: center; }

    /* .is-generator outranks a bare .ws__grid, so restate it here or the
       narrow control column survives onto phones and blows the layout. */
    .ws__grid, .ws__grid.is-generator { grid-template-columns: 1fr; }
    /* Flex items floor at their content width, and labels like
       PARAGRAPHS_MODE won't shrink — stack them instead of clipping. */
    .mod__modes, .ws__grid.is-generator .mod__modes { flex-direction: column; }
    .lab__mode { min-width: 0; }
    .lab__ta, .lab__out { min-height: 240px; }
    .ws__dock-body { height: auto; max-height: 300px; }
}

@media (max-width: 640px) {
    .ws__main { padding: 0.75rem; gap: 0.75rem; }
    .ws__title { font-size: 0.95rem; }
    .mod__foot { flex-wrap: wrap; }
    .lab__table .col-time, .lab__table .col-status { display: none; }
    .lab__help-table td:first-child { width: 40%; }
    .ws__statusbar { font-size: 0.58rem; padding: 0 0.6rem; gap: 0.5rem; }
    .ws__statusbar-mid { display: none; }
}

/* Too narrow for the status line; the rail footer already says it. */
@media (max-width: 420px) {
    .ws__statusbar-ok { display: none; }
    /* The three action icons matter more than the encoding label. */
    #input-meta { display: none; }
    .mod__head { flex-wrap: wrap; row-gap: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ws *, .ws *::before, .ws *::after { transition: none !important; }
}
