/*
 * base.css — minimal, mobile-first UI kit with automatic light/dark mode. No fonts, no framework.
 *
 * Purpose:  a clean starting stylesheet for admin tools and internal apps.
 * Usage:    <link rel="stylesheet" href="/assets/base.css">  — then change the tokens in :root
 *           (--accent etc.) per project. Works with a strict CSP (no inline styles needed).
 * Includes: tokens (light + dark), top bar, footer, .wrap, .card, .grid, .page-head, .actions,
 *           .btn (.ghost .danger .small), forms (.stack, label.check), weekday chips (.days/.day),
 *           .flash (-ok -error -info), .badge, .tabs, .crumbs, .files list, .code viewer, .table,
 *           .snippet, .visually-hidden
 * Origin:   MiGit
 */

:root {
    --bg: #f6f4ef;
    --surface: #ffffff;
    --ink: #1c1b18;
    --muted: #6b675e;
    --line: #e2ded4;
    --accent: #1f6b52;
    --accent-ink: #ffffff;
    --accent-soft: #e3f0ea;
    --danger: #a8322a;
    --danger-soft: #f8e5e2;
    --info-soft: #e8eef7;
    --add: #1f7a46;
    --mod: #9a6a00;
    --del: #a8322a;
    --code-bg: #fbfaf7;
    --radius: 8px;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131311;
        --surface: #1b1b18;
        --ink: #e9e5dc;
        --muted: #9a958a;
        --line: #2e2d29;
        --accent: #5cc39a;
        --accent-ink: #0e1a14;
        --accent-soft: #1d3329;
        --danger: #ec7a70;
        --danger-soft: #3a201d;
        --info-soft: #1e2633;
        --add: #6fd39b;
        --mod: #e0b450;
        --del: #ec7a70;
        --code-bg: #161614;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 var(--sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; margin-top: 1.2rem; }
p { margin: 0 0 .8rem; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.hint { color: var(--muted); font-size: .86rem; margin: 0; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }

/* Header / footer */
.top {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem;
    padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-family: var(--mono); font-weight: 700; color: var(--ink); letter-spacing: -.02em; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); margin-right: .35rem; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .9rem; margin-left: auto; font-size: .92rem; }
.main-nav a { color: var(--muted); }
.main-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 2.5rem; flex: 1; }
.foot { display: flex; justify-content: space-between; gap: 1rem; padding: .8rem 1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.lang-switch button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }

/* Building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card.narrow { max-width: 440px; margin: 2rem auto; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid > .card { margin-bottom: 0; }
.grid + .card, .grid + section { margin-top: 1rem; }
@media (min-width: 820px) {
    .grid { grid-template-columns: 1fr 1fr; }
    .grid.wide-first { grid-template-columns: 1.6fr 1fr; }
    .grid { align-items: start; }
}
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1, .page-head h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.actions.right { justify-content: flex-end; }
.inline { display: inline; margin: 0; }
.empty { color: var(--muted); padding: 1.5rem 0; text-align: center; }
.badge { display: inline-block; font-size: .72rem; padding: .05rem .45rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; font-weight: 600; }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.big-code { font-size: 2.6rem; font-weight: 700; margin: .5rem 0; color: var(--muted); }
.snippet { background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: .6rem; font: .8rem/1.4 var(--mono); white-space: pre-wrap; word-break: break-all; }
.scroll-x { overflow-x: auto; }
ul.plain { list-style: none; padding: 0; margin: 0 0 .8rem; }
ul.plain li { padding: .2rem 0; }

/* Buttons & forms */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    font: inherit; font-weight: 600; font-size: .9rem; line-height: 1.2;
    padding: .55rem .95rem; border-radius: 6px; border: 1px solid var(--accent);
    background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: .32rem .6rem; font-size: .82rem; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
.linkish:hover { color: var(--ink); text-decoration: underline; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.stack > .btn { align-self: flex-start; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: .45rem; font-weight: 400; }
label.check.strong { font-weight: 600; }
input[type=text], input[type=password], input[type=number], select, textarea {
    font: inherit; font-weight: 400; width: 100%; padding: .55rem .65rem;
    border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--ink);
}
input[type=file] { font-size: .85rem; font-weight: 400; max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, .linkish:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .88rem; font-weight: 600; margin-bottom: .35rem; padding: 0; }
.inline-fields { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }
.inline-fields legend { width: 100%; }
textarea.code-input { font: .85rem/1.5 var(--mono); tab-size: 4; resize: vertical; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.editor textarea.code-input { min-height: 55vh; }
.days { display: flex; flex-wrap: wrap; gap: .4rem; }
.days legend { width: 100%; }
.day { flex-direction: row; font-weight: 400; }
.day input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.day span { display: inline-block; min-width: 3.1rem; text-align: center; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-size: .85rem; }
.day input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.day input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Flash messages */
.flash { padding: .65rem .8rem; border-radius: 6px; margin: 0 0 1rem; font-size: .9rem; background: var(--info-soft); }
.flash-ok { background: var(--accent-soft); color: var(--ink); border-left: 3px solid var(--accent); }
.flash-error { background: var(--danger-soft); border-left: 3px solid var(--danger); }
.flash-info { border-left: 3px solid var(--muted); }
.flash ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* Tabs, breadcrumbs, toolbar */
.tabs { display: flex; gap: .2rem; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: .45rem .75rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-size: .9rem; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .75rem; }
.crumbs { font-size: .92rem; word-break: break-all; }
.crumbs .sep { color: var(--muted); margin: 0 .2rem; }

/* File lists */
.files { list-style: none; padding: 0; margin: 0 0 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.files li { display: flex; align-items: baseline; gap: .6rem; padding: .45rem .8rem; border-top: 1px solid var(--line); }
.files li:first-child { border-top: 0; }
.entry { font-family: var(--mono); font-size: .9rem; word-break: break-all; }
.entry.dir { font-weight: 700; }
.entry.dir::before { content: "▸ "; color: var(--muted); }
.entry.file::before { content: "· "; color: var(--muted); }
.add { color: var(--add); } .mod { color: var(--mod); } .del { color: var(--del); }

/* Code viewer with line numbers: <div class="code"><table><tr id="L1"><td class="ln"><a href="#L1">1</a></td><td class="lc">…</td></tr></table></div> */
.code { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.code table { border-collapse: collapse; width: 100%; font: .83rem/1.55 var(--mono); }
.code td { padding: 0 .8rem; vertical-align: top; }
.code .ln { width: 1%; text-align: right; user-select: none; border-right: 1px solid var(--line); padding-left: .6rem; }
.code .ln a { color: var(--muted); }
.code .lc { white-space: pre; tab-size: 4; }
.code tr:target { background: var(--accent-soft); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table select { width: auto; }

.danger-zone { border-color: var(--danger-soft); }
