@font-face {
    font-family: 'Monocraft';
    src: url('/fonts/Monocraft.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}


:root {
    color-scheme: dark;
    --bg: #040b16;
    --bg-deep: #02060d;
    --surface: #071425;
    --surface-2: color-mix(in srgb, #0b1c30 80%, #000);
    --surface-3: #11263d;
    --line: #213a58;
    --line-soft: rgba(33, 58, 88, .55);
    --ink: #e8f0fa;
    --ink-soft: #c3d3e5;
    --muted: #92a6bf;
    --accent: #2d4696;
    --accent-strong: #5268ad;
    --accent-soft: rgba(45, 70, 150, .2);
    --warm: #b97b50;
    --warm-soft: rgba(185, 123, 80, .14);
    --button: #b97b50;
    --button-strong: #c98b5e;
    --ok: #74b87a;
    --warn: #f0c36d;
    --bad: #f18a9b;
    --code-bg: #02060d;
    --scroll-track: #02060d;
    --scroll-thumb: #2b4260;
    --user-bg: rgba(185, 123, 80, .075);
    --assistant-bg: rgba(45, 70, 150, .12);
    --radius-panel: 10px;
    --radius-control: 8px;
    --fs-body: 16px;
    --fs-title: 18px;
    --fs-small: 13px;
    --fs-meta: 12px;
    --fs-code: 14px;
    --console-font: 16px;
    --console-meta: max(4px, calc(var(--console-font) * .75));
    --console-small: max(4px, calc(var(--console-font) * .875));
    --console-part: max(4px, calc(var(--console-font) - 2px));
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .18);
    font-family: Monocraft, ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: var(--fs-body);
    font-weight: 400;
    font-synthesis: none;
}

[data-theme="tokyo-night"] {
    --bg: #1a1b26;
    --bg-deep: #16161e;
    --surface: #24283b;
    --surface-2: color-mix(in srgb, #2b2f45 80%, #000);
    --surface-3: #343b5a;
    --line: #414868;
    --line-soft: rgba(65, 72, 104, .65);
    --ink: #c0caf5;
    --ink-soft: #a9b1d6;
    --muted: #7f8bb0;
    --accent: #7aa2f7;
    --accent-strong: #9ab8ff;
    --accent-soft: rgba(122, 162, 247, .16);
    --warm: #e0af68;
    --warm-soft: rgba(224, 175, 104, .14);
    --button: #e0af68;
    --button-strong: #f0c17c;
    --code-bg: #16161e;
    --scroll-track: #16161e;
    --scroll-thumb: #414868;
    --user-bg: rgba(224, 175, 104, .08);
    --assistant-bg: rgba(122, 162, 247, .08);
}

[data-theme="monokai"] {
    --bg: #1e1f1c;
    --bg-deep: #191a17;
    --surface: #272822;
    --surface-2: color-mix(in srgb, #30312a 80%, #000);
    --surface-3: #3b3c34;
    --line: #4b4c45;
    --line-soft: rgba(75, 76, 69, .65);
    --ink: #f8f8f2;
    --ink-soft: #d6d6cf;
    --muted: #a6a69c;
    --accent: #66d9ef;
    --accent-strong: #8be9fd;
    --accent-soft: rgba(102, 217, 239, .14);
    --warm: #fd971f;
    --warm-soft: rgba(253, 151, 31, .14);
    --button: #fd971f;
    --button-strong: #ffb347;
    --code-bg: #191a17;
    --scroll-track: #191a17;
    --scroll-thumb: #4b4c45;
    --user-bg: rgba(253, 151, 31, .08);
    --assistant-bg: rgba(102, 217, 239, .08);
}

[data-theme="one-dark"] {
    --bg: #282c34;
    --bg-deep: #21252b;
    --surface: #2f343d;
    --surface-2: color-mix(in srgb, #3a404b 80%, #000);
    --surface-3: #474e59;
    --line: #4b5263;
    --line-soft: rgba(75, 82, 99, .65);
    --ink: #abb2bf;
    --ink-soft: #c8cdd6;
    --muted: #7f8796;
    --accent: #61afef;
    --accent-strong: #8cc8ff;
    --accent-soft: rgba(97, 175, 239, .15);
    --warm: #d19a66;
    --warm-soft: rgba(209, 154, 102, .14);
    --button: #d19a66;
    --button-strong: #e3b184;
    --code-bg: #21252b;
    --scroll-track: #21252b;
    --scroll-thumb: #4b5263;
    --user-bg: rgba(209, 154, 102, .08);
    --assistant-bg: rgba(97, 175, 239, .08);
}

[data-theme="dracula"] {
    --bg: #282a36;
    --bg-deep: #21222c;
    --surface: #2f3241;
    --surface-2: color-mix(in srgb, #383b4d 80%, #000);
    --surface-3: #44475a;
    --line: #44475a;
    --line-soft: rgba(68, 71, 90, .7);
    --ink: #f8f8f2;
    --ink-soft: #d8d8e6;
    --muted: #9ba0b8;
    --accent: #bd93f9;
    --accent-strong: #d7b6ff;
    --accent-soft: rgba(189, 147, 249, .14);
    --warm: #ffb86c;
    --warm-soft: rgba(255, 184, 108, .14);
    --button: #ffb86c;
    --button-strong: #ffd09b;
    --code-bg: #21222c;
    --scroll-track: #21222c;
    --scroll-thumb: #44475a;
    --user-bg: rgba(255, 184, 108, .08);
    --assistant-bg: rgba(189, 147, 249, .08);
}

[data-theme="nord"] {
    --bg: #2e3440;
    --bg-deep: #272c36;
    --surface: #3b4252;
    --surface-2: color-mix(in srgb, #434c5e 80%, #000);
    --surface-3: #4c566a;
    --line: #4c566a;
    --line-soft: rgba(76, 86, 106, .7);
    --ink: #eceff4;
    --ink-soft: #d8dee9;
    --muted: #9aa6b8;
    --accent: #88c0d0;
    --accent-strong: #a9d6e2;
    --accent-soft: rgba(136, 192, 208, .14);
    --warm: #d08770;
    --warm-soft: rgba(208, 135, 112, .14);
    --button: #d08770;
    --button-strong: #e5a28d;
    --code-bg: #272c36;
    --scroll-track: #272c36;
    --scroll-thumb: #4c566a;
    --user-bg: rgba(208, 135, 112, .08);
    --assistant-bg: rgba(136, 192, 208, .08);
}

[data-theme="gruvbox"] {
    --bg: #282828;
    --bg-deep: #1d2021;
    --surface: #32302f;
    --surface-2: color-mix(in srgb, #3c3836 80%, #000);
    --surface-3: #504945;
    --line: #504945;
    --line-soft: rgba(80, 73, 69, .7);
    --ink: #ebdbb2;
    --ink-soft: #d5c4a1;
    --muted: #a89984;
    --accent: #83a598;
    --accent-strong: #a6c4b8;
    --accent-soft: rgba(131, 165, 152, .14);
    --warm: #d79921;
    --warm-soft: rgba(215, 153, 33, .14);
    --button: #d79921;
    --button-strong: #e8b64a;
    --code-bg: #1d2021;
    --scroll-track: #1d2021;
    --scroll-thumb: #504945;
    --user-bg: rgba(215, 153, 33, .08);
    --assistant-bg: rgba(131, 165, 152, .08);
}

[data-theme="catppuccin"] {
    --bg: #1e1e2e;
    --bg-deep: #181825;
    --surface: #25253a;
    --surface-2: color-mix(in srgb, #313244 80%, #000);
    --surface-3: #45475a;
    --line: #45475a;
    --line-soft: rgba(69, 71, 90, .7);
    --ink: #cdd6f4;
    --ink-soft: #bac2de;
    --muted: #a6adc8;
    --accent: #89b4fa;
    --accent-strong: #b4d0ff;
    --accent-soft: rgba(137, 180, 250, .14);
    --warm: #fab387;
    --warm-soft: rgba(250, 179, 135, .14);
    --button: #fab387;
    --button-strong: #ffc6a5;
    --code-bg: #181825;
    --scroll-track: #181825;
    --scroll-thumb: #45475a;
    --user-bg: rgba(250, 179, 135, .08);
    --assistant-bg: rgba(137, 180, 250, .08);
}

[data-theme="solarized"] {
    --bg: #002b36;
    --bg-deep: #001f27;
    --surface: #073642;
    --surface-2: color-mix(in srgb, #0b4453 80%, #000);
    --surface-3: #115566;
    --line: #586e75;
    --line-soft: rgba(88, 110, 117, .7);
    --ink: #eee8d5;
    --ink-soft: #93a1a1;
    --muted: #839496;
    --accent: #268bd2;
    --accent-strong: #56a9e6;
    --accent-soft: rgba(38, 139, 210, .14);
    --warm: #b58900;
    --warm-soft: rgba(181, 137, 0, .16);
    --button: #b58900;
    --button-strong: #d6a51a;
    --code-bg: #001f27;
    --scroll-track: #001f27;
    --scroll-thumb: #586e75;
    --user-bg: rgba(181, 137, 0, .09);
    --assistant-bg: rgba(38, 139, 210, .09);
}

[data-theme="github-dark"] {
    --bg: #0d1117;
    --bg-deep: #010409;
    --surface: #161b22;
    --surface-2: color-mix(in srgb, #21262d 80%, #000);
    --surface-3: #30363d;
    --line: #30363d;
    --line-soft: rgba(48, 54, 61, .7);
    --ink: #c9d1d9;
    --ink-soft: #b1bac4;
    --muted: #8b949e;
    --accent: #58a6ff;
    --accent-strong: #79c0ff;
    --accent-soft: rgba(88, 166, 255, .14);
    --warm: #d29922;
    --warm-soft: rgba(210, 153, 34, .14);
    --button: #d29922;
    --button-strong: #e3b341;
    --code-bg: #010409;
    --scroll-track: #010409;
    --scroll-thumb: #30363d;
    --user-bg: rgba(210, 153, 34, .08);
    --assistant-bg: rgba(88, 166, 255, .08);
}

[data-theme="ayu"] {
    --bg: #0b0e14;
    --bg-deep: #070a0f;
    --surface: #0f131a;
    --surface-2: color-mix(in srgb, #1a1f29 80%, #000);
    --surface-3: #252c38;
    --line: #2d3640;
    --line-soft: rgba(45, 54, 64, .7);
    --ink: #bfbdb6;
    --ink-soft: #a6a39b;
    --muted: #7d8590;
    --accent: #59c2ff;
    --accent-strong: #7ed0ff;
    --accent-soft: rgba(89, 194, 255, .14);
    --warm: #ffb454;
    --warm-soft: rgba(255, 180, 84, .14);
    --button: #ffb454;
    --button-strong: #ffc978;
    --code-bg: #070a0f;
    --scroll-track: #070a0f;
    --scroll-thumb: #2d3640;
    --user-bg: rgba(255, 180, 84, .08);
    --assistant-bg: rgba(89, 194, 255, .08);
}

[data-theme="material"] {
    --bg: #0b0d14;
    --bg-deep: #06070c;
    --surface: #11141e;
    --surface-2: color-mix(in srgb, #1a1e2a 80%, #000);
    --surface-3: #252b3b;
    --line: #2a354b;
    --line-soft: rgba(42, 53, 75, .7);
    --ink: #eeffff;
    --ink-soft: #c5d1e0;
    --muted: #8d9bb0;
    --accent: #3556a0;
    --accent-strong: #5268ad;
    --accent-soft: rgba(53, 86, 160, .2);
    --warm: #e5b56b;
    --warm-soft: rgba(229, 181, 107, .14);
    --button: #e5b56b;
    --button-strong: #f0c982;
    --code-bg: #06070c;
    --scroll-track: #06070c;
    --scroll-thumb: #2a354b;
    --user-bg: rgba(229, 181, 107, .08);
    --assistant-bg: rgba(53, 86, 160, .12);
}

/* No cyan/light-blue interface accents. Theme identity stays in surfaces and warm tones. */
[data-theme="tokyo-night"] {
    --accent: #344f9b;
    --accent-strong: #5268ad;
    --accent-soft: rgba(52, 79, 155, .2);
    --assistant-bg: rgba(52, 79, 155, .12);
}

[data-theme="monokai"] {
    --accent: #3b4f9a;
    --accent-strong: #5268ad;
    --accent-soft: rgba(59, 79, 154, .2);
    --assistant-bg: rgba(59, 79, 154, .12);
}

[data-theme="one-dark"] {
    --accent: #38549c;
    --accent-strong: #5268ad;
    --accent-soft: rgba(56, 84, 156, .2);
    --assistant-bg: rgba(56, 84, 156, .12);
}

[data-theme="dracula"] {
    --accent: #3d56a2;
    --accent-strong: #5268ad;
    --accent-soft: rgba(61, 86, 162, .2);
    --assistant-bg: rgba(61, 86, 162, .12);
}

[data-theme="nord"] {
    --accent: #3b578f;
    --accent-strong: #5268ad;
    --accent-soft: rgba(59, 87, 143, .2);
    --assistant-bg: rgba(59, 87, 143, .12);
}

[data-theme="gruvbox"] {
    --accent: #455f8c;
    --accent-strong: #5d74a5;
    --accent-soft: rgba(69, 95, 140, .2);
    --assistant-bg: rgba(69, 95, 140, .12);
}

[data-theme="catppuccin"] {
    --accent: #3856a0;
    --accent-strong: #5268ad;
    --accent-soft: rgba(56, 86, 160, .2);
    --assistant-bg: rgba(56, 86, 160, .12);
}

[data-theme="solarized"] {
    --accent: #2f5594;
    --accent-strong: #5268ad;
    --accent-soft: rgba(47, 85, 148, .2);
    --assistant-bg: rgba(47, 85, 148, .12);
}

[data-theme="github-dark"] {
    --accent: #2c5596;
    --accent-strong: #5268ad;
    --accent-soft: rgba(44, 85, 150, .2);
    --assistant-bg: rgba(44, 85, 150, .12);
}

[data-theme="ayu"] {
    --accent: #315896;
    --accent-strong: #5268ad;
    --accent-soft: rgba(49, 88, 150, .2);
    --assistant-bg: rgba(49, 88, 150, .12);
}

html[data-custom="true"] {
    --bg: var(--p-bg);
    --bg-deep: color-mix(in srgb, var(--p-bg) 55%, #000);
    --surface: var(--p-surface);
    --surface-2: color-mix(in srgb, color-mix(in srgb, var(--p-surface) 76%, var(--p-bg)) 80%, #000);
    --surface-3: color-mix(in srgb, var(--p-surface) 58%, var(--p-bg) 42%);
    --line: color-mix(in srgb, var(--p-ink) 22%, var(--p-surface));
    --line-soft: color-mix(in srgb, var(--line) 58%, transparent);
    --ink: var(--p-ink);
    --ink-soft: color-mix(in srgb, var(--p-ink) 82%, var(--p-surface));
    --muted: color-mix(in srgb, var(--p-ink) 55%, var(--p-surface));
    --accent: var(--p-accent);
    --accent-strong: color-mix(in srgb, var(--p-accent) 78%, #fff);
    --accent-soft: color-mix(in srgb, var(--p-accent) 22%, transparent);
    --warm: var(--p-button);
    --warm-soft: color-mix(in srgb, var(--p-button) 18%, transparent);
    --button: var(--p-button);
    --button-strong: color-mix(in srgb, var(--p-button) 82%, #fff);
    --ok: #74b87a;
    --warn: #d8af62;
    --bad: #dd7d8c;
    --code-bg: color-mix(in srgb, var(--p-bg) 55%, #000);
    --scroll-track: color-mix(in srgb, var(--p-bg) 55%, #000);
    --scroll-thumb: color-mix(in srgb, var(--p-ink) 28%, var(--p-surface));
    --user-bg: color-mix(in srgb, var(--p-button) 10%, transparent);
    --assistant-bg: color-mix(in srgb, var(--p-accent) 15%, transparent);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

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

/* The page rail is a separate fixed block, not an overlay thumb. */
html {
    overflow-y: auto;
}

html.has-app-scrollbar {
    scrollbar-width: none;
}

html.has-app-scrollbar::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body {
    overflow-x: clip;
}

body.has-app-scrollbar {
    padding-right: var(--app-scrollbar-width, 14px);
}

.app-scroll-rail {
    position: fixed;
    z-index: 120;
    top: 0;
    right: 0;
    width: var(--app-scrollbar-width, 14px);
    height: 100vh;
    background: transparent;
    border-left: 1px solid var(--line, #213a58);
    touch-action: none;
}

.app-scroll-rail::before {
    content: "";
    position: absolute;
    top: 18px;
    bottom: 18px;
    left: 50%;
    width: 6px;
    margin-left: -3px;
    border-radius: 99px;
    background: var(--muted, #92a6bf);
}

.app-scroll-rail[hidden] { display: none; }

.app-scroll-arrow {
    position: absolute;
    left: 50%;
    z-index: 2;
    width: 10px;
    height: 12px;
    min-width: 0;
    min-height: 0;
    padding: 0;
    display: grid;
    place-items: center;
    transform: translateX(-50%);
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted, #92a6bf);
    font-size: 0;
    line-height: 0;
    overflow: hidden;
    appearance: none;
    opacity: .5;
    cursor: pointer;
    transition: color .1s ease, opacity .1s ease;
}

.app-scroll-arrow.up { top: 2px; }
.app-scroll-arrow.down { bottom: 2px; }
.app-scroll-arrow svg {
    width: 8px;
    height: 8px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}
.app-scroll-arrow:hover { color: var(--ink-soft, #c3d3e5); opacity: 1; }
.app-scroll-arrow:disabled { opacity: .2; cursor: default; }

.app-scroll-thumb {
    position: absolute;
    top: 0;
    left: 50%;
    right: auto;
    width: 6px;
    margin-left: -3px;
    min-height: 28px;
    border-radius: 99px;
    background: var(--scroll-thumb, #5268ad);
    cursor: grab;
    transition: filter .1s ease;
}

.app-scroll-rail:hover .app-scroll-thumb { filter: brightness(.85); }
.app-scroll-rail.dragging .app-scroll-thumb { filter: brightness(.75); }
.app-scroll-thumb:active { cursor: grabbing; }

body.has-app-scrollbar .master-panel {
    right: var(--app-scrollbar-width, 14px);
}

@media (max-width: 760px) {
    /* Native touch scrolling is more predictable on phones; keep the rail desktop-only. */
    .app-scroll-rail { display: none !important; }
    html.has-app-scrollbar { scrollbar-width: auto; }
    html.has-app-scrollbar::-webkit-scrollbar { width: 12px; height: 12px; }
    body.has-app-scrollbar { padding-right: 0; }
}


body {
    background: radial-gradient(900px 500px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%), radial-gradient(700px 420px at 0% 0%, color-mix(in srgb, var(--surface-2) 45%, transparent), transparent 65%), var(--bg);
    color: var(--ink);
    line-height: 1.5;
    font-family: inherit;
    font-weight: 400;
}

button, input, textarea, select {
    font: inherit;
    font-weight: 400;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    cursor: pointer;
}

::selection {
    background: color-mix(in srgb, var(--accent) 30%, transparent);
}

strong, b {
    font-weight: 400;
    color: var(--warm);
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--scroll-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 99px;
    border: 2px solid var(--scroll-track);
    background-clip: padding-box;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--accent);
        background-clip: padding-box;
    }

* {
    scrollbar-width: auto;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

input[type="number"] {
    appearance: textfield;
}

    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
        appearance: none;
        margin: 0;
    }

:root {
    --app-header-h: 58px;
    --page-max: 1500px;
    --page-x: clamp(14px, 2.4vw, 28px);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 16px;
    container-type: inline-size;
    container-name: app-header;
    min-height: var(--app-header-h);
    padding-left: 8px;
    padding-right: 8px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 96%, var(--bg));
    backdrop-filter: blur(10px);
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 0 1 auto;
}

.app-sidebar-toggle { flex: 0 0 auto; }

.app-brand-block { min-width: 0; }

.app-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.app-brand-title {
    display: inline-flex;
    font-size: 17px;
    letter-spacing: .04em;
    color: var(--ink);
    white-space: nowrap;
}

.brand-jesk {
    background: linear-gradient(100deg, var(--ink) 0%, var(--accent-strong) 42%, var(--accent) 55%, var(--ink) 100%);
    background-size: 220% 100%;
    background-position: 50% 50%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.app-brand-page {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    white-space: nowrap;
}

.app-brand-sub {
    max-width: 320px;
    margin: 2px 0 0;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-nav {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    min-width: 0;
    margin-left: auto;
    overflow: hidden;
}

.app-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    border-radius: 7px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    transition: background .12s, color .12s;
}

.app-nav-link:hover { color: var(--ink); background: var(--surface-2); }

.app-nav-link.active {
    color: var(--ink);
    background: var(--accent-soft);
    box-shadow: inset 0 -2px 0 var(--accent);
}

.app-nav-link .icon { width: 15px; height: 15px; }

.app-header-actions {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.app-live {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 9px;
    border: 1px solid color-mix(in srgb, var(--accent-strong) 52%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 20%, var(--surface));
    color: var(--ink-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, #fff 4%, transparent);
    font-size: 11px;
    white-space: nowrap;
}

.app-live .live-dot {
    background: var(--ok);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}

.app-logout { min-height: 30px; padding: 4px 8px; }
.app-master-slot { display: flex; align-items: center; }

.lang-switch {
    min-width: 34px;
    height: 30px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-2);
    color: var(--muted);
    font: inherit;
    font-size: 10px;
    letter-spacing: .08em;
    cursor: pointer;
}

.lang-switch:hover { color: var(--ink); border-color: var(--accent-strong); background: var(--accent-soft); }
.app-header .app-nav-toggle {
    display: none;
    border-color: var(--line);
    color: var(--ink-soft);
}
.app-header .app-nav-toggle:hover {
    border-color: var(--accent-strong);
    background: var(--surface-2);
    color: var(--ink);
}

.app-shell {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 24px var(--page-x) 48px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 7px 11px;
    min-height: 34px;
    background: var(--surface-2);
    color: var(--ink-soft);
    font-size: var(--fs-small);
    font-weight: 400;
    transition: background .12s, color .12s, border-color .12s;
    white-space: nowrap;
}

    .btn:hover {
        background: var(--surface-3);
        color: var(--ink);
        border-color: color-mix(in srgb, var(--line) 80%, #fff);
    }

    .btn.primary {
        background: var(--button);
        color: var(--p-button-ink, #1b1009);
        border-color: var(--button);
    }

        .btn.primary:hover {
            background: var(--button-strong);
            border-color: color-mix(in srgb, var(--button) 80%, #fff);
        }

    .btn.ghost {
        background: transparent;
    }

        .btn.ghost:hover {
            background: var(--surface-2);
        }

    .btn.small {
        min-height: 29px;
        padding: 4px 9px;
        font-size: var(--fs-meta);
    }

    .btn.tiny {
        min-height: 26px;
        padding: 3px 7px;
        font-size: var(--fs-meta);
    }

    .btn.warn-btn {
        color: var(--warm);
    }

    .btn.danger-btn {
        color: var(--bad);
    }

    .btn:disabled {
        opacity: .45;
        cursor: not-allowed;
    }

    .btn:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

.live-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    border-radius: 10px;
    color: var(--muted);
    background: var(--surface);
    font-size: var(--fs-meta);
}

.live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 3px rgba(102, 199, 174, .12);
}

    .live-dot.pulse {
        animation: pulse 1.2s ease-in-out infinite;
    }

@keyframes pulse {
    0%,100% {
        opacity: .45;
        transform: scale(.85);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .live-dot.pulse {
        animation: none;
    }
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.summary-card {
    padding: 13px 15px;
    border-radius: var(--radius-panel);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .summary-card span {
        color: var(--muted);
        font-size: var(--fs-meta);
    }

    .summary-card strong {
        font-size: 22px;
        font-weight: 400;
        color: var(--ink);
    }

    .summary-card.wide strong {
        font-size: var(--fs-small);
        padding-top: 5px;
        color: var(--accent);
    }

.spend-panel {
    background: var(--surface);
    border-radius: var(--radius-panel);
    padding: 14px 16px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.spend-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 11px;
}

.spend-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid color-mix(in srgb, var(--page-accent) 55%, var(--line));
    border-radius: 999px;
    background: color-mix(in srgb, var(--page-accent) 12%, transparent);
    color: var(--page-accent);
    font-size: 9px;
    letter-spacing: .09em;
    text-transform: uppercase;
    white-space: nowrap;
}

.plan-badge.plan-plus { color: var(--warm); border-color: color-mix(in srgb, var(--warm) 60%, var(--line)); background: color-mix(in srgb, var(--warm) 12%, transparent); }
.plan-badge.plan-unknown { color: var(--muted); border-color: var(--line); background: transparent; }
.plan-badge.plan-pro { color: var(--accent-strong); }

    .spend-head h2 {
        margin: 0;
        font-size: var(--fs-small);
    }

.spend-bars {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.spend-item > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: var(--fs-meta);
    margin-bottom: 5px;
}

.spend-item {
    --limit-color: var(--accent-strong, #5268ad);
}

.spend-item:nth-child(1) { --limit-color: var(--accent-strong, #5268ad); }
.spend-item:nth-child(2) { --limit-color: var(--ok, #74b87a); }
.spend-item:nth-child(3) { --limit-color: var(--warn, #f0c36d); }

.spend-item b {
    padding: 2px 7px;
    border: 1px solid var(--limit-color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--limit-color) 10%, transparent);
    color: var(--limit-color);
    font-size: var(--fs-meta);
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.spend-item .context-track {
    height: 12px;
    border: 1px solid var(--limit-color);
    background: color-mix(in srgb, var(--limit-color) 8%, transparent);
}

.spend-item .context-track i {
    background: color-mix(in srgb, var(--limit-color) 50%, transparent);
}

.spend-item .context-track i.warn {
    background: color-mix(in srgb, var(--warn, #f0c36d) 50%, transparent);
}

.spend-item .context-track i.critical {
    background: color-mix(in srgb, var(--bad, #f18a9b) 50%, transparent);
}

.spend-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.context-track {
    height: 6px;
    border-radius: 99px;
    background: var(--muted);
    overflow: hidden;
}

    .context-track i {
        display: block;
        height: 100%;
        width: 0;
        border-radius: inherit;
        background: var(--accent);
        transition: width .25s ease;
    }

        .context-track i.warn {
            background: var(--warn);
        }

        .context-track i.critical {
            background: var(--bad);
        }

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin: 20px 0 9px;
}

    .section-head h2 {
        margin: 0;
        font-size: var(--fs-body);
    }

    .section-head p {
        margin: 2px 0 0;
        font-size: var(--fs-small);
    }

.muted {
    color: var(--muted);
}

.tiny {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.legend {
    color: var(--muted);
    font-size: var(--fs-meta);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

    .dot.warn {
        background: var(--warn);
    }

    .dot.bad {
        background: var(--bad);
    }

.agents-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.agent-card {
    min-width: 0;
    background: var(--surface);
    border-radius: var(--radius-panel);
    padding: 14px;
}

    .agent-card.loading {
        color: var(--muted);
        font-size: var(--fs-small);
        grid-column: 1 / -1;
    }

    .agent-card.status-working, .agent-card.status-error {
        box-shadow: none;
    }

.agent-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.agent-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

    .agent-title h3 {
        margin: 0;
        font-size: var(--fs-small);
        white-space: nowrap;
    }

.agent-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--muted);
    flex: 0 0 auto;
}

.status-working .agent-dot {
    background: var(--accent);
    animation: pulse 1.2s ease-in-out infinite;
}

.status-idle .agent-dot {
    background: var(--ok);
}

.status-waiting .agent-dot {
    background: var(--warn);
}

.status-error .agent-dot {
    background: var(--bad);
}

.status-pill {
    padding: 3px 6px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-meta);
    display: inline-grid;
    place-items: center;
}

    .status-pill .icon {
        width: 1em;
        height: 1em;
    }

.status-working .status-pill .icon {
    color: var(--accent);
}

.status-idle .status-pill .icon {
    color: var(--ok);
}

.status-waiting .status-pill .icon {
    color: var(--warn);
}

.status-error .status-pill .icon {
    color: var(--bad);
}

.status-spin {
    transform-origin: 12px 12px;
    animation: status-spin 1s linear infinite;
}

@keyframes status-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .status-spin {
        animation: none;
    }
}

.agent-worktree {
    color: var(--muted);
    font-size: var(--fs-meta);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 45%;
}

.context-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 10px;
}

    .context-row .context-track {
        flex: 1;
    }

    .context-row b {
        color: var(--ink-soft);
        font-size: var(--fs-meta);
        font-weight: 400;
        white-space: nowrap;
    }

    .context-row .muted {
        font-size: var(--fs-meta);
    }

.claim {
    min-height: 20px;
    color: var(--ink-soft);
    font-size: var(--fs-small);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

    .claim b {
        color: var(--warm);
    }

.agent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin: 9px 0 8px;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.last-event {
    min-height: 38px;
    color: var(--ink-soft);
    font-size: var(--fs-small);
    line-height: 1.45;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

    .last-event.working {
        color: transparent;
        background: linear-gradient(90deg, var(--muted), var(--accent), var(--button), var(--muted));
        background-size: 220% 100%;
        -webkit-background-clip: text;
        background-clip: text;
        animation: action-shimmer 2.2s linear infinite;
    }

@media (prefers-reduced-motion: reduce) {
    .last-event.working {
        animation: none;
    }
}

@keyframes action-shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}

.agent-error {
    margin-top: 7px;
    color: var(--bad);
    font-size: var(--fs-small);
    overflow-wrap: anywhere;
}

.lower-grid {
    display: grid;
    grid-template-columns: minmax(0, 2.3fr) minmax(300px, .9fr);
    gap: 12px;
    margin-top: 18px;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius-panel);
    min-width: 0;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
}

    .panel-head h2 {
        margin: 0;
        font-size: var(--fs-small);
    }

    .panel-head p {
        margin: 2px 0 0;
        font-size: var(--fs-meta);
    }

.task-list {
    padding: 0 14px 14px;
    max-height: 460px;
    overflow: auto;
}

.task-row {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 9px 0;
    border-top: 1px solid var(--line-soft);
}

    .task-row:first-child {
        border-top: 0;
    }

.task-main {
    min-width: 0;
}

.task-id {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.done-no {
    color: var(--warm);
}

.task-title {
    color: var(--ink-soft);
    font-size: var(--fs-small);
    margin-top: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-detail {
    color: var(--muted);
    font-size: var(--fs-meta);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-done .task-title {
    color: var(--muted);
}

.task-blocked .task-title {
    color: var(--bad);
}

.side-panel {
    display: flex;
    flex-direction: column;
}

.event-log {
    padding: 0 14px;
    max-height: 300px;
    overflow: auto;
}

.event-row {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 0;
    border-top: 1px solid var(--line-soft);
    color: var(--ink-soft);
    font-size: var(--fs-small);
}

    .event-row:first-child {
        border-top: 0;
    }

.event-agent {
    color: var(--warm);
    font-size: var(--fs-meta);
    flex: 0 0 auto;
}

.event-kind {
    color: var(--muted);
    font-size: var(--fs-meta);
    flex: 0 0 auto;
}

.event-row small {
    margin-left: auto;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.info-block {
    margin: 12px 14px 14px;
    padding-top: 11px;
    border-top: 1px solid var(--line);
}

    .info-block h3 {
        margin: 0 0 5px;
        font-size: var(--fs-small);
    }

    .info-block p {
        margin: 0 0 6px;
        color: var(--muted);
        font-size: var(--fs-small);
    }

.nav-link {
    color: var(--accent);
    font-size: var(--fs-small);
}

    .nav-link:hover {
        color: var(--accent-strong);
    }

dialog {
    border: 0;
    border-radius: var(--radius-panel);
    padding: 0;
    width: min(620px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    margin: auto;
    overflow: auto;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 30px 100px rgba(0, 0, 0, .55);
}

    dialog::backdrop {
        background: rgba(3, 8, 15, .75);
        backdrop-filter: blur(3px);
    }

    dialog form, dialog .dialog-body {
        padding: 18px;
        display: grid;
        gap: 11px;
    }

.dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

    body dialog .dialog-head h2 {
        margin: 0;
        font-size: 16px;
        line-height: 1.3;
    }

    body dialog .dialog-head p {
        margin: 4px 0 0;
        color: var(--muted);
        font-size: 11px;
        line-height: 1.45;
    }

    body dialog .dialog-head .icon-btn {
        flex: 0 0 auto;
        width: 32px;
        height: 32px;
        padding: 0;
        border-radius: var(--radius-control);
        font-size: 18px;
        line-height: 1;
    }

    body dialog .dialog-actions {
        align-items: center;
        margin-top: 12px;
    }

    body dialog .notice {
        margin: 0;
    }

.icon-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    padding: 10px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--radius-control);
}

    .icon-btn:hover {
        color: var(--ink);
        background: var(--surface-2);
    }

.icon {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

dialog label {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: var(--fs-meta);
}

dialog input, dialog textarea, dialog select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--bg-deep);
    color: var(--ink);
    padding: 8px 9px;
    font-size: var(--fs-small);
    outline: none;
}

    dialog input:focus, dialog textarea:focus, dialog select:focus {
        border-color: var(--accent);
    }

dialog .check {
    display: flex;
    align-items: center;
    gap: 7px;
    padding-top: 20px;
    color: var(--ink-soft);
}

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

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 7px;
    margin-top: 4px;
}

.toast {
    position: fixed;
    inset: auto 18px 18px auto;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    margin: 0;
    border: 0;
    max-width: min(460px, calc(100vw - 36px));
    padding: 10px 13px;
    border-radius: var(--radius-control);
    background: var(--surface-3);
    color: var(--ink);
    font-size: var(--fs-small);
    line-height: 1.45;
    overflow-wrap: anywhere;
    box-shadow: 0 16px 50px rgba(0, 0, 0, .45);
    animation: jesk-toast-in .26s cubic-bezier(.2, .8, .2, 1);
}

.toast[popover]:not(:popover-open) { display: none; }

@keyframes jesk-toast-in {
    from { opacity: 0; transform: translateY(8px) translateX(18px); }
    to { opacity: 1; transform: translateY(0) translateX(0); }
}

    .toast.error {
        color: #f3b2bc;
        background: #2a1a22;
    }

/* Task list in the console sidebar */
.side-block-title {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.side-count {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 19px;
    padding: 0 6px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--warm);
    font-size: var(--fs-meta);
}

.side-tasks .side-task-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding-right: 4px;
}

.side-tasks .side-task {
    padding: 6px 8px;
    align-items: start;
}

    .side-tasks .side-task .icon {
        margin-top: 2px;
    }

.side-tasks .side-task-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    white-space: normal;
    overflow: hidden;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.side-tasks .side-task-id {
    display: block;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--fs-meta);
}

.chip-count {
    margin-left: 4px;
    color: var(--warm);
}

/* Confirmation and colour dialogs */
.confirm-dialog {
    width: min(460px, calc(100vw - 28px));
}

.confirm-message {
    color: var(--ink-soft);
    font-size: var(--fs-small);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.confirm-dialog .dialog-actions {
    padding-top: 4px;
}

.color-dialog {
    width: min(460px, calc(100vw - 28px));
}

.color-picker {
    display: grid;
    gap: 11px;
}

    .color-picker label {
        gap: 5px;
    }

    .color-picker input[type="range"] {
        appearance: none;
        width: 100%;
        height: 16px;
        border: 1px solid var(--line);
        border-radius: 99px;
        padding: 0;
        outline: none;
    }

        .color-picker input[type="range"]::-webkit-slider-thumb {
            appearance: none;
            width: 18px;
            height: 18px;
            border-radius: 50%;
            border: 2px solid var(--ink);
            background: var(--surface);
            box-shadow: 0 2px 8px rgba(0, 0, 0, .45);
        }

        .color-picker input[type="range"]::-moz-range-thumb {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            border: 2px solid var(--ink);
            background: var(--surface);
        }

.color-preview-large {
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 10px;
    display: grid;
    gap: 6px;
}

    .color-preview-large .pv-line {
        height: 8px;
        border-radius: 99px;
    }

.color-value {
    color: var(--ink);
    font-size: var(--fs-small);
    letter-spacing: .04em;
}

.side-hint {
    margin: 0 0 7px;
    color: var(--muted);
    font-size: var(--fs-meta);
    line-height: 1.45;
}

/* View profiles */
.profile-section {
    display: grid;
    gap: 9px;
    border-top: 1px solid var(--line);
    padding-top: 11px;
}

.profile-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
}

    .profile-head h3 {
        margin: 0;
        font-size: var(--fs-small);
    }

.profile-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.profile-list {
    display: grid;
    gap: 6px;
}

.profile-empty {
    color: var(--muted);
    font-size: var(--fs-meta);
}

.profile-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 7px 8px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-control);
    background: var(--surface-2);
}

    .profile-card.active {
        border-color: var(--accent);
    }

.profile-card-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink-soft);
    font-size: var(--fs-small);
}

.profile-card-actions {
    display: flex;
    gap: 5px;
}

.profile-mini {
    grid-column: 1 / -1;
    display: flex;
    gap: 4px;
}

    .profile-mini span {
        width: 26px;
        height: 13px;
        border-radius: 3px;
        border: 1px solid var(--line-soft);
    }

.color-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
}

.color-field {
    display: grid;
    gap: 3px;
    justify-items: start;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    padding: 5px;
    background: var(--bg-deep);
    color: var(--muted);
    font-size: var(--fs-meta);
}

    .color-field .color-swatch {
        width: 100%;
        height: 22px;
        border-radius: 4px;
        border: 1px solid var(--line-soft);
    }

    .color-field code {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--muted);
        font-size: 10px;
    }

#profile-save {
    align-self: end;
}

@media (max-width: 560px) {
    .color-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.color-preview {
    display: grid;
    grid-template-columns: 55px minmax(0, 1fr);
    gap: 6px;
    min-height: 96px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
}

.color-preview-side {
    border-radius: 5px;
}

.color-preview-main {
    display: grid;
    align-content: start;
    gap: 6px;
    padding: 8px;
    border-radius: 5px;
}

    .color-preview-main .pv-line {
        height: 7px;
        border-radius: 99px;
        width: 70%;
    }

        .color-preview-main .pv-line.short {
            width: 44%;
        }

    .color-preview-main .pv-button {
        width: 48px;
        height: 14px;
        border-radius: 4px;
    }

@media (max-width: 1280px) {
    .agents-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell {
        padding: 14px 14px 30px;
    }

    .summary-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .summary-card.wide {
        grid-column: span 3;
    }

    .lower-grid {
        grid-template-columns: 1fr;
    }

    .spend-bars {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 10px 10px 28px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .summary-card {
        padding: 10px;
    }

        .summary-card strong {
            font-size: 19px;
        }

        .summary-card.wide {
            grid-column: span 2;
        }

    .spend-bars {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .agents-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .lower-grid {
        gap: 8px;
        margin-top: 12px;
    }

    .task-row {
        gap: 6px;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 5px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    dialog .check {
        padding-top: 0;
    }

    dialog {
        width: calc(100vw - 12px);
        max-height: calc(100dvh - 12px);
        margin: auto;
        overflow: auto;
    }

        dialog form, dialog .dialog-body {
            padding: 12px;
            max-height: calc(100dvh - 24px);
        }
}

@media (max-width: 420px) {
    .activity {
        display: none;
    }

    .summary-grid {
        gap: 4px;
    }

    .summary-card strong {
        font-size: 17px;
    }

    .agent-meta {
        gap: 6px;
    }
}

/* Shared page primitives. Page CSS may refine, but these must work everywhere. */
body { --page-accent: var(--accent); --page-tint: var(--accent-soft); }
body[data-page="tasks"] { --page-accent: #7aa2f7; --page-tint: rgba(122, 162, 247, .14); }
body[data-page="projects"] { --page-accent: var(--warm); --page-tint: var(--warm-soft); }
body[data-page="workspace"] { --page-accent: #7dd3fc; --page-tint: rgba(125, 211, 252, .12); }
body[data-page="github"] { --page-accent: #c4a7ff; --page-tint: rgba(196, 167, 255, .13); }
body[data-page="journal"] { --page-accent: var(--warn); --page-tint: color-mix(in srgb, var(--warn) 13%, transparent); }
body[data-page="usage"] { --page-accent: var(--ok); --page-tint: color-mix(in srgb, var(--ok) 12%, transparent); }
body[data-page="settings"] { --page-accent: var(--accent-strong); --page-tint: var(--accent-soft); }
body[data-page="consoles"] { --page-accent: var(--accent); --page-tint: var(--accent-soft); }

.panel {
    border: 1px solid var(--line-soft);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--page-accent) 6%, transparent), transparent 140px),
        var(--surface);
}

.panel-head h2 {
    position: relative;
    padding-left: 11px;
}

.panel-head h2::before {
    content: "";
    position: absolute;
    left: 0;
    top: .15em;
    width: 3px;
    height: 1.05em;
    border-radius: 3px;
    background: var(--page-accent);
    box-shadow: 0 0 12px color-mix(in srgb, var(--page-accent) 45%, transparent);
}

.notice:empty { display: none; }

.summary-card {
    position: relative;
    border-top: 2px solid var(--card-accent, var(--page-accent));
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--card-accent, var(--page-accent)) 10%, transparent), transparent 75%),
        var(--surface);
}

.summary-card:nth-child(1) { --card-accent: #7aa2f7; }
.summary-card:nth-child(2) { --card-accent: var(--warn); }
.summary-card:nth-child(3) { --card-accent: var(--ok); }
.summary-card:nth-child(4) { --card-accent: var(--bad); }
.summary-card:nth-child(5) { --card-accent: var(--accent-strong); }

.summary-card strong { color: var(--card-accent, var(--ink)); }

.agent-card {
    border: 1px solid var(--line-soft);
    border-left: 3px solid var(--page-accent);
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--page-accent) 7%, transparent), transparent 60%),
        var(--surface);
}
.field {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.field-label {
    color: var(--muted);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.notice {
    min-height: 16px;
    margin: 4px 0 0;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 12px;
}

.notice.error { color: var(--bad); }

.small { font-size: var(--fs-meta); }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 0 0 12px;
}

.toolbar input[type="search"] {
    flex: 1 1 220px;
    min-width: 160px;
    padding: 8px 10px;
    background: var(--bg-deep);
    color: inherit;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    font: inherit;
    font-size: 13px;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    padding: 5px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    letter-spacing: .04em;
    cursor: pointer;
}

.chip:hover { color: var(--ink); }

.chip.active {
    border-color: var(--accent-strong);
    background: var(--accent-soft);
    color: var(--ink);
}

.project-bar { padding: 0 0 12px; min-width: 0; }
.project-bar .field { max-width: min(420px, 100%); min-width: 0; width: 100%; }
.project-bar select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 8px 10px;
    background: var(--surface);
    color: inherit;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    font: inherit;
    font-size: 13px;
}

.auto-pill {
    padding: 2px 9px;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 12%, transparent);
    font-size: 11px;
    letter-spacing: .04em;
}

.auto-pill.off { color: var(--muted); }
.auto-pill.paused { color: var(--warn); }
.auto-pill.on { color: var(--ok); }

@media (max-width: 1560px) {
    .console-page #activity-label,
    .console-page .app-logout span { display: none; }
}

@media (max-width: 1500px) {
    .app-nav-label { display: none; }
    .app-nav-link { padding: 8px; }
}

@media (max-width: 980px) {
    .app-shell { padding: 18px var(--page-x) 32px; }
}

@media (max-width: 940px) {
    :root { --app-header-h: 52px; }

    .app-header,
    .console-page .app-header {
        gap: 8px;
        padding: 0 8px;
    }

    .app-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        max-height: calc(100dvh - var(--app-header-h));
        padding: 9px 12px 12px;
        overflow: auto;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
    }

    .app-header.nav-open .app-nav { display: flex; }
    .app-nav-link { padding: 10px 12px; }
    .app-nav-label { display: inline; }
    .app-header .app-nav-toggle { display: inline-flex; }
    .app-brand-sub { max-width: 220px; }
    .app-logout span { display: none; }
    .app-header-actions .app-logout.btn.small,
    .app-header-actions .app-nav-toggle,
    .app-header-actions .master-toggle {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        padding: 0;
        justify-content: center;
    }
    .master-toggle-label { display: none; }
}

@media (max-width: 760px) {
    .app-shell { padding: 14px var(--page-x) 28px; }
}

@media (max-width: 620px) {
    .app-brand-sub { display: none; }
    .app-brand-page { display: none; }
    .app-live { display: none; }
    .app-header-actions { gap: 5px; }
}

@media (max-width: 420px) {
    .app-brand-title { font-size: 15px; }
}

/* The app header responds to the width left by the master panel, not only to viewport width. */
@container app-header (max-width: 1100px) {
    .app-nav-label { display: none; }
    .app-nav-link { padding: 8px; }
    .app-logout span { display: none; }
    .app-live #activity-label { display: none; }
}

@container app-header (max-width: 780px) {
    .app-nav {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        max-height: calc(100dvh - var(--app-header-h));
        padding: 9px 12px 12px;
        overflow: auto;
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
    }

    .app-header.nav-open .app-nav { display: flex; }
    .app-nav-link { padding: 10px 12px; }
    .app-nav-label { display: inline; }
    .app-header .app-nav-toggle { display: inline-flex; }
    .app-brand-sub { max-width: 220px; }
    .master-toggle-label { display: none; }
    .master-toggle { padding: 5px 7px; }
}

@container app-header (max-width: 600px) {
    .app-brand-sub { display: none; }
    .app-brand-page { display: none; }
    .app-live { display: none; }
    .app-header-actions { gap: 5px; }
}

@container app-header (max-width: 420px) {
    .app-brand-title { font-size: 15px; }
}

/* A dropdown menu always names its destinations, even when the header is icon-only. */
.app-header.nav-open .app-nav-label { display: inline; }

/* Shared control language: checkboxes are switches, radios are themed discs. */
body {
    --control-accent: var(--page-accent, var(--accent-strong, var(--accent)));
}

.summary-card,
.agent-card,
.settings-block {
    --control-accent: var(--card-accent, var(--page-accent, var(--accent-strong)));
}

input[type="checkbox"][data-switch] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.switch-track {
    --switch-w: clamp(30px, 2.5em, 46px);
    --switch-h: clamp(16px, 1.333em, 24px);
    --switch-thumb: calc(var(--switch-h) - 4px);
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    width: var(--switch-w);
    height: var(--switch-h);
    padding: 2px;
    border-radius: 999px;
    background: var(--bg-deep);
    box-shadow: inset 0 0 0 1px var(--line);
    cursor: pointer;
    vertical-align: middle;
    transition: background-color .24s ease, box-shadow .24s ease;
}

.switch-thumb {
    width: var(--switch-thumb);
    height: var(--switch-thumb);
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
    transition:
        transform .3s cubic-bezier(.2, .9, .2, 1.2),
        background-color .24s ease;
}

input[data-switch]:checked + .switch-track {
    background: var(--control-accent);
    box-shadow: inset 0 0 0 1px var(--control-accent);
}

input[data-switch]:checked + .switch-track .switch-thumb {
    transform: translateX(calc(var(--switch-w) - var(--switch-thumb) - 4px));
    background: var(--ink);
}

input[data-switch]:focus-visible + .switch-track {
    outline: 2px solid color-mix(in srgb, var(--control-accent) 72%, white);
    outline-offset: 3px;
}

input[data-switch]:disabled + .switch-track {
    opacity: .45;
    cursor: not-allowed;
}

input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    display: inline-grid;
    place-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 50%;
    background-color: var(--bg-deep);
    background-image: none;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, .25);
    cursor: pointer;
    vertical-align: middle;
    transition: border-color .2s ease, box-shadow .2s ease, transform .12s ease;
}

input[type="radio"]:checked {
    border-color: var(--control-accent);
    background-image: radial-gradient(circle, var(--control-accent) 0 4.5px, transparent 5px);
    background-size: 11px 11px;
    box-shadow:
        inset 0 1px 4px rgba(0, 0, 0, .18),
        0 0 0 3px color-mix(in srgb, var(--control-accent) 18%, transparent);
    animation: jesk-radio-pop .26s ease;
}
input[type="radio"]:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--control-accent) 72%, white);
    outline-offset: 3px;
}
input[type="radio"]:disabled { opacity: .45; cursor: not-allowed; }

@keyframes jesk-radio-pop {
    0% { transform: scale(.82); }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    input[type="checkbox"],
    input[type="radio"],
    .switch-track,
    .switch-thumb {
        transition: none;
    }
    input[type="radio"]:checked { animation: none; }
    .toast { animation: none; }
}

/* Unified button contract aliases and touch targets. */
.btn.sm, .btn.small { min-height: 32px; padding: 5px 10px; font-size: var(--fs-meta); }
.btn.xs, .btn.tiny { min-height: 28px; padding: 3px 8px; font-size: var(--fs-meta); }
.btn.danger, .btn.danger-btn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.btn.danger:hover, .btn.danger-btn:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
.btn.secondary { background: transparent; color: var(--ink-soft); }
.btn.icon { padding: 0; width: 36px; min-width: 36px; }
.btn[aria-busy="true"] { cursor: progress; opacity: .7; }
.btn:active:not(:disabled) { transform: translateY(1px); }
@media (pointer: coarse) {
  .btn, .icon-btn, .chip { min-height: 44px; }
  .btn.icon, .icon-btn { min-width: 44px; }
}

/* Accessible overflow menus (details/summary). */
.ui-menu { position: relative; display: inline-block; }
.ui-menu > summary { list-style: none; cursor: pointer; }
.ui-menu > summary::-webkit-details-marker { display: none; }
.ui-menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
  min-width: 190px; max-height: min(70vh, 420px); overflow: auto;
  padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-control);
  background: var(--surface); box-shadow: 0 16px 40px rgba(0,0,0,.32);
}
.ui-menu-list a, .ui-menu-list button {
  display: flex; align-items: center; width: 100%; min-height: 36px;
  padding: 7px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-soft); text-align: left; text-decoration: none;
  font: inherit; cursor: pointer;
}
.ui-menu-list a:hover, .ui-menu-list button:hover, .ui-menu-list [role="menuitem"]:focus-visible {
  background: var(--surface-2); color: var(--ink); outline: none;
}
.ui-menu-meta { display: block; padding: 7px 10px; color: var(--muted); font-size: var(--fs-meta); }
@media (max-width: 480px) { .ui-menu-list { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; } }

/* Global live/reconnect indicator. */
.app-live {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px;
  padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: var(--fs-meta); white-space: nowrap;
}
.app-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.app-live[data-live-state="live"] { color: var(--good); }
.app-live[data-live-state="live"] .app-live-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 18%, transparent); }
.app-live[data-live-state="reconnect"] { color: var(--warm); }
.app-live[data-live-state="reconnect"] .app-live-dot { background: var(--warm); }
.app-live[data-live-state="offline"] { color: var(--bad); }
.app-live[data-live-state="offline"] .app-live-dot { background: var(--bad); }
@media (max-width: 600px) { .app-live [data-connection-label] { display: none; } }

/* Default chat profile picker (settings, project dialogs, automation). */
.default-profile {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
}

.default-profile-model {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    width: 100%;
    min-width: 0;
    height: 32px;
    min-height: 32px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-2);
    color: var(--ink-soft);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.default-profile-model:hover,
.default-profile-model:focus-visible {
    border-color: var(--accent);
    background: var(--surface-3);
    outline: none;
}

.default-profile-title {
    flex: 1 1 auto;
    max-width: 100%;
    overflow: hidden;
    font-size: var(--fs-small);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.default-profile-field {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 3px;
    flex: 0 0 auto;
    min-width: 92px;
    color: var(--muted);
    font-size: var(--fs-meta);
}

.default-profile-model-field {
    flex: 1 1 220px;
    min-width: 0;
}

.default-profile-model-field > span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.default-profile-field select {
    height: 32px;
    min-height: 32px;
    padding: 0 7px;
    border: 1px solid var(--line);
    border-radius: var(--radius-control);
    background: var(--surface-2);
    color: var(--ink-soft);
    font: inherit;
    font-size: var(--fs-small);
    color-scheme: dark;
}

@media (max-width: 620px) {
    .default-profile-field {
        flex: 1 1 0;
    }

    .default-profile-model-field {
        flex-basis: 100%;
    }
}
