:root {
  --bg: #f5f8fc;
  --bg-soft: #edf3f9;
  --surface: #ffffff;
  --surface-2: #f7fbff;
  --text: #102033;
  --muted: #66778b;
  --line: #dce6ef;
  --accent: #18b7c9;
  --accent-2: #6b5cff;
  --accent-dark: #0b7f8d;
  --accent-soft: rgba(24, 183, 201, .12);
  --success: #1ea96d;
  --warning: #d99b24;
  --shadow: 0 18px 50px rgba(25, 51, 78, .10);
  --radius: 24px;
  --radius-sm: 16px;
  --shell: 1240px;
}

html[data-theme="dark"] {
  --bg: #08111c;
  --bg-soft: #0d1926;
  --surface: #101d2b;
  --surface-2: #122233;
  --text: #edf7ff;
  --muted: #9aacc0;
  --line: #22374a;
  --accent: #40d4e4;
  --accent-2: #8f82ff;
  --accent-dark: #71e5ef;
  --accent-soft: rgba(64, 212, 228, .12);
  --shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
.shell { width: min(var(--shell), calc(100% - 32px)); margin: 0 auto; }
.noscript { padding: 12px 18px; background: #b42318; color: #fff; text-align: center; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(18px);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
}
.topbar-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-weight: 900; font-size: 22px; color: #fff;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(24, 183, 201, .22);
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { letter-spacing: .08em; font-size: 14px; }
.brand-copy small { color: var(--muted); letter-spacing: .16em; font-size: 10px; margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.back-webapps {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 14px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 800; white-space: nowrap;
  transition: border-color .18s, background .18s, transform .18s;
}
.back-webapps:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.back-webapps:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.lang-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.lang-btn { border: 0; background: transparent; color: var(--muted); border-radius: 999px; min-width: 38px; height: 34px; font-weight: 800; font-size: 12px; }
.lang-btn.is-active { background: var(--accent-soft); color: var(--accent-dark); }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

.hero {
  position: relative;
  padding: 64px 0 30px;
  background:
    radial-gradient(circle at 10% 20%, rgba(24,183,201,.15), transparent 29%),
    radial-gradient(circle at 90% 10%, rgba(107,92,255,.13), transparent 28%);
}
.hero-grid { display: grid; grid-template-columns: 1.08fr .92fr; align-items: center; gap: 38px; min-height: 560px; }
.eyebrow, .section-kicker { color: var(--accent-dark); font-size: 12px; font-weight: 900; letter-spacing: .12em; }
.hero h1 { font-size: clamp(40px, 6vw, 74px); line-height: .98; letter-spacing: -.045em; margin: 14px 0 22px; max-width: 850px; }
.hero-lead { max-width: 730px; color: var(--muted); font-size: clamp(17px, 2vw, 21px); margin: 0 0 24px; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 22px; }
.hero-pills span { padding: 9px 12px; border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 82%, transparent); font-size: 13px; font-weight: 700; }
.hero-note { max-width: 720px; padding: 14px 16px; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 10px 16px 16px 10px; color: var(--muted); }
.hero-note strong { color: var(--text); }
.hero-art { position: relative; min-height: 520px; display: grid; place-items: center; isolation: isolate; }
.hero-art::before {
  content: ""; position: absolute; width: min(470px, 90%); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(64,212,228,.26), rgba(107,92,255,.08) 58%, transparent 70%);
  z-index: -2;
}
.alien-img { width: min(390px, 78%); max-height: 610px; object-fit: contain; filter: drop-shadow(0 26px 24px rgba(24, 65, 95, .20)); }
.orbit { position: absolute; border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 50%; z-index: -1; animation: orbitSpin 28s linear infinite; }
.orbit::after { content:""; position:absolute; width:12px; height:12px; border-radius:50%; background:var(--accent); top:14%; left:7%; box-shadow:0 0 18px var(--accent); }
.orbit-a { width: 390px; height: 390px; }
.orbit-b { width: 480px; height: 480px; animation-duration: 40s; animation-direction: reverse; opacity: .5; }
@keyframes orbitSpin { to { transform: rotate(360deg); } }

.calculator-section { padding: 30px 0 70px; }
.app-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 24px; }
.app-main { display: grid; gap: 22px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.section-heading { display: flex; justify-content: space-between; gap: 22px; align-items: center; margin-bottom: 22px; }
.section-heading h2, .result-heading h2 { margin: 3px 0 3px; font-size: clamp(24px, 3vw, 32px); letter-spacing: -.02em; }
.section-heading p, .result-heading p { margin: 0; color: var(--muted); }
.section-icon { width: 76px; height: 76px; object-fit: contain; flex: 0 0 auto; }
.badge-img { width: 150px; height: 82px; object-fit: contain; }
.compact-heading { margin-bottom: 14px; }

.mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 18px 0 24px; }
.mode-btn { text-align: left; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); padding: 15px 16px; border-radius: 16px; display: grid; gap: 2px; }
.mode-btn small { color: var(--muted); }
.mode-btn.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--accent-soft); }

.form-grid { display: grid; gap: 16px; }
.form-grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.field { display: grid; gap: 7px; align-content: start; color: var(--text); font-weight: 700; font-size: 13px; }
.field input, .field select {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); color: var(--text); padding: 12px 13px; outline: none; transition: border-color .18s, box-shadow .18s;
}
.field input:focus, .field select:focus, .money-input input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-suffix, .money-input { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); overflow: hidden; }
.input-suffix input, .money-input input { border: 0; border-radius: 0; background: transparent; box-shadow: none !important; }
.input-suffix span { color: var(--muted); padding-right: 12px; white-space: nowrap; font-weight: 700; }
.money-input { min-width: 128px; }
.money-input .currency-symbol { color: var(--accent-dark); padding-left: 11px; font-weight: 900; }
.money-input input { padding-left: 8px; min-width: 80px; }
.money-input.full { width: 100%; }
.calculated-field { padding: 11px 13px; border: 1px dashed var(--accent); border-radius: 13px; background: var(--accent-soft); }
.calculated-field strong { font-size: 23px; }
.calculated-field small { color: var(--muted); font-weight: 500; }

.cost-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.cost-card { display: grid; grid-template-columns: 54px minmax(0,1fr) auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 17px; padding: 12px; background: var(--surface-2); }
.cost-icon { width: 54px; height: 54px; object-fit: contain; }
.cost-copy { display: grid; gap: 2px; min-width: 0; }
.cost-copy strong { font-size: 14px; }
.cost-copy small { color: var(--muted); font-size: 12px; }
.pet-irrelevant { opacity: .48; }
.pet-irrelevant::after { content: ""; }

.results-panel { position: relative; }
.results-sticky { position: sticky; top: 94px; background: #0c1726; color: #f6fbff; border-radius: 26px; padding: 24px; overflow: hidden; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.results-sticky::before { content:""; position:absolute; width:260px; height:260px; border-radius:50%; background:rgba(64,212,228,.10); right:-110px; top:-110px; }
.result-heading { position: relative; }
.result-heading .section-kicker { color: #76e5ef; }
.result-heading p { color: #9fb1c4; font-size: 13px; }
.primary-result { margin: 22px 0 16px; padding: 18px; border: 1px solid rgba(255,255,255,.12); border-radius: 19px; background: rgba(255,255,255,.06); display: grid; }
.primary-result span { color: #b7c6d5; font-size: 13px; }
.primary-result strong { font-size: 40px; line-height: 1.1; letter-spacing: -.04em; margin: 4px 0; }
.primary-result small { color: #7f95aa; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.result-card { padding: 13px; border-radius: 15px; background: rgba(255,255,255,.06); display: grid; gap: 4px; }
.result-card span { color: #aebfd0; font-size: 12px; }
.result-card strong { font-size: 18px; }
.budget-with-emergency { margin: 14px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-radius: 16px; background: linear-gradient(135deg, rgba(64,212,228,.14), rgba(143,130,255,.13)); }
.budget-with-emergency div { display: grid; gap: 3px; }
.budget-with-emergency span { color: #b9c7d5; font-size: 12px; }
.budget-with-emergency strong { font-size: 20px; }
.budget-with-emergency img { width: 54px; height: 54px; object-fit: contain; }
.breakdown { margin-top: 17px; }
.breakdown-head { display:flex; justify-content:space-between; gap:10px; font-size:12px; color:#bac9d7; }
.breakdown-list { display:grid; gap:9px; margin-top:11px; }
.breakdown-item { display:grid; grid-template-columns: 1fr auto; gap:6px 10px; }
.breakdown-label { font-size:12px; color:#d7e2ec; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.breakdown-value { font-size:12px; color:#9fb1c4; }
.bar { grid-column:1 / -1; height:7px; border-radius:999px; background:rgba(255,255,255,.08); overflow:hidden; }
.bar > span { display:block; height:100%; border-radius:999px; background:linear-gradient(90deg,#40d4e4,#8f82ff); }
.actions { display:grid; gap:9px; margin-top:20px; }
.btn { border:0; border-radius:14px; padding:13px 15px; font-weight:800; }
.btn-primary { background:#40d4e4; color:#07151d; }
.btn-secondary { background:rgba(255,255,255,.08); color:#fff; border:1px solid rgba(255,255,255,.12); }
.save-status { min-height: 18px; margin-top: 10px; color: #8fa5b9; font-size: 11px; text-align: center; }

.pet-gallery { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; padding-bottom:70px; }
.mini-pet { min-height:150px; background:var(--surface); border:1px solid var(--line); border-radius:22px; display:flex; align-items:center; justify-content:center; gap:12px; padding:14px; box-shadow:var(--shadow); }
.mini-pet img { width:90px; height:90px; object-fit:contain; }
.mini-pet span { font-weight:900; }
.info-section { padding: 10px 0 70px; }
.info-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:18px; }
.info-grid article { padding: 24px; border-top: 3px solid var(--accent); background: var(--surface); border-radius: 6px 6px 20px 20px; }
.info-grid h2 { font-size: 20px; margin: 0 0 8px; }
.info-grid p { color: var(--muted); margin:0; }
.footer { border-top:1px solid var(--line); background:var(--surface); }
.footer-inner { min-height:82px; display:flex; justify-content:space-between; align-items:center; gap:20px; color:var(--muted); font-size:13px; }
.footer a { color:var(--text); font-weight:900; text-decoration:none; }

body.mode-quick .advanced-only { display: none !important; }

@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr 400px; }
  .app-layout { grid-template-columns: 1fr; }
  .results-sticky { position: relative; top: auto; }
  .form-grid-4 { grid-template-columns: repeat(2,1fr); }
  .cost-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .shell { width: min(100% - 22px, var(--shell)); }
  .topbar-inner { min-height: 64px; gap: 8px; }
  .top-actions { gap: 6px; }
  .back-webapps { min-height: 40px; padding: 0 10px; font-size: 12px; }
  .brand-copy small { display:none; }
  .hero { padding-top: 34px; }
  .hero-grid { grid-template-columns: 1fr; min-height: 0; gap: 6px; }
  .hero h1 { font-size: clamp(38px, 13vw, 58px); }
  .hero-art { min-height: 390px; }
  .alien-img { width: min(310px, 82%); max-height: 430px; }
  .orbit-a { width: 300px; height:300px; }
  .orbit-b { width: 360px; height:360px; }
  .panel { padding: 18px; border-radius: 20px; }
  .section-heading { align-items:flex-start; }
  .section-icon { width:62px; height:62px; }
  .badge-img { width:110px; height:70px; }
  .form-grid-4, .form-grid-3 { grid-template-columns: 1fr; }
  .mode-switch { grid-template-columns: 1fr; }
  .cost-card { grid-template-columns: 48px minmax(0,1fr); }
  .cost-icon { width:48px; height:48px; }
  .cost-card .money-input { grid-column:1 / -1; width:100%; }
  .pet-gallery { grid-template-columns:repeat(2,1fr); }
  .mini-pet { flex-direction:column; }
  .info-grid { grid-template-columns:1fr; }
  .footer-inner { padding:20px 0; min-height:0; display:grid; }
}

@media (max-width: 430px) {
  .back-webapps { padding: 0 8px; font-size: 0; }
  .back-webapps::before { content: "← WebApps"; font-size: 11px; }
  .lang-switch { gap:0; }
  .lang-btn { min-width:32px; }
  .brand-copy strong { font-size:12px; }
  .hero-pills span { font-size:12px; }
  .pet-gallery { grid-template-columns:1fr 1fr; gap:10px; }
  .mini-pet { min-height:130px; }
  .mini-pet img { width:74px; height:74px; }
}

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

@media print {
  :root, html[data-theme="dark"] { --bg:#fff; --surface:#fff; --surface-2:#fff; --text:#111; --muted:#555; --line:#ddd; }
  body { background:#fff; }
  .topbar, .hero-art, .hero-pills, .hero-note, .mode-switch, .app-main, .pet-gallery, .info-section, .footer, .actions, .save-status { display:none !important; }
  .hero { padding:0 0 18px; background:#fff; }
  .hero-grid { display:block; min-height:0; }
  .hero h1 { font-size:32px; }
  .hero-lead { font-size:15px; }
  .calculator-section { padding:0; }
  .app-layout { display:block; }
  .results-sticky { position:static; background:#fff; color:#111; box-shadow:none; border:1px solid #ddd; }
  .result-heading p, .primary-result span, .primary-result small, .result-card span, .budget-with-emergency span, .breakdown-head, .breakdown-value, .breakdown-label { color:#555 !important; }
  .primary-result, .result-card, .budget-with-emergency { background:#fff; border:1px solid #ddd; }
  .bar { background:#eee; }
  .bar > span { background:#333; }
}
