/* ============================================================
   libadwaita tokens
   ============================================================ */
:root {
    --window-bg:        #fafafb;
    --sidebar-bg:       #ebebeb;
    --headerbar-bg:     #ebebeb;
    --headerbar-bg-backdrop: #f6f5f4;
    --card-bg:          #ffffff;
    --card-shade:       rgba(0,0,0,0.045);
    --view-bg:          #ffffff;
    --border:           rgba(0,0,0,0.12);
    --border-strong:    rgba(0,0,0,0.22);
    --overlay:          rgba(0,0,0,0.04);

    --fg:               #2e3436;
    --fg-dim:           #5e5c64;
    --fg-mute:          #9a9996;

    --accent:           #3584e4;
    --accent-fg:        #ffffff;
    --accent-hover:     #1c71d8;
    --accent-soft:      rgba(53,132,228,0.12);

    /* Resize affordances: shared thickness so H/V look the same on subpixel displays */
    --resize-line-thickness: 2px;
    --resize-line-thickness-hc: 3px;
    --resize-line-idle:  rgba(0, 0, 0, 0.11);
    --resize-line-hover: rgba(0, 0, 0, 0.36);

    --success:          #26a269;
    --warning:          #e5a50a;
    --error:            #c01c28;
    --error-soft:       rgba(192,28,40,0.10);

    --radius-card:      10px;
    --radius-button:    6px;
    --radius-pill:      999px;

    --font-body:        'Cantarell','Adwaita Sans',ui-sans-serif,sans-serif;
    --font-mono:        'IBM Plex Mono','Source Code Pro',ui-monospace,monospace;

    --h-tag:        #1c71d8;
    --h-tag-punct:  #5e5c64;
    --h-attr:       #26a269;
    --h-string:     #a51d2d;
    --h-doctype:    #613583;
    --h-comment:    #9a9996;
    --h-keyword:    #a51d2d;
    --h-number:     #c64600;
    --h-func:       #1c71d8;
}

:root.dark {
    --window-bg:        #242424;
    --sidebar-bg:       #2a2a2a;
    --headerbar-bg:     #303030;
    --headerbar-bg-backdrop: #2a2a2a;
    --card-bg:          #3a3a3a;
    --card-shade:       rgba(255,255,255,0.055);
    --view-bg:          #1e1e1e;
    --border:           rgba(255,255,255,0.10);
    --border-strong:    rgba(255,255,255,0.18);

    --fg:               #ffffff;
    --fg-dim:           #deddda;
    --fg-mute:          #9a9996;

    --accent:           #78aeed;
    --accent-fg:        #03172b;
    --accent-hover:     #99c1f1;
    --accent-soft:      rgba(120,174,237,0.18);

    --resize-line-thickness: 2px;
    --resize-line-thickness-hc: 3px;
    --resize-line-idle:  rgba(255, 255, 255, 0.10);
    --resize-line-hover: rgba(255, 255, 255, 0.38);

    --error-soft:       rgba(237,51,59,0.18);

    --h-tag:        #78aeed;
    --h-tag-punct:  #deddda;
    --h-attr:       #8ff0a4;
    --h-string:     #ff7b8a;
    --h-doctype:    #c061cb;
    --h-comment:    #77767b;
    --h-keyword:    #ff7b8a;
    --h-number:     #ffbe6f;
    --h-func:       #78aeed;
}

*,*::before,*::after { box-sizing: border-box; }
html,body {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    font-family: var(--font-body);
    color: var(--fg);
    background: var(--window-bg);
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior: none;
    touch-action: manipulation;
}
button, input, textarea {
    font: inherit; color: inherit;
    -webkit-tap-highlight-color: transparent;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.app {
    width: 100vw; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    background: var(--window-bg);
    overflow: hidden;
}

/* ============================================================
   Headerbar
   ============================================================ */
.headerbar {
    display: flex; align-items: center;
    height: 48px; min-height: 48px;
    padding: 0 8px 0 12px;
    background: var(--headerbar-bg);
    border-bottom: 1px solid var(--border);
    gap: 6px;
    user-select: none;
    flex-shrink: 0;
}
.app-title {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700;
    letter-spacing: 0.01em;
    min-width: 0;
    overflow: hidden;
}
.app-logo {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, #3584e4, #1c71d8);
    display: grid; place-items: center;
    color: white; font-weight: 800;
    font-family: var(--font-mono);
    font-size: 11px;
    box-shadow: 0 2px 6px rgba(53,132,228,0.35);
    flex-shrink: 0;
}
.app-title-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-title-sub {
    font-weight: 400;
    color: var(--fg-dim);
    font-size: 12px;
    padding-left: 10px;
    margin-left: 4px;
    border-left: 1px solid var(--border-strong);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toolbar-spacer { flex: 1; min-width: 0; }

.hb-btn {
    width: 34px; height: 34px;
    border: none; background: transparent;
    border-radius: var(--radius-button);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--fg);
    transition: background 120ms;
    flex-shrink: 0;
}
.hb-btn:hover { background: var(--card-shade); }
.hb-btn:active { background: var(--border); }
.hb-btn svg { width: 16px; height: 16px; }

.hb-toggle {
    padding: 0 12px;
    height: 32px;
    border-radius: var(--radius-button);
    border: 1px solid var(--border);
    background: var(--card-bg);
    cursor: pointer; color: var(--fg);
    font-size: 13px;
    display: inline-flex; align-items: center; gap: 7px;
    transition: all 120ms;
    font-weight: 500;
    flex-shrink: 0;
}
.hb-toggle:hover { background: var(--card-shade); }
.hb-toggle.primary {
    background: var(--accent); color: var(--accent-fg);
    border-color: transparent; font-weight: 600;
}
.hb-toggle.primary:hover { background: var(--accent-hover); }
.hb-toggle-label { display: inline; }

/* ============================================================
   Banner
   ============================================================ */
.banner-slot { flex-shrink: 0; }
.banner {
    background: linear-gradient(180deg, #fef3d0, #fbe89a);
    border-bottom: 1px solid #d4a017;
    color: #694a00;
    padding: 10px 14px;
    font-size: 13px;
    display: flex; align-items: center; gap: 10px;
    animation: slideDown 260ms cubic-bezier(.22,.61,.36,1);
}
:root.dark .banner {
    background: linear-gradient(180deg, #3d3017, #2a2211);
    color: #f2d375;
    border-bottom-color: #7a5c12;
}
.banner svg { width: 18px; height: 18px; flex-shrink: 0; }
.banner-text { flex: 1; min-width: 0; }
.banner-text b { font-weight: 700; }
.banner-btn {
    padding: 4px 10px;
    height: 28px;
    border-radius: var(--radius-button);
    border: 1px solid currentColor;
    background: transparent;
    color: inherit;
    font-size: 12px; cursor: pointer; font-weight: 600;
    flex-shrink: 0;
}
.banner-btn:hover { background: rgba(0,0,0,0.06); }
.banner-close {
    width: 28px; height: 28px;
    border-radius: var(--radius-button);
    border: none; background: transparent; color: inherit; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.banner-close:hover { background: rgba(0,0,0,0.06); }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ============================================================
   Main layout
   ============================================================ */
.main {
    --sidebar-w: 260px;
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 240ms cubic-bezier(.22,.61,.36,1), border-color 240ms;
    min-width: 0;
}
.sidebar.collapsed { width: 0; border-right-color: transparent; }
.sidebar-inner {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    display: flex; flex-direction: column;
    height: 100%;
}
.main-resize-handle {
    width: 2px;
    cursor: ew-resize;
    flex-shrink: 0;
    background: transparent;
    touch-action: none;
    z-index: 3;
    position: relative;
}
/* Wider invisible grab strip; never paint this or the bar looks “fat”. */
.main-resize-handle::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -4px; right: -4px;
    background: transparent;
}
/* Painted line: same thickness token as console resize (horizontal). */
.main-resize-handle::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: var(--resize-line-thickness);
    transform: translateX(-50%);
    background: var(--resize-line-idle);
    transition: background 120ms;
    pointer-events: none;
}
.main-resize-handle:hover::after,
.layout-resizing-sidebar .main-resize-handle::after { background: var(--resize-line-hover); }

@media (prefers-contrast: more) {
    .main-resize-handle::after {
        width: var(--resize-line-thickness-hc);
    }
    .main-resize-handle:hover::after,
    .layout-resizing-sidebar .main-resize-handle::after {
        background: var(--fg);
    }
}
.sidebar-toolbar {
    display: flex; align-items: center;
    padding: 8px 6px 8px 12px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    height: 40px; min-height: 40px;
    flex-shrink: 0;
}
.sidebar-title {
    flex: 1;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-mute);
}
.icon-btn {
    width: 28px; height: 28px;
    border: none; background: transparent;
    border-radius: var(--radius-button);
    cursor: pointer;
    color: var(--fg-dim);
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--card-shade); color: var(--fg); }
.icon-btn svg { width: 14px; height: 14px; }

/* ============================================================
   File tree + drag-and-drop
   ============================================================ */
.file-tree {
    flex: 1;
    overflow: auto;
    padding: 4px;
    position: relative;
}
.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 4px;
    border-radius: var(--radius-button);
    cursor: pointer;
    color: var(--fg-dim);
    font-size: 13px;
    user-select: none;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 30px;
    transition: background 80ms;
}
.tree-row:hover { background: var(--card-shade); }
.tree-row.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
:root.dark .tree-row.active { color: #fff; }
.tree-row.dragging { opacity: 0.35; }
.tree-row.drop-target-into {
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 2px var(--accent);
}
.tree-row.drop-target-before::before,
.tree-row.drop-target-after::after {
    content: '';
    position: absolute;
    left: 4px; right: 4px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
    pointer-events: none;
}
.tree-row.drop-target-before::before { top: -1px; }
.tree-row.drop-target-after::after   { bottom: -1px; }

.tree-row .chev {
    width: 14px; flex-shrink: 0;
    transition: transform 160ms;
    opacity: 0.7;
    display: inline-flex; align-items: center; justify-content: center;
}
.tree-row.folder .chev::before {
    content: '';
    display: inline-block;
    width: 0; height: 0;
    border-left: 4px solid currentColor;
    border-top: 3.5px solid transparent;
    border-bottom: 3.5px solid transparent;
    transition: transform 160ms;
}
.tree-row.folder.expanded .chev::before { transform: rotate(90deg); }
.tree-row:not(.folder) .chev { visibility: hidden; }
.tree-row .icon { width: 16px; height: 16px; flex-shrink: 0; }
.tree-row .icon svg { width: 16px; height: 16px; }
.tree-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.tree-row .row-action {
    display: none;
    width: 22px; height: 22px;
    border: none; background: transparent;
    border-radius: 4px;
    cursor: pointer;
    color: var(--fg-dim);
    align-items: center; justify-content: center;
    flex-shrink: 0;
}
.tree-row:hover .row-action { display: inline-flex; }
.tree-row .row-action:hover { background: var(--border); }
.tree-row .row-action svg { width: 12px; height: 12px; }
.tree-row .rename-input {
    flex: 1;
    padding: 2px 6px;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--fg);
    outline: none; font: inherit;
    min-width: 0;
}

.tree-drop-root {
    margin: 4px;
    padding: 10px;
    border: 1.5px dashed transparent;
    border-radius: var(--radius-button);
    color: var(--fg-mute);
    font-size: 11.5px;
    text-align: center;
    transition: all 120ms;
    min-height: 32px;
    display: none;
}
.file-tree.dragging .tree-drop-root { display: block; }
.tree-drop-root.drop-target-into {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

/* Touch drag helpers */
.tree-row.mobile-drag-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 0 0 2px var(--accent);
}
.dragging-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 600;
    background: var(--card-bg);
    border: 1px solid var(--accent);
    border-radius: var(--radius-button);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    padding: 6px 12px;
    font-size: 13px;
    color: var(--fg);
    display: flex; align-items: center; gap: 8px;
    opacity: 0.95;
    transform: translate(-50%, -50%);
    max-width: 260px;
    overflow: hidden;
}

/* ============================================================
   Sidebar footer
   ============================================================ */
.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--fg-mute);
    line-height: 1.4;
    flex-shrink: 0;
}
.seal {
    display: flex; align-items: center; gap: 8px;
    padding: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-button);
    font-size: 10.5px;
    color: var(--fg-dim);
    margin-bottom: 8px;
}
.seal-badge {
    width: 28px; height: 28px; border-radius: 50%;
    background: conic-gradient(from 0deg, #c01c28, #e5a50a, #26a269, #1c71d8, #613583, #c01c28);
    flex-shrink: 0;
    display: grid; place-items: center;
    color: white; font-weight: 700; font-size: 9px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4);
}

/* ============================================================
   Sidebar scrim (mobile)
   ============================================================ */
.sidebar-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms;
}
.sidebar-scrim.open { opacity: 1; pointer-events: auto; }

/* ============================================================
   Content
   ============================================================ */
.content {
    flex: 1;
    min-width: 0;
    display: flex; flex-direction: column;
    background: var(--view-bg);
    overflow: hidden;
}
.tabbar {
    display: flex; align-items: stretch;
    background: var(--headerbar-bg-backdrop);
    border-bottom: 1px solid var(--border);
    height: 36px; min-height: 36px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    scrollbar-width: thin;
}
.tabbar::-webkit-scrollbar { height: 3px; }
.tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 0 8px 0 14px;
    height: 100%;
    font-size: 13px;
    color: var(--fg-dim);
    background: transparent;
    border: none;
    border-right: 1px solid var(--border);
    cursor: pointer;
    white-space: nowrap;
    transition: background 120ms;
    position: relative;
    flex-shrink: 0;
}
.tab:hover { background: var(--card-shade); }
.tab.active {
    background: var(--view-bg);
    color: var(--fg);
    font-weight: 600;
}
.tab.active::after {
    content: ''; position: absolute;
    left: 0; right: 0; top: 0;
    height: 2px;
    background: var(--accent);
}
.tab-close {
    width: 22px; height: 22px;
    border: none; background: transparent;
    border-radius: 4px; cursor: pointer;
    color: var(--fg-dim);
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0.6;
}
.tab-close:hover { background: var(--border); opacity: 1; }
.tab-close svg { width: 10px; height: 10px; }
.tab-empty {
    padding: 0 14px;
    color: var(--fg-mute);
    font-size: 12px;
    font-style: italic;
    display: inline-flex; align-items: center;
}

.content-toolbar {
    display: flex; align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--headerbar-bg-backdrop);
    border-bottom: 1px solid var(--border);
    height: 40px; min-height: 40px;
    flex-shrink: 0;
}
.toolbar-breadcrumb {
    font-size: 12px;
    color: var(--fg-mute);
    font-family: var(--font-mono);
    padding: 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.toolbar-breadcrumb .crumb-sep { color: var(--fg-mute); margin: 0 4px; }
.toolbar-breadcrumb .crumb-file { color: var(--fg); font-weight: 600; }

.editor-area {
    flex: 1;
    display: flex; flex-direction: column;
    min-height: 0;
    overflow: hidden;
}
.editor-wrap {
    position: relative;
    background: var(--view-bg);
    overflow: hidden;
    display: flex;
    flex: 1;
    min-height: 0;
}
.line-numbers {
    padding: 14px 10px 14px 14px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--fg-mute);
    background: var(--view-bg);
    border-right: 1px solid var(--border);
    user-select: none;
    overflow: hidden;
    white-space: pre;
    min-width: 50px;
    line-height: 1.55;
    flex-shrink: 0;
}
.editor-inner {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.highlight-overlay, .code-editor {
    position: absolute;
    inset: 0;
    padding: 14px 16px;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.55;
    tab-size: 4;
    white-space: pre;
    overflow: auto;
    border: none;
}
.highlight-overlay {
    pointer-events: none;
    color: var(--fg);
    background: transparent;
    display: none;
}
.editor-inner.highlighted .highlight-overlay { display: block; }
.editor-inner.highlighted .code-editor {
    color: transparent;
    caret-color: var(--fg);
    background: transparent;
}
.code-editor {
    color: var(--fg);
    background: transparent;
    outline: none;
    resize: none;
}
.code-editor::selection { background: var(--accent-soft); }

.h-tag       { color: var(--h-tag); }
.h-tag-punct { color: var(--h-tag-punct); }
.h-attr      { color: var(--h-attr); }
.h-string    { color: var(--h-string); }
.h-doctype   { color: var(--h-doctype); font-weight: 600; }
.h-comment   { color: var(--h-comment); font-style: italic; }
.h-keyword   { color: var(--h-keyword); font-weight: 600; }
.h-number    { color: var(--h-number); }
.h-func      { color: var(--h-func); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-mute); background-clip: padding-box; border: 2px solid transparent; }

.editor-empty {
    flex: 1;
    display: grid; place-items: center;
    padding: 40px;
    text-align: center;
    color: var(--fg-mute);
}
.editor-empty .ee-title { font-size: 18px; font-weight: 600; color: var(--fg-dim); margin-bottom: 8px; }
.editor-empty .ee-desc { font-size: 13px; max-width: 380px; line-height: 1.6; }

/* ============================================================
   Popover
   ============================================================ */
.popover {
    position: fixed;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: 0 8px 20px rgba(0,0,0,0.16), 0 2px 6px rgba(0,0,0,0.10);
    padding: 6px;
    min-width: 220px;
    max-width: min(300px, calc(100vw - 16px));
    z-index: 250;
    opacity: 0;
    transform: translateY(-4px) scale(0.985);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 130ms ease, transform 130ms ease;
}
.popover.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.popover-item {
    display: flex;
    width: 100%;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--fg);
    border-radius: var(--radius-button);
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    gap: 10px;
    align-items: center;
    min-height: 36px;
}
.popover-item:hover { background: var(--card-shade); }
.popover-item:focus-visible { background: var(--card-shade); outline: none; }
.popover-item.destructive { color: var(--error); }
.popover-sep { height: 1px; background: var(--border); margin: 4px 0; }
.popover-item .kbd {
    margin-left: auto;
    font-size: 11px;
    color: var(--fg-mute);
    font-family: var(--font-mono);
}
.popover-item svg { width: 14px; height: 14px; opacity: 0.8; flex-shrink: 0; }

/* ============================================================
   Dialogs
   ============================================================ */
.dialog-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 9999 !important;
    display: grid;
    place-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms;
    padding: 16px;
}
.dialog-backdrop.open { opacity: 1; pointer-events: auto; }
.dialog {
    background: var(--window-bg);
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.40);
    width: min(600px, 100%);
    max-height: calc(100dvh - 32px);
    display: flex; flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 180ms;
}
.dialog-backdrop.open .dialog { transform: scale(1); }
.dialog-header {
    height: 48px;
    padding: 0 6px 0 16px;
    display: flex; align-items: center;
    background: var(--headerbar-bg);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}
.dialog-body {
    padding: 18px;
    overflow: auto;
    flex: 1;
    min-height: 0;
}
.dialog-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--headerbar-bg-backdrop);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.pref-group { margin-bottom: 12px; }
.pref-group:last-child { margin-bottom: 0; }
.pref-group-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-dim);
    margin: 0 0 8px 2px;
}
.pref-list {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    overflow: hidden;
}
.pref-row {
    padding: 12px 14px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border);
}
.pref-row:last-child { border-bottom: none; }
.pref-row-text { flex: 1; min-width: 0; }
.pref-row-title {
    font-size: 13.5px; color: var(--fg); font-weight: 500;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.pref-row-title .lock-badge {
    font-size: 10px;
    padding: 1px 6px;
    background: var(--error-soft);
    color: var(--error);
    border-radius: var(--radius-pill);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.pref-row-sub { font-size: 11.5px; color: var(--fg-mute); margin-top: 3px; line-height: 1.45; }
.pref-row-sub b { color: var(--warning); }
.pref-row-sub code { font-family: var(--font-mono); background: var(--card-shade); padding: 1px 4px; border-radius: 3px; }

.switch {
    position: relative;
    width: 46px; height: 28px;
    flex-shrink: 0;
    cursor: pointer;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute;
    inset: 0;
    background: #bfbfbf;
    border-radius: var(--radius-pill);
    transition: background 160ms;
}
:root.dark .switch .slider { background: #555; }
.switch .slider::before {
    content: '';
    position: absolute;
    height: 24px; width: 24px;
    top: 2px; left: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 160ms;
    box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }
.switch.locked .slider { opacity: 0.75; cursor: not-allowed; }
.switch.locked .slider::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='white'><path d='M4 7V5a4 4 0 118 0v2h1v8H3V7zm2 0h4V5a2 2 0 10-4 0z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 6px center;
    opacity: 0.9;
}

.btn {
    padding: 8px 16px;
    border-radius: var(--radius-button);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--fg);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 120ms;
    min-height: 36px;
}
.btn:hover { background: var(--card-shade); }
.btn.suggested {
    background: var(--accent);
    color: var(--accent-fg);
    border-color: transparent; font-weight: 600;
}
.btn.suggested:hover { background: var(--accent-hover); }
.btn.destructive {
    background: var(--error);
    color: white;
    border-color: transparent;
    font-weight: 600;
}

.prompt-input, .asm-edit-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-button);
    background: var(--card-bg);
    color: var(--fg);
    font-size: 14px;
    outline: none;
    transition: border-color 120ms, box-shadow 120ms;
    font-family: var(--font-mono);
}
.prompt-input:focus, .asm-edit-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.prompt-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--fg);
}
.prompt-error {
    font-size: 12px;
    color: var(--error);
    margin-top: 8px;
    min-height: 16px;
}

.about-icon {
    width: 80px; height: 80px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, #3584e4, #1c71d8);
    border-radius: 20px;
    display: grid; place-items: center;
    color: white; font-size: 32px; font-weight: 800;
    box-shadow: 0 6px 20px rgba(53,132,228,0.4);
    font-family: var(--font-mono);
}
.about-title { text-align: center; font-size: 18px; font-weight: 700; margin: 0 0 2px; }
.about-version { text-align: center; color: var(--fg-mute); font-size: 12px; margin-bottom: 18px; }
.about-body { font-size: 13px; color: var(--fg-dim); text-align: center; line-height: 1.6; }
.about-body strong { color: var(--fg); }
.about-meta {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--fg-mute);
    text-align: center;
    font-family: var(--font-mono);
}
.curriculum-row {
    display: grid;
    grid-template-columns: 1fr auto;
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    gap: 12px;
    font-size: 13px;
}
.curriculum-row:last-child { border: none; }
.curriculum-row code { font-family: var(--font-mono); color: var(--accent); font-size: 12px; word-break: break-word; }
.curriculum-row.banned code { color: var(--error); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.curriculum-row .year { color: var(--fg-mute); font-size: 11px; font-family: var(--font-mono); }

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(20px);
    background: #2e3436;
    color: white;
    padding: 10px 16px;
    border-radius: var(--radius-pill);
    font-size: 13px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    opacity: 0;
    pointer-events: none;
    transition: all 240ms;
    z-index: 10000 !important;
    max-width: calc(100vw - 32px);
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Statusbar
   ============================================================ */
.statusbar {
    height: 26px;
    min-height: 26px;
    padding: 0 12px;
    background: var(--headerbar-bg);
    border-top: 1px solid var(--border);
    display: flex; align-items: center;
    font-size: 11.5px;
    color: var(--fg-dim);
    gap: 14px;
    font-family: var(--font-mono);
    flex-shrink: 0;
    overflow: hidden;
}
.status-ok { color: var(--success); }
.status-err { color: var(--error); }
.status-sep { opacity: 0.4; }
.statusbar > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-right { display: flex; gap: 14px; margin-left: auto; flex-shrink: 0; }

/* ============================================================
   Mobile responsive
   ============================================================ */
@media (max-width: 900px) {
    .dbg-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto auto auto;
        grid-template-areas: "funcs" "disasm" "regs" "stack" "log";
    }
    .dbg-funcs { max-height: 140px; border-right-width: 0; border-bottom-width: 1px; }
    .dbg-regs-pane { max-height: 180px; border-right-width: 0; border-bottom-width: 1px; }
    .dbg-stack-pane { max-height: 160px; border-right-width: 0; border-bottom-width: 1px; }
    .dbg-log-pane { max-height: 160px; }
    .disasm-line { grid-template-columns: 20px 90px 1fr auto; gap: 8px; font-size: 12px; }
    .disasm-bytes { display: none; }
    @media (min-width: 640px) {
        .disasm-line { grid-template-columns: 20px 90px 120px 1fr auto; }
        .disasm-bytes { display: inline; }
    }
    .dbg-func-list { display: flex; overflow-x: auto; overflow-y: hidden; padding: 6px; gap: 6px; }
    .dbg-func-item { flex-shrink: 0; min-width: 200px; margin-bottom: 0; }
    .dbg-toolbar { padding: 8px 10px; flex-wrap: nowrap; overflow-x: auto; }
    .dbg-btn, .dbg-select { height: 30px; }
    .dbg-btn { padding: 0 12px; }
    .dbg-exploit { width: auto; flex-wrap: nowrap; }
    .disasm-actions { visibility: visible; opacity: 1; }
    .dbg-docs-panel {
        top: 96px;
        width: calc(100% - 16px);
        max-height: calc(100% - 104px);
    }
    .dbg-help {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .dbg-help-nav {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
    }
    .dbg-help-tab { flex: 1 1 160px; }
    .dbg-help-main { max-width: none; }
}

@media (min-width: 721px) and (max-width: 1024px) {
    .dbg-toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    .dbg-exploit {
        flex-wrap: nowrap;
        gap: 6px;
    }
    .dbg-select { min-width: 240px; }
}

@media (max-width: 720px) {
    .app-title-sub { display: none; }
    .hb-toggle-label { display: none; }
    .hb-toggle { padding: 0 10px; }
    .sidebar {
        position: absolute;
        left: 0; top: 0; bottom: 0;
        width: min(300px, 85vw);
        z-index: 30;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
        transform: translateX(-100%);
        transition: transform 240ms cubic-bezier(.22,.61,.36,1);
        border-right: 1px solid var(--border);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar.collapsed {
        width: min(300px, 85vw);
        transform: translateX(-100%);
        border-right: 1px solid var(--border);
    }
    .sidebar-inner { width: 100%; min-width: 0; }
    .main-resize-handle { display: none; }
    .content { width: 100%; }
    .dialog {
        width: 100%;
        max-height: calc(100dvh - 16px);
    }
    .dialog-backdrop { padding: 8px; }
    .dialog-footer { padding: 10px; }
    .dialog-footer .btn { flex: 1; min-width: 0; }
    .statusbar { font-size: 10.5px; gap: 10px; padding: 0 8px; }
    .statusbar .status-sep:nth-of-type(n+3) { display: none; }
    .statusbar > span:nth-child(n+5) { display: none; }
    .status-right > span:nth-child(n+2) { display: none; }
}

@media (max-width: 480px) {
    .app-title-name { font-size: 13px; }
    .app-logo { width: 24px; height: 24px; font-size: 10px; }
    .tab { padding: 0 6px 0 10px; font-size: 12px; }
    .headerbar { gap: 4px; padding: 0 6px; }
    .hb-btn { width: 36px; height: 36px; }
    .hb-toggle { height: 34px; min-height: 34px; }
    .output-panel { height: 200px; }
    .line-numbers { min-width: 38px; padding: 14px 8px 14px 8px; font-size: 12px; }
    .highlight-overlay, .code-editor { padding: 12px; font-size: 12px; }
    .banner { padding: 10px 12px; font-size: 12px; gap: 8px; flex-wrap: wrap; }
    .banner-btn { flex: 1; min-width: 120px; }
    .new-file-fields { grid-template-columns: 1fr; }
    .shell-screen { height: min(50vh, 360px); }
    .qnx-session { padding: 8px; }
    .qnx-window-frame { width: calc(100vw - 16px); height: calc(100vh - 16px); border-radius: 6px; }
    .qnx-window { width: calc(100vw - 50px); left: 12px !important; }
}

/* Touch targets */
@media (hover: none) and (pointer: coarse) {
    .tree-row .row-action { display: inline-flex; }
    .disasm-actions { visibility: visible; }
}
