/* ==========================================================================
   Base: reset, typography, global elements
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font-sans);
    -webkit-font-smoothing: antialiased;
    transition: background-color var(--t) var(--ease), color var(--t) var(--ease);
}
/* kill legacy <center>/<font> side effects without touching markup */
center { display: block; text-align: center; }
font { color: inherit; font-size: inherit; }
img { max-width: 100%; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

h1, h2, h3, h4 { color: var(--text); line-height: 1.25; margin: 0 0 var(--space-3); letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
em { color: var(--text-muted); }

::selection { background: var(--primary-soft); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* ---------- form controls (also overrides legacy inline colors) ---------- */
input:not([type]), input[type=text], input[type=password], input[type=email], input[type=number], input[type=search],
input[type=tel], input[type=url], select, textarea {
    width: auto;
    max-width: 100%;
    font: inherit;
    padding: 10px 12px;
    color: var(--text) !important;
    background: var(--input-bg) !important;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:hover, select:hover, textarea:hover { border-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }
input[type=checkbox], input[type=radio] { accent-color: var(--primary); width: 1.05em; height: 1.05em; vertical-align: middle; }
select { appearance: none; padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important; background-position: right 12px center !important; }
label { color: var(--text-2); }

table { border-collapse: collapse; }
td, th { vertical-align: top; }

/* utilities */
.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.grow { flex: 1 1 auto; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
