/* Calculator pages (templates/calculators/*) */
.calc-head { padding: 10px 0 18px; }
.calc-head h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 3.6vw, 2rem); }
.calc-head p { margin: 0; color: var(--muted); }

.calc-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.calc-side { position: sticky; top: 78px; display: flex; flex-direction: column; gap: 8px; }
.calc-form .field:last-child { margin-bottom: 0; }
.calc-sec { font-size: 1rem; margin: 18px 0 10px; }
.calc-sec:first-child { margin-top: 0; }
.calc-grid { gap: 0 12px; }
.calc-check { margin: 4px 0 14px; }
.calc-more { border-top: 1px solid var(--line); padding: 12px 0 2px; margin-top: 4px; }
.calc-more summary { cursor: pointer; font-weight: 600; margin-bottom: 10px; }
.calc-note { margin: 0 4px; }

.input-suffix { display: flex; align-items: stretch; }
.input-suffix input { border-top-right-radius: 0; border-bottom-right-radius: 0; font-variant-numeric: tabular-nums; }
.input-suffix span { display: flex; align-items: center; padding: 0 12px; font-size: .85rem; color: var(--muted); white-space: nowrap;
  background: var(--surface-2); border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-suffix input:only-child { border-radius: var(--radius-sm); }

.seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.seg button { flex: 1; min-width: 110px; padding: 7px 10px; font: inherit; font-size: .88rem; color: var(--text); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--surface); box-shadow: 0 1px 3px rgb(0 0 0 / .12); font-weight: 600; color: var(--accent); }

.thai-date { display: grid; grid-template-columns: 1fr 1.3fr 1.3fr; gap: 6px; }

.calc-result { display: flex; flex-direction: column; gap: 12px; }
.res-big { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius-sm); background: var(--accent-soft); }
.res-big span { font-size: .85rem; color: var(--muted); }
.res-big b { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.25; font-variant-numeric: tabular-nums; word-break: break-word; }
.res-big small { font-size: .85rem; color: var(--muted); }
.res-big.ok { background: var(--ok-soft); } .res-big.ok b { color: var(--ok); }
.res-big.warn { background: var(--gold-soft); } .res-big.warn b { color: var(--gold); }
.res-big.lvl-ok b { color: var(--ok); } .res-big.lvl-warn b { color: var(--gold); }
.res-big.lvl-high b, .res-big.lvl-low b { color: var(--bad); }
.res-text { font-size: 1.25rem !important; }
.res-h { font-size: 1rem; margin: 6px 0 0; }
.res-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.res-table th, .res-table td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.res-table th { text-align: left; font-weight: 400; color: var(--muted); padding-right: 12px; }
.res-table td { text-align: right; font-variant-numeric: tabular-nums; }
.res-table tr.strong th, .res-table tr.strong td { font-weight: 700; color: var(--text); }
.res-table.compact td { text-align: left; }
.res-note { margin: 0; font-size: .88rem; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.res-note.ok { background: var(--ok-soft); }
.res-note.bad { background: var(--bad-soft); color: var(--bad); }
.res-words { display: flex; gap: 8px; align-items: center; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.calc-actions { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 12px; }
.calc-msg { margin: 0; }
.calc-msg.ok { color: var(--ok); }
.calc-msg.bad { color: var(--bad); }

.bmi-bar { position: relative; height: 10px; border-radius: 5px;
  background: linear-gradient(90deg, #60a5fa 0 17.5%, #22c55e 17.5% 40%, #eab308 40% 50%, #f97316 50% 75%, #ef4444 75%); }
.bmi-bar i { position: absolute; top: -5px; width: 4px; height: 20px; margin-left: -2px; border-radius: 2px; background: var(--text); }
.bmi-legend { display: grid; grid-template-columns: 17.5fr 22.5fr 10fr 25fr 25fr; color: var(--muted); margin-top: -6px; }
.glasses { font-size: 1.3rem; letter-spacing: 2px; line-height: 1.6; }

.pct-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pct-row:first-child { padding-top: 0; }
.pct-row input { width: 110px; text-align: right; }
.pct-out { font-size: 1.1rem; color: var(--accent); font-variant-numeric: tabular-nums; }

.calc-schedule { margin-top: 16px; }
.calc-schedule h2 { font-size: 1.1rem; margin: 0 0 12px; }
.calc-schedule details { margin-top: 12px; }
.calc-schedule summary { cursor: pointer; font-weight: 500; margin-bottom: 8px; }
.num-table { width: 100%; font-size: .85rem; }
.num-table td, .num-table th { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.num-table td:first-child, .num-table th:first-child { text-align: center; }
.calc-schedule .table-wrap { max-height: 420px; overflow: auto; }

.calc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.calc-card { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.calc-card:hover { border-color: var(--tint-ink, var(--accent)); transform: translateY(-2px); box-shadow: var(--shadow); }
.calc-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.calc-txt > span { font-size: .85rem; color: var(--muted); }
.calc-ico, .calc-h-ico { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px;
  background: var(--tint, var(--accent-soft)); color: var(--tint-ink, var(--accent)); }
.calc-ico .icon, .calc-h-ico .icon { width: 24px; height: 24px; }
.cat-ico { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; vertical-align: -6px;
  background: var(--tint); color: var(--tint-ink); margin-right: 4px; }
.cat-ico .icon { width: 18px; height: 18px; }
.calc-card:hover .calc-ico { transform: scale(1.06); }
.calc-ico { transition: transform .15s; }
.calc-h-ico { display: inline-grid; vertical-align: middle; margin-right: 12px; width: 44px; height: 44px; font-size: 1.35rem; }
/* one soft colour per category */
.cat-finance { --tint: #fef3c7; --tint-ink: #b45309; }
.cat-business { --tint: #ede9fe; --tint-ink: #6d28d9; }
.cat-date { --tint: #dbeafe; --tint-ink: #1d4ed8; }
.cat-health { --tint: #dcfce7; --tint-ink: #15803d; }
.cat-home { --tint: #ffedd5; --tint-ink: #c2410c; }
.cat-education { --tint: #fce7f3; --tint-ink: #be185d; }
[data-theme=dark] :is(.cat-finance, .cat-business, .cat-date, .cat-health, .cat-home, .cat-education) { --tint-ink: #f1eee9; }
[data-theme=dark] .cat-finance { --tint: #3a2d12; } [data-theme=dark] .cat-business { --tint: #2b2440; }
[data-theme=dark] .cat-date { --tint: #1c2840; } [data-theme=dark] .cat-health { --tint: #173123; }
[data-theme=dark] .cat-home { --tint: #3a2516; } [data-theme=dark] .cat-education { --tint: #3a1f2e; }
.calc-group .section-title a { color: inherit; text-decoration: none; }

.calc-mini { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20; display: grid; grid-template-columns: 1fr auto;
  align-items: center; gap: 0 10px; padding: 10px 14px; font: inherit; text-align: left; color: var(--accent-ink);
  background: var(--accent); border: 0; border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .25); cursor: pointer; }
.calc-mini span { grid-column: 1; font-size: .78rem; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calc-mini b { grid-column: 1; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.calc-mini i { grid-column: 2; grid-row: 1 / 3; font-style: normal; font-size: .85rem; font-weight: 600; }

@media (max-width: 820px) {
  .calc-layout { grid-template-columns: minmax(0, 1fr); }
  .calc-side { position: static; }
}
@media (max-width: 480px) {
  .calc-grid.grid-2, .calc-grid.grid-3 { grid-template-columns: minmax(0, 1fr); }
  .pct-row input { width: 90px; }
}

/* comparison tables (marketplaces, appliances) */
.res-table.cmp thead th { font-size: .78rem; color: var(--muted); font-weight: 500; text-align: right; padding-bottom: 4px; }
.res-table.cmp thead th:first-child { text-align: left; }
.res-table.cmp tbody th { color: var(--text); }

/* appliance rows */
.appl-head, .appl-row { display: grid; grid-template-columns: minmax(0, 2fr) 80px 70px 60px; gap: 6px; align-items: center; }
.appl-head { margin-bottom: 4px; }
.appl-row { margin-bottom: 6px; }
.appl-row input, .appl-row select { padding: 7px 8px; font-size: .88rem; }
@media (max-width: 480px) { .appl-head, .appl-row { grid-template-columns: minmax(0, 1fr) 64px 56px 48px; } }

/* phase 3 */
.countdown { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.countdown div { display: flex; flex-direction: column; align-items: center; padding: 12px 4px; border-radius: var(--radius-sm); background: var(--surface-2); }
.countdown b { font-size: clamp(1.4rem, 5vw, 2rem); font-variant-numeric: tabular-nums; color: var(--accent); }
.countdown span { font-size: .78rem; color: var(--muted); }
.res-table tr.past td { color: var(--muted); }
.gpa-head, .gpa-row { display: grid; grid-template-columns: minmax(0, 1fr) 80px 80px; gap: 6px; align-items: center; }
.tcas-head, .tcas-row { display: grid; grid-template-columns: minmax(0, 1.4fr) 80px 80px 74px; gap: 6px; align-items: center; }
.gpa-head, .tcas-head { margin-bottom: 4px; }
.gpa-row, .tcas-row { margin-bottom: 6px; }
.gpa-row input, .gpa-row select, .tcas-row input { padding: 7px 8px; font-size: .88rem; }
@media (max-width: 480px) { .tcas-head, .tcas-row { grid-template-columns: minmax(0, 1fr) 60px 56px 56px; } }

.res-words .keep { flex: 1; }

/* scientific calculator keypad + ratio row (pages_extra.py) */
.calc-expr { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.calc-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.calc-keys button { padding: 12px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: 600 1.05rem var(--font); cursor: pointer; }
.calc-keys button:hover { border-color: var(--accent); }
.calc-keys .fn { background: var(--surface-2); font-size: .9rem; }
.calc-keys .op { color: var(--accent); }
.calc-keys .eq { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.calc-ratio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calc-ratio input { width: 90px; text-align: center; font-size: 1.1rem; }
.calc-ratio b { font-size: 1.3rem; }
