@font-face {
        font-family: 'IBM Plex Mono';
        src: url('./fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
        font-weight: 400;
        font-display: block;
}
@font-face {
        font-family: 'IBM Plex Mono';
        src: url('./fonts/ibm-plex-mono-latin-500-normal.woff2') format('woff2');
        font-weight: 500;
        font-display: block;
}
@font-face {
        font-family: 'IBM Plex Sans';
        src: url('./fonts/ibm-plex-sans-latin-400-normal.woff2') format('woff2');
        font-weight: 400;
        font-display: swap;
}
@font-face {
        font-family: 'IBM Plex Sans';
        src: url('./fonts/ibm-plex-sans-latin-500-normal.woff2') format('woff2');
        font-weight: 500;
        font-display: swap;
}

:root {
        color-scheme: dark;
        --surface-base: #111217;
        --surface-panel: #1a1c22;
        --surface-raised: #262932;
        --surface-hover: #30343e;
        --surface-current-line: #191b21;
        --surface-selection: #2a4a73;
        --surface-find-match: #5a4a1a;
        --surface-bracket-match: #3a4152;
        --text-primary: #e6e8ef;
        --text-secondary: #b1b8c8;
        --text-muted: #8a91a2;
        --text-gutter: #5c6373;
        --line-divider: #2c303a;
        --accent: #7fb0ff;
        --danger: #ff8a8a;

        --code-keyword: #c79bff;
        --code-type: #6fd3c7;
        --code-constant: #ffb86b;
        --code-number: #ffb86b;
        --code-string: #a6d189;
        --code-char: #a6d189;
        --code-comment: #7d8597;
        --code-builtin: #ff8fb8;
        --code-directive: #ff8fb8;
        --code-declaration: #7fb0ff;
        --code-function: #8fc3ff;
        --code-field: #d7c08a;
        --code-operator: #b1b8c8;
        --code-bracket: #9aa3b5;
        --code-register: #ffd479;
        --code-bad-byte: #ff8a8a;

        --code-font-size: 16px;
        --code-line-height: 1.5;
        --code-tab-size: 8;
        --keys-height: 0px;
        --ui-font: 'IBM Plex Sans', system-ui, sans-serif;
        --code-font: 'IBM Plex Mono', ui-monospace, monospace;
}

* {
        box-sizing: border-box;
}

html, body {
        margin: 0;
        height: 100%;
        background: var(--surface-base);
        color: var(--text-primary);
        font-family: var(--ui-font);
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
}

button, select, input, .button-like {
        font: inherit;
        color: var(--text-primary);
        background: var(--surface-raised);
        border: 1px solid var(--line-divider);
        border-radius: 8px;
        padding: 6px 12px;
        min-height: 36px;
        cursor: pointer;
}
button:hover, .button-like:hover {
        background: var(--surface-hover);
}
button:focus-visible, select:focus-visible, input:focus-visible, .button-like:focus-within {
        outline: 2px solid var(--accent);
        outline-offset: 1px;
}

.app {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        padding-top: env(safe-area-inset-top);
}

.top-bar {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 6px 8px;
        background: var(--surface-panel);
        border-bottom: 1px solid var(--line-divider);
}
.file-name:hover {
        background: var(--surface-raised);
}
.file-name {
        flex: 1;
        min-width: 0;
        text-align: left;
        font-family: var(--code-font);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        background: transparent;
        border-color: transparent;
}
.dirty {
        color: var(--accent);
        margin-left: 6px;
}
.top-actions {
        display: flex;
        gap: 6px;
}

.find-bar {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 6px 8px;
        background: var(--surface-panel);
        border-bottom: 1px solid var(--line-divider);
}
.find-bar[hidden] {
        display: none;
}
.find-bar input {
        flex: 1;
        min-width: 0;
        cursor: text;
        font-family: var(--code-font);
        font-size: 16px;
}
.find-count {
        color: var(--text-muted);
        font-size: 14px;
        min-width: 4em;
        text-align: right;
}

.scroller {
        flex: 1;
        scrollbar-color: var(--surface-hover) var(--surface-base);
        overflow: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
}
.sheet {
        display: flex;
        min-height: 100%;
        min-width: 100%;
        width: max-content;
}
.gutter, .highlight, .source {
        margin: 0;
        font-family: var(--code-font);
        font-size: var(--code-font-size);
        line-height: var(--code-line-height);
        tab-size: var(--code-tab-size);
        -moz-tab-size: var(--code-tab-size);
        font-variant-ligatures: none;
        letter-spacing: 0;
        white-space: pre;
        word-wrap: normal;
        overflow-wrap: normal;
}
.gutter {
        position: sticky;
        left: 0;
        z-index: 2;
        padding: 8px 10px 8px 8px;
        min-width: 3.5em;
        text-align: right;
        color: var(--text-gutter);
        background: var(--surface-base);
        border-right: 1px solid var(--line-divider);
        user-select: none;
        -webkit-user-select: none;
}
.gutter .current {
        color: var(--text-secondary);
}
.code {
        position: relative;
        flex: 1;
}
.highlight {
        padding: 8px 48px 50vh 10px;
        color: var(--text-primary);
        pointer-events: none;
        min-height: 100%;
}
.source {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 8px 48px 50vh 10px;
        border: 0;
        border-radius: 0;
        outline: none;
        resize: none;
        overflow: hidden;
        background: transparent;
        color: transparent;
        -webkit-text-fill-color: transparent;
        caret-color: var(--text-primary);
}
.source::selection {
        background: var(--surface-selection);
        color: transparent;
        -webkit-text-fill-color: transparent;
}

.highlight .kw { color: var(--code-keyword); }
.highlight .ty { color: var(--code-type); }
.highlight .con { color: var(--code-constant); }
.highlight .num { color: var(--code-number); }
.highlight .str { color: var(--code-string); }
.highlight .chr { color: var(--code-char); }
.highlight .com { color: var(--code-comment); font-style: italic; }
.highlight .bi { color: var(--code-builtin); }
.highlight .dir { color: var(--code-directive); }
.highlight .decl { color: var(--code-declaration); font-weight: 500; }
.highlight .fn { color: var(--code-function); }
.highlight .fld { color: var(--code-field); }
.highlight .op { color: var(--code-operator); }
.highlight .br { color: var(--code-bracket); }
.highlight .reg { color: var(--code-register); }
.highlight .bad { color: var(--code-bad-byte); text-decoration: wavy underline; }
.highlight .br.match { background: var(--surface-bracket-match); color: var(--text-primary); border-radius: 2px; }
.highlight .br.unmatched { color: var(--danger); }
.highlight mark { background: var(--surface-find-match); color: inherit; border-radius: 2px; }

.keys {
        display: flex;
        gap: 4px;
        overflow-x: auto;
        padding: 4px 6px;
        background: var(--surface-panel);
        border-top: 1px solid var(--line-divider);
        scrollbar-width: none;
}
.keys[hidden] {
        display: none;
}
.keys::-webkit-scrollbar {
        display: none;
}
.keys button {
        flex: none;
        min-width: 40px;
        min-height: 40px;
        padding: 4px 8px;
        font-family: var(--code-font);
        font-size: 17px;
        touch-action: manipulation;
}

.status-bar {
        display: flex;
        gap: 12px;
        padding: 4px 10px calc(4px + env(safe-area-inset-bottom));
        font-size: 13px;
        color: var(--text-muted);
        background: var(--surface-panel);
        border-top: 1px solid var(--line-divider);
        white-space: nowrap;
        overflow: hidden;
}
.status-bar .version {
        margin-left: auto;
}

.panel {
        width: min(32rem, calc(100vw - 24px));
        max-height: calc(100dvh - 48px);
        padding: 0 16px 16px;
        color: var(--text-primary);
        background: var(--surface-panel);
        border: 1px solid var(--line-divider);
        border-radius: 12px;
}
.panel::backdrop {
        background: rgb(0 0 0 / 55%);
}
.panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
}
.panel-head h2 {
        font-size: 18px;
        font-weight: 500;
}
.panel-close {
        min-width: 40px;
}
.file-list {
        list-style: none;
        margin: 0 0 12px;
        padding: 0;
        max-height: 50dvh;
        overflow: auto;
}
.file-list button {
        width: 100%;
        display: flex;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 4px;
        text-align: left;
        font-family: var(--code-font);
}
.file-list button[aria-current="true"] {
        border-color: var(--accent);
}
.file-list .when {
        color: var(--text-muted);
        font-family: var(--ui-font);
        font-size: 13px;
        white-space: nowrap;
}
.panel-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
}
.button-like {
        display: inline-flex;
        align-items: center;
}
.danger {
        color: var(--danger);
}
.panel-note {
        color: var(--text-muted);
        font-size: 14px;
}
.setting {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin: 12px 0;
}
.stepper {
        display: flex;
        align-items: center;
        gap: 8px;
}
.stepper output {
        min-width: 2.5em;
        text-align: center;
}

.find-box {
        position: absolute;
        z-index: 1;
        background: var(--surface-find-match);
        border-radius: 2px;
        pointer-events: none;
        mix-blend-mode: screen;
}
