/* style.css — LoanCalc component styles */
/* Requires tokens.css to be loaded first */

/* ── Reset & base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: var(--font-body); background: var(--color-bg); color: var(--color-text); line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* ── Utilities ──────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.tool-panel { display: none; }
.tool-panel.active { display: block; }

/* ── Header ─────────────────────────────────────────── */
header { background: var(--color-navy); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid rgba(255,255,255,0.06); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.logo-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-text { font-family: var(--font-display); font-size: 20px; font-weight: 700; color: var(--color-white); letter-spacing: -0.02em; }
.logo-text span { color: var(--color-gold); }
header nav { display: flex; gap: 6px; }
header nav a { color: rgba(255,255,255,0.65); text-decoration: none; font-size: 13px; font-weight: 400; padding: 6px 12px; border-radius: var(--r-xs); transition: all .15s; }
header nav a:hover { color: var(--color-white); background: rgba(255,255,255,0.08); }

/* ── Tool nav wrapper ───────────────────────────────── */
.tool-nav-wrap { background: var(--color-navy); position: sticky; top: 64px; z-index: 90; }

/* ── Tab nav ────────────────────────────────────────── */
.tab-nav { display: flex; justify-content: center; gap: 0; padding: 0 20px; max-width: 700px; margin: 0 auto; border-bottom: 1px solid rgba(255,255,255,0.08); }
#tool-nav { max-width: 900px; border-bottom: 2px solid rgba(255,255,255,0.08); }
.tab-btn { flex: 1; padding: 14px 8px; background: transparent; border: none; border-bottom: 2px solid transparent; color: rgba(255,255,255,0.55); font-size: 14px; font-weight: 400; cursor: pointer; font-family: var(--font-body); transition: all .2s; white-space: nowrap; }
.tab-btn:hover { color: rgba(255,255,255,0.75); }
.tab-btn.active { color: var(--color-white); border-bottom-color: var(--color-gold); font-weight: 500; }
.tab-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; border-radius: var(--r-xs); }

/* ── Segmented loan type nav ────────────────────────── */
.loan-seg { display: flex; border: 1.5px solid var(--color-border); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 28px; background: var(--color-surface-raised); }
.loan-seg .tab-btn { padding: 12px 8px; border-bottom: none; border-bottom-color: transparent; color: var(--color-muted); font-size: 12px; font-weight: 500; }
.loan-seg .tab-btn:not(:last-child) { border-right: 1.5px solid var(--color-border); }
.loan-seg .tab-btn:hover:not(.active) { color: var(--color-text); background: var(--color-bg); }
.loan-seg .tab-btn.active { background: var(--color-navy); color: var(--color-white); border-bottom-color: transparent; }
.loan-seg .tab-btn:focus-visible { border-radius: 0; }
[dir="rtl"] .loan-seg .tab-btn:not(:last-child) { border-right: none; border-left: 1.5px solid var(--color-border); }

/* ── Hero ───────────────────────────────────────────── */
.hero { background: var(--color-navy); padding: 32px 0 28px; text-align: center; position: relative; overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse 80% 60% at 50% 100%, var(--color-hero-glow) 0%, transparent 70%); pointer-events: none; }
.hero h1 { font-family: var(--font-display); font-size: clamp(32px,5vw,54px); font-weight: 700; color: var(--color-white); line-height: 1.15; letter-spacing: -0.025em; margin-bottom: 16px; }
.hero h1 em { font-style: normal; color: var(--color-gold); }
.hero-sub { font-size: 17px; color: rgba(255,255,255,0.65); max-width: 520px; margin: 0 auto 28px; font-weight: 300; line-height: 1.7; }

/* ── Calculator card ────────────────────────────────── */
.calc-section { background: var(--color-bg); padding: 48px 0 0; }
.calc-card { background: var(--color-surface); border-radius: var(--r-2xl); box-shadow: var(--shadow-elevated); overflow: hidden; border: 1px solid var(--color-border); }
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 400px; }
.calc-grid > * { min-width: 0; overflow: hidden; }
@media(max-width:720px) { .calc-grid { grid-template-columns: 1fr; } }

/* ── Inputs panel ───────────────────────────────────── */
.inputs-panel { padding: 36px 40px; border-right: 1px solid var(--color-border); }
@media(max-width:720px) { .inputs-panel { padding: 28px 24px; border-right: none; } }
.input-group { margin-bottom: 28px; }
.input-group:last-of-type { margin-bottom: 0; }
.ig-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ig-label { font-size: 13px; font-weight: 500; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.ig-val { display: flex; align-items: center; gap: 2px; background: var(--color-surface-raised); border: 1.5px solid var(--color-border); border-radius: var(--r-sm); padding: 4px 10px; transition: border-color .15s; }
.ig-val:focus-within { border-color: var(--color-focus); box-shadow: 0 0 0 3px var(--color-focus-ring); }
.ig-sym { font-size: 14px; color: var(--color-muted); font-weight: 500; }
.ig-input { width: 70px; min-width: 0; border: none; background: transparent; font-size: 14px; font-weight: 500; color: var(--color-text); font-family: var(--font-body); text-align: right; outline: none; }
.ig-unit { font-size: 14px; color: var(--color-muted); font-weight: 400; }
.ig-clamp-note { font-size: 11px; color: var(--color-gold); opacity: 0; transition: opacity .2s; min-height: 14px; margin-top: 3px; padding-left: 2px; }
.ig-clamp-note.visible { opacity: 1; }

/* ── Range sliders ──────────────────────────────────── */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; background: var(--color-border); outline: none; cursor: pointer; margin-bottom: 6px; }
input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 99px; }
input[type=range]::-moz-range-track { height: 5px; border-radius: 99px; background: var(--slider-track); }
input[type=range]::-moz-range-progress { height: 5px; border-radius: 99px; background: var(--slider-fill); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--color-navy); border: 3px solid var(--color-white); box-shadow: 0 2px 8px rgba(10,22,40,0.25); cursor: pointer; transition: transform .1s; margin-top: -8.5px; }
input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--color-navy); border: 3px solid var(--color-white); cursor: pointer; }
input[type=range]:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; border-radius: 99px; }
.range-ends { display: flex; justify-content: space-between; font-size: 11px; color: var(--color-muted); }

/* ── Helper note ────────────────────────────────────── */
.helper-note { margin-top: 24px; padding: 12px 16px; background: var(--color-gold-wash); border-radius: var(--r-md); border: 1px solid rgba(200,151,58,0.35); font-size: 12px; color: var(--color-gold-deep); line-height: 1.5; }
.helper-note strong { display: block; margin-bottom: 2px; font-size: 13px; color: var(--color-navy); }

/* ── Results panel ──────────────────────────────────── */
.results-panel { padding: 36px 40px; background: var(--color-navy); display: flex; flex-direction: column; gap: 20px; justify-content: center; overflow: hidden; min-width: 0; }
@media(max-width:720px) { .results-panel { padding: 28px 24px; order: -1; border-bottom: 1px solid rgba(255,255,255,0.1); } }
.monthly-card { text-align: center; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.monthly-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255,255,255,0.55); margin-bottom: 8px; font-weight: 400; }
.monthly-amount { font-family: var(--font-display); font-size: clamp(18px,4vw,56px); font-weight: 700; color: var(--color-white); letter-spacing: -0.03em; line-height: 1.1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; width: 100%; display: block; text-align: center; }
.monthly-sub { font-size: 13px; color: rgba(255,255,255,0.6); margin-top: 6px; }
.results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.res-box { background: rgba(255,255,255,0.06); border-radius: var(--r-md); padding: 12px 14px; border: 1px solid rgba(255,255,255,0.08); }
.res-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: rgba(255,255,255,0.55); margin-bottom: 4px; }
.res-val { font-size: 14px; font-weight: 500; color: var(--color-white); font-family: var(--font-body); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; display: block; }
.res-val.gold { color: var(--color-gold); }
.breakdown-row { margin-top: 4px; }
.breakdown-label { display: flex; justify-content: space-between; font-size: 12px; color: rgba(255,255,255,0.6); margin-bottom: 6px; }
.breakdown-bar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 99px; overflow: hidden; position: relative; }
.bar-p { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.7); transform-origin: left center; transform: scaleX(0); transition: transform .4s cubic-bezier(.4,0,.2,1); }
.bar-i { position: absolute; right: 0; top: 0; width: 100%; height: 100%; background: var(--color-gold); transform-origin: right center; transform: scaleX(0); transition: transform .4s cubic-bezier(.4,0,.2,1); }

/* ── Chart section ──────────────────────────────────── */
.chart-section { padding: 48px 0; }
.section-title { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--color-navy); margin-bottom: 6px; }
.section-sub { font-size: 14px; color: var(--color-muted); margin-bottom: 28px; }
.chart-wrap { background: var(--color-surface); border-radius: var(--r-xl); border: 1px solid var(--color-border); box-shadow: var(--shadow-ambient); padding: 32px; display: grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: center; }
@media(max-width:720px) { .chart-wrap { grid-template-columns: 1fr; gap: 24px; } }
.chart-canvas-wrap { position: relative; height: 240px; width: 240px; margin: 0 auto; }
.chart-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); text-align: center; pointer-events: none; }
.chart-center-num { font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--color-navy); }
.chart-center-lbl { font-size: 11px; color: var(--color-muted); margin-top: 2px; }
.chart-stats { display: flex; flex-direction: column; gap: 20px; }
.chart-stat-item { display: flex; align-items: center; gap: 14px; }
.stat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.stat-dot.navy { background: var(--color-navy); }
.stat-dot.gold { background: var(--color-gold); }
.stat-info .stat-lbl { font-size: 12px; color: var(--color-muted); }
.stat-info .stat-val { font-size: 20px; font-weight: 500; color: var(--color-text); font-family: var(--font-body); }
.stat-info .stat-pct { font-size: 13px; color: var(--color-muted); margin-inline-start: 6px; }
.chart-divider { height: 1px; background: var(--color-border); margin: 8px 0; }
.payoff-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; }
.payoff-row--no-top { padding-top: 0; }
.po-label { font-size: 13px; color: var(--color-muted); }
.po-val { font-size: 16px; font-weight: 500; color: var(--color-navy); }

/* ── Amortization section ───────────────────────────── */
.amort-section { padding: 0 0 48px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.toggle-btn { padding: 8px 18px; background: transparent; border: 1.5px solid var(--color-border); border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--color-muted); cursor: pointer; font-family: var(--font-body); transition: all .15s; }
.toggle-btn:hover { border-color: var(--color-navy); color: var(--color-navy); }
.toggle-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.table-wrap { background: var(--color-surface); border-radius: var(--r-xl); border: 1px solid var(--color-border); box-shadow: var(--shadow-ambient); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: var(--color-navy); }
thead th { padding: 14px 18px; text-align: right; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.07em; color: rgba(255,255,255,0.55); white-space: nowrap; }
thead th:first-child { text-align: left; }
tbody tr { border-top: 1px solid var(--color-border); transition: background .1s; }
tbody tr:hover { background: var(--color-surface-raised); }
tbody td { padding: 12px 18px; text-align: right; color: var(--color-text); font-size: 14px; font-family: var(--font-body); }
tbody td:first-child { text-align: left; font-weight: 500; color: var(--color-navy); }
tbody td.red { color: var(--color-loss); }
tbody td.green { color: var(--color-gain); }

/* ── How section ────────────────────────────────────── */
.how-section { background: var(--color-navy); padding: 64px 0; color: var(--color-white); }
.how-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: start; }
@media(max-width:720px) { .how-grid { grid-template-columns: 1fr; gap: 32px; } }
.how-section h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--color-white); margin-bottom: 16px; }
.how-section h3 { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--color-white); margin: 24px 0 10px; }
.how-section p { font-size: 15px; color: rgba(255,255,255,0.65); line-height: 1.75; margin-bottom: 14px; }
.formula-box { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); border-radius: var(--r-lg); padding: 18px 22px; font-family: var(--font-mono); font-size: 14px; color: rgba(255,255,255,0.85); line-height: 1.8; margin: 16px 0; }
.formula-vars { display: flex; flex-direction: column; gap: 6px; }
.formula-var { display: flex; gap: 10px; font-size: 13px; }
.formula-var strong { color: var(--color-gold); font-family: var(--font-mono); min-width: 16px; }
.formula-var span { color: rgba(255,255,255,0.6); }
.tips-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.tips-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: rgba(255,255,255,0.65); line-height: 1.6; }
.tips-list li::before { content: '→'; color: var(--color-gold); flex-shrink: 0; margin-top: 2px; font-size: 14px; }

/* ── FAQ section ────────────────────────────────────── */
.faq-section { padding: 64px 0; }
.faq-section h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--color-navy); margin-bottom: 28px; }
.faq-list { display: flex; flex-direction: column; gap: 2px; }
.faq-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r-md); overflow: hidden; transition: box-shadow .15s; }
.faq-item:hover { box-shadow: var(--shadow-ambient); }
.faq-q { width: 100%; padding: 18px 22px; background: transparent; border: none; text-align: left; font-size: 15px; font-weight: 500; color: var(--color-navy); cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-family: var(--font-body); line-height: 1.4; }
.faq-q .chevron { width: 20px; height: 20px; border-radius: 50%; background: var(--color-surface-raised); border: 1px solid var(--color-border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 12px; color: var(--color-muted); transition: transform .2s; }
.faq-item.open .chevron { transform: rotate(180deg); }
.faq-a { display: none; padding: 0 22px 18px; font-size: 14px; color: var(--color-muted); line-height: 1.7; }
.faq-item.open .faq-a { display: block; }
.faq-q:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }

/* ── Footer ─────────────────────────────────────────── */
footer { background: var(--color-navy-mid); border-top: 1px solid rgba(255,255,255,0.06); padding: 40px 0 32px; text-align: center; }
.footer-logo { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
.footer-logo-text { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--color-white); }
.footer-logo-text span { color: var(--color-gold); }
footer p { font-size: 13px; color: rgba(255,255,255,0.55); margin-bottom: 6px; line-height: 1.6; }
.footer-disclaimer { font-size: 12px; color: rgba(255,255,255,0.25); max-width: 560px; margin: 16px auto 0; line-height: 1.6; }
.footer-links { display: flex; justify-content: center; gap: 20px; margin: 16px 0; }
.footer-links a { font-size: 13px; color: rgba(255,255,255,0.55); text-decoration: none; transition: color .15s; }
.footer-links a:hover { color: rgba(255,255,255,0.75); }
.footer-copy { margin-top: 16px; }

/* ── Settings ───────────────────────────────────────── */
.settings-btn { width: auto; padding: 0 12px 0 8px; gap: 6px; border-radius: var(--r-sm); border: 1px solid rgba(255,255,255,0.15); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.6); transition: all .15s; flex-shrink: 0; height: 36px; }
.settings-btn:hover { background: rgba(255,255,255,0.1); color: var(--color-white); }
.settings-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.settings-btn svg { width: 16px; height: 16px; }
.settings-btn-label { font-size: 12px; font-weight: 400; color: rgba(255,255,255,0.55); letter-spacing: 0.03em; }
@media(max-width:480px) { .settings-btn-label { display: none; } }
.settings-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 999; cursor: pointer; }
.settings-overlay.open { display: block; }
.settings-drawer { position: fixed; top: 0; right: 0; transform: translateX(calc(100% + 1px)); width: 320px; height: 100vh; background: var(--color-navy-mid); border-left: 1px solid rgba(255,255,255,0.08); z-index: 1000; transition: transform .25s cubic-bezier(.4,0,.2,1); overflow-y: auto; display: flex; flex-direction: column; }
.settings-drawer.open { transform: translateX(0); }
.settings-head { padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; justify-content: space-between; }
.settings-title { font-size: 15px; font-weight: 500; color: var(--color-white); }
.settings-close { width: 28px; height: 28px; border-radius: var(--r-xs); border: 1px solid rgba(255,255,255,0.12); background: transparent; cursor: pointer; color: rgba(255,255,255,0.6); font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.settings-close:hover { background: rgba(255,255,255,0.1); color: var(--color-white); }
.settings-body { padding: 24px; display: flex; flex-direction: column; gap: 24px; flex: 1; }
.settings-group { display: flex; flex-direction: column; gap: 8px; }
.settings-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.6); font-weight: 500; }
.settings-select { width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06); color: var(--color-white); font-size: 14px; font-family: var(--font-body); cursor: pointer; outline: none; transition: border-color .15s; -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.settings-select:focus-visible { border-color: var(--color-focus); }
.settings-select option { background: var(--color-navy-mid); color: var(--color-white); }
.settings-note { font-size: 12px; color: rgba(255,255,255,0.35); line-height: 1.6; }
.settings-save { margin: 0 24px 24px; padding: 11px; border-radius: var(--r-sm); background: var(--color-gold); border: none; color: var(--color-navy); font-size: 14px; font-weight: 500; cursor: pointer; font-family: var(--font-body); transition: opacity .15s; }
.settings-save:hover { opacity: .88; }
.settings-save:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
#pref-current-display { display: flex; flex-wrap: wrap; gap: 6px; }
.pref-tag { display: inline-flex; align-items: center; gap: 5px; background: rgba(200,151,58,0.15); border: 1px solid rgba(200,151,58,0.3); border-radius: var(--r-xs); padding: 4px 10px; font-size: 12px; color: var(--color-gold); }

/* ── Toast ──────────────────────────────────────────── */
#pref-toast { position: fixed; bottom: 24px; right: 24px; padding: 10px 18px; border-radius: var(--r-sm); background: var(--color-navy-mid); border: 1px solid rgba(200,151,58,0.35); color: var(--color-gold); font-size: 13px; font-weight: 500; font-family: var(--font-body); box-shadow: 0 4px 20px rgba(0,0,0,0.35); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; z-index: 9999; }
#pref-toast.show { opacity: 1; transform: translateY(0); }


/* ── Currency converter ─────────────────────────────── */
.cur-body { padding: 32px 36px; }
.cur-status { font-size: 12px; color: var(--color-muted); margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }
.cur-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-border); display: inline-block; flex-shrink: 0; }
.cur-group { margin-bottom: 14px; }
.cur-group-lg { margin-bottom: 20px; }
.cur-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-muted); font-weight: 500; display: block; margin-bottom: 7px; }
.cur-amount-input { width: 100%; border: 1.5px solid var(--color-border); border-radius: var(--r-sm); padding: 11px 14px; font-size: 20px; font-weight: 500; font-family: var(--font-body); color: var(--color-text); background: var(--color-surface); outline: none; transition: border-color .15s; }
.cur-selects-row { display: grid; grid-template-columns: 1fr 44px 1fr; align-items: end; gap: 10px; margin-bottom: 14px; }
.cur-sel { border: 1.5px solid var(--color-border); border-radius: var(--r-sm); padding: 10px 32px 10px 11px; font-size: 13px; font-family: var(--font-body); color: var(--color-text); background: var(--color-surface); -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235B6278' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; width: 100%; min-width: 0; }
.cur-swap-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; border-radius: 50%; border: 1.5px solid var(--color-border); background: var(--color-surface); cursor: pointer; font-size: 16px; color: var(--color-muted); display: flex; align-items: center; justify-content: center; transition: all .15s; flex-shrink: 0; margin-bottom: 1px; }
.cur-result-box { width: 100%; border: 2px solid var(--color-focus); border-radius: var(--r-sm); padding: 13px 16px; font-size: 22px; font-weight: 600; font-family: var(--font-display); color: var(--color-navy); background: var(--color-blue-light); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.cur-rate-row { display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 16px; background: var(--color-surface-raised); border-radius: var(--r-md); border: 1px solid var(--color-border); font-size: 13px; color: var(--color-muted); }
.cur-rate-val { color: var(--color-text); }
.cur-quick { margin-top: 24px; }
.cur-quick-lbl { font-size: 12px; font-weight: 500; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 12px; }
.cur-quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px,1fr)); gap: 8px; }
.cur-swap-btn:hover { background: var(--color-navy); color: var(--color-white); border-color: var(--color-navy); }
.cur-swap-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--color-focus-ring); }
.cur-amount-input:focus-visible { border-color: var(--color-focus); outline: none; box-shadow: 0 0 0 3px var(--color-focus-ring); }
.cur-sel:focus-visible { border-color: var(--color-focus); outline: none; box-shadow: 0 0 0 3px var(--color-focus-ring); }
.cur-retry-btn { padding: 3px 10px; font-size: 11px; font-family: var(--font-body); font-weight: 500; color: var(--color-focus); background: transparent; border: 1.5px solid var(--color-border); border-radius: 5px; cursor: pointer; transition: all .15s; margin-left: 4px; line-height: 1.4; }
.cur-retry-btn:hover { background: var(--color-focus); color: var(--color-white); border-color: var(--color-focus); }
.cur-retry-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.status-refresh-btn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--color-border); background: transparent; color: var(--color-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .15s, border-color .15s, color .15s; flex-shrink: 0; padding: 0; }
.status-refresh-btn svg { width: 12px; height: 12px; }
.status-refresh-btn:hover { background: var(--color-surface-raised); color: var(--color-text); border-color: var(--color-muted); }
.status-refresh-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.status-refresh-btn:disabled { opacity: 0.4; cursor: default; }
@keyframes spin-refresh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.status-refresh-btn.spinning svg { animation: spin-refresh .65s cubic-bezier(0.4,0,0.2,1) 1; }
.copy-link-btn { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; background: transparent; border: 1px solid rgba(255,255,255,0.2); border-radius: var(--r-xs); font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.45); cursor: pointer; font-family: var(--font-body); transition: all .15s; letter-spacing: 0.03em; align-self: flex-end; margin-top: 8px; }
.copy-link-btn:hover { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.75); border-color: rgba(255,255,255,0.35); }
.copy-link-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
@media(max-width:720px) { .cur-body { padding: 28px 24px; } }

/* ── Commodity cards ────────────────────────────────── */
.commodity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
@media(max-width:600px) { .commodity-grid { grid-template-columns: 1fr; } }
.commodity-card { padding: 24px 28px; }
.commodity-header { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.commodity-icon { width: 36px; height: 36px; border-radius: var(--r-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.commodity-icon--gold { background: var(--color-gold-wash); border: 1px solid var(--color-gold); }
.commodity-icon--oil { background: var(--color-oil-bg); border: 1px solid var(--color-oil-border); }
.commodity-name { flex: 1; }
.commodity-name-title { font-size: 13px; font-weight: 500; color: var(--color-navy); }
.commodity-name-sub { font-size: 11px; color: var(--color-muted); }
.commodity-status { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.commodity-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border); display: inline-block; }
.commodity-status-text { font-size: 11px; color: var(--color-muted); }
.commodity-price { font-family: var(--font-display); font-size: 32px; font-weight: 600; color: var(--color-navy); margin-bottom: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.commodity-unit { font-size: 13px; color: var(--color-muted); margin-bottom: 14px; }
.commodity-weights { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.commodity-weight-cell { background: var(--color-surface-raised); border-radius: var(--r-sm); padding: 8px 10px; border: 1px solid var(--color-border); }
.commodity-weight-label { font-size: 10px; color: var(--color-muted); margin-bottom: 2px; }
.commodity-weight-value { font-size: 13px; font-weight: 500; color: var(--color-navy); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.commodity-local { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--color-border); }
.commodity-local-label { font-size: 11px; color: var(--color-muted); margin-bottom: 4px; }
.commodity-local-value { font-size: 18px; font-weight: 500; color: var(--color-navy); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Panel section containers ───────────────────────── */
.panel-section { padding: 64px 0; background: var(--color-bg); }
.panel-section--dark { padding: 64px 0; background: var(--color-navy); }
.panel-description { padding: 0 0 32px; background: var(--color-bg); }
.panel-description--dark { padding: 32px 0; background: var(--color-navy); }

/* ── Prose text blocks ──────────────────────────────── */
.prose { max-width: 65ch; font-size: 15px; color: var(--color-muted); line-height: 1.8; }
.prose--on-dark { max-width: 65ch; font-size: 15px; color: rgba(255,255,255,0.55); line-height: 1.8; }

/* ── Section title/sub dark variants ────────────────── */
.section-title--on-dark { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--color-white); margin-bottom: 6px; }
.section-sub--on-dark { font-size: 14px; color: rgba(255,255,255,0.55); margin-bottom: 28px; }
.section-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--color-muted); font-weight: 500; margin-bottom: 16px; }
.section-group-divider { border-top: 1px solid var(--color-border); padding-top: 20px; margin-top: 4px; }

/* ── CI chart container ─────────────────────────────── */
.ci-chart-wrap { background: var(--color-surface); border-radius: var(--r-xl); border: 1px solid var(--color-border); box-shadow: var(--shadow-ambient); padding: 32px; margin-top: 24px; }
.ci-chart-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--color-navy); margin-bottom: 6px; }
.ci-chart-sub { font-size: 13px; color: var(--color-muted); margin-bottom: 20px; }
.ci-chart-canvas { position: relative; height: 280px; }

/* ── Refinance verdict ──────────────────────────────── */
.rf-verdict { margin-top: 8px; padding: 12px 16px; border-radius: var(--r-md); font-size: 13px; line-height: 1.5; background: var(--verdict-neutral-bg); color: var(--verdict-neutral-fg); }
.rf-verdict--negative { background: var(--verdict-negative-bg); color: var(--verdict-negative-fg); }
.rf-verdict--warn     { background: var(--verdict-warn-bg);     color: var(--verdict-warn-fg); }
.rf-verdict--positive { background: var(--verdict-positive-bg); color: var(--verdict-positive-fg); }

/* ── Animations ─────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.calc-card, .chart-wrap, .table-wrap { animation: fadeUp .4s cubic-bezier(0.16,1,0.3,1) both; }

/* ── RTL overrides ──────────────────────────────────── */
[dir="rtl"] .header-inner { flex-direction: row-reverse; }
[dir="rtl"] .settings-btn { order: -1; }
[dir="rtl"] .settings-drawer { right: auto; left: 0; border-left: none; border-right: 1px solid rgba(255,255,255,0.08); transform: translateX(calc(-100% - 1px)); }
[dir="rtl"] .settings-drawer.open { transform: translateX(0); }
[dir="rtl"] .ig-head { flex-direction: row-reverse; }
[dir="rtl"] #cur-swap { transform: scaleX(-1); }
[dir="rtl"] .cur-sel { background-position: left 12px center; padding-right: 11px; padding-left: 32px; }
[dir="rtl"] .breakdown-label { flex-direction: row-reverse; }
[dir="rtl"] .results-grid { direction: rtl; }
[dir="rtl"] .faq-q { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .how-grid { direction: rtl; }
[dir="rtl"] thead th:first-child { text-align: right; }
[dir="rtl"] tbody td:first-child { text-align: right; }
[dir="rtl"] thead th:not(:first-child) { text-align: left; }
[dir="rtl"] tbody td:not(:first-child) { text-align: left; }
[dir="rtl"] .tips-list li::before { content: '\2190'; }
[dir="rtl"] #pref-toast { right: auto; left: max(24px, env(safe-area-inset-left, 24px)); }

/* ── Responsive ─────────────────────────────────────── */
@media(max-width:520px) {
  .header-inner nav { display: none; }
  .results-grid { grid-template-columns: 1fr; }
  .tab-nav { overflow-x: auto; justify-content: flex-start; padding: 0 8px; scrollbar-width: none; -ms-overflow-style: none; }
  .tab-nav::-webkit-scrollbar { display: none; }
  .tab-nav .tab-btn { flex: 0 0 auto; padding: 14px 16px; }
}
@media(max-width:768px) {
  .ig-input, .cur-sel, .settings-select { font-size: 16px; }
}

/* ── Reduced motion ─────────────────────────────────── */
@media(prefers-reduced-motion:reduce) {
  .calc-card, .chart-wrap, .table-wrap { animation: none; opacity: 1; transform: none; }
  .bar-p, .bar-i, .faq-q .chevron, .settings-drawer { transition: none; }
  * { transition-duration: .01ms !important; }
  #pref-toast { transition: none !important; }
}

/* ── Safe-area insets (iOS notch / home bar) ─────── */
header { padding-top: env(safe-area-inset-top, 0px); }
.header-inner { min-height: 64px; height: auto; }
.tool-nav-wrap { top: calc(64px + env(safe-area-inset-top, 0px)); }
footer { padding-bottom: max(32px, calc(32px + env(safe-area-inset-bottom, 0px))); }
#pref-toast {
  bottom: max(24px, calc(24px + env(safe-area-inset-bottom, 0px)));
  right: max(24px, env(safe-area-inset-right, 24px));
}

/* ── Settings drawer — cap to viewport width ─────── */
.settings-drawer { width: min(320px, calc(100vw - 20px)); }

/* ── Monthly payment — larger on mobile (hero output) */
@media(max-width:720px) {
  .monthly-amount { font-size: clamp(32px, 8.5vw, 52px); }
}

/* ── Loan-type tabs — scrollable on narrow screens ── */
@media(max-width:460px) {
  .loan-seg { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .loan-seg .tab-btn { flex: 0 0 auto; padding: 12px 14px; }
}

/* ── Slider — larger thumb for touch ────────────── */
@media(max-width:768px) {
  input[type=range]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -11.5px; }
  input[type=range]::-moz-range-thumb { width: 28px; height: 28px; }
}

/* ── Section vertical padding — compressed on mobile  */
@media(max-width:520px) {
  .calc-section { padding: 20px 0 0; }
  .chart-section { padding: 32px 0; }
  .amort-section { padding: 0 0 32px; }
  .how-section { padding: 40px 0; }
  .faq-section { padding: 40px 0; }
  .panel-section { padding: 40px 0; }
  .panel-section--dark { padding: 40px 0; }
}

/* ── Calculator card — softer radius on narrow screens */
@media(max-width:440px) {
  .calc-card { border-radius: var(--r-xl); }
}

/* ── Input row — wrap when label is long ─────────── */
@media(max-width:360px) {
  .ig-head { flex-wrap: wrap; gap: 6px; }
}

/* ── Footer links — wrap on narrow screens ──────── */
@media(max-width:440px) {
  .footer-links { flex-wrap: wrap; gap: 10px; }
}

/* ── Commodity cards — tighter on very narrow screens */
@media(max-width:400px) {
  .commodity-card { padding: 20px; }
  .commodity-weight-cell { padding: 6px 8px; }
  .commodity-weights { gap: 6px; }
}

/* ── content-visibility for below-fold sections ─── */
.chart-section { content-visibility: auto; contain-intrinsic-size: 0 500px; }
.amort-section { content-visibility: auto; contain-intrinsic-size: 0 450px; }
.how-section   { content-visibility: auto; contain-intrinsic-size: 0 500px; }
.faq-section   { content-visibility: auto; contain-intrinsic-size: 0 600px; }

/* ── Landscape phone — compressed hero ──────────── */
@media(max-height:500px) and (orientation:landscape) {
  .hero { padding: 14px 0 12px; }
  .hero h1 { font-size: clamp(22px, 4vw, 36px); margin-bottom: 8px; }
  .hero-sub { font-size: 14px; margin-bottom: 14px; }
}

/* ── Tablet (720–800px) — ease panel horizontal padding ─── */
@media(max-width:800px) {
  .inputs-panel  { padding: 28px 28px; }
  .results-panel { padding: 28px 28px; }
}
/* Re-assert 720px values (overridden by the broader 800px rule above) */
@media(max-width:720px) {
  .inputs-panel  { padding: 28px 24px; }
  .results-panel { padding: 28px 24px; }
}

/* ── Tool-nav — fade hint that tabs scroll horizontally ──── */
@media(max-width:520px) {
  .tool-nav-wrap::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 48px;
    background: linear-gradient(to right, transparent, var(--color-navy));
    pointer-events: none;
    z-index: 1;
  }
  [dir="rtl"] .tool-nav-wrap::after {
    right: auto; left: 0;
    background: linear-gradient(to left, transparent, var(--color-navy));
  }
}

/* ── Currency selects — stack vertically on narrow screens ─ */
@media(max-width:480px) {
  .cur-selects-row {
    grid-template-columns: 1fr;
    row-gap: 6px;
  }
  .cur-swap-btn { justify-self: center; }
}

/* ── Toast — cap width so it never clips on narrow screens ─ */
@media(max-width:480px) {
  #pref-toast { max-width: calc(100vw - 48px); }
}

/* ── Currency body — tighter padding at very narrow screens ─ */
@media(max-width:360px) {
  .cur-body { padding: 20px 16px; }
}

/* ── SEO content section ────────────────────────────── */
.seo-content { padding: 64px 0; background: var(--color-bg); }
.seo-content h2 { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--color-white); margin-bottom: 20px; }
.seo-content h3 { font-family: var(--font-display); font-size: 19px; font-weight: 600; color: var(--color-white); margin: 32px 0 10px; }
.seo-content p { font-size: 15px; color: var(--color-muted); line-height: 1.8; margin-bottom: 14px; }
.seo-content ul { margin: 0 0 16px 0; padding-left: 20px; }
.seo-content li { font-size: 15px; color: var(--color-muted); line-height: 1.75; margin-bottom: 6px; }
.seo-content strong { color: rgba(255,255,255,0.85); }
.seo-content a { color: var(--color-gold); text-decoration: none; }
.seo-content a:hover { text-decoration: underline; }
.seo-table-wrap { overflow-x: auto; margin: 20px 0 24px; }
.seo-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.seo-table th { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); font-weight: 500; padding: 10px 14px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.1); }
.seo-table td { padding: 9px 14px; color: var(--color-muted); border-bottom: 1px solid rgba(255,255,255,0.06); }
.seo-table tr:last-child td { border-bottom: none; }
@media(max-width:720px) { .seo-content { padding: 40px 0; } }
