/* ==========================================================================
   Domestic Margin Studio · dicekorea.com
   스마트스토어 · 쿠팡 윙 · 로켓그로스 정산/수수료/광고비 통합 계산기 (9번)
   외부 CDN·폰트 의존성 없음. CSP `default-src 'self'; style-src 'self';
   script-src 'self'` 환경에서 그대로 동작합니다. (인라인 script/style 0개)
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #F4F7FC;
  --surface: #FFFFFF;
  --surface-2: #F8FAFE;
  --ink: #0F172A;
  --ink-2: #3B4A63;
  --muted: #6B7A90;
  --line: #E3E9F4;
  --line-soft: #EEF2F9;
  --brand: #2563EB;
  --brand-dark: #1D4ED8;
  --brand-soft: #EDF3FF;
  --green: #0E9F6E;
  --green-soft: #E7F8F0;
  --amber: #B45309;
  --amber-soft: #FEF5E7;
  --red: #D92D20;
  --red-soft: #FEECEB;
  --violet: #6D28D9;
  --violet-soft: #F3EEFF;
  --radius-lg: 20px;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 18px 38px -28px rgba(15, 23, 42, .45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
          "Malgun Gothic", "Noto Sans KR", "Noto Sans CJK KR", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: .92em; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 24px; }

.skip {
  position: absolute; left: -999px; top: 8px; z-index: 100;
  background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip:focus { left: 16px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; height: 64px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand__mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(150deg, #3B82F6, #1D4ED8);
  color: #fff;
  box-shadow: 0 6px 14px -6px rgba(37, 99, 235, .8);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand__text small { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

.topbar__actions { display: flex; align-items: center; gap: 10px; }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: #EEF2F9; border-radius: 11px;
}
.seg button {
  border: 0; background: transparent; cursor: pointer;
  font: inherit; font-size: 12.5px; font-weight: 700; letter-spacing: .01em;
  color: var(--muted); padding: 6px 11px; border-radius: 8px;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.seg button:hover { color: var(--ink-2); }
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--brand);
  box-shadow: var(--shadow-sm);
}
.seg--wide { display: flex; flex-wrap: wrap; width: 100%; }
.seg--wide button { flex: 1 1 0; padding: 8px 6px; font-size: 12px; text-align: center; min-width: 0; }
.seg--three button { font-size: 11.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer;
  padding: 9px 15px; border-radius: 10px; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .1s ease;
}
.btn:hover { border-color: #C8D5EC; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .62; }
.btn--primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 8px 18px -12px rgba(37, 99, 235, .95);
}
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: #EEF2F9; color: var(--ink-2); }
.btn--sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn--lg { width: 100%; padding: 12px 18px; font-size: 14.5px; border-radius: 12px; }
.btn--wide { width: 100%; }
.btn--danger { color: var(--red); border-color: #F4D3D0; background: #fff; }
.btn--danger:hover { background: var(--red-soft); border-color: #EFC4C0; }
.btn[aria-pressed="true"] { background: var(--brand-soft); border-color: #C7DBFF; color: var(--brand-dark); }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap;
}
.pill--green { background: var(--green-soft); color: var(--green); }
.pill--amber { background: var(--amber-soft); color: var(--amber); }
.pill--red { background: var(--red-soft); color: var(--red); }
.pill--blue { background: var(--brand-soft); color: var(--brand); }
.pill--violet { background: var(--violet-soft); color: var(--violet); }
.pill--grey { background: #EEF2F9; color: var(--muted); }
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- hero ---------- */

.hero { padding: 42px 0 6px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .13em;
  color: var(--brand); text-transform: uppercase;
}
.eyebrow::before {
  content: ""; width: 18px; height: 2px; border-radius: 2px; background: var(--brand);
}
.hero h1 {
  margin-top: 14px;
  font-size: clamp(27px, 4vw, 40px);
  line-height: 1.24; letter-spacing: -.035em; font-weight: 700;
  max-width: 24em; word-break: keep-all;
}
.hero h1 em {
  font-style: normal; color: var(--brand);
  background: linear-gradient(transparent 62%, #DCE7FF 62%);
  padding: 0 2px;
}
.hero__sub { margin-top: 14px; max-width: 62em; font-size: 15px; color: var(--ink-2); }
.hero__sub strong { color: var(--ink); font-weight: 650; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chips li {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px;
  box-shadow: var(--shadow-sm);
}
.chips li::before { content: "✓"; color: var(--green); font-weight: 700; font-size: 12px; }

/* ---------- layout ---------- */

.studio {
  display: grid;
  grid-template-columns: minmax(0, 396px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  margin-top: 28px;
}

.sidebar { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 20px;
}
.card__head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.card__num {
  flex: none; display: grid; place-items: center;
  width: 26px; height: 26px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand);
  font-size: 12.5px; font-weight: 700; margin-top: 1px;
}
.card__num--violet { background: var(--violet-soft); color: var(--violet); font-size: 12px; }
.card__num--grey { background: #EEF2F9; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.card__title { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; }
.card__hint { margin-top: 2px; font-size: 12.5px; color: var(--muted); }

/* ---------- fields ---------- */

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.card > .field { margin-top: 14px; }
.card > .fields + .field { margin-top: 14px; }

.field > label,
.field .label,
label.inline {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 12.5px; font-weight: 650; color: var(--ink-2);
}

input[type="text"], input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  appearance: none; -webkit-appearance: none;
}
input[type="text"], input[type="date"], select { height: 42px; padding-top: 0; padding-bottom: 0; }
input[type="number"] { height: 42px; font-variant-numeric: tabular-nums; }
select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.6 4.6 6 8l3.4-3.4' fill='none' stroke='%236B7A90' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px 12px;
}
input:hover, select:hover, textarea:hover { border-color: #CFD9EA; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .16);
}
input::placeholder, textarea::placeholder { color: #A6B2C4; }
input[readonly] {
  background: var(--surface-2); color: var(--ink-2);
  font-variant-numeric: tabular-nums; border-style: dashed;
}

.fi-note { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
.fi-note strong { color: var(--ink-2); font-weight: 650; }

/* ---------- presets ---------- */

.presets { margin-top: 14px; }
.presets .label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.presets__row { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.preset {
  display: flex; align-items: center; gap: 7px; text-align: left;
  font: inherit; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.preset:hover { border-color: #C7D6F2; background: #fff; color: var(--ink); }
.preset.is-on { border-color: #C3D8FF; background: var(--brand-soft); color: var(--brand-dark); }
.preset__num {
  flex: none; display: grid; place-items: center;
  width: 18px; height: 18px; border-radius: 6px;
  background: #fff; border: 1px solid var(--line);
  font-size: 10px; font-weight: 800; color: var(--brand);
}
.preset.is-on .preset__num { background: var(--brand); border-color: var(--brand); color: #fff; }
.preset__text { min-width: 0; }

/* ---------- toggles ---------- */

.togglehead { display: flex; align-items: center; gap: 8px; }
.ratebox { width: 74px !important; flex: none; text-align: right; }
.togglehead .unit { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- ad roas ---------- */

.adroas {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding: 10px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  font-size: 12.5px; color: var(--ink-2);
}
.adroas strong { font-size: 16px; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- results ---------- */

.result { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.result__head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.section__title { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.section__desc { margin-top: 3px; font-size: 13px; color: var(--muted); }

/* ---------- compare tiles ---------- */

.compare { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.ctile {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 16px 16px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.ctile__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ctile__name {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--ink); min-width: 0;
}
.ctile__dot { flex: none; width: 8px; height: 8px; border-radius: 3px; }
.ctile__dot--smt { background: #03C75A; }
.ctile__dot--wing { background: #E52528; }
.ctile__dot--rocket { background: #6D28D9; }
.ctile__main { display: flex; flex-direction: column; gap: 1px; }
.ctile__k { font-size: 10.5px; font-weight: 800; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; }
.ctile__profit {
  font-size: 26px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ctile__profit.is-neg { color: var(--red); }
.ctile__meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--ink-2); }
.ctile__meta span { display: inline-flex; align-items: baseline; gap: 3px; }
.ctile__meta b { font-weight: 700; font-variant-numeric: tabular-nums; }
.ctile__bar {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; height: 6px; border: 0; border-radius: 999px;
  background: #EEF2F9; overflow: hidden;
}
.ctile__bar::-webkit-progress-bar { background: #EEF2F9; border-radius: 999px; }
.ctile__bar::-webkit-progress-value { background: var(--brand); border-radius: 999px; }
.ctile__bar::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.ctile.is-best .ctile__bar::-webkit-progress-value { background: var(--green); }
.ctile.is-best .ctile__bar::-moz-progress-bar { background: var(--green); }
.ctile__bar.is-loss::-webkit-progress-value { background: var(--red); }
.ctile__bar.is-loss::-moz-progress-bar { background: var(--red); }
.ctile.is-best { border-color: #BFD4FF; box-shadow: 0 1px 2px rgba(37, 99, 235, .08), 0 20px 40px -30px rgba(37, 99, 235, .8); }
.ctile.is-best .ctile__bar { background: #E7F8F0; }
.ctile.is-best .ctile__bar::-webkit-progress-bar { background: #E7F8F0; }
.ctile__flag {
  flex: none;
  font-size: 10px; font-weight: 800; letter-spacing: .02em; line-height: 1.6;
  color: #fff; background: var(--brand);
  border-radius: 999px; padding: 0 7px;
  box-shadow: 0 6px 14px -8px rgba(37, 99, 235, .9);
}
.ctile.is-loss { border-color: #F4D3D0; }

/* ---------- matrix table ---------- */

.tablewrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td {
  padding: 8px 10px; text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--line-soft);
}
.matrix thead th {
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.matrix th:first-child, .matrix td:first-child {
  text-align: left; white-space: normal; color: var(--ink-2);
  font-weight: 600; font-size: 12.5px;
}
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tr.is-total td { font-weight: 750; color: var(--ink); font-size: 14px; padding-top: 10px; padding-bottom: 10px; }
.matrix tr.is-total td:first-child { font-weight: 750; }
.matrix tr.is-head td { background: var(--surface-2); font-size: 11.5px; letter-spacing: .03em; color: var(--muted); text-transform: uppercase; font-weight: 800; }
.matrix td.is-neg { color: var(--red); }
.matrix td.is-best { color: var(--green); font-weight: 750; }
.matrix .sub { display: block; font-size: 10.5px; color: var(--muted); font-weight: 500; }
.matrix tr.is-head td:first-child { color: var(--muted); }

/* ---------- duo ---------- */

.duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }

/* ---------- gauge ---------- */

.gaugewrap { margin: 14px 0 4px; }
.gauge {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 10px; border: 0; border-radius: 999px;
  background: #EEF2F9; overflow: hidden; display: block;
}
.gauge::-webkit-progress-bar { background: #EEF2F9; border-radius: 999px; }
.gauge::-webkit-progress-value {
  background: linear-gradient(90deg, #93B4FF, #2563EB);
  border-radius: 999px;
}
.gauge::-moz-progress-bar { background: var(--brand); border-radius: 999px; }
.gauge.is-loss::-webkit-progress-value { background: linear-gradient(90deg, #F7B4AE, #D92D20); }
.gauge.is-loss::-moz-progress-bar { background: var(--red); }
.gauge__legend {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  margin-top: 6px; font-size: 10.5px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.gauge__lg { display: inline-flex; align-items: center; gap: 4px; }
.gauge__lg::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor;
}
.gauge__lg--now { color: var(--brand); }
.gauge__lg--bep { color: var(--amber); }
.gauge__lg--safe { color: var(--green); }

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.kpi {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 10px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.kpi__k { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: var(--muted); text-transform: uppercase; }
.kpi__v { font-size: 15.5px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.statusrow { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- target ---------- */

.target {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 14px; padding: 14px;
  border-radius: var(--radius); border: 1px solid #E1EAFB;
  background: linear-gradient(180deg, #F8FBFF, #F2F7FF);
}
.target__k { font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--brand); }
.target__v {
  font-size: 28px; font-weight: 750; letter-spacing: -.03em; line-height: 1.15;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.target__v.is-none { color: var(--red); font-size: 17px; letter-spacing: 0; }
#btnApplyTarget { margin-top: 10px; }

/* ---------- scenarios ---------- */

.scenario__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.scenario__actions .fi-note { margin-left: auto; font-variant-numeric: tabular-nums; }

.scenarios { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.scenario {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm);
}
.scenario__main { min-width: 0; flex: 1 1 auto; }
.scenario__title {
  font-size: 12.5px; font-weight: 650; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scenario__meta { display: flex; flex-wrap: wrap; gap: 4px 9px; margin-top: 3px; font-size: 11px; color: var(--muted); }
.scenario__meta span { white-space: nowrap; }
.scenario__meta b { color: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.scenario__actions2 { display: flex; gap: 6px; flex: none; }

/* ---------- notes ---------- */

.notes { display: flex; flex-direction: column; gap: 7px; }
.notes li {
  position: relative; padding-left: 14px;
  font-size: 12px; color: var(--ink-2); line-height: 1.6;
}
.notes li::before {
  content: ""; position: absolute; left: 2px; top: .62em;
  width: 5px; height: 5px; border-radius: 50%; background: #C3D2EA;
}

/* ---------- empty / footer / toast ---------- */

.empty {
  padding: 26px 20px; text-align: center; color: var(--muted); font-size: 13px;
  border: 1px dashed var(--line); border-radius: var(--radius-lg); background: var(--surface-2);
  margin-top: 12px;
}
.empty strong { display: block; color: var(--ink-2); font-size: 13.5px; margin-bottom: 4px; }

.foot {
  margin: 38px 0 0; padding: 22px 0 44px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px; line-height: 1.7;
}
.foot p + p { margin-top: 6px; }
.foot strong { color: var(--ink-2); font-weight: 650; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: #0F172A; color: #fff; font-size: 13px; font-weight: 600;
  padding: 11px 18px; border-radius: 12px; z-index: 80;
  box-shadow: 0 18px 34px -18px rgba(15, 23, 42, .8);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  max-width: min(92vw, 520px); text-align: center;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }

.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;
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .studio { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .sidebar > .card:first-child { grid-column: 1 / -1; }
}

@media (max-width: 1020px) {
  .compare { grid-template-columns: minmax(0, 1fr); }
  .duo { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .topbar__actions .pill { display: none; }
  .card { padding: 17px; border-radius: 16px; }
  .topbar__inner { height: 58px; }
  .brand__text small { display: none; }
  .hero { padding-top: 28px; }
  .hero h1 { font-size: 24px; }
  .eyebrow { font-size: 10.5px; letter-spacing: .08em; }
  .hero__sub { font-size: 13.5px; }
  .btn { padding: 8px 12px; font-size: 13px; }
  .brand__mark { width: 30px; height: 30px; border-radius: 10px; }
  .brand__text strong { font-size: 14px; }
  .seg button { padding: 6px 9px; }
  .seg--wide button { flex: 1 1 calc(50% - 4px); }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .ctile__profit { font-size: 23px; }
  .matrix th, .matrix td { padding: 7px 6px; font-size: 12px; }
  .matrix th:first-child, .matrix td:first-child { font-size: 11.5px; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .scenario { align-items: flex-start; flex-direction: column; gap: 8px; }
  .scenario__actions2 { width: 100%; justify-content: flex-end; }
  .scenario__actions .fi-note { margin-left: 0; }
}

@media (max-width: 420px) {
  .topbar__actions .btn--ghost { display: none; }
  .ratebox { width: 64px !important; }
  .target__v { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; animation: none !important; }
}

@media print {
  .topbar, .toast, .btn, .chips, .presets, .sidebar, .scenario__actions2, .scenario__actions { display: none !important; }
  body { background: #fff; }
  .card, .ctile { box-shadow: none; break-inside: avoid; }
}
