/* =========================================================
   AURUM FINANCE — DESIGN SYSTEM
   Premium dark wealth dashboard with restrained gold accents.
   ========================================================= */
:root {
  color-scheme: dark;
  --bg: #060c17;
  --bg-elevated: #0a1322;
  --surface: #0e1828;
  --surface-2: #121e30;
  --surface-3: #17253a;
  --line: rgba(188, 205, 225, 0.12);
  --line-strong: rgba(188, 205, 225, 0.2);
  --text: #f4f7fb;
  --text-soft: #c8d1df;
  --muted: #8290a4;
  --muted-2: #657287;
  --gold: #d8ad58;
  --gold-bright: #f0cb77;
  --gold-soft: rgba(216, 173, 88, 0.13);
  --green: #4ed29a;
  --green-soft: rgba(78, 210, 154, 0.13);
  --amber: #f2bd5c;
  --amber-soft: rgba(242, 189, 92, 0.14);
  --orange: #f28b4b;
  --orange-soft: rgba(242, 139, 75, 0.14);
  --red: #f06c75;
  --red-soft: rgba(240, 108, 117, 0.14);
  --blue: #78a9ff;
  --blue-soft: rgba(120, 169, 255, 0.13);
  --shadow-sm: 0 10px 30px rgba(0, 0, 0, 0.16);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.28);
  --radius-sm: 10px;
  --radius-md: 15px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --focus: 0 0 0 3px rgba(216, 173, 88, 0.32);
  --header-height: 78px;
  --mobile-nav-height: 70px;
  --ease: cubic-bezier(.2,.8,.2,1);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f6;
  --bg-elevated: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #e9eef4;
  --line: rgba(20, 32, 50, 0.1);
  --line-strong: rgba(20, 32, 50, 0.17);
  --text: #111b2a;
  --text-soft: #37465a;
  --muted: #657287;
  --muted-2: #8290a4;
  --gold: #a67827;
  --gold-bright: #8d6218;
  --gold-soft: rgba(166, 120, 39, 0.1);
  --green: #16865b;
  --green-soft: rgba(22, 134, 91, 0.1);
  --amber: #9a6814;
  --amber-soft: rgba(154, 104, 20, 0.1);
  --orange: #bd5419;
  --orange-soft: rgba(189, 84, 25, 0.1);
  --red: #c53b49;
  --red-soft: rgba(197, 59, 73, 0.1);
  --blue: #3569be;
  --blue-soft: rgba(53, 105, 190, 0.1);
  --shadow-sm: 0 10px 30px rgba(35, 48, 66, 0.08);
  --shadow-lg: 0 24px 70px rgba(35, 48, 66, 0.13);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% -10%, rgba(216, 173, 88, 0.08), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
button, select { cursor: pointer; touch-action: manipulation; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .58; }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: none; box-shadow: var(--focus); }
input::placeholder { color: var(--muted-2); opacity: 1; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 999; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--gold); color: #15100a; font-weight: 800; transition: top .2s var(--ease); }
.skip-link:focus { top: 12px; }

.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 0 30px; }
.app-header { min-height: var(--header-height); display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 0 18px; }
.brand-block { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 46px; height: 46px; border: 1px solid rgba(216,173,88,.34); border-radius: 15px; background: var(--gold-soft); color: var(--gold-bright); box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.brand-mark svg { width: 24px; height: 24px; }
.brand-logo-frame { overflow: hidden; border-color: rgba(216,173,88,.42); background: #fff; }
.brand-logo-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.eyebrow, .section-kicker, .card-kicker { display: block; color: var(--gold); font-size: .68rem; font-weight: 800; letter-spacing: .14em; line-height: 1.2; text-transform: uppercase; }
.brand-title { margin-top: 3px; font-size: 1.08rem; font-weight: 850; letter-spacing: .1em; line-height: 1.1; }
.brand-title span { color: var(--gold); }
.brand-block p { margin: 5px 0 0; color: var(--muted); font-size: .78rem; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.connection-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-soft); font-size: .76rem; font-weight: 700; }
.signal-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.connection-pill.is-offline .signal-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.button, .icon-button { min-height: 44px; border: 1px solid transparent; border-radius: 12px; font-weight: 760; transition: transform .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease), color .2s var(--ease); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; font-size: .84rem; white-space: nowrap; }
.button:hover, .icon-button:hover { transform: translateY(-1px); }
.button:active, .icon-button:active, .tab-button:active, .segment:active { transform: scale(.98); }
.button-primary { background: var(--gold); color: #171106; box-shadow: 0 9px 22px rgba(216,173,88,.16); }
[data-theme="light"] .button-primary { color: #fff; }
.button-primary:hover { background: var(--gold-bright); }
.button-secondary { border-color: var(--line-strong); background: var(--surface); color: var(--text-soft); }
.button-secondary:hover { border-color: rgba(216,173,88,.44); color: var(--text); }
.button-danger { border-color: rgba(240,108,117,.26); background: var(--red-soft); color: var(--red); }
.icon-button { display: grid; place-items: center; width: 44px; padding: 0; border-color: var(--line); background: var(--surface); color: var(--text-soft); }
.is-loading .refresh-icon, .refresh-icon.is-spinning { animation: spin .85s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.market-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow-sm); overflow: hidden; }
.strip-stat { display: flex; align-items: center; min-width: 0; gap: 12px; padding: 16px 18px; border-right: 1px solid var(--line); }
.strip-stat:last-child { border-right: 0; }
.strip-icon { display: grid; place-items: center; flex: 0 0 auto; width: 38px; height: 38px; border-radius: 12px; background: var(--blue-soft); color: var(--blue); font-size: .75rem; font-weight: 850; }
.strip-icon.gold { background: var(--gold-soft); color: var(--gold); }
.strip-stat > div:last-child { min-width: 0; }
.strip-stat span { display: block; color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.strip-stat strong { display: block; overflow: hidden; margin-top: 4px; color: var(--text); font-size: .9rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.value-button { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; max-width: 100%; padding: 0; border: 0; background: none; text-align: left; }
.value-button:hover strong, .copy-value:hover strong { color: var(--gold-bright); }

.tab-nav { position: sticky; top: 10px; z-index: 50; display: flex; width: fit-content; max-width: 100%; margin: 20px auto 0; padding: 5px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--bg-elevated) 88%, transparent); box-shadow: var(--shadow-sm); backdrop-filter: blur(18px); }
.tab-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 155px; min-height: 46px; padding: 0 16px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 760; transition: background-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease); }
.tab-button:hover { color: var(--text); }
.tab-button.is-active { background: var(--surface-3); color: var(--gold-bright); box-shadow: inset 0 0 0 1px rgba(216,173,88,.12), 0 6px 14px rgba(0,0,0,.1); }
.tab-button svg { width: 18px; height: 18px; }

main { padding: 38px 0 70px; }
.tab-panel { animation: panel-in .28s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin: 7px 0 5px; font-size: clamp(1.65rem, 3vw, 2.35rem); font-weight: 760; letter-spacing: -.045em; line-height: 1.1; }
.page-heading p { max-width: 650px; margin: 0; color: var(--muted); font-size: .92rem; }

.card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card-head h2, .section-label h2, .converter-head h2 { margin: 5px 0 0; font-size: 1.05rem; line-height: 1.2; }
.status-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 25px; padding: 0 8px; border: 1px solid currentColor; border-radius: 999px; font-size: .6rem; font-weight: 850; letter-spacing: .1em; }
.status-live { background: var(--green-soft); color: var(--green); }
.status-cached { background: var(--amber-soft); color: var(--amber); }
.status-manual { background: var(--blue-soft); color: var(--blue); }
.status-error { background: var(--red-soft); color: var(--red); }
.status-loading { background: var(--gold-soft); color: var(--gold); }

.source-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.source-card { position: relative; min-height: 302px; padding: 22px; overflow: hidden; }
.source-card::after { content: ""; position: absolute; inset: auto -60px -90px auto; width: 190px; height: 190px; border: 1px solid rgba(216,173,88,.1); border-radius: 50%; pointer-events: none; }
.hero-quote { display: flex; align-items: baseline; min-height: 44px; max-width: 100%; margin: 32px 0 12px; padding: 0; border: 0; background: none; text-align: left; }
.hero-quote strong { overflow: hidden; color: var(--text); font-size: clamp(2.1rem, 5vw, 3.55rem); font-weight: 730; font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1; text-overflow: ellipsis; }
.hero-quote .quote-prefix { margin-right: 5px; color: var(--gold); font-size: 1.3rem; font-weight: 800; }
.hero-quote small { margin-left: 9px; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.source-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; padding-bottom: 18px; color: var(--muted); font-size: .72rem; }
.segmented { display: inline-flex; max-width: 100%; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: var(--bg-elevated); }
.segment { min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .03em; }
.segment:hover { color: var(--text-soft); }
.segment.is-active { background: var(--surface-3); color: var(--gold-bright); box-shadow: inset 0 0 0 1px var(--line); }
.segmented.compact .segment, .segmented.mini .segment { min-height: 44px; padding: 0 11px; font-size: .67rem; }
.manual-field { position: relative; z-index: 1; margin-top: 16px; }
label { display: block; margin-bottom: 7px; color: var(--text-soft); font-size: .76rem; font-weight: 730; }
.input-shell { display: flex; align-items: center; min-height: 48px; border: 1px solid var(--line-strong); border-radius: 11px; background: var(--bg-elevated); transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.input-shell:focus-within { border-color: rgba(216,173,88,.55); box-shadow: var(--focus); }
.input-shell > span { padding-left: 13px; color: var(--gold); font-size: .8rem; font-weight: 780; white-space: nowrap; }
.input-shell input { min-width: 0; width: 100%; height: 46px; padding: 0 12px; border: 0; outline: 0; background: transparent; color: var(--text); font-variant-numeric: tabular-nums; }
.input-shell input:focus { box-shadow: none; }
.input-shell input[readonly] { color: var(--text-soft); }
.input-shell small { padding-right: 13px; color: var(--muted); font-size: .68rem; font-weight: 700; white-space: nowrap; }
.field-note { margin: 7px 0 0; color: var(--muted); font-size: .67rem; }

.section-label { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 38px 0 15px; }
.section-label > div > span { color: var(--muted); font-size: .7rem; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.formula-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-family: var(--mono); font-size: .66rem; }
.gold-result-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.karat-card { position: relative; display: grid; grid-template-columns: auto minmax(120px,.65fr) minmax(220px,1fr); align-items: center; gap: 20px; min-height: 170px; padding: 24px; overflow: hidden; }
.karat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--gold); }
.karat-18::before { background: var(--blue); }
.karat-orb { display: grid; place-items: center; width: 74px; height: 74px; border: 1px solid rgba(216,173,88,.32); border-radius: 50%; background: var(--gold-soft); color: var(--gold-bright); }
.karat-18 .karat-orb { border-color: rgba(120,169,255,.28); background: var(--blue-soft); color: var(--blue); }
.karat-orb span { grid-area: 1/1; margin-top: -5px; font-size: 1.55rem; font-weight: 800; line-height: 1; }
.karat-orb small { grid-area: 1/1; align-self: end; margin-bottom: 10px; font-size: .56rem; font-weight: 850; }
.karat-copy span { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.karat-copy h3 { margin: 4px 0 0; font-size: 1.15rem; }
.karat-values { border-left: 1px solid var(--line); padding-left: 20px; }
.metric-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; min-height: 48px; padding: 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); font-size: .7rem; }
.metric-row strong { font-size: .94rem; font-variant-numeric: tabular-nums; text-align: right; }

.insight-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; margin-top: 18px; }
.market-compare-card { padding: 22px; }
.compare-columns { display: grid; grid-template-columns: repeat(2,1fr); gap: 1px; margin: 22px 0 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--line); overflow: hidden; }
.compare-columns > div { padding: 16px; background: var(--bg-elevated); }
.compare-columns span, .compare-columns small { display: block; color: var(--muted); font-size: .68rem; }
.compare-columns strong { display: block; margin: 7px 0 2px; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.comparison-callout { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 15px; padding: 13px 14px; border-radius: 11px; }
.comparison-callout strong { font-size: .84rem; }
.comparison-callout span { color: var(--muted); font-size: .68rem; text-align: right; }
.comparison-callout.is-neutral { background: var(--surface-2); }
.comparison-callout.is-positive { background: var(--red-soft); color: var(--red); }
.comparison-callout.is-negative { background: var(--green-soft); color: var(--green); }
.compare-source-meta { padding: 0 1px 13px; }

.formula-card { overflow: hidden; }
.formula-card summary { display: flex; align-items: center; justify-content: space-between; min-height: 78px; padding: 18px 20px; cursor: pointer; list-style: none; }
.formula-card summary::-webkit-details-marker { display: none; }
.formula-card summary svg { transition: transform .2s var(--ease); }
.formula-card[open] summary svg { transform: rotate(90deg); }
.formula-stack { display: flex; align-items: center; gap: 9px; padding: 0 20px 20px; overflow-x: auto; scrollbar-width: thin; }
.formula-stack > div { min-width: 112px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elevated); }
.formula-stack span { display: block; color: var(--muted); font-size: .62rem; }
.formula-stack strong { display: block; margin-top: 5px; font-family: var(--mono); font-size: .69rem; }
.formula-stack > b { color: var(--gold); }
.formula-stack .formula-total { border-color: rgba(216,173,88,.26); background: var(--gold-soft); }

/* Purchase calculator */
.purchase-layout { display: grid; grid-template-columns: minmax(310px,.75fr) minmax(0,1.35fr); align-items: start; gap: 18px; }
.form-card { position: sticky; top: 88px; padding: 22px; }
.step-number { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; color: var(--gold); font-family: var(--mono); font-size: .75rem; }
.purchase-context-grid { display: grid; gap: 14px; margin-top: 24px; }
.purchase-purpose { min-width: 0; margin: 0; padding: 0; border: 0; }
.purchase-purpose legend { margin-bottom: 7px; color: var(--text-soft); font-size: .76rem; font-weight: 730; }
.purpose-segments { display: flex; width: 100%; }
.purpose-segments .segment { flex: 1; }
.purpose-guidance { margin: 8px 0 0; color: var(--muted); font-size: .67rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; margin-top: 24px; }
.field-group { min-width: 0; }
.field-section { margin-top: 18px; }
.field-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.field-heading label { margin: 0; }
.field-heading small { display: block; margin-top: 2px; color: var(--muted); font-size: .64rem; }
input:not(.input-shell input), select { width: 100%; min-height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 11px; outline: 0; background: var(--bg-elevated); color: var(--text); font-variant-numeric: tabular-nums; }
select { padding-right: 36px; }
.field-error { display: block; min-height: 17px; margin-top: 4px; color: var(--red); font-size: .66rem; }
.privacy-note { display: flex; align-items: flex-start; gap: 9px; margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: .67rem; }
.privacy-note svg { flex: 0 0 auto; width: 16px; height: 16px; color: var(--green); }
.comparison-save-button { width: 100%; margin-top: 12px; }
.comparison-save-error { min-height: 0; }
.purchase-analysis { min-width: 0; }
.analysis-hero-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.analysis-stat { min-width: 0; padding: 18px; }
.analysis-stat.featured { border-color: rgba(216,173,88,.27); background: linear-gradient(145deg, var(--surface), var(--gold-soft)); }
.analysis-stat > span, .analysis-stat > small { display: block; color: var(--muted); font-size: .65rem; }
.analysis-stat button { display: block; min-width: 44px; min-height: 44px; max-width: 100%; margin: 10px 0 3px; padding: 0; border: 0; background: none; text-align: left; }
.analysis-stat strong { display: block; overflow: hidden; font-size: 1.05rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.premium-gauge-card, .discount-card { margin-top: 12px; padding: 22px; }
.info-button { position: relative; display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.info-button::after { content: attr(data-tooltip); position: absolute; z-index: 20; right: 0; top: calc(100% + 8px); width: min(330px, 78vw); padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-3); box-shadow: var(--shadow-lg); color: var(--text-soft); font-size: .69rem; font-weight: 500; line-height: 1.5; opacity: 0; pointer-events: none; transform: translateY(-5px); transition: .2s var(--ease); }
.info-button:hover::after, .info-button:focus-visible::after { opacity: 1; transform: none; }
.quality-head-actions { display: flex; align-items: center; gap: 8px; }
.purpose-badge { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface-2); color: var(--text-soft); font-size: .61rem; font-weight: 800; white-space: nowrap; }
.purpose-badge.investment { border-color: rgba(78,210,154,.26); background: var(--green-soft); color: var(--green); }
.purpose-badge.jewelry { border-color: rgba(216,173,88,.28); background: var(--gold-soft); color: var(--gold-bright); }
.gauge { position: relative; margin: 38px 4px 10px; padding-top: 8px; }
.gauge-track { display: grid; grid-template-columns: 1fr .5fr .7fr .8fr 1fr; height: 9px; border-radius: 999px; overflow: hidden; }
.gauge-track span { display: block; }
.g-excellent { background: #32b77a; }.g-good { background: #87c866; }.g-moderate { background: #dfb54a; }.g-expensive { background: #df833f; }.g-very-expensive { background: #d85360; }
.gauge-marker { position: absolute; top: 0; width: 2px; height: 25px; background: var(--text); transform: translateX(-50%); transition: left .35s var(--ease); }
.gauge-marker::after { content: ""; position: absolute; left: 50%; top: -5px; width: 8px; height: 8px; border: 2px solid var(--surface); border-radius: 50%; background: var(--text); transform: translateX(-50%); }
.gauge-marker span { position: absolute; bottom: calc(100% + 7px); left: 50%; padding: 3px 6px; border-radius: 5px; background: var(--surface-3); font-family: var(--mono); font-size: .61rem; white-space: nowrap; transform: translateX(-50%); }
.gauge-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .59rem; font-weight: 700; text-transform: uppercase; }
.premium-detail { display: grid; grid-template-columns: repeat(2,1fr); margin-top: 19px; border-top: 1px solid var(--line); }
.premium-detail > div { padding-top: 14px; }
.premium-detail > div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.premium-detail span { display: block; color: var(--muted); font-size: .66rem; }
.premium-detail strong { display: block; margin-top: 5px; font-size: .9rem; }
.break-even-panel { display: grid; grid-template-columns: minmax(150px,.7fr) minmax(0,1.3fr); align-items: center; gap: 18px; margin-top: 18px; padding: 15px; border: 1px solid rgba(216,173,88,.24); border-radius: 13px; background: linear-gradient(135deg, var(--gold-soft), var(--surface-2)); }
.break-even-panel > div > span { display: block; color: var(--muted); font-size: .65rem; }
.break-even-panel > div > strong { display: block; margin-top: 4px; color: var(--gold-bright); font-size: 1.28rem; font-variant-numeric: tabular-nums; }
.break-even-panel p { margin: 0; color: var(--text-soft); font-size: .72rem; }
.break-even-panel p strong { color: var(--text); font-variant-numeric: tabular-nums; }
.savings-chip { padding: 6px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: .64rem; font-weight: 750; }
.data-table { margin-top: 16px; }
.data-table > div { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 18px; min-height: 42px; border-bottom: 1px solid var(--line); }
.data-table > div:last-child { border-bottom: 0; }
.data-table span { color: var(--muted); font-size: .72rem; }
.data-table strong { font-size: .78rem; font-variant-numeric: tabular-nums; text-align: right; }
.purchase-formula { margin-top: 18px; }
.formula-explanation { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 9px; padding: 0 20px 20px; }
.formula-explanation code { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg-elevated); color: var(--text-soft); font-size: .68rem; overflow-wrap: anywhere; }

.comparison-workspace { margin-top: 18px; padding: 22px; }
.comparison-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.comparison-toolbar h2 { margin: 5px 0 4px; font-size: 1.12rem; }
.comparison-toolbar p { max-width: 680px; margin: 0; color: var(--muted); font-size: .7rem; }
.comparison-toolbar-actions { display: flex; align-items: center; gap: 9px; }
.comparison-count { display: inline-flex; align-items: center; min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: .68rem; font-weight: 750; white-space: nowrap; }
.comparison-insights { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.comparison-insights > div { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.comparison-insights span, .comparison-insights small { display: block; color: var(--muted); font-size: .62rem; }
.comparison-insights strong { display: block; overflow: hidden; margin: 4px 0 2px; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.comparison-empty { display: flex; align-items: center; justify-content: center; gap: 13px; min-height: 150px; margin-top: 18px; border: 1px dashed var(--line-strong); border-radius: 14px; color: var(--muted); text-align: left; }
.comparison-empty strong { color: var(--text-soft); font-size: .85rem; }
.comparison-empty p { margin: 3px 0 0; font-size: .68rem; }
.comparison-table-wrap { margin-top: 18px; overflow-x: auto; scrollbar-width: thin; }
.comparison-table { min-width: 1080px; }
.comparison-table-head, .comparison-row { display: grid; grid-template-columns: minmax(150px,1.45fr) 92px 76px minmax(115px,1fr) minmax(115px,1fr) minmax(115px,1fr) 86px 94px 62px; align-items: center; gap: 10px; }
.comparison-table-head { min-height: 38px; padding: 0 12px; color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.comparison-row { min-height: 78px; padding: 11px 12px; border-top: 1px solid var(--line); transition: background-color .2s var(--ease); }
.comparison-row:hover { background: var(--surface-2); }
.comparison-row > div { min-width: 0; }
.comparison-row strong { display: block; overflow: hidden; font-size: .72rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.comparison-title-cell strong { font-size: .8rem; }
.comparison-title-cell small { display: block; margin-top: 3px; color: var(--muted); font-size: .58rem; }
.comparison-mobile-label { display: none; color: var(--muted); font-size: .58rem; }
.comparison-quality { display: block; margin-top: 3px; color: var(--muted); font-size: .56rem; }
.comparison-remove { min-width: 44px; min-height: 44px; padding: 0 7px; border: 1px solid rgba(240,108,117,.2); border-radius: 10px; background: var(--red-soft); color: var(--red); font-size: .62rem; font-weight: 750; }

/* Currency */
.toman-sync-card { display: grid; grid-template-columns: 1fr minmax(280px,.55fr) auto; align-items: center; gap: 24px; padding: 20px 22px; }
.sync-summary { display: flex; align-items: center; gap: 14px; }
.sync-summary h2 { margin: 4px 0 3px; font-size: 1rem; }
.sync-summary p { margin: 0; color: var(--muted); font-size: .7rem; }
.sync-icon { display: grid; place-items: center; flex: 0 0 auto; width: 48px; height: 48px; border: 1px solid rgba(216,173,88,.28); border-radius: 15px; background: var(--gold-soft); color: var(--gold); font-size: 1.15rem; font-weight: 800; }
.sync-icon.flag-pair { position: relative; display: block; width: 62px; overflow: visible; }
.flag-pair img { position: absolute; width: 34px; height: 25px; border: 2px solid var(--surface); border-radius: 7px; object-fit: cover; box-shadow: 0 5px 14px rgba(0,0,0,.24); }
.flag-pair img:first-child { left: 7px; top: 7px; z-index: 2; }
.flag-pair img:last-child { right: 6px; bottom: 6px; }
.sync-input label { margin-bottom: 5px; font-size: .67rem; }
.fx-rate-grid { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 12px; }
.fx-card { position: relative; min-width: 0; min-height: 228px; padding: 17px; cursor: pointer; transition: transform .2s var(--ease), border-color .2s var(--ease); }
.fx-card input { cursor: text; }
.fx-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.fx-card.is-selected { border-color: rgba(216,173,88,.38); }
.fx-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 9px; }
.fx-code { display: flex; align-items: center; min-width: 0; gap: 10px; }
.currency-flag { position: relative; display: block; flex: 0 0 auto; width: 48px; height: 36px; overflow: hidden; border: 1px solid rgba(255,255,255,.16); border-radius: 9px; background: var(--surface-3); box-shadow: 0 7px 16px rgba(0,0,0,.2); }
.currency-flag img { display: block; width: 100%; height: 100%; object-fit: cover; }
.currency-flag.is-small { width: 38px; height: 29px; border-radius: 7px; }
.currency-symbol { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--surface-3); color: var(--gold); font-size: .76rem; font-weight: 800; }
.fx-code strong { font-size: .92rem; }
.fx-code small { display: block; max-width: 95px; overflow: hidden; color: var(--muted); font-size: .58rem; text-overflow: ellipsis; white-space: nowrap; }
.fx-rate { margin: 24px 0 3px; }
.fx-rate span { color: var(--muted); font-size: .62rem; }
.fx-rate strong { display: block; overflow: hidden; margin-top: 4px; font-size: 1.2rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; }
.fx-rate small { color: var(--muted); font-size: .62rem; }
.fx-card-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 2px 7px; margin-top: 12px; padding-top: 7px; border-top: 1px solid var(--line); }
.fx-card-time { display: block; margin-top: 8px; color: var(--muted-2); font-size: .58rem; }
.text-button { min-width: 44px; min-height: 44px; padding: 0 5px; border: 0; background: none; color: var(--muted); font-size: .65rem; font-weight: 750; }
.text-button:hover { color: var(--gold); }
.fx-use-button { color: var(--gold); }
.fx-manual-input { min-height: 37px !important; margin-top: 9px; padding: 0 9px !important; font-size: .76rem; }
.converter-card { margin-top: 18px; padding: 24px; }
.converter-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.converter-controls { display: flex; align-items: center; gap: 7px; }
.converter-input-row { display: flex; align-items: end; gap: 12px; max-width: 760px; margin-top: 24px; }
.currency-select-wrap { flex: 1 1 360px; }
.amount-field { flex: 1 1 460px; }
.input-shell.large { min-height: 62px; }
.input-shell.large input { height: 60px; font-size: 1.35rem; font-weight: 700; }
.conversion-summary { display: flex; align-items: baseline; gap: 10px; margin-top: 15px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elevated); }
.conversion-summary span, .conversion-summary small { color: var(--muted); font-size: .67rem; }
.conversion-summary strong { font-family: var(--mono); font-size: .83rem; }
.conversion-summary small { margin-left: auto; }
.conversion-results { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.conversion-result { display: flex; align-items: center; gap: 12px; min-width: 0; min-height: 78px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.conversion-result button { min-width: 0; min-height: 44px; padding: 0; border: 0; background: none; text-align: left; }
.conversion-result span { display: block; color: var(--muted); font-size: .61rem; }
.conversion-result strong { display: block; overflow: hidden; margin-top: 3px; font-size: .84rem; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.conversion-result.is-source { border-color: rgba(216,173,88,.32); background: var(--gold-soft); }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.settings-card { padding: 22px; }
.heading-icon { color: var(--gold); }
.settings-fields { display: grid; gap: 15px; margin-top: 22px; }
.settings-fields.two-col { grid-template-columns: repeat(2,minmax(0,1fr)); }
.settings-fields small, .settings-intro { color: var(--muted); font-size: .66rem; }
.settings-fields .field-group > small { display: block; margin-top: 5px; }
.settings-fields code { color: var(--text-soft); }
.settings-intro { margin: 16px 0 13px; }
.threshold-profiles { display: grid; gap: 12px; }
.threshold-profile { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
.threshold-profile > div:first-child { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.threshold-profile > div:first-child strong { color: var(--text-soft); font-size: .69rem; }
.threshold-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 9px; }
.threshold-grid label { position: relative; margin: 0; }
.threshold-grid label > span { display: block; margin-bottom: 6px; font-size: .66rem; }
.threshold-grid input { padding-right: 28px; }
.threshold-grid small { position: absolute; right: 10px; bottom: 14px; color: var(--muted); }
.data-actions-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 18px; padding: 22px; }
.data-actions-card h2 { margin: 5px 0 3px; font-size: 1.02rem; }
.data-actions-card p { margin: 0; color: var(--muted); font-size: .7rem; }
.data-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.source-notes { display: grid; grid-template-columns: repeat(3,1fr); gap: 0; margin-top: 18px; overflow: hidden; }
.source-note { display: flex; gap: 13px; padding: 20px; border-right: 1px solid var(--line); }
.source-note:last-child { border-right: 0; }
.source-note > span { display: grid; place-items: center; flex: 0 0 auto; width: 31px; height: 31px; border-radius: 9px; background: var(--gold-soft); color: var(--gold); font-family: var(--mono); font-size: .65rem; }
.source-note h3 { margin: 0 0 4px; font-size: .85rem; }
.source-note p { margin: 0; color: var(--muted); font-size: .67rem; }

.app-footer { display: flex; justify-content: space-between; gap: 18px; padding: 24px 0 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: .66rem; }
.toast-region { position: fixed; z-index: 1000; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); pointer-events: none; }
.toast { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px; min-height: 52px; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-3); box-shadow: var(--shadow-lg); color: var(--text-soft); font-size: .74rem; animation: toast-in .25s var(--ease); }
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.toast.warning::before { background: var(--amber); }
.toast.error::before { background: var(--red); }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }
.skeleton { position: relative; color: transparent !important; overflow: hidden; background: var(--surface-3); border-radius: 6px; }
.hero-quote strong.skeleton { display: inline-block; width: min(230px, 58vw); height: 48px; }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.08), transparent); transform: translateX(-100%); animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* Responsive layout */
@media (max-width: 1180px) {
  .analysis-hero-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .fx-rate-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .conversion-results { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .karat-card { grid-template-columns: auto 1fr; }
  .karat-values { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; padding: 8px 0 0; }
}

@media (max-width: 900px) {
  .app-shell { padding: 0 20px; }
  .connection-pill { display: none; }
  .market-strip { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .strip-stat:nth-child(2) { border-right: 0; }
  .strip-stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .tab-nav { width: 100%; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-button { flex: 1 0 142px; min-width: 142px; }
}

@media (max-width: 760px) {
  .source-grid, .gold-result-grid, .insight-grid { grid-template-columns: 1fr; }
  .purchase-layout { grid-template-columns: 1fr; }
  .form-card { position: static; }
  .toman-sync-card { grid-template-columns: 1fr minmax(260px,.7fr); }
  .toman-sync-card > .status-badge { grid-column: 1 / -1; justify-self: start; }
  .settings-grid { grid-template-columns: 1fr; }
  .source-notes { grid-template-columns: 1fr; }
  .source-note { border-right: 0; border-bottom: 1px solid var(--line); }
  .source-note:last-child { border-bottom: 0; }
  .comparison-workspace { padding: 18px; }
  .comparison-toolbar { align-items: stretch; flex-direction: column; gap: 14px; }
  .comparison-toolbar-actions { justify-content: space-between; }
  .comparison-table-wrap { overflow: visible; }
  .comparison-table { min-width: 0; }
  .comparison-table-head { display: none; }
  #comparison-rows { display: grid; gap: 10px; }
  .comparison-row { grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 13px 16px; min-height: 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); }
  .comparison-row:hover { background: var(--surface-2); }
  .comparison-title-cell, .comparison-action-cell { grid-column: 1 / -1; }
  .comparison-row strong { overflow: visible; text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
  .comparison-mobile-label { display: block; margin-bottom: 4px; }
  .comparison-action-cell { padding-top: 2px; }
  .comparison-remove { width: 100%; }
}

@media (max-width: 680px) {
  html { scroll-padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 16px); }
  body { padding-bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 20px); }
  .app-shell { padding: 0 14px; }
  .app-header { min-height: 0; align-items: center; padding: 14px 0 12px; }
  .brand-block p, .header-actions .button span, .strip-update { display: none; }
  .brand-mark { width: 42px; height: 42px; }
  .brand-title { font-size: .95rem; }
  .market-strip { grid-template-columns: repeat(3,minmax(0,1fr)); margin-top: 7px; }
  .strip-stat { padding: 12px 10px; border-bottom: 0 !important; }
  .strip-stat:nth-child(2) { border-right: 1px solid var(--line); }
  .strip-icon { width: 31px; height: 31px; border-radius: 9px; }
  .strip-stat span { font-size: .55rem; }
  .strip-stat strong { font-size: .7rem; }
  .tab-nav {
    position: fixed;
    z-index: 100;
    inset: auto 0 0;
    isolation: isolate;
    width: 100%;
    max-width: none;
    min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom));
    margin: 0;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    border: 1px solid var(--line-strong);
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    overflow: visible;
    background: var(--bg-elevated);
    background: color-mix(in srgb, var(--bg-elevated) 97%, transparent);
    box-shadow: 0 -16px 42px rgba(0,0,0,.3);
    backdrop-filter: blur(22px) saturate(130%);
    -webkit-backdrop-filter: blur(22px) saturate(130%);
  }
  .tab-button { position: relative; flex: 1 1 25%; min-width: 0; min-height: 58px; padding: 0 4px; flex-direction: column; gap: 3px; border-radius: 13px; font-size: .62rem; }
  .tab-button::before { content: ""; position: absolute; top: 3px; left: 50%; width: 22px; height: 2px; border-radius: 999px; background: transparent; transform: translateX(-50%); transition: width .2s var(--ease), background-color .2s var(--ease); }
  .tab-button.is-active::before { width: 32px; background: var(--gold); }
  .tab-button svg { width: 20px; height: 20px; }
  main { padding: 27px 0 28px; }
  .page-heading { align-items: flex-start; margin-bottom: 18px; }
  .page-heading h1 { font-size: 1.55rem; }
  .page-heading p { font-size: .79rem; }
  .page-heading > .button { min-width: 44px; padding: 0 12px; font-size: 0; }
  .page-heading > .button.mobile-label-button { min-width: auto; font-size: .68rem; }
  .page-heading > .button svg { margin: 0; }
  .source-card { min-height: 0; padding: 18px; }
  .hero-quote { margin-top: 28px; }
  .hero-quote strong { font-size: 2.35rem; }
  .section-label { margin-top: 29px; }
  .formula-chip { display: none; }
  .karat-card { padding: 19px; }
  .compare-columns { grid-template-columns: 1fr; }
  .comparison-callout { align-items: flex-start; flex-direction: column; }
  .comparison-callout span { text-align: left; }
  .formula-stack { align-items: stretch; flex-direction: column; overflow: visible; }
  .formula-stack > div { width: 100%; }
  .formula-stack > b { text-align: center; }
  .form-grid { grid-template-columns: 1fr; }
  .analysis-hero-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analysis-stat { padding: 15px; }
  .analysis-stat strong { font-size: .9rem; }
  .premium-detail { grid-template-columns: 1fr; }
  .premium-detail > div + div { padding-left: 0; border-left: 0; }
  .formula-explanation { grid-template-columns: 1fr; }
  .toman-sync-card { grid-template-columns: 1fr; padding: 18px; }
  .fx-rate-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .converter-card { padding: 18px; }
  .converter-head { flex-direction: column; }
  .converter-controls { width: 100%; }
  .converter-head .segmented { width: 100%; }
  .converter-head .segment { flex: 1; padding: 0 8px; }
  input, select { font-size: 16px; }
  .fx-manual-input { font-size: 16px; }
  .converter-input-row { flex-direction: column; align-items: stretch; }
  .currency-select-wrap, .amount-field { flex-basis: auto; }
  .conversion-summary { align-items: flex-start; flex-direction: column; }
  .conversion-summary small { margin-left: 0; }
  .conversion-results { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .settings-fields.two-col, .threshold-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .data-actions-card { align-items: flex-start; flex-direction: column; }
  .data-actions { width: 100%; justify-content: stretch; }
  .data-actions .button { flex: 1 1 100%; }
  .app-footer { flex-direction: column; gap: 6px; padding-bottom: 12px; }
  .toast-region { bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px); }
}

@media (max-width: 520px) {
  .app-shell { padding: 0 12px; }
  .app-header { gap: 10px; }
  .brand-block { gap: 10px; }
  .header-actions { gap: 7px; }
  .market-strip { border-radius: 17px; }
  .strip-stat { gap: 8px; padding: 11px 8px; }
  .strip-icon { width: 29px; height: 29px; }
  .page-heading { gap: 10px; }
  .page-heading h1 { font-size: 1.45rem; }
  .page-heading > .button.mobile-label-button { max-width: 88px; line-height: 1.15; white-space: normal; }
  .card { border-radius: 17px; }
  .form-card, .settings-card, .premium-gauge-card, .discount-card { padding: 18px; }
  .field-heading { align-items: flex-start; flex-direction: column; }
  .field-heading .segmented { width: 100%; }
  .field-heading .segment { flex: 1; }

  .analysis-hero-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analysis-stat.featured, .analysis-stat.premium-stat { grid-column: 1 / -1; }
  .analysis-stat.featured strong, .analysis-stat.premium-stat strong { font-size: 1.05rem; }
  .analysis-stat strong { overflow: visible; font-size: clamp(.78rem,3.6vw,.98rem); text-overflow: clip; white-space: normal; overflow-wrap: anywhere; }
  .quality-head-actions { flex-wrap: wrap; justify-content: flex-end; }
  .break-even-panel { grid-template-columns: 1fr; gap: 9px; }
  .comparison-insights { grid-template-columns: 1fr; }
  .comparison-empty { align-items: flex-start; justify-content: flex-start; min-height: 0; padding: 18px; }

  .sync-summary { align-items: flex-start; }
  .sync-icon.flag-pair { width: 58px; }
  .fx-rate-grid { grid-template-columns: 1fr; gap: 10px; }
  .fx-card { display: grid; grid-template-columns: minmax(0,1fr) minmax(116px,.72fr); align-items: center; gap: 10px 14px; min-height: 0; padding: 16px; }
  .fx-card-head { grid-column: 1; grid-row: 1; align-items: center; }
  .fx-code small { max-width: 130px; font-size: .64rem; }
  .fx-rate { grid-column: 2; grid-row: 1; align-self: stretch; display: flex; flex-direction: column; justify-content: center; margin: 0; padding-left: 14px; border-left: 1px solid var(--line); }
  .fx-rate strong { font-size: 1.25rem; }
  .fx-manual-input { grid-column: 1 / -1; margin: 0; }
  .fx-card-actions { grid-column: 1 / -1; justify-content: flex-start; margin-top: 0; padding-top: 5px; }
  .fx-card-actions .text-button { flex: 1; min-width: 125px; border-radius: 8px; background: var(--surface-2); }
  .fx-card-time { grid-column: 1 / -1; margin-top: -7px; }
  .currency-flag { width: 52px; height: 39px; }
  .conversion-results { grid-template-columns: 1fr; }
  .conversion-result { min-height: 72px; }
  .settings-fields.two-col { grid-template-columns: 1fr; }
  .threshold-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .data-table > div { grid-template-columns: minmax(0,1fr) minmax(115px,.8fr); }
  .data-table strong { overflow-wrap: anywhere; }
}

@media (max-width: 390px) {
  .header-actions { gap: 6px; }
  .brand-block { gap: 9px; }
  .brand-block .eyebrow { font-size: .56rem; }
  .brand-title { font-size: .82rem; }
  .strip-stat { gap: 7px; }
  .strip-icon { display: none; }
  .page-heading > .button.mobile-label-button { max-width: 74px; padding-inline: 9px; }
}

/* Phone landscape: keep the same persistent bottom navigation instead of
   switching back to the tablet/desktop sticky tab strip based on width alone. */
@media (max-width: 950px) and (max-height: 520px) {
  html { scroll-padding-bottom: calc(60px + env(safe-area-inset-bottom) + 12px); }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom) + 14px); }
  .tab-nav {
    position: fixed;
    z-index: 100;
    inset: auto 0 0;
    isolation: isolate;
    width: 100%;
    max-width: none;
    min-height: calc(60px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 5px max(10px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    border: 1px solid var(--line-strong);
    border-width: 1px 0 0;
    border-radius: 18px 18px 0 0;
    overflow: visible;
    background: var(--bg-elevated);
    background: color-mix(in srgb, var(--bg-elevated) 97%, transparent);
    box-shadow: 0 -14px 36px rgba(0,0,0,.3);
    backdrop-filter: blur(22px) saturate(130%);
    -webkit-backdrop-filter: blur(22px) saturate(130%);
  }
  .tab-button { position: relative; flex: 1 1 25%; min-width: 0; min-height: 50px; padding: 0 8px; flex-direction: row; gap: 7px; border-radius: 12px; font-size: .68rem; }
  .tab-button svg { width: 18px; height: 18px; }
  .formula-stack { align-items: stretch; flex-wrap: wrap; overflow: visible; }
  .formula-stack > div { flex: 1 1 135px; }
  main { padding-bottom: 24px; }
  .toast-region { bottom: calc(60px + env(safe-area-inset-bottom) + 10px); }
}

@media (max-width: 350px) {
  .app-shell { padding-inline: 9px; }
  .brand-block .eyebrow { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading > .button { align-self: flex-start; }
  .page-heading > .button.mobile-label-button { max-width: none; }
  .fx-card { grid-template-columns: 1fr; }
  .fx-card-head, .fx-rate, .fx-manual-input, .fx-card-actions, .fx-card-time { grid-column: 1; }
  .fx-rate { grid-row: auto; padding: 12px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .fx-card-actions .text-button { min-width: 100%; }
  .comparison-toolbar-actions { align-items: stretch; flex-direction: column; }
  .comparison-count { justify-content: center; }
  .comparison-row { grid-template-columns: 1fr; }
  .comparison-title-cell, .comparison-action-cell { grid-column: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
