/*
    main.css
    M Daniel Lana · VS Code simulation
    Layout: CSS Grid. Colors: custom properties per [data-theme].
*/

/* ==========================================================================
   Themes
   ========================================================================== */

:root,
[data-theme="mdl-dark"] {
    color-scheme: dark;
    --bg: #1a1d23;
    --bg-side: #15171c;
    --bg-bar: #111317;
    --bg-panel: #16181d;
    --bg-input: #0f1114;
    --bg-widget: #1f232a;
    --bg-hover: rgba(255, 255, 255, .06);
    --bg-active: rgba(255, 255, 255, .1);
    --bg-line: rgba(255, 255, 255, .04);
    --bg-select: rgba(105, 142, 239, .28);
    --bg-flash: rgba(231, 47, 95, .18);
    --border: #262a33;
    --fg: #c0c0c0;
    --fg-muted: #7d8590;
    --fg-strong: #f1f1f1;
    --accent: #e72f5f;
    --accent-fg: #fff;
    --focus: #698eef;
    --ln: #4a6470;
    --ln-active: #76c9e1;
    --guide: rgba(255, 255, 255, .07);

    --tok-comment: #3fa55f;
    --tok-keyword: #5f78e0;
    --tok-control: #b77ee0;
    --tok-type: #76a0f5;
    --tok-ns: #c0c0c0;
    --tok-string: #d05a7c;
    --tok-number: #b5cea8;
    --tok-fn: #e0c98a;
    --tok-prop: #8fc7e8;
    --tok-var: #c0c0c0;
    --tok-punct: #8b929b;
    --tok-heading: #e72f5f;
    --tok-code: #d7a35b;

    --error: #e72f5f;
    --warning: #ff8c4a;
    --info: #76c9e1;
    --success: #3fcf63;

    --term-fg: #c6c6c6;
    --term-prompt: #22da26;

    --hero-hi: #f1f1f1;
    --hero-name: #e72f5f;
    --shadow: 0 8px 28px rgba(0, 0, 0, .55);
}

[data-theme="monokai"] {
    color-scheme: dark;
    --bg: #272822;
    --bg-side: #1e1f1c;
    --bg-bar: #1a1b17;
    --bg-panel: #1e1f1c;
    --bg-input: #191a16;
    --bg-widget: #2d2e27;
    --bg-hover: rgba(255, 255, 255, .06);
    --bg-active: rgba(255, 255, 255, .1);
    --bg-line: rgba(255, 255, 255, .05);
    --bg-select: rgba(73, 72, 62, .9);
    --bg-flash: rgba(249, 38, 114, .2);
    --border: #3b3c35;
    --fg: #f8f8f2;
    --fg-muted: #90908a;
    --fg-strong: #ffffff;
    --accent: #f92672;
    --accent-fg: #fff;
    --focus: #66d9ef;
    --ln: #6f705e;
    --ln-active: #e6db74;
    --guide: rgba(255, 255, 255, .08);

    --tok-comment: #88846f;
    --tok-keyword: #f92672;
    --tok-control: #f92672;
    --tok-type: #66d9ef;
    --tok-ns: #f8f8f2;
    --tok-string: #e6db74;
    --tok-number: #ae81ff;
    --tok-fn: #a6e22e;
    --tok-prop: #fd971f;
    --tok-var: #f8f8f2;
    --tok-punct: #c0c0b8;
    --tok-heading: #a6e22e;
    --tok-code: #e6db74;

    --error: #f92672;
    --warning: #fd971f;
    --info: #66d9ef;
    --success: #a6e22e;

    --term-fg: #f8f8f2;
    --term-prompt: #a6e22e;

    --hero-hi: #f8f8f2;
    --hero-name: #f92672;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #ffffff;
    --bg-side: #f3f3f3;
    --bg-bar: #e8e8e8;
    --bg-panel: #f8f8f8;
    --bg-input: #ffffff;
    --bg-widget: #f3f3f3;
    --bg-hover: rgba(0, 0, 0, .05);
    --bg-active: rgba(0, 0, 0, .09);
    --bg-line: rgba(0, 0, 0, .035);
    --bg-select: rgba(0, 96, 192, .18);
    --bg-flash: rgba(196, 30, 74, .14);
    --border: #dcdcdc;
    --fg: #2b2f36;
    --fg-muted: #6e7681;
    --fg-strong: #111;
    --accent: #c41e4a;
    --accent-fg: #fff;
    --focus: #0060c0;
    --ln: #9aa0a6;
    --ln-active: #0b216f;
    --guide: rgba(0, 0, 0, .09);

    --tok-comment: #008000;
    --tok-keyword: #0000ff;
    --tok-control: #af00db;
    --tok-type: #267f99;
    --tok-ns: #2b2f36;
    --tok-string: #a31515;
    --tok-number: #098658;
    --tok-fn: #795e26;
    --tok-prop: #001080;
    --tok-var: #001080;
    --tok-punct: #444;
    --tok-heading: #c41e4a;
    --tok-code: #a31515;

    --error: #e51400;
    --warning: #bf6e00;
    --info: #1a85ff;
    --success: #2a8a3e;

    --term-fg: #2b2f36;
    --term-prompt: #0f7b0f;

    --hero-hi: #2b2f36;
    --hero-name: #c41e4a;
    --shadow: 0 8px 24px rgba(0, 0, 0, .18);
}

/* ==========================================================================
   Base
   ========================================================================== */

:root {
    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
    --font-code: "Inconsolata", ui-monospace, "Cascadia Code", Consolas, monospace;
    --font-brand: "Share Tech Mono", ui-monospace, monospace;
    --code-size: clamp(14px, .45vw + 10px, 18px);
    --activity-w: 48px;
    --sidebar-w: 250px;
    --titlebar-h: 34px;
    --statusbar-h: 24px;
    --panel-h: 34%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    display: grid;
    grid-template-rows: auto var(--titlebar-h) minmax(0, 1fr) var(--statusbar-h);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--bg);
    color: var(--fg);
    font: 13px/1.4 var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body.resizing {
    cursor: ns-resize;
    user-select: none;
}

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

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

kbd {
    font-family: var(--font-ui);
}

:focus-visible {
    outline: 1px solid var(--focus);
    outline-offset: -1px;
}

[hidden] {
    display: none !important;
}

.ico {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.ico-filled {
    fill: currentColor;
    stroke: none;
}

.ico-ellipsis {
    stroke-width: 2.6;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    color: var(--fg-muted);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--fg-strong);
}

.skip-link {
    position: absolute;
    left: 8px;
    top: -40px;
    z-index: 100;
    padding: 6px 10px;
    background: var(--accent);
    color: var(--accent-fg);
    border-radius: 4px;
}

.skip-link:focus {
    top: 8px;
}

.sev-error,
.t-error { color: var(--error); }
.sev-warning,
.t-warning { color: var(--warning); }
.sev-info { color: var(--info); }
.t-success { color: var(--success); }

.spin {
    animation: spin 1s linear infinite;
}

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

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px 32px;
    padding: clamp(12px, 2vh, 24px) clamp(16px, 3vw, 40px) clamp(10px, 1.6vh, 18px) calc(var(--activity-w) + clamp(12px, 2vw, 24px));
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-brand);
    position: relative;
    overflow: hidden;
}

.hero::after {
    /* soft glow behind the name */
    content: "";
    position: absolute;
    left: 10%;
    top: -60%;
    width: 50%;
    height: 200%;
    background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
    pointer-events: none;
}

.hero-id,
.hero-links {
    position: relative;
    z-index: 1;
}

.hero p {
    margin: 0;
}

.hero-hi {
    color: var(--hero-hi);
    font-size: clamp(14px, 1.4vw, 22px);
    line-height: 1.1;
}

.hero-name {
    margin: 0;
    color: var(--hero-name);
    font-weight: 400;
    font-size: clamp(28px, 4.6vw, 64px);
    line-height: 1;
    letter-spacing: .02em;
    text-shadow: 0 0 24px color-mix(in srgb, var(--hero-name) 35%, transparent);
}

.hero-role {
    color: var(--hero-hi);
    font-size: clamp(14px, 1.7vw, 26px);
    line-height: 1.2;
    min-height: 1.2em;
}

.hero-caret {
    color: var(--accent);
    animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.hero-links {
    display: grid;
    gap: 4px;
    font-size: clamp(13px, 1.25vw, 19px);
}

.hero-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--fg-muted);
    transition: color .2s, transform .2s;
}

.hero-link:hover,
.hero-link:focus-visible {
    color: var(--fg-strong);
    transform: translateX(3px);
}

.hero-link:nth-child(1) { color: #4a8ad0; }
.hero-link:nth-child(2) { color: #6b66d8; }
[data-theme="light"] .hero-link:nth-child(1) { color: #1f62b0; }
[data-theme="light"] .hero-link:nth-child(2) { color: #4a43b8; }

.hero-link-icon .ico {
    width: 1.05em;
    height: 1.05em;
}

.hero-link .sep {
    color: var(--fg-muted);
    opacity: .55;
    margin: 0 .05em;
}

/* ==========================================================================
   Title bar
   ========================================================================== */

.titlebar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 8px;
    background: var(--bg-bar);
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.titlebar-logo,
.titlebar-burger {
    display: grid;
    place-items: center;
    width: var(--activity-w);
    height: 100%;
    flex: none;
    color: var(--fg);
}

.titlebar-logo .ico {
    width: 20px;
    height: 20px;
}

.titlebar-logo:hover {
    color: var(--fg-strong);
}

.titlebar-burger {
    display: none;
}

.menubar {
    display: flex;
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
}

.menubar-item {
    padding: 4px 9px;
    border-radius: 5px;
    color: var(--fg);
    white-space: nowrap;
}

.menubar-item:hover,
.menubar-item.open {
    background: var(--bg-hover);
    color: var(--fg-strong);
}

.command-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 1 420px;
    min-width: 120px;
    margin: 0 auto;
    height: 24px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--fg-muted);
}

.command-center:hover {
    background: var(--bg-active);
    color: var(--fg-strong);
}

.command-center .ico {
    width: 14px;
    height: 14px;
}

.titlebar-spacer {
    flex: 0 1 140px;
}

/* ==========================================================================
   Workbench
   ========================================================================== */

.workbench {
    display: grid;
    grid-template-columns: var(--activity-w) var(--sidebar-w) minmax(0, 1fr);
    min-height: 0;
    position: relative;
}

.workbench.sidebar-closed {
    grid-template-columns: var(--activity-w) 0 minmax(0, 1fr);
}

.workbench.sidebar-closed .sidebar {
    visibility: hidden;
}

/* Activity bar */
.activitybar {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-bar);
    border-right: 1px solid var(--border);
    z-index: 6;
    overflow-y: auto;
    scrollbar-width: none;
}

.activity-top,
.activity-bottom {
    display: flex;
    flex-direction: column;
}

.activity {
    position: relative;
    display: grid;
    place-items: center;
    width: var(--activity-w);
    height: var(--activity-w);
    color: var(--fg-muted);
    transition: color .15s;
}

.activity .ico {
    width: 24px;
    height: 24px;
    stroke-width: 1.4;
    transition: transform .15s;
}

.activity:hover {
    color: var(--fg-strong);
}

.activity:hover .ico {
    transform: scale(1.08);
}

.activity.active {
    color: var(--fg-strong);
}

.activity.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
}

/* Pulse badge on run / fix, like the original page */
.activity.pulse::after {
    content: "";
    position: absolute;
    top: 10px;
    right: 9px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00bfd8;
    box-shadow: 0 0 0 0 rgba(0, 191, 216, .6);
    animation: pulse 2.2s ease-out infinite;
}

.activity[data-activity="fix"].pulse::after {
    background: var(--accent);
    animation-name: pulse-accent;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 191, 216, .7); }
    70%, 100% { box-shadow: 0 0 0 8px rgba(0, 191, 216, 0); }
}

@keyframes pulse-accent {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); }
    70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

/* Side bar */
.sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-side);
    border-right: 1px solid var(--border);
}

.sidebar-backdrop {
    display: none;
}

.sidebar-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 35px;
    flex: none;
    padding: 0 8px 0 20px;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.sidebar-close {
    display: none;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-top: 1px solid var(--border);
}

.sidebar-section.grow {
    flex: 1;
}

.sidebar-section.scroll,
.sidebar-section .tree {
    overflow-y: auto;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 22px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--fg);
}

.section-count {
    margin-left: auto;
    margin-right: 8px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--bg-active);
    font-weight: 400;
}

.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    height: 24px;
    padding: 0 10px 0 calc(var(--depth, 1) * 10px);
    text-align: left;
    color: var(--fg);
    white-space: nowrap;
}

.tree-row:hover {
    background: var(--bg-hover);
}

.tree-row.active {
    background: var(--bg-active);
    color: var(--fg-strong);
}

.tree-twistie {
    display: inline-grid;
    place-items: center;
    width: 16px;
    flex: none;
}

.tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-desc {
    color: var(--fg-muted);
    font-size: 12px;
}

.tree-error .tree-label { color: var(--error); }
.tree-warning .tree-label { color: var(--warning); }

.tree-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 11px;
    text-align: center;
    background: color-mix(in srgb, currentColor 18%, transparent);
}

.tree-error .tree-badge { color: var(--error); }
.tree-warning .tree-badge { color: var(--warning); }

.tree-empty {
    margin: 4px 20px;
    color: var(--fg-muted);
}

.tree-ico {
    color: var(--fg-muted);
}

/* File type badges */
.file-icon {
    display: inline-block;
    min-width: 18px;
    font: 700 10px/1 var(--font-ui);
    text-align: center;
    flex: none;
}

.fi-cs { color: #a074c4; }
.fi-json { color: #cbcb41; }
.fi-md { color: #519aba; }
.fi-txt { color: var(--fg-muted); }

/* Extensions view */
.ext-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    padding: 8px 12px 8px 16px;
    text-align: left;
}

.ext-row:hover {
    background: var(--bg-hover);
}

.ext-logo {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--c) 22%, transparent);
    color: var(--c);
    font: 700 15px/1 var(--font-code);
    border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}

.ext-logo-project {
    --c: var(--accent);
}

.ext-info {
    display: grid;
    min-width: 0;
}

.ext-name {
    font-weight: 600;
    color: var(--fg-strong);
}

.ext-detail,
.ext-publisher {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fg-muted);
    font-size: 12px;
}

.ext-publisher {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ext-verified {
    width: 12px;
    height: 12px;
    color: var(--info);
}

.ext-installed {
    font-size: 11px;
    color: var(--fg-muted);
}

/* ==========================================================================
   Main area: editor + panel
   ========================================================================== */

.main-area {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    min-width: 0;
    min-height: 0;
    background: var(--bg);
}

.main-area.panel-open {
    grid-template-rows: minmax(80px, 1fr) var(--panel-h);
}

.main-area.panel-open.panel-max {
    grid-template-rows: 0 minmax(0, 1fr);
}

.main-area:not(.panel-open) .panel {
    display: none;
}

.editor-group {
    display: grid;
    grid-template-rows: 35px 24px minmax(0, 1fr);
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.editor-group.empty {
    grid-template-rows: 35px 0 minmax(0, 1fr);
}

/* Tabs */
.tabs-row {
    display: flex;
    background: var(--bg-side);
    min-width: 0;
}

.tabs {
    display: flex;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}

.tabs::-webkit-scrollbar {
    height: 3px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
    height: 35px;
    padding: 0 6px 0 12px;
    border-right: 1px solid var(--border);
    color: var(--fg-muted);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
}

.tab:hover {
    color: var(--fg);
}

.tab.active {
    background: var(--bg);
    color: var(--fg-strong);
}

.tab.active::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--accent);
}

.tab-error .tab-label { color: var(--error); }
.tab-warning .tab-label { color: var(--warning); }

.tab-count {
    font-size: 11px;
    color: inherit;
    opacity: .8;
}

.tab-error .tab-count { color: var(--error); }
.tab-warning .tab-count { color: var(--warning); }

.tab-mode {
    font-size: 11px;
    font-style: italic;
    color: var(--fg-muted);
}

.tab-close {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    opacity: 0;
}

.tab.active .tab-close,
.tab:hover .tab-close,
.tab:focus-visible .tab-close {
    opacity: 1;
}

.tab-close:hover {
    background: var(--bg-hover);
}

.tab-close .ico {
    width: 14px;
    height: 14px;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 6px;
    flex: none;
}

.action-run {
    color: var(--success);
}

/* Breadcrumbs */
.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 14px;
    color: var(--fg-muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    border-bottom: 1px solid transparent;
}

.crumb {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.crumb-sep {
    width: 12px;
    height: 12px;
    opacity: .6;
}

.sym {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.sym-namespace { border: 1.5px solid var(--fg-muted); }
.sym-class { background: #ee9d28; }
.sym-method { background: #b180d7; transform: rotate(45deg) scale(.8); }

/* Progress bar (under tabs) */
.editor-progress {
    position: absolute;
    left: 0;
    right: 0;
    top: 35px;
    height: 2px;
    z-index: 3;
    opacity: 0;
    transition: opacity .3s;
}

.editor-progress.active {
    opacity: 1;
}

.editor-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, transparent, var(--accent));
    transition: width .1s linear;
}

/* Editor body */
.editor-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 92px;
    min-height: 0;
    position: relative;
}

.no-minimap .editor-body,
.editor-body:has(.preview:not([hidden])) {
    grid-template-columns: minmax(0, 1fr);
}

.no-minimap .minimap {
    display: none;
}

.editor {
    --ln-chars: 2;
    overflow: auto;
    min-height: 0;
    padding: 4px 0 40vh;
    font-family: var(--font-code);
    font-size: var(--code-size);
    font-weight: 300;
    line-height: 1.65;
    color: var(--fg);
    scrollbar-color: var(--bg-active) transparent;
    outline: none;
}

.editor:focus-visible {
    box-shadow: inset 0 0 0 1px var(--focus);
}

.lines {
    min-width: max-content;
}

.editor.wrap .lines {
    min-width: 0;
}

.line {
    display: grid;
    grid-template-columns: 18px calc(var(--ln-chars) * 1ch + 1.4ch) 18px minmax(0, 1fr);
    align-items: start;
    position: relative;
    border: 1px solid transparent;
    border-left: 0;
    border-right: 0;
}

.line.active {
    border-color: var(--bg-active);
    background: var(--bg-line);
}

.line.flash {
    animation: flash 1.2s ease-out;
}

@keyframes flash {
    from { background: var(--bg-flash); }
}

.ln {
    text-align: right;
    color: var(--ln);
    font-family: var(--font-code);
    font-size: .82em;
    line-height: inherit;
    padding-top: .1em;
    user-select: none;
}

.line.active .ln {
    color: var(--ln-active);
}

.glyph {
    display: grid;
    place-items: center;
    height: 1.65em;
}

.lightbulb {
    color: #f5c242;
    animation: bulb 2.4s ease-in-out infinite;
}

.lightbulb .ico {
    width: 15px;
    height: 15px;
    fill: color-mix(in srgb, #f5c242 35%, transparent);
}

@keyframes bulb {
    50% { opacity: .55; }
}

.fold {
    display: grid;
    place-items: center;
    height: 1.65em;
    color: var(--fg-muted);
    opacity: 0;
    transition: opacity .2s;
}

.fold .ico {
    width: 14px;
    height: 14px;
}

.editor:hover .fold,
.fold.is-collapsed,
.fold:focus-visible {
    opacity: 1;
}

.code {
    display: block;
    padding-left: var(--ind);
    padding-right: 2ch;
    white-space: pre;
    background-image: repeating-linear-gradient(90deg, var(--guide) 0 1px, transparent 1px 4ch);
    background-size: var(--ind) 100%;
    background-repeat: no-repeat;
}

.editor.wrap .code {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding-left: calc(var(--ind) + 2ch);
    text-indent: -2ch;
}

.code a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
    text-underline-offset: 2px;
}

.code a:hover {
    text-decoration-color: currentColor;
}

.fold-ellipsis {
    margin: 0 .4ch;
    padding: 0 .4ch;
    border: 1px solid var(--fg-muted);
    border-radius: 3px;
    color: var(--fg-muted);
    font-size: .85em;
    line-height: 1.2;
    text-indent: 0;
    background: var(--bg-hover);
}

.fold-ellipsis:hover {
    color: var(--fg-strong);
}

/* Tokens */
.t-comment { color: var(--tok-comment); font-style: italic; }
.t-keyword { color: var(--tok-keyword); }
.t-control { color: var(--tok-control); }
.t-type { color: var(--tok-type); }
.t-ns { color: var(--tok-ns); }
.t-string { color: var(--tok-string); }
.t-number { color: var(--tok-number); }
.t-fn { color: var(--tok-fn); }
.t-prop { color: var(--tok-prop); }
.t-var { color: var(--tok-var); }
.t-punct { color: var(--tok-punct); }
.t-heading { color: var(--tok-heading); font-weight: 500; }
.t-quote { color: var(--tok-comment); }
.t-quoted { font-style: italic; }
.t-bold { font-weight: 500; color: var(--fg-strong); }
.t-italic { font-style: italic; }
.t-code { color: var(--tok-code); }
.t-link-text { color: var(--tok-type); }
.t-link-url { color: var(--tok-string); }

/* Diagnostics */
.squiggle {
    text-decoration-line: underline;
    text-decoration-style: wavy;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
    cursor: help;
}

.squiggle-error { text-decoration-color: var(--error); }
.squiggle-warning { text-decoration-color: var(--warning); }
.squiggle-info { text-decoration-style: dotted; text-decoration-color: var(--info); }

.lens {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 3ch;
    padding: 0 8px;
    border-radius: 3px;
    font-family: var(--font-ui);
    font-size: .72em;
    font-weight: 400;
    font-style: italic;
    line-height: 1.6;
    text-indent: 0;
    white-space: nowrap;
    vertical-align: 1px;
    cursor: help;
    animation: lens-in .5s ease-out both;
}

.lens .ico {
    width: 12px;
    height: 12px;
}

.lens-error { color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }
.lens-warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 10%, transparent); }
.lens-info { color: var(--info); background: color-mix(in srgb, var(--info) 8%, transparent); }

.line.has-error { background: color-mix(in srgb, var(--error) 5%, transparent); }
.line.has-warning { background: color-mix(in srgb, var(--warning) 4%, transparent); }

@keyframes lens-in {
    from { opacity: 0; transform: translateX(-8px); }
}

.caret {
    display: inline-block;
    width: 0;
    height: 1.2em;
    margin-right: -2px;
    border-left: 2px solid var(--fg-strong);
    vertical-align: text-bottom;
    animation: blink 1s steps(1) infinite;
}

/* Intro animation for the first file */
.editor.intro .line {
    animation: line-in .45s ease-out both;
    animation-delay: calc(var(--i) * 30ms);
}

@keyframes line-in {
    from { opacity: 0; transform: translateX(-12px); }
}

/* Minimap */
.minimap {
    position: relative;
    border-left: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.minimap canvas {
    position: absolute;
    inset: 0;
}

.minimap-slider {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--bg-hover);
    transition: background .15s;
}

.minimap:hover .minimap-slider {
    background: var(--bg-active);
}

/* Markdown preview */
.preview {
    overflow: auto;
    padding: 24px clamp(16px, 4vw, 56px) 80px;
    min-height: 0;
}

.markdown-body {
    max-width: 760px;
    font-size: 15px;
    line-height: 1.65;
    color: var(--fg);
}

.markdown-body h1 {
    margin: 0 0 .6em;
    padding-bottom: .3em;
    border-bottom: 1px solid var(--border);
    color: var(--fg-strong);
    font-family: var(--font-brand);
    font-weight: 400;
    font-size: 2em;
}

.markdown-body h2 {
    margin: 1.4em 0 .5em;
    padding-bottom: .2em;
    border-bottom: 1px solid var(--border);
    color: var(--fg-strong);
    font-size: 1.3em;
    font-weight: 600;
}

.markdown-body blockquote {
    margin: 0 0 1em;
    padding: .4em 1em;
    border-left: 4px solid var(--accent);
    background: var(--bg-line);
    border-radius: 0 6px 6px 0;
}

.markdown-body blockquote p {
    margin: .2em 0;
}

.markdown-body blockquote strong {
    font-size: 1.15em;
    color: var(--fg-strong);
}

.markdown-body a {
    color: var(--focus);
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    padding: .1em .4em;
    border-radius: 4px;
    background: var(--bg-active);
    font-family: var(--font-code);
    font-size: .95em;
}

.markdown-body ul {
    padding-left: 1.4em;
}

/* Watermark (no editors open) */
.watermark {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--fg-muted);
}

.watermark-logo {
    margin-bottom: 18px;
    font: 72px/1 var(--font-brand);
    color: var(--bg-active);
}

.watermark-row {
    display: grid;
    grid-template-columns: 170px 130px;
    gap: 16px;
    text-align: right;
    padding: 2px 8px;
    border-radius: 4px;
}

.watermark-row kbd {
    text-align: left;
    color: var(--fg);
}

.watermark-row:hover {
    background: var(--bg-hover);
}

/* ==========================================================================
   Panel
   ========================================================================== */

.panel {
    display: grid;
    grid-template-rows: 35px minmax(0, 1fr);
    min-height: 0;
    position: relative;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
}

.panel-sash {
    position: absolute;
    left: 0;
    right: 0;
    top: -3px;
    height: 6px;
    cursor: ns-resize;
    z-index: 4;
}

.panel-sash:hover {
    background: var(--focus);
    transition: background .2s .3s;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px 0 10px;
}

.panel-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.panel-tab {
    position: relative;
    padding: 7px 8px;
    font-size: 11px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--fg-muted);
    white-space: nowrap;
}

.panel-tab:hover,
.panel-tab.active {
    color: var(--fg-strong);
}

.panel-tab.active::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 0;
    height: 1px;
    background: var(--fg-strong);
}

.panel-badge {
    display: inline-block;
    min-width: 18px;
    margin-left: 4px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bg-active);
    color: var(--fg);
    text-align: center;
}

.panel-actions {
    display: flex;
    gap: 2px;
}

.panel-view {
    min-height: 0;
    height: 100%;
    overflow: auto;
}

/* Problems */
.problems-view {
    padding: 2px 0 8px;
}

.problems-empty {
    margin: 8px 20px;
    color: var(--fg-muted);
}

.problems-file {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 10px;
    font-weight: 600;
}

.problems-folder {
    font-weight: 400;
    color: var(--fg-muted);
}

.badge-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bg-active);
    font-size: 11px;
    font-weight: 400;
    text-align: center;
}

.problem-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 24px;
    padding: 2px 10px 2px 34px;
    text-align: left;
}

.problem-row:hover {
    background: var(--bg-hover);
}

.problem-msg {
    flex: 1 1 auto;
    min-width: 0;
}

.problem-meta {
    flex: none;
    color: var(--fg-muted);
    font-size: 12px;
}

/* Output */
.output-view {
    padding: 6px 16px;
    font-family: var(--font-code);
    font-size: calc(var(--code-size) * .88);
    color: var(--fg-muted);
}

.out-error {
    color: var(--error);
}

/* Terminal */
.terminal-view {
    font-family: var(--font-code);
    font-size: calc(var(--code-size) * .9);
    line-height: 1.5;
    color: var(--term-fg);
    cursor: text;
}

.term-scroll {
    height: 100%;
    overflow: auto;
    padding: 6px 16px 16px;
}

.term-line {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    min-height: 1.5em;
}

.term-line a {
    color: var(--focus);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.t-prompt,
.term-prompt {
    color: var(--term-prompt);
}

.t-cmd {
    color: var(--fg-strong);
}

.t-dim {
    color: var(--fg-muted);
}

.t-accent {
    color: var(--accent);
}

.term-line.t-bold {
    font-weight: 500;
    color: var(--fg-strong);
}

.term-line.t-error { color: var(--error); }
.term-line.t-warning { color: var(--warning); }
.term-line.t-success { color: var(--success); }
.term-line.t-accent { color: var(--accent); }

.term-input-row {
    display: flex;
    align-items: baseline;
    gap: 1ch;
    margin: 0;
}

.terminal-view.busy .term-input-row {
    opacity: .4;
}

.term-input {
    flex: 1;
    min-width: 0;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--fg-strong);
    font: inherit;
    caret-color: var(--term-prompt);
}

.term-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    white-space: normal;
}

.term-chip {
    padding: 1px 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-hover);
    color: var(--term-prompt);
    font-family: var(--font-code);
    font-size: .95em;
    transition: background .15s, border-color .15s;
}

.term-chip:hover {
    background: var(--bg-active);
    border-color: var(--term-prompt);
}

/* ==========================================================================
   Status bar
   ========================================================================== */

.statusbar {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    background: var(--bg-bar);
    border-top: 1px solid var(--border);
    color: var(--fg);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    z-index: 7;
}

.sb-left,
.sb-right {
    display: flex;
    min-width: 0;
}

.sb-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    color: inherit;
}

.sb-item .ico {
    width: 14px;
    height: 14px;
}

button.sb-item:hover {
    background: var(--bg-hover);
    color: var(--fg-strong);
}

.sb-remote {
    background: var(--accent);
    color: var(--accent-fg);
    padding: 0 10px;
}

button.sb-remote:hover {
    background: color-mix(in srgb, var(--accent) 85%, #fff);
    color: var(--accent-fg);
}

.sb-problems .ico-error { margin-left: 2px; }
.sb-problems .ico-warning { margin-left: 6px; }
.sb-problems.has-problems .ico-error { color: var(--error); }
.sb-problems.has-problems .ico-warning { color: var(--warning); }

.sb-bell.has-unread {
    color: var(--fg-strong);
}

.sb-bell.has-unread .ico {
    animation: ring 2s ease-in-out infinite;
    transform-origin: 50% 10%;
}

@keyframes ring {
    0%, 60%, 100% { transform: rotate(0); }
    65% { transform: rotate(14deg); }
    75% { transform: rotate(-12deg); }
    85% { transform: rotate(6deg); }
}

/* ==========================================================================
   Overlays: quick input, menus, hover, notifications
   ========================================================================== */

.quick-input {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.qi-backdrop {
    position: absolute;
    inset: 0;
}

.qi-box {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, calc(100vw - 16px));
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-widget);
    box-shadow: var(--shadow);
    animation: drop .14s ease-out;
}

@keyframes drop {
    from { opacity: 0; transform: translate(-50%, -6px); }
}

.qi-input {
    width: 100%;
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--focus);
    border-radius: 4px;
    outline: none;
    background: var(--bg-input);
    color: var(--fg-strong);
    font: 14px var(--font-ui);
}

.qi-list {
    max-height: min(420px, 55vh);
    margin-top: 6px;
    overflow-y: auto;
}

.qi-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 26px;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.qi-row.active {
    background: color-mix(in srgb, var(--focus) 30%, transparent);
    color: var(--fg-strong);
}

.qi-row.disabled {
    cursor: default;
    color: var(--fg-muted);
}

.qi-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.qi-label mark {
    background: none;
    color: var(--focus);
    font-weight: 700;
}

[data-theme="light"] .qi-row.active .qi-label mark {
    color: var(--fg-strong);
}

.qi-desc {
    color: var(--fg-muted);
    font-size: 12px;
}

.qi-keys {
    margin-left: auto;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-hover);
    font-size: 11px;
    color: var(--fg);
}

.qi-check {
    margin-left: auto;
    color: var(--success);
}

.qi-empty {
    padding: 6px 8px;
    color: var(--fg-muted);
}

.context-menu {
    position: fixed;
    z-index: 45;
    min-width: 230px;
    max-width: calc(100vw - 12px);
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-widget);
    box-shadow: var(--shadow);
}

.cm-item {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 26px;
    padding: 2px 10px 2px 6px;
    border-radius: 4px;
    text-align: left;
    white-space: nowrap;
}

.cm-item:hover,
.cm-item:focus-visible {
    background: color-mix(in srgb, var(--focus) 30%, transparent);
    color: var(--fg-strong);
    outline: none;
}

.cm-keys {
    margin-left: 24px;
    color: var(--fg-muted);
    font-size: 12px;
}

.cm-sep {
    height: 1px;
    margin: 4px 6px;
    background: var(--border);
}

.cm-header {
    padding: 6px 8px 2px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.hover-widget {
    position: fixed;
    z-index: 40;
    max-width: min(520px, calc(100vw - 16px));
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-widget);
    box-shadow: var(--shadow);
    font-size: 13px;
}

.hover-body {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
}

.hover-error > .ico { color: var(--error); }
.hover-warning > .ico { color: var(--warning); }
.hover-info > .ico { color: var(--info); }

.hover-msg {
    color: var(--fg-strong);
}

.hover-meta {
    margin-top: 2px;
    color: var(--fg-muted);
    font-size: 12px;
}

.hover-actions {
    padding: 4px 6px;
    border-top: 1px solid var(--border);
}

.hover-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--focus);
}

.hover-action:hover {
    background: var(--bg-hover);
}

.hover-action .ico {
    color: #f5c242;
}

.hover-action kbd {
    color: var(--fg-muted);
}

.notifications {
    position: fixed;
    right: 12px;
    bottom: calc(var(--statusbar-h) + 10px);
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-widget);
    box-shadow: var(--shadow);
    animation: toast-in .25s ease-out;
    transition: opacity .2s, transform .2s;
}

.toast.leaving {
    opacity: 0;
    transform: translateY(8px);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(12px); }
}

.toast-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 8px 8px 12px;
}

.toast-main > .ico {
    margin-top: 1px;
}

.toast-msg {
    flex: 1;
    color: var(--fg-strong);
}

.toast-close {
    width: 22px;
    height: 22px;
    margin-top: -3px;
}

.toast-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 12px 12px;
}

.btn {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-fg);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 85%, #fff);
}

.btn-secondary {
    background: var(--bg-active);
}

.btn-secondary:hover {
    background: color-mix(in srgb, var(--fg) 20%, transparent);
}

.noscript {
    position: fixed;
    inset: auto 0 0;
    padding: 16px;
    background: var(--bg-widget);
    text-align: center;
}

.noscript a {
    color: var(--focus);
}

/* Hosting badge (Netlify free plan), moved into the title bar.
   See js/ui/HostBadge.js */
.has-host-badge .titlebar {
    padding-right: 168px;
}

.has-host-badge #nl-badge-frame:not(.host-badge-open) {
    top: var(--host-badge-top, 0px) !important;
    bottom: auto !important;
    transform: scale(var(--host-badge-scale, 1));
    transform-origin: top right;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablets and small laptops */
@media (max-width: 1100px) {
    .menubar-item {
        padding: 4px 6px;
    }

    .problem-meta {
        display: none;
    }
}

/* Sidebar becomes a drawer */
@media (max-width: 899px) {
    :root {
        --activity-w: 44px;
        --panel-h: 45%;
    }

    .workbench,
    .workbench.sidebar-closed {
        grid-template-columns: var(--activity-w) minmax(0, 1fr);
    }

    .sidebar {
        position: absolute;
        top: 0;
        bottom: 0;
        left: var(--activity-w);
        width: min(300px, calc(100vw - var(--activity-w) - 24px));
        z-index: 8;
        box-shadow: var(--shadow);
        transform: translateX(0);
        transition: transform .22s ease, visibility .22s;
    }

    .workbench.sidebar-closed .sidebar {
        transform: translateX(calc(-100% - var(--activity-w)));
    }

    .sidebar-close {
        display: inline-grid;
    }

    .sidebar-backdrop {
        display: block;
        position: absolute;
        inset: 0 0 0 var(--activity-w);
        z-index: 7;
        background: rgba(0, 0, 0, .45);
        transition: opacity .22s;
    }

    .workbench.sidebar-closed .sidebar-backdrop {
        opacity: 0;
        pointer-events: none;
    }

    .main-area {
        grid-column: 2;
        grid-row: 1;
    }

    .minimap,
    .editor-body {
        grid-template-columns: minmax(0, 1fr);
    }

    .minimap {
        display: none;
    }

    .lens {
        display: none;
    }

    .menubar {
        display: none;
    }

    .titlebar-logo {
        display: none;
    }

    .titlebar-burger {
        display: grid;
    }

    .command-center {
        flex: 1 1 auto;
    }

    .titlebar-spacer {
        flex: 0 0 4px;
    }

    .sb-wide {
        display: none;
    }
}

/* Phones */
@media (max-width: 600px) {
    .hero {
        gap: 8px;
        padding: 10px 12px;
        align-items: flex-end;
    }

    .hero-name {
        font-size: clamp(22px, 7.2vw, 34px);
        white-space: nowrap;
    }

    .breadcrumbs .crumb:not(:last-child),
    .breadcrumbs .crumb-sep {
        display: none;
    }

    .breadcrumbs .crumb:nth-last-child(1) {
        display: inline-flex;
    }

    .line {
        grid-template-columns: 14px calc(var(--ln-chars) * 1ch + .8ch) 14px minmax(0, 1fr);
    }

    .sb-branch span,
    .sb-remote span,
    .sb-progress-text {
        display: none;
    }

    .notifications {
        right: 8px;
        left: 8px;
        width: auto;
    }

    .tab {
        padding-left: 10px;
    }

    .tab-mode {
        display: none;
    }
}

/* Compact hero links (icons only): phones and short landscape screens */
@media (max-width: 600px), (max-height: 560px) {
    .hero-links {
        display: flex;
        flex: none;
        gap: 2px;
    }

    .hero-link {
        display: grid;
        place-items: center;
        width: 34px;
        height: 34px;
        border-radius: 8px;
        background: var(--bg-hover);
    }

    .hero-link:hover {
        transform: none;
    }

    .hero-link-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    .hero-link-icon .ico {
        width: 18px;
        height: 18px;
    }
}

/* Short screens: compact hero */
@media (max-height: 560px) {
    .hero-hi {
        display: none;
    }

    .hero {
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .hero-name {
        font-size: 24px;
    }
}

/* Touch: bigger targets, always-visible fold controls */
@media (pointer: coarse) {
    .fold {
        opacity: 1;
    }

    .tab-close {
        opacity: 1;
    }

    .tree-row {
        height: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
