/* Tiny World server pages: functional, accessible, no inline styles or scripts (strict CSP).
   Official visual design is delivered separately; every colour and size below is a token so it can be re-skinned. */
:root {
    --bg: #ffffff;
    --fg: #14171f;
    --muted: #4b5364;
    --line: #c9cfdb;
    --accent: #1f4fd8;
    --accent-fg: #ffffff;
    --surface: #f4f6fb;
    --danger: #a11a1a;
    --ok-bg: #e6f4ea;
    --ok-fg: #14532d;
    --warn-bg: #fff4d6;
    --warn-fg: #6b4a00;
    --crit-bg: #fde8e8;
    --crit-fg: #7f1d1d;
    --focus: #b45309;
    --radius: 6px;
    --gap: 1rem;
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10131a;
        --fg: #e8ebf3;
        --muted: #a9b1c3;
        --line: #333a4a;
        --accent: #7aa2ff;
        --accent-fg: #0b1020;
        --surface: #181c26;
        --danger: #ff8a8a;
        --ok-bg: #123322;
        --ok-fg: #b7f0cc;
        --warn-bg: #3a2c0a;
        --warn-fg: #ffe4a1;
        --crit-bg: #421414;
        --crit-fg: #ffc9c9;
        --focus: #fbbf24;
    }
}

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

html { font-size: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 1rem/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

main, .site-header, .site-footer, .notice { max-width: 46rem; margin-inline: auto; padding-inline: var(--gap); }
main { padding-block: 1.5rem 3rem; outline: none; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 var(--gap); }
h2 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.muted, .hint { color: var(--muted); }
.hint { margin: 0.25rem 0 0; font-size: 0.9rem; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }

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

.skip-link {
    position: absolute; left: -999px; top: 0; padding: 0.5rem 1rem;
    background: var(--accent); color: var(--accent-fg); z-index: 10;
}
.skip-link:focus { left: 0; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.site-header {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--gap);
    padding-block: 0.75rem; border-bottom: 1px solid var(--line);
}
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--fg); text-decoration: none; }

.site-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--gap);
    padding-block: 1rem; border-top: 1px solid var(--line); font-size: 0.9rem;
}
.lang-switch { display: flex; gap: 0.75rem; }
.lang-switch [aria-current="true"] { font-weight: 700; text-decoration: underline; }

form.inline { display: inline; }
.inline-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.field { margin: 0 0 var(--gap); }
.field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.field-check { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: baseline; }
.field-check label { display: inline; font-weight: 400; }
.field-check .field-error { flex-basis: 100%; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
    width: 100%; padding: 0.55rem 0.7rem; font: inherit; color: var(--fg); background: var(--bg);
    border: 1px solid var(--muted); border-radius: var(--radius);
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.field-error { color: var(--danger); margin: 0.25rem 0 0; font-weight: 600; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 var(--gap); }

.button, button.button {
    display: inline-block; padding: 0.55rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer;
    color: var(--accent-fg); background: var(--accent); border: 2px solid var(--accent); border-radius: var(--radius);
    text-decoration: none;
}
.button-secondary { color: var(--accent); background: transparent; }
.button-danger { color: #fff; background: var(--danger); border-color: var(--danger); }
@media (prefers-color-scheme: dark) { .button-danger { color: #10131a; } }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.notice { display: block; margin-block: var(--gap); padding-block: 0.7rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.notice h2 { margin-top: 0; }
.notice-success, .notice-info { background: var(--ok-bg); color: var(--ok-fg); }
.notice-warning { background: var(--warn-bg); color: var(--warn-fg); }
.notice-critical { background: var(--crit-bg); color: var(--crit-fg); }
.notice a { color: inherit; }

.rows { list-style: none; padding: 0; margin: 0; }
.rows li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.codes { columns: 2; list-style: none; padding: 0; font-size: 1.05rem; }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.metrics { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 0.75rem; }
.metrics dt, .metrics dd { display: inline; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
thead th { border-bottom: 2px solid var(--line); }
.status { font-weight: 700; }
.status-disabled { color: var(--danger); }
.status-dev { color: var(--warn-fg); }
@media (prefers-color-scheme: light) { .status-dev { color: #8a5b00; } }

.qr { width: 12rem; max-width: 100%; padding: 0.5rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr svg { display: block; width: 100%; height: auto; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.95em; word-break: break-all; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.error-page { text-align: left; }

@media (max-width: 40rem) {
    .facts { grid-template-columns: 1fr; }
    .codes { columns: 1; }
    table { display: block; overflow-x: auto; }
}

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Admin tables retain their columns in a labelled keyboard-scrollable region. */
.admin-dashboard main{min-width:0;max-width:46rem}
.admin-dashboard main section{min-width:0;max-width:100%}
.table-viewport{position:relative;width:100%;max-width:100%;overflow-x:auto}
.table-viewport .admin-table{display:table;overflow:visible;min-width:38rem}
.table-viewport .inline-form input{min-width:12rem}
.admin-dashboard .facts>*{min-width:0;overflow-wrap:anywhere}
