/* Shared look for the engineering tools, matching the landing page and app.
   Colours come from the CSS variables in tools.css; `.paper` areas and print use the light palette. */
:root { color-scheme: dark; --brand: #ffb020; --brand-ink: #0a0a0a; --cyan: #5ee6ff; }
.paper, .no-theme { color-scheme: light; color: #0f172a; }
.paper { background-color: #fff; }

html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif !important;
    background-color: #07090d;
    color: rgb(var(--c-slate-800));
    letter-spacing: -0.005em;
}
body::before {
    content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background:
        radial-gradient(60vmax 40vmax at 90% -10%, rgba(255, 176, 32, 0.08), transparent 60%),
        radial-gradient(50vmax 40vmax at -10% 40%, rgba(94, 230, 255, 0.06), transparent 60%),
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 56px 56px,
        #07090d;
}
h1, h2, h3 { letter-spacing: -0.025em; }
::selection { background: var(--brand); color: #000; }
code, kbd, .font-mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Form controls (low specificity so utility classes still win) */
/* Element-level specificity: beats Tailwind's reset (same weight, loaded later) but not utility classes */
:is(input, select, textarea):where(:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file])) {
    background-color: rgba(0, 0, 0, 0.35);
    color: rgb(var(--c-slate-900));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}
:where(.paper) :where(input, select, textarea) { background-color: #fff; color: #111827; border-color: #d1d5db; }
input::placeholder, textarea::placeholder { color: #5b6576; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(255, 176, 32, 0.2) !important; }
input[type=range], input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
option { background: #0f141c; color: #eef2f8; }

/* Scrollbars */
* { scrollbar-color: #2b3443 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b3443; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }

/* Keep printed output plain */
@media print {
    :root { color-scheme: light; }
    body { background: #fff !important; color: #111 !important; }
    body::before { display: none; }
}

/* ---------- Light theme (html[data-theme=light], set by tools-theme.js; same switch as the app) ---------- */
:root[data-theme=light] { color-scheme: light; }
:root[data-theme=light] body { background-color: #f3f5f8; }
:root[data-theme=light] body::before {
    background:
        radial-gradient(60vmax 40vmax at 90% -10%, rgba(255, 176, 32, 0.10), transparent 60%),
        radial-gradient(50vmax 40vmax at -10% 40%, rgba(14, 116, 144, 0.06), transparent 60%),
        linear-gradient(rgba(15, 23, 42, 0.04) 1px, transparent 1px) 0 0 / 56px 56px,
        linear-gradient(90deg, rgba(15, 23, 42, 0.04) 1px, transparent 1px) 0 0 / 56px 56px,
        #f3f5f8;
}
:root[data-theme=light] :is(input, select, textarea):where(:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file])) { background-color: #fff; border-color: rgba(15, 23, 42, 0.16); }
:root[data-theme=light] input::placeholder, :root[data-theme=light] textarea::placeholder { color: #94a3b8; }
:root[data-theme=light] option { background: #fff; color: #0f172a; }
:root[data-theme=light] * { scrollbar-color: #c3cad6 transparent; }
:root[data-theme=light] ::-webkit-scrollbar-thumb { background: #c3cad6; background-clip: padding-box; }

/* ---------- The switch ---------- */
.cos-theme-toggle { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 999px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(15, 20, 28, 0.85); color: #eef2f8; transition: background .15s, transform .15s; }
.cos-theme-toggle:hover { background: rgba(255, 176, 32, 0.18); }
.cos-theme-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.cos-theme-toggle.floating { position: fixed; left: 14px; bottom: 14px; z-index: 2147482000; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
:root[data-theme=light] .cos-theme-toggle { border-color: rgba(15, 23, 42, 0.14); background: rgba(255, 255, 255, 0.92); color: #0f172a; }
:root[data-theme=light] .cos-theme-toggle.floating { box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15); }
@media print { .cos-theme-toggle { display: none !important; } }
