/*
 * ConvertAll: the tool's own components, styled in the site's design language (13 Nov 2026, automatic mode, on the UltraCompress
 * Pro template). The first part is the shared block of the template tools (as in tools-app/word-counter/styles.css): tokens,
 * page, hero, buttons, toolbar and pill tabs, fields, toasts, information sections and windows. The second part is ConvertAll's
 * own components from the original's styles on the site's tokens: the category list, the smart search, the From and To boxes,
 * the yellow tape, every unit, saved pairs, settings and the practical tools. Its ink-black buttons and chips became the site's
 * pills; its own header, bottom tab bar on phones and footer are gone (nothing is fixed to the bottom of the screen). Base:
 * /libs/site-pages.css and /libs/shared-nav.css. Light is the default; dark applies when <html> has no data-theme. Written once
 * from the template and the original's styles, then edited by hand: this file is the source.
 */

/* ----- Tokens the tool adds ----- */
:root {
    --surface: #ffffff;
    --surface-2: #f3f4f8;
    --ring: rgba(139, 92, 246, 0.18);
    --app-max: 1600px;
    --line: rgba(0, 0, 0, 0.1);
    --line-strong: rgba(0, 0, 0, 0.24);
    --ok: #166534;
    --ok-soft: rgba(22, 101, 52, 0.09);
    --bad: #b91c1c;
    --bad-soft: rgba(185, 28, 28, 0.08);
    --warn: #92400e;
    --warn-soft: rgba(217, 119, 6, 0.1);
    --head: 81px;
    /* the original's names, on the site's tokens */
    --panel: var(--surface);
    --panel-2: var(--surface-2);
    --muted: var(--text-2);
    --border: var(--line);
    --border-strong: var(--line-strong);
    --good: var(--ok);
    --focus: var(--brand);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    /* the tape keeps the original's measuring-tape yellow in both themes */
    --blade: #f6c21c;
    --blade-hi: #ffd94f;
    --blade-edge: #c39500;
    --blade-ink: #1d1b14;
    --blade-off: #d9d4c2;
    --needle: #e0313a;
    --tile-bg: #16191f;
    --tile-ink: #f6c21c;
}
:root:not([data-theme="light"]) {
    --surface: #14141f;
    --surface-2: rgba(255, 255, 255, 0.05);
    --line: rgba(255, 255, 255, 0.1);
    --line-strong: rgba(255, 255, 255, 0.26);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.1);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.1);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.1);
    --blade-off: #5a5546;
    --needle: #ff4f57;
    --tile-bg: #262b33;
}
@media (max-width: 639.98px) { :root { --head: 65px; } }

/* ----- Page: full width, the page provides the side space ----- */
.container.app-container { max-width: calc(var(--app-max) + 2 * var(--content-gutter)); margin-top: 16px; }
@media (min-width: 640px) { .container.app-container { margin-top: 24px; } }

/* ----- The site header is the first thing on the page and stays at the top ----- */
body { padding-top: 0; }
body > header { position: sticky; top: 0; z-index: 50; }
header .site-nav { position: relative; top: auto; }
.theme-toggle { top: 90px; }
@media (max-width: 639.98px) { .theme-toggle { top: 75px; } } /* the header is 81 px tall from 640 px, 65 px below */
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ----- Hero ----- */
.app-hero { margin: 0 0 2rem; text-align: center; }
.app-brand { display: inline-flex; align-items: center; gap: 12px; margin-bottom: 1.25rem; font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700; font-size: 1.1rem; color: var(--text-strong); }
.app-brand img { width: 44px; height: 44px; border-radius: 12px; display: block; }
.app-hero h1 { margin-bottom: 0.75rem; }
.app-tagline { color: var(--text-2); font-size: 1.125rem; line-height: 1.6; max-width: 46rem; margin: 0 auto; }

/* ----- The site's text rules (p, ul, li, headings, tables) must not reach the tool: same weight as the site's ----- */
:where(.app-shell) p, :where(.app-shell) ul, :where(.app-shell) ol, :where(.app-shell) li, :where(.dialog) p, :where(.dialog) ul, :where(.dialog) li { margin: 0; line-height: 1.5; }
:where(.app-shell) ul, :where(.app-shell) ol { padding: 0; list-style: none; }
:where(.app-shell) h2, :where(.app-shell) h3, :where(.app-shell) h4, :where(.dialog) h2, :where(.dialog) h3 { margin: 0; line-height: 1.25; }
:where(.app-shell) table, :where(.dialog) table { width: auto; margin: 0; border-radius: 0; overflow: visible; background: none; }
:where(.app-shell) th, :where(.app-shell) td { border: 0; padding: 0; color: inherit; }
.app-shell, .dialog { font-size: 1rem; }

/* ----- Small helpers ----- */
main [hidden], .dialog [hidden] { display: none !important; }
.ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 0.82rem; font-weight: 400; line-height: 1.45; }
.hint:empty { display: none; }
.err { color: var(--bad); font-size: 0.85rem; font-weight: 600; }
.err:empty { display: none; }
/* What a tool has to say about a value that is no mistake but gives no answer (a measurement outside its chart). */
.tool-note { color: var(--warn); font-size: 0.9rem; font-weight: 600; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.link:hover { color: var(--link-hover); }
.app-shell code, .dialog code { font-family: var(--mono); font-size: 0.85em; padding: 1px 6px; border-radius: 6px; background: var(--code-bg); color: var(--code-text); }
kbd { font-family: var(--mono); font-size: 0.78rem; font-weight: 700; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--chip-border); border-bottom-width: 2px; background: var(--chip); color: var(--text-strong); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ----- Buttons: the original's classes in the site's pills ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 1px solid var(--surface-border); border-radius: 9999px; background: var(--surface); color: var(--text-strong); font-family: inherit; font-weight: 600; font-size: 0.925rem; line-height: 1.2; padding: 10px 20px; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease; }
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-2px); }
.btn .ico { width: 17px; height: 17px; }
.btn.primary, .btn[aria-pressed="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }
.btn.primary:hover:not(:disabled), .btn[aria-pressed="true"]:hover { color: #fff; box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4); }
.btn[aria-pressed="true"] .ico { fill: currentColor; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { border-color: var(--brand); }
.btn.danger { color: var(--danger); border-color: rgba(185, 28, 28, 0.35); }
.btn.danger:hover:not(:disabled) { background: var(--danger-strong); color: #fff; border-color: transparent; }
.small-btn { min-height: 36px; padding: 7px 14px; font-size: 0.85rem; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--surface-border); background: var(--surface); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; padding: 0; font-family: inherit; transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.icon-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }

/* ----- Toolbar and the four sections as pill tabs ----- */
.app-shell { margin: 0 0 3rem; scroll-margin-top: 90px; display: flex; flex-direction: column; gap: 20px; }
.app-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 26px; background: var(--surface-2); max-width: 100%; }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 16px; border: 0; border-radius: 9999px; background: transparent; font-family: inherit; font-size: 0.875rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease; }
.tab .ico { width: 16px; height: 16px; }
.tab:hover { color: var(--link); }
.tab[aria-current="page"] { background: var(--gradient-brand); color: #fff; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
@media (min-width: 1024px) { .tab-browse { display: none; } }
@media (max-width: 639.98px) {
    .app-toolbar { flex-direction: column-reverse; align-items: stretch; }
    .toolbar-right { justify-content: flex-start; } /* away from the site's round theme button at the right edge */
    .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; border-radius: 22px; }
    .tab { padding: 8px 4px; min-width: 0; }
    .tab .ico { display: none; }
}
.shell-hint { margin: 0; }
.shell-hint .link { font-size: inherit; }

/* ----- Fields ----- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; padding: 0; margin: 0; }
.label { font-weight: 600; font-size: 0.875rem; color: var(--text-strong); }
.input, .select { width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px; background: var(--field); border: 1px solid var(--field-border); border-radius: 12px; font-family: inherit; font-size: 0.95rem; color: var(--text); outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.input::placeholder { color: var(--placeholder); }
.input[aria-invalid="true"] { border-color: var(--bad); }
textarea.input { resize: vertical; min-height: 150px; line-height: 1.55; }
.select { width: auto; max-width: 100%; appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 14px; cursor: pointer; }
.select option, .fbox-unit option { color: #0a0a14; background: #fff; }
.check-row { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: 0.925rem; color: var(--text); padding: 4px 0; }
.check-row input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 6px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--surface); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease; }
.seg button:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.seg button[aria-checked="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 5px 13px; border-radius: 9999px; border: 1px solid var(--chip-border); background: var(--chip); font-family: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text-2); cursor: pointer; transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease; }
.chip .ico { width: 14px; height: 14px; }
.chip:hover { border-color: var(--brand); color: var(--link); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--gradient-brand); color: #fff; border-color: transparent; }
.chip.saved .ico-star { fill: var(--blade); color: var(--blade-edge); }
.chip[aria-pressed="true"] .ico-star { color: #fff; }

/* ----- Toasts ----- */
.toasts { position: fixed; bottom: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; max-width: calc(100vw - 32px); pointer-events: none; }
.toast { pointer-events: auto; background: #0a0a14; color: #fff; border: 1px solid rgba(255, 255, 255, 0.12); border-left: 4px solid var(--brand); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3); min-width: 260px; max-width: 460px; font-size: 0.875rem; font-weight: 500; overflow-wrap: anywhere; animation: slideIn 0.3s ease; transition: opacity 0.3s ease, transform 0.3s ease; }
.toast.leaving { opacity: 0; transform: translateX(40px); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ----- Information sections ----- */
.info-section { margin: 0 0 2.5rem; }
.info-section h2 { font-size: 1.75rem; margin: 0 0 1.25rem; }
.info-section .info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 1rem 0 1.5rem; }
.info-stack { display: grid; gap: 12px; }
.info-card { background: var(--surface); border: 1px solid var(--surface-border); border-radius: 16px; box-shadow: var(--surface-shadow); padding: 20px; transition: transform 0.3s ease, box-shadow 0.3s ease; }
.info-card:hover { transform: translateY(-4px); box-shadow: var(--surface-hover-shadow); }
.info-card--small { padding: 16px; box-shadow: none; }
.info-card h3 { margin: 0 0 0.75rem; font-size: 1.15rem; }
.info-card p { color: var(--text-2); margin-bottom: 0.75rem; }
.info-card p:last-child { margin-bottom: 0; }
.step-card { position: relative; padding-top: 24px; }
.step-num { position: absolute; top: -16px; left: 20px; width: 34px; height: 34px; border-radius: 50%; background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); }
.step-head { display: flex; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.step-head h3 { margin: 0; }
.step-emoji { font-size: 1.6rem; line-height: 1; }
.info-section details.info-card { padding: 0; }
.info-section details.info-card summary { cursor: pointer; padding: 16px 20px; font-weight: 600; color: var(--text-strong); list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.info-section details.info-card summary::-webkit-details-marker { display: none; }
.info-section details.info-card summary::after { content: '+'; color: var(--link); font-weight: 700; font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.info-section details.info-card[open] summary::after { content: '\2212'; }
.info-section details.info-card p { padding: 0 20px 16px; margin: 0; color: var(--text-2); }

/* ----- Windows (the original's: the head and the buttons sit inside the body) ----- */
.dialog { margin: auto; border: 1px solid var(--surface-border); border-radius: 20px; padding: 0; width: min(520px, calc(100vw - 16px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35); }
.dialog.wide { width: min(700px, calc(100vw - 16px)); }
.dialog::backdrop { background: rgba(10, 10, 20, 0.6); backdrop-filter: blur(6px); }
.dialog[open] { animation: pop 0.2s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.dialog-body h2 { font-size: 1.2rem; color: var(--text-strong); }
.dialog-body h3 { font-size: 1rem; color: var(--text-strong); margin-top: 6px; }
.dialog-body p { color: var(--text); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; align-items: center; }
.examples { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; list-style: disc; }
.plain-list { margin: 0; padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; list-style: disc; }

/* ===== ConvertAll's own components ===== */

/* ----- Layout: the category list beside the workspace from 1024 px; Saved and Settings replace both ----- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
@media (min-width: 1024px) { .layout { grid-template-columns: 236px minmax(0, 1fr); gap: 40px; } }
.app-shell:not([data-view="convert"]):not([data-view="browse"]) .layout { display: none; }
.screen { display: flex; flex-direction: column; gap: 22px; width: 100%; min-width: 0; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.view-title { font-size: clamp(1.35rem, 2.4vw, 1.7rem); color: var(--text-strong); }
.lead { margin-top: 4px; color: var(--muted); max-width: 72ch; }
.workspace { min-width: 0; display: flex; flex-direction: column; gap: 22px; outline: none; }
#page { display: flex; flex-direction: column; gap: 26px; min-width: 0; }

/* ----- The category list (rail) ----- */
.rail { display: none; min-width: 0; }
.app-shell[data-view="browse"] .rail { display: block; }
.app-shell[data-view="browse"] .workspace { display: none; }
@media (min-width: 1024px) {
    .rail { display: block; position: sticky; top: calc(var(--head) + 16px); max-height: calc(100vh - var(--head) - 32px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding-right: 4px; }
    .app-shell[data-view="browse"] .workspace { display: flex; }
}
.rail-search { position: relative; margin-bottom: 14px; }
.rail-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.rail-input { width: 100%; min-height: 42px; padding: 9px 12px 9px 38px; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); color: var(--text); font-family: inherit; font-size: 0.95rem; outline: none; }
.rail-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.rail-group { margin-bottom: 16px; }
.rail-group h2 { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin: 0 0 4px; letter-spacing: 0.01em; font-family: inherit; }
.rail-items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.app-shell[data-view="browse"] .rail-items { gap: 4px; }
@media (min-width: 480px) and (max-width: 1023px) { .app-shell[data-view="browse"] .rail-items { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 760px) and (max-width: 1023px) { .app-shell[data-view="browse"] .rail-items { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rail-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 4px 8px 4px 4px; border: 0; border-radius: 12px; background: transparent; text-align: left; font-family: inherit; font-size: 0.925rem; color: var(--text); cursor: pointer; transition: background 0.2s ease, color 0.2s ease; }
.rail-item:hover { background: var(--tint-brand); color: var(--link); }
.rail-item[aria-current="page"] { background: var(--surface); font-weight: 650; box-shadow: inset 3px 0 0 var(--brand), 0 1px 3px rgba(0, 0, 0, 0.08); }
.rail-item .rail-sub { display: block; font-size: 0.76rem; color: var(--muted); font-weight: 400; }
.rail-empty { color: var(--muted); font-size: 0.9rem; padding: 8px 0; }

/* Symbol tiles: the unit symbol is the icon (the original's ink and yellow). */
.tile { flex: none; display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; padding: 0 2px; background: var(--tile-bg); color: var(--tile-ink); font-weight: 700; font-size: 0.72rem; letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; overflow: hidden; white-space: nowrap; }
.tile.long { font-size: 0.6rem; }
.tile.big { width: 46px; height: 46px; border-radius: 12px; font-size: 0.95rem; }
.tile.big.long { font-size: 0.76rem; }

/* ----- The smart search ----- */
.smart { position: relative; display: flex; align-items: center; z-index: 15; }
.smart-ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.smart-input { width: 100%; min-height: 50px; padding: 12px 52px 12px 44px; border: 1px solid var(--field-border); border-radius: 14px; background: var(--field); color: var(--text); font-family: inherit; font-size: 1rem; outline: none; transition: border-color 0.2s ease, box-shadow 0.2s ease; }
.smart-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.smart-input::placeholder { color: var(--placeholder); }
.smart-kbd { position: absolute; right: 16px; color: var(--muted); pointer-events: none; }
.smart-input:focus ~ .smart-kbd { display: none; }
@media (hover: none) { .smart-kbd { display: none; } }
.smart-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--surface-border); border-radius: 14px; box-shadow: 0 16px 44px rgba(0, 0, 0, 0.22); max-height: min(60vh, 420px); overflow-y: auto; }
.smart-results li { display: flex; align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px; cursor: pointer; min-height: 48px; color: var(--text); }
.smart-results li[aria-selected="true"], .smart-results li:hover { background: var(--tint-brand); }
.smart-results .sr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.smart-results .sr-value { font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--text-strong); }
.smart-results .sr-sub { font-size: 0.82rem; color: var(--muted); }
.smart-results .sr-msg { color: var(--muted); font-size: 0.9rem; cursor: default; }

/* ----- The converter ----- */
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between; }
.page-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title p { color: var(--muted); font-size: 0.875rem; }
.pairs-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pairs-row .label-inline { font-size: 0.82rem; color: var(--muted); margin-right: 4px; }
.conv { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); align-items: stretch; }
@media (min-width: 900px) { .conv { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 14px; } }
.fbox { scroll-margin-top: calc(var(--head) + 12px); scroll-margin-bottom: 12px; display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--surface-border); border-radius: 16px; background: var(--surface); box-shadow: var(--surface-shadow); transition: border-color 0.2s ease, box-shadow 0.2s ease; overflow: hidden; }
.fbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.fbox.invalid { border-color: var(--bad); }
.fbox-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 8px 8px 0; }
.fbox-input { border: 0; background: transparent; outline: none; width: 100%; min-width: 0; font-family: inherit; color: var(--text-strong); font-size: clamp(1.6rem, 3.4vw, 2.35rem); font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; padding: 2px 8px 8px; line-height: 1.2; }
.fbox-input::placeholder { color: var(--placeholder); }
.fbox-note { padding: 0 8px 8px; font-size: 0.85rem; color: var(--muted); min-height: 1.5em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fbox-note.err { color: var(--bad); font-weight: 600; }
.fbox-unit { border: 0; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--text-strong); min-height: 46px; padding: 10px 8px; font-family: inherit; font-size: 0.95rem; font-weight: 600; width: 100%; cursor: pointer; outline: none; }
.fbox-unit:focus-visible { outline: 2px solid var(--brand); outline-offset: -3px; }
.swap { align-self: center; justify-self: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--surface-border); background: var(--surface); color: var(--text-strong); display: grid; place-items: center; cursor: pointer; transition: transform 0.25s ease, border-color 0.2s ease, color 0.2s ease; }
.swap:hover { border-color: var(--brand); color: var(--link); }
.swap .ico { width: 22px; height: 22px; }
@media (min-width: 900px) { .swap .ico { transform: rotate(90deg); } }
.swap.turn { transform: rotate(180deg); }
.equation { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 0.925rem; color: var(--text); }
.equation .eq-main { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--text-strong); font-weight: 600; }
.equation .eq-sub { color: var(--muted); font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 9999px; font-size: 0.78rem; font-weight: 700; border: 1px solid var(--line); white-space: nowrap; }
.tag .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.tag.exact { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.tag.rounded { color: var(--muted); }
.tag.approx { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.region-note { font-size: 0.85rem; color: var(--warn); }

/* ----- The tape ----- */
.tape-wrap { display: flex; flex-direction: column; gap: 8px; }
.tape { position: relative; height: 100px; border-radius: 12px; overflow: hidden; touch-action: pan-y; cursor: grab; user-select: none; -webkit-user-select: none; box-shadow: 0 1px 0 var(--blade-edge), 0 6px 18px rgba(120, 90, 0, 0.18); }
:root:not([data-theme="light"]) .tape { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.tape:active { cursor: grabbing; }
.tape:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
.tape svg { display: block; width: 100%; height: 100%; }
.tape .blade { fill: var(--blade); }
.tape .blade-hi { fill: var(--blade-hi); opacity: 0.55; }
.tape .off { fill: var(--blade-off); opacity: 0.6; }
.tape .seam { stroke: var(--blade-edge); stroke-width: 1; }
.tape .tick { stroke: var(--blade-ink); stroke-width: 1; shape-rendering: crispEdges; }
.tape .tick.major { stroke-width: 1.6; }
.tape .lab { fill: var(--blade-ink); font: 600 11px 'Inter', system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.tape .unit-tab { fill: var(--blade-ink); }
.tape .unit-lab { fill: var(--blade); font: 700 11px 'Inter', system-ui, sans-serif; }
.tape .needle { stroke: var(--needle); stroke-width: 2.4; }
.tape .needle-cap { fill: var(--needle); }
.tape-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); }
.zoom { display: inline-flex; gap: 6px; }
.zoom .icon-btn { width: 36px; height: 36px; }

/* ----- Every unit ----- */
.units-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.units-head h3 { font-size: 1.05rem; color: var(--text-strong); }
.units-filter { position: relative; flex: 0 1 280px; min-width: 180px; }
.units-filter .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.units-filter .input { padding-left: 38px; min-height: 40px; }
.ugroup-title { font-size: 0.82rem; color: var(--muted); font-weight: 600; margin: 14px 0 4px; font-family: inherit; }
.ulist { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 28px; }
@media (min-width: 760px) { .ulist { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .ulist { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.urow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 10px; border-bottom: 1px solid var(--line); min-height: 48px; padding: 4px 0; }
.urow.is-to .u-name { font-weight: 700; }
.urow.is-to { box-shadow: inset 3px 0 0 var(--brand); padding-left: 8px; }
.u-set { border: 0; background: transparent; padding: 4px 0; text-align: left; min-width: 0; display: flex; flex-direction: column; border-radius: 6px; font-family: inherit; color: var(--text); cursor: pointer; }
.u-set:hover .u-name { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.u-name { font-size: 0.9rem; overflow-wrap: anywhere; }
.u-val { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.95rem; text-align: right; overflow-wrap: anywhere; color: var(--text-strong); }
.u-val sup, .eq-main sup, .sr-value sup { font-size: 0.7em; }
.u-acts { display: flex; gap: 2px; }
.u-acts button { width: 34px; height: 34px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; padding: 0; cursor: pointer; }
.u-acts button:hover { background: var(--tint-brand); color: var(--link); }
.u-acts button[aria-pressed="true"] { color: var(--link); }
.u-acts button[aria-pressed="true"] .ico { fill: currentColor; }
.u-acts .ico { width: 16px; height: 16px; }

/* ----- Sections, lists, tables ----- */
.section { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 18px; min-width: 0; }
.section > h3 { font-size: 1.05rem; color: var(--text-strong); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-head h3 { font-size: 1.05rem; color: var(--text-strong); }
.list { display: flex; flex-direction: column; }
.lrow { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); padding: 8px 0; min-height: 56px; }
.lrow-main { flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 2px 0; display: flex; align-items: center; gap: 12px; border-radius: 8px; font-family: inherit; color: var(--text); cursor: pointer; }
.lrow-main > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.lrow-main:hover .lrow-title { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.lrow-title { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--text-strong); }
.lrow-sub { font-size: 0.82rem; color: var(--muted); }
.lrow .icon-btn { width: 36px; height: 36px; border-color: transparent; background: transparent; color: var(--muted); }
.lrow .icon-btn:hover { color: var(--bad); }
.empty { color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 14px; padding: 22px 8px; text-align: center; font-size: 0.925rem; }
.saved-cols { display: grid; gap: 32px 48px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .saved-cols { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); } }
.saved-cols section { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.table-wrap { overflow-x: auto; }
.app-shell .table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; color: var(--text); }
.app-shell .table th, .app-shell .table td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.app-shell .table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; background: none; }
.app-shell .table tbody tr:hover { background: var(--surface-2); }
.app-shell .table tr.hit td { background: color-mix(in srgb, var(--blade) 28%, transparent); font-weight: 700; color: var(--text-strong); }
.app-shell .table tr.hit td .muted, .app-shell .table tr.hit td .link { color: var(--text-strong); }
.app-shell .table tr.hit td:first-child { box-shadow: inset 3px 0 0 var(--blade-edge); padding-left: 6px; }
.app-shell .table .click-row { cursor: pointer; }
.settings-grid { display: grid; gap: 28px 56px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.set-group { display: flex; flex-direction: column; gap: 14px; border-top: 1px solid var(--line); padding-top: 18px; min-width: 0; color: var(--text); }
.set-group h3 { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; color: var(--text-strong); }
.set-group .select { width: 100%; }

/* ----- The practical tools ----- */
.form-grid { display: grid; gap: 14px 18px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } .form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.pair { display: flex; gap: 8px; }
.pair .input { flex: 1 1 auto; min-width: 0; }
.pair .select, .pair .btn { flex: 0 0 auto; }
.readouts { display: grid; gap: 0 32px; grid-template-columns: minmax(0, 1fr); margin: 0; }
@media (min-width: 640px) { .readouts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .readouts { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.readouts div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--line); padding: 10px 0; min-width: 0; }
.readouts dt { color: var(--muted); font-size: 0.9rem; }
.readouts dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; overflow-wrap: anywhere; color: var(--text-strong); }
.readouts .lead-out { grid-column: 1 / -1; }
.readouts .lead-out dd { font-size: clamp(1.3rem, 2.6vw, 1.8rem); }
.readouts .lead-out dd .num { overflow-wrap: anywhere; }
.big-out { font-size: clamp(1.1rem, 2vw, 1.35rem); font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; color: var(--text-strong); }
.words { font-size: 1.05rem; line-height: 1.6; overflow-wrap: anywhere; max-width: 80ch; color: var(--text); }
.prose-out { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.7; border-left: 3px solid var(--blade); padding: 2px 0 2px 14px; overflow-wrap: anywhere; color: var(--text); }
.scale-bar { position: relative; height: 14px; border-radius: 999px; overflow: visible; display: flex; margin: 18px 0 30px; }
.scale-bar span { height: 100%; }
.scale-bar span:first-child { border-radius: 999px 0 0 999px; }
.scale-bar span:nth-child(4) { border-radius: 0 999px 999px 0; }
.scale-bar .seg-a { background: color-mix(in srgb, #d97706 55%, transparent); }
.scale-bar .seg-b { background: color-mix(in srgb, #16a34a 60%, transparent); }
.scale-bar .seg-c { background: color-mix(in srgb, #d97706 75%, transparent); }
.scale-bar .seg-d { background: color-mix(in srgb, #dc2626 70%, transparent); }
.scale-bar .marker { position: absolute; top: -6px; width: 4px; height: 26px; border-radius: 2px; background: var(--text-strong); transform: translateX(-2px); }
.scale-bar .marker-lab { position: absolute; top: 24px; transform: translateX(-50%); font-size: 0.8rem; font-weight: 700; white-space: nowrap; color: var(--text-strong); }
.visual { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; }
.visual svg { max-width: 100%; height: auto; }
.visual figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.diff-pos { color: var(--ok); }
.diff-neg { color: var(--bad); }
.app-shell .readouts dd .icon-btn { width: 32px; height: 32px; display: inline-grid; vertical-align: middle; }

/* ----- Phones ----- */
@media (max-width: 639px) {
    .app-hero { margin-bottom: 1.5rem; }
    .app-tagline { font-size: 1rem; }
    .toasts { bottom: 16px; right: 16px; left: 16px; align-items: stretch; }
    .toast { min-width: 0; max-width: none; }
    .dialog-body { padding: 16px; }
    .info-section h2 { font-size: 1.4rem; }
    .info-section .info-grid, .info-three { grid-template-columns: 1fr; }
    .info-card { padding: 16px; }
    .step-num { left: 16px; }
}
@media (max-width: 420px) {
    .page-head .actions .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .page-head .actions .btn { padding: 9px 12px; }
}
@media (min-width: 640px) and (max-width: 1023.98px) {
    .info-section .info-grid, .info-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    .btn, .icon-btn, .tab, .seg button, .chip, .info-card, .dialog, .toast, .swap, .rail-item { transition: none; animation: none; }
    .btn:hover, .icon-btn:hover, .chip:hover, .seg button:hover, .info-card:hover { transform: none; }
}

@media print {
    .app-toolbar, .shell-hint, .toasts, .rail, .smart, .tape-wrap, .theme-toggle { display: none !important; }
}

/* Phones: 16 px text, 44 px tap targets (AdSense audit H-04, 8 Oct 2026). */
@media (max-width: 639.98px) {
    main button, main select, main summary, main [role="button"], main .btn,
    main input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="range"]) { min-height: 44px; }
    main .icon-btn, main .zoom .icon-btn, main .lrow .icon-btn, main .readouts dd .icon-btn { width: 44px; height: 44px; min-width: 44px; }
    main .tab { min-width: 44px; }
    main .u-acts button { width: 44px; height: 44px; }
    main .rail-item { min-height: 44px; }
    main :is(p, li, .hint, .label, .input, .select, .seg button, .chip, .tab, .muted, .link, .check-row, .rail-item, .rail-sub, .rail-input, .smart-input, .sr-sub, .fbox-label, .fbox-note, .fbox-unit, .equation, .eq-sub, .tag, .region-note, .tape-bar, .u-name, .u-val, .ugroup-title, .lrow-title, .lrow-sub, .empty, .readouts dt, .readouts dd, .table, .big-out, .words, .prose-out, .page-title p, .label-inline, .err, .visual figure, .marker-lab, .rail-group h2, .rail-empty) { font-size: 1rem; }
    main .readouts .lead-out dd { font-size: 1.3rem; }
    .dialog button, .dialog .btn, .dialog input:not([type="checkbox"]), .dialog select { min-height: 44px; }
    .dialog .icon-btn { width: 44px; height: 44px; }
    .dialog :is(p, li, .hint, .label, .input, .muted, .small, .examples) { font-size: 1rem; }
    main .check-row { min-height: 44px; align-items: center; }
    main .seg button, main .chip { min-height: 44px; }
    main .page-head .actions .btn { min-width: 44px; }
    main .urow { grid-template-columns: minmax(44px, 1fr) minmax(0, auto) auto; }
    main .u-set { min-width: 44px; }
    main .app-shell .table th, main .app-shell .table td, main .smart-results li, main .smart-results .sr-msg { font-size: 1rem; }
    /* The second line of a Browse entry and the words on buttons are read like any other text (14 Nov 2026). */
    main .app-shell .rail-item .rail-sub, main .app-shell .btn, main .app-shell .btn span, main .app-shell .tool-note { font-size: 1rem; }
    main .app-shell .table .link { min-width: 44px; min-height: 44px; text-align: left; }
}
