/* ── Global stylesheet, no framework ──────────────────────────────────────
   Loaded by base.html on every page (docs.html — standalone Swagger UI — is
   the one exception). Visual language borrowed from kekavigi.xyz: a plain
   card on a gray page background, system sans-serif, classic blue links, no
   border-radius or shadow, and no max-width. */

* {
    box-sizing: border-box;
}

/* Tokens and values copied from kekavigi.xyz's own stylesheet
   (style_8702.css) — same palette, same fonts, minus its --measure/--gutter
   max-width. */
:root {
    --bg: #dcdcdc;
    --card-bg: #fff;
    --bg-soft: #f0f0f0;
    --border: #999;
    --border-light: #ccc;
    --text: #000;
    --muted: #666;
    --link: #00e;
    --font: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

html {
    background: var(--bg);
}

body {
    margin: 2rem;
    padding: 2rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
}

@media (max-width: 600px) {
    body {
        margin: 0.75rem;
        padding: 1.25rem;
    }
}

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.25;
    margin: 1.25rem 0 0.5rem;
}

h2 { font-size: 1.4rem; }
h3 { margin-top: 1.9rem; font-size: 1.12rem; }

p { margin: 0 0 1.15rem; }

ul, ol {
    margin: 0 0 1.15rem;
    padding-left: 1.3rem;
}

li { margin: 0.3rem 0; }

a {
    color: var(--link);
    text-decoration: underline;
}

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

.nav-links a, .logout-form .logout-btn {
    text-decoration: none;
}

.nav-links a:hover, .logout-form .logout-btn:hover {
    text-decoration: underline;
}

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

/* ── Nav ────────────────────────────────────────────────────────────────── */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding-bottom: 1rem;
    margin-bottom: 1.75rem;
    border-bottom: 1px solid var(--border-light);
}

.nav h1 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1.1rem;
    font-size: 0.95rem;
}

.logout-form {
    display: contents;
}

.logout-form .logout-btn {
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    color: var(--link);
    font: inherit;
    cursor: pointer;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
label {
    display: block;
    margin: 0.85rem 0 0.3rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input, textarea, select {
    font: inherit;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
}

input:focus, textarea:focus, select:focus {
    outline: 2px solid var(--link);
    outline-offset: 1px;
}

button, input[type="submit"] {
    font: inherit;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    cursor: pointer;
}

button:hover, input[type="submit"]:hover {
    border-color: var(--link);
    color: var(--link);
}

form > button, form > input[type="submit"] {
    margin-top: 0.85rem;
    width: auto;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9rem;
    margin: 1.4rem 0;
}

th, td {
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--border-light);
}

thead th {
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

/* ── Definition lists (info.html) ──────────────────────────────────────────
   Same two-column dt/dd grid as kekavigi.xyz's own .links list. */
/* The `hidden` attribute only carries display:none from the UA sheet, so any
   author rule setting display on the same element un-hides it — `dl` right
   below is one. Stated once here rather than guarded per element. */
[hidden] {
    display: none !important;
}

dl {
    display: grid;
    grid-template-columns: 6.25rem 1fr;
    align-items: baseline;
    gap: 0 1rem;
    margin: 1.4rem 0;
}

dt, dd {
    margin: 0;
    padding: 0.55rem 0;
}

dt {
    font-weight: 700;
    white-space: nowrap;
}

@media (max-width: 480px) {
    dl { grid-template-columns: 1fr; }
    dt { padding: 0.55rem 0 0; }
    dd { padding-top: 0.15rem; }
}

/* ── Two-column guide body (info.html) ─────────────────────────────────────
   Multi-column rather than a grid, so the columns balance themselves. Sections
   never split across the rule. Below the breakpoint it folds back to one
   column and the rule goes with it. */
.info-grid {
    column-count: 2;
    column-gap: 2.5rem;
    column-rule: 1px solid var(--border-light);
}

.info-grid > section {
    break-inside: avoid;
    margin-bottom: 1.9rem;
}

/* The section already carries the gap, and the first heading in a column
   should sit level with the rule's top rather than below its own margin. */
.info-grid > section > h3 {
    margin-top: 0;
}

@media (max-width: 60rem) {
    .info-grid {
        column-count: 1;
        column-rule: none;
    }
}

/* ── Inline code ────────────────────────────────────────────────────────── */
code {
    font-family: Monaco, Consolas, "Lucida Console", monospace;
    font-size: 0.86em;
    background: var(--bg-soft);
    padding: 0.1em 0.35em;
}

/* ── Article / header blocks (dialogs, stat cards) ─────────────────────── */
article {
    border: 1px solid var(--border-light);
    padding: 1rem;
    margin: 1rem 0;
}

article header {
    font-weight: 600;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.error-msg {
    border: none;
    border-left: 2px solid currentColor;
    padding: 0.5rem 0 0.5rem 0.75rem;
    color: #b00020;
}

/* ── Dialogs ────────────────────────────────────────────────────────────── */
dialog {
    border: 1px solid var(--border);
    padding: 0;
    max-width: 480px;
    width: 90vw;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog article {
    position: relative;
    margin: 0;
    border: none;
    padding: 1.25rem;
}

button[aria-label="close"] {
    position: absolute;
    top: 0.9rem;
    right: 1rem;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

button[aria-label="close"]::before {
    content: "×";
}

button[aria-label="close"]:hover {
    color: var(--text);
    border: none;
}

/* ── Minion table (admin.html) ──────────────────────────────────────────
   A table wrapped in a sideways-scrolling box: on a phone the columns keep
   their alignment and the viewport pans across them. `tabindex` is not set on
   the wrapper, so keyboard users reach the overflow through the table. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.4rem 0;
}

.table-scroll > table {
    margin: 0;
}

/* Columns hold their labels rather than wrapping mid-word; the wrapper takes
   the extra width as scroll. */
.minion-table th,
.minion-table td {
    white-space: nowrap;
}

.minion-table button {
    padding: 0.2rem 0.6rem;
}

/* ── Screen-reader-only text ────────────────────────────────────────────── */
.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;
}

/* ── Toasts ─────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1000;
    max-width: min(360px, calc(100vw - 2rem));
}

.toast {
    padding: 0.6rem 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-light);
    color: var(--text);
    font-size: 0.95rem;
    animation: toast-in 0.18s ease-out;
    position: relative;
    cursor: pointer;
}

.toast-leaving {
    opacity: 0;
    transition: opacity 0.3s;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .toast { animation: none; }
    .toast-leaving { transition: none; }
}

@media (max-width: 600px) {
    .toast-container {
        top: 1rem;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        align-items: center;
    }
}
