/* Design tokens, base elements and shared components of «Зацепка». */

:root {
    color-scheme: light;
    --bg: #f3f0e8;
    --surface: #fbf9f4;
    --surface-2: #efebe1;
    --surface-3: #e6e1d4;
    --line: #ddd6c8;
    --line-strong: #c9c1b0;
    --text: #1f2329;
    --muted: #6b6f76;
    --faint: #9a9a94;
    --accent: #d08a1e;
    --accent-ink: #94570a;
    --accent-soft: rgba(208, 138, 30, .14);
    --on-accent: #1b1406;
    --danger: #b4432f;
    --ok: #3c7d4a;
    --shadow: 0 1px 2px rgba(40, 32, 16, .06), 0 8px 24px rgba(40, 32, 16, .08);
    --shadow-pop: 0 2px 6px rgba(40, 32, 16, .1), 0 18px 48px rgba(40, 32, 16, .18);

    --map-country: #e8e3d4;
    --map-field: #e1dac5;
    --map-forest: #d2dcc2;
    --map-land: #f1ede3;
    --map-park: #cddcbc;
    --map-cemetery: #d6d9cb;
    --map-cemetery-rows: #c3c8b6;
    --map-street: #fdfcf8;
    --map-bldg: #ddd5c4;
    --map-water: #a8c5d5;
    --map-avenue: #ffffff;
    --map-avenue-casing: #d6ccb9;
    --map-embank: #e4ddcd;
    --map-rail: #8c877d;
    --map-rail-ties: #f1ede3;
    --map-label: #77705f;
    --map-label-water: #4c7286;
    --map-pin: #fbf9f4;
    --map-pin-line: #8f8775;
    --map-pin-icon: #4a4639;

    --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-read: "Iowan Old Style", Charter, "Charter BT", Georgia, "Times New Roman", serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --radius: 12px;
    --radius-sm: 8px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f1216;
        --surface: #161a20;
        --surface-2: #1c2128;
        --surface-3: #242a33;
        --line: #2a313b;
        --line-strong: #3a424e;
        --text: #e8e5de;
        --muted: #949aa3;
        --faint: #6c727b;
        --accent: #f0b44c;
        --accent-ink: #f3bf62;
        --accent-soft: rgba(240, 180, 76, .14);
        --on-accent: #1b1406;
        --danger: #e07a64;
        --ok: #7cc28a;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
        --shadow-pop: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .5);

        --map-country: #11151a;
        --map-field: #141a1e;
        --map-forest: #13201a;
        --map-land: #191e25;
        --map-park: #16261d;
        --map-cemetery: #1a221e;
        --map-cemetery-rows: #24302a;
        --map-street: #262d37;
        --map-bldg: #222832;
        --map-water: #0d2433;
        --map-avenue: #3b3427;
        --map-avenue-casing: #11151a;
        --map-embank: #20262e;
        --map-rail: #4c535d;
        --map-rail-ties: #191e25;
        --map-label: #6f7782;
        --map-label-water: #4f7d97;
        --map-pin: #1f252d;
        --map-pin-line: #59616d;
        --map-pin-icon: #c9c6be;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f1216;
    --surface: #161a20;
    --surface-2: #1c2128;
    --surface-3: #242a33;
    --line: #2a313b;
    --line-strong: #3a424e;
    --text: #e8e5de;
    --muted: #949aa3;
    --faint: #6c727b;
    --accent: #f0b44c;
    --accent-ink: #f3bf62;
    --accent-soft: rgba(240, 180, 76, .14);
    --on-accent: #1b1406;
    --danger: #e07a64;
    --ok: #7cc28a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .5);

    --map-country: #11151a;
    --map-field: #141a1e;
    --map-forest: #13201a;
    --map-land: #191e25;
    --map-park: #16261d;
    --map-cemetery: #1a221e;
    --map-cemetery-rows: #24302a;
    --map-street: #262d37;
    --map-bldg: #222832;
    --map-water: #0d2433;
    --map-avenue: #3b3427;
    --map-avenue-casing: #11151a;
    --map-embank: #20262e;
    --map-rail: #4c535d;
    --map-rail-ties: #191e25;
    --map-label: #6f7782;
    --map-label-water: #4f7d97;
    --map-pin: #1f252d;
    --map-pin-line: #59616d;
    --map-pin-icon: #c9c6be;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

a { color: var(--accent-ink); }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }

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

.btn-primary:hover { background: var(--accent); filter: brightness(1.06); }

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

.btn-small { min-height: 30px; padding: 0 12px; font-size: 13px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: var(--muted);
}

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

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.field {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

textarea.field { resize: vertical; line-height: 1.45; }

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

.hidden { display: none !important; }

/* Modal dialog */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(10, 12, 16, .55);
    backdrop-filter: blur(2px);
    animation: fade-in .15s ease-out;
}

.modal {
    width: min(720px, 100%);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    overflow: hidden;
    animation: pop-in .18s ease-out;
}

.modal-small { width: min(440px, 100%); }
.modal:focus { outline: none; }

.modal-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px 22px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 { flex: 1; font-size: 18px; }

.modal-body { padding: 20px 22px; overflow: auto; }

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 60;
    max-width: calc(100% - 32px);
    padding: 10px 16px;
    border-radius: 12px;
    background: var(--text);
    color: var(--bg);
    font-weight: 500;
    box-shadow: var(--shadow-pop);
    transform: translateX(-50%);
    animation: pop-in .18s ease-out;
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.toast { animation-name: toast-in; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* Error page */
.center-stage {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    text-align: center;
}

.center-stage h1 { font-size: 28px; }

.modal-text { margin: 0 0 14px; color: var(--muted); }
.modal-wide { width: min(980px, 100%); }

.stars { display: inline-flex; gap: 1px; }
.star .icon { width: 15px; height: 15px; stroke: var(--line-strong); stroke-width: 1.6; }
.star.on .icon { fill: var(--accent); stroke: var(--accent); }

/* Listening */
.entry-listen { flex: none; margin: -4px -6px 0 0; width: 30px; height: 30px; }
.entry-listen .icon { width: 17px; height: 17px; }
.entry-listen.on { color: var(--accent-ink); background: var(--accent-soft); }
.doc-actions { display: flex; justify-content: flex-end; margin: -6px 0 12px; }

.player {
    position: fixed;
    left: 50%;
    bottom: 20px;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: min(520px, calc(100% - 32px));
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-pop);
    transform: translateX(-50%);
    animation: toast-in .18s ease-out;
}
.player-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; margin-right: 6px; }
.player-wave { display: grid; place-items: center; color: var(--accent-ink); }
.player-wave .icon { width: 20px; height: 20px; }
.player-wave.on .icon { animation: wave 1.2s ease-in-out infinite; }
@keyframes wave { 50% { opacity: .45; } }

/* Settings */
.settings { display: grid; gap: 22px; }
.settings h3 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.settings section { display: grid; gap: 10px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); justify-self: start; }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 600; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
    display: grid;
    gap: 4px;
    justify-items: start;
    padding: 14px;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: left;
}
.mode-card .icon { width: 26px; height: 26px; color: var(--muted); margin-bottom: 4px; }
.mode-card span { color: var(--muted); font-size: 13px; line-height: 1.35; }
.mode-card.on { border-color: var(--accent); background: var(--accent-soft); }
.mode-card.on .icon { color: var(--accent-ink); }
.field-label { display: grid; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.field-label input[type=range] { accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

@media (max-width: 820px) {
    .player { bottom: calc(72px + env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
    .mode-cards { grid-template-columns: 1fr; }
}
.small { font-size: 13.5px; margin: 0 0 10px; }
