:root {
    color-scheme: light;
    --page: #eef2f4;
    --surface: #fff;
    --ink: #14242b;
    --muted: #52636b;
    --line: #d8e0e4;
    --document: #f6f9fa;
    --accent: #17604d;
    --selection: #e3f4ed;
    --danger: #8a2a38;
    font: 15px/1.5 "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    background: var(--page);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; overflow-wrap: anywhere; }
h1, h2, p, pre { margin: 0; }
h1 { font-size: 1.48rem; letter-spacing: -.025em; }
h2 { font-size: 1rem; }
a { color: var(--accent); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
input, select {
    min-width: 0; min-height: 38px; padding: 6px 10px; border: 1px solid #adbcc3;
    border-radius: 7px; background: var(--surface);
}
input[type="checkbox"] { min-height: auto; inline-size: 1rem; block-size: 1rem; flex: none; accent-color: var(--accent); }
[aria-invalid="true"] { border-color: var(--danger); }
.button {
    display: inline-flex; justify-content: center; align-items: center; gap: .38em;
    min-height: 38px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px;
    background: var(--surface); color: var(--ink); font-weight: 620; font-size: .92rem; text-decoration: none; text-align: center;
}
.button:hover:not(:disabled) { background: var(--document); border-color: var(--muted); }
.button:disabled { opacity: .5; cursor: default; }
.button.primary { color: white; background: var(--accent); border-color: var(--accent); }
.button.primary:hover:not(:disabled) { background: #0f4d3d; }
.button.danger, .error { color: var(--danger); }
.muted, small { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; inset: 8px auto auto 8px; background: var(--surface); padding: 8px; z-index: 2; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.site-header {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
    min-height: 65px; padding: 12px clamp(12px, 3vw, 38px); border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.12rem; font-weight: 650; text-decoration: none; }
.brand strong { color: var(--accent); font-family: Consolas, ui-monospace, monospace; }
.brand-mark {
    display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 9px;
    background: var(--accent); color: #fff; font: 650 15px/1 Consolas, ui-monospace, monospace;
}
.site-header nav, .admin-nav, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
nav a { text-decoration: none; }
nav [aria-current="page"] { text-decoration: underline; font-weight: 650; }
.site-main { padding: clamp(12px, 2.3vw, 28px); max-width: 1600px; margin-inline: auto; }
.panel { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-width: 0; }
.panel-heading {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
    gap: 8px 12px; min-height: 51px; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.notice { margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.notice.error { border-color: #d9a4aa; }
.auth-panel { margin: min(8vh, 55px) auto; max-width: 440px; padding: 22px; }
.form-panel { max-width: 800px; }
.form-stack { display: grid; gap: 7px; }
.form-stack label:not(.check-row) { font-weight: 620; }
.form-stack small { margin: 0 0 3px; }
.form-stack .actions, .form-stack > .button { margin-top: 10px; }
.form-stack fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-width: 0; }
.auth-panel h1, .form-panel h1 { margin-bottom: 12px; }
.auth-panel p, .form-panel > p { margin-bottom: 10px; }
.admin-nav { margin-bottom: 12px; }
.admin-panel { padding: 16px; }
.admin-panel .panel-heading { padding: 0 0 12px; }
.admin-panel > p { margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; margin-top: 8px; text-align: left; }
.data-table td, .data-table th { border-bottom: 1px solid var(--line); padding: 8px 7px; vertical-align: top; }
.data-table form { margin-top: 4px; }
.confirm-action summary { color: var(--danger); }
.confirm-action p { margin-block: 5px; }
.preset-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; margin-bottom: 12px; }
.preset-field { display: flex; align-items: center; gap: 7px; min-width: 0; font-weight: 620; }
.preset-field select { max-width: min(250px, 55vw); }
.download-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-inline-start: auto; min-width: 0; }
#download-filename { font: .85rem/1.4 Consolas, ui-monospace, monospace; }
.workspace { display: grid; grid-template-columns: minmax(0, var(--tree-width, 42%)) 18px minmax(0, 1fr); align-items: stretch; }
.tree-panel, .preview-panel { min-width: 0; min-height: 290px; }
.divider { display: grid; place-items: center; cursor: col-resize; touch-action: none; }
.divider::before { content: ""; height: 34px; width: 5px; border-inline: 1px solid var(--muted); }
.divider:hover::before, .divider:focus-visible::before { border-color: var(--accent); }
.tree { display: grid; gap: 4px; padding: 10px; }
.tree summary { padding: 7px 5px; font-weight: 650; }
.tree-branch { display: grid; gap: 4px; border-inline-start: 1px solid var(--line); margin-inline-start: 10px; padding-inline-start: 9px; }
.tree-entry { border-radius: 7px; padding: 3px 6px; }
.tree-entry[data-checked="true"] { background: var(--selection); }
.tree-line, .check-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tree-line { flex-wrap: wrap; }
.check-row { padding: 4px 0; }
.tree-line .check-row { flex: 1 1 130px; }
.description-button { padding: 3px; background: transparent; border: 0; color: var(--accent); text-decoration: underline; font-size: .85rem; border-radius: 3px; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; padding: 4px 6px; font: inherit; font-size: .88rem; color: var(--muted); }
.document { margin: 12px; border: 1px solid var(--line); background: var(--document); border-radius: 8px; }
.filename { padding: 8px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-family: Consolas, ui-monospace, monospace; }
#preview-content, .preview-status { padding: 12px; min-height: 180px; }
#preview-content { white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.6 Consolas, ui-monospace, monospace; }
.preview-jump { display: none; }
dialog {
    max-width: min(420px, calc(100% - 24px)); width: 100%; color: var(--ink);
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
dialog::backdrop { background: #10202470; }
dialog .actions { justify-content: flex-end; }
@media (max-width: 959px) {
    .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .divider { display: none; }
    .preview-jump { display: inline-block; margin-bottom: 8px; }
    .tree-panel { min-height: auto; }
}
@media (max-width: 650px) {
    .site-header nav { width: 100%; }
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .data-table tbody, .data-table tr, .data-table td { display: block; }
    .data-table tr { padding: 5px 0; border-bottom: 1px solid var(--line); }
    .data-table td { display: grid; grid-template-columns: minmax(0, 9ch) minmax(0, 1fr); gap: 5px; border: 0; }
    .data-table td::before { content: attr(data-label); font-weight: 650; font-size: .82rem; }
    .data-table td > * { grid-column: 2; }
    .download-actions { margin-inline-start: 0; }
}
@media (pointer: coarse) {
    .button, input:not([type="checkbox"]), select, .description-button { min-height: 44px; }
    .check-row, .tree summary { min-height: 44px; align-content: center; }
}
