/* Reset, type, buttons and form controls. */

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    /* A faint dot grid: the desk is a drafting surface, not a void. */
    background: radial-gradient(var(--dots) 1px, transparent 1.5px) 0 0 / 22px 22px, var(--desk);
    color: var(--ink);
    font: 400 0.875rem/1.45 var(--sans);
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset, pre { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 8px 0; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: 0.01em; line-height: 1.15; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1rem; }
h3 { font-size: 1.125rem; }

a { color: inherit; }
b, strong { font-weight: 600; }
small { font-size: 0.8125rem; color: var(--ink-soft); }
code, .mono { font-family: var(--mono); font-size: 0.8125rem; }
kbd {
    font: 600 0.6875rem var(--sans);
    padding: 2px 5px;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--ink-soft);
    background: var(--panel);
}
time { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
main:focus { outline: none; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.skip {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 100;
    padding: 8px 12px;
    background: var(--brand-fill);
    color: var(--on-brand);
    border-radius: var(--r);
    transform: translateY(-200%);
}
.skip:focus { transform: none; }

.soft { color: var(--ink-soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.noscript { padding: 24px; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 34px;
    padding: 0 13px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--raised);
    color: var(--ink);
    font: 600 0.8125rem/1 var(--sans);
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}
.btn:hover { border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn.primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--brand-fill) 82%, white), var(--brand-fill));
    border-color: var(--brand-fill);
    color: var(--on-brand);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger, .btn[data-tone="danger"] { color: var(--down); }
.btn.danger { border-color: var(--down); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 0.78125rem; }
.btn.icon { width: 34px; padding: 0; }
.btn.block { width: 100%; height: 40px; }
.btn .i { flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--brand);
    font: 600 0.8125rem var(--sans);
    text-decoration: none;
    cursor: pointer;
}
.link:hover { text-decoration: underline; }

.i {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: none;
}

/* ---------- Form controls ---------- */

input, select, textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--raised);
    color: var(--ink);
    font: 400 0.875rem/1.4 var(--sans);
}
input[type="checkbox"] { width: 16px; min-height: 0; height: 16px; padding: 0; accent-color: var(--brand-fill); flex: none; }
input[readonly] { background: var(--well); color: var(--ink-soft); }
input::placeholder, textarea::placeholder { color: var(--ink-faint); }
textarea { resize: vertical; }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

.field { display: grid; gap: 6px; }
.field-label { font-weight: 600; font-size: 0.8125rem; }
.field-hint { font-size: 0.8125rem; color: var(--ink-soft); }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.field.row .field-label { font-weight: 400; font-size: 0.875rem; }

.affix { display: flex; align-items: stretch; }
.affix input { border-radius: var(--r) 0 0 var(--r); min-width: 0; }
.affix span {
    display: flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 var(--r) var(--r) 0;
    background: var(--well);
    color: var(--ink-soft);
    font-family: var(--mono);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.check { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.group { display: grid; gap: 12px; }
.group legend { font: 700 0.9375rem var(--display); padding: 0; margin-bottom: 10px; }

.form { display: grid; gap: 16px; }
.form-end { display: flex; justify-content: flex-end; gap: 8px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0; cursor: pointer; }
.switch-track {
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: var(--line);
    transition: background 0.15s;
    position: relative;
    flex: none;
}
.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--raised);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--brand-fill); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brand); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); background: var(--well); padding: 2px; gap: 2px; }
.seg button {
    height: 28px;
    padding: 0 11px;
    border: 0;
    border-radius: 3px;
    background: none;
    color: var(--ink-soft);
    font: 600 0.8125rem var(--sans);
    cursor: pointer;
    white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--raised); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.pick select { width: auto; min-height: 34px; padding-block: 5px; font-weight: 600; font-size: 0.8125rem; }

.search { position: relative; display: flex; align-items: center; flex: 1 1 200px; max-width: 320px; }
.search .i { position: absolute; left: 10px; color: var(--ink-faint); pointer-events: none; }
.search input { padding-left: 32px; min-height: 34px; }

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