:root {
  --bg: #0B1220;
  --card: #111827;
  --card2: #0f172a;
  --border: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --dim: #64748b;
  --teal: #2DD4BF;
  --coral: #F87171;
  --amber: #f59e0b;
  --green: #10b981;
  --maxw: 720px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--teal); }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 80px; }
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(11,18,32,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  font-weight: 800; letter-spacing: -.02em; color: var(--text);
  text-decoration: none; font-size: .95rem;
}
.brand span { color: var(--teal); }
.nav-links { margin-left: auto; display: flex; gap: 14px; font-size: .85rem; }
.nav-links a { color: var(--muted); text-decoration: none; font-weight: 600; }
.nav-links a:hover { color: var(--text); }

.hero { padding: 28px 0 8px; }
.hero .pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(45,212,191,.12); color: var(--teal);
  border: 1px solid rgba(45,212,191,.3);
  font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  margin-bottom: 12px;
}
.hero h1 {
  font-size: clamp(1.45rem, 4.5vw, 1.9rem);
  font-weight: 800; letter-spacing: -.03em; line-height: 1.3;
  margin-bottom: 10px; text-wrap: balance;
}
.hero p { color: var(--muted); font-size: .95rem; margin-bottom: 8px; }
.hook {
  color: #fff; font-weight: 700; font-size: 1.02rem;
  margin: 12px 0 4px;
}
.hook em { color: var(--coral); font-style: normal; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  margin: 16px 0;
}
.card h2 {
  font-size: 1rem; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.hint { font-size: .78rem; color: var(--dim); font-weight: 500; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: .88rem; font-weight: 600; margin-bottom: 8px; color: #cbd5e1;
}
.stepper {
  display: flex; align-items: center; gap: 10px;
}
.stepper button {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card2);
  color: var(--text); font-size: 1.2rem; font-weight: 700; cursor: pointer;
  flex-shrink: 0;
}
.stepper button:hover { border-color: var(--teal); color: var(--teal); }
.stepper .val {
  flex: 1; text-align: center;
  font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums;
  color: #fff;
}
.stepper .unit { font-size: .85rem; color: var(--muted); font-weight: 600; margin-left: 2px; }
input[type="range"] {
  width: 100%; margin-top: 10px; accent-color: var(--teal);
}

.nights {
  display: flex; gap: 10px; overflow-x: auto;
  padding-bottom: 6px; -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.night {
  flex: 0 0 88px; scroll-snap-align: start;
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 8px; text-align: center;
}
.night .dow {
  font-size: .72rem; font-weight: 700; color: var(--muted);
  margin-bottom: 6px; letter-spacing: .02em;
}
.night .dow.today { color: var(--teal); }
.night .nv {
  font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums;
  margin: 6px 0; color: #fff;
}
.night button {
  width: 100%; height: 28px; border: none; border-radius: 7px;
  background: rgba(45,212,191,.1); color: var(--teal);
  font-weight: 700; cursor: pointer; font-size: .9rem;
}
.night button:active { opacity: .7; }
.night.debt { border-color: rgba(248,113,113,.45); }
.night.surplus { border-color: rgba(45,212,191,.35); }

.advanced {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.advanced summary {
  cursor: pointer; font-size: .88rem; font-weight: 700; color: var(--muted);
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.toggle-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 12px; font-size: .88rem;
}
.toggle-row input { margin-top: 3px; accent-color: var(--teal); width: 18px; height: 18px; }
.warn-inline {
  margin-top: 8px; font-size: .8rem; color: #fcd34d;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  border-radius: 8px; padding: 10px 12px;
}

.result {
  background: linear-gradient(160deg, rgba(45,212,191,.08), rgba(248,113,113,.06));
  border: 1px solid rgba(45,212,191,.25);
  border-radius: 16px;
  padding: 22px 18px;
  margin: 18px 0;
  text-align: center;
}
.result .label { font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.result .big {
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  font-weight: 900; letter-spacing: -.04em;
  color: #fff; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.result .big .u { font-size: .45em; color: var(--muted); font-weight: 700; margin-left: 4px; }
.result .big.debt-on { color: var(--coral); }
.result .sub {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 18px; text-align: left;
}
.result .stat {
  background: rgba(0,0,0,.25); border-radius: 10px; padding: 12px;
}
.result .stat .k { font-size: .75rem; color: var(--dim); font-weight: 600; }
.result .stat .v { font-size: 1.15rem; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

.bars {
  display: flex; gap: 6px; align-items: flex-end; height: 72px;
  margin: 16px 0 8px; padding: 0 4px;
}
.bars .bar-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%;
  justify-content: flex-end;
}
.bars .bar {
  width: 100%; max-width: 36px; border-radius: 5px 5px 2px 2px; min-height: 4px;
}
.bars .bar.debt { background: var(--coral); }
.bars .bar.surplus { background: var(--teal); opacity: .75; }
.bars .bar.zero { background: var(--border); height: 4px !important; }
.bars .bl { font-size: .65rem; color: var(--dim); font-weight: 600; }
.legend {
  font-size: .78rem; color: var(--muted); text-align: center; margin-bottom: 8px;
}
.legend strong { color: var(--coral); }

.tip {
  margin-top: 14px; text-align: left;
  background: rgba(45,212,191,.08); border: 1px solid rgba(45,212,191,.25);
  border-radius: 10px; padding: 12px 14px; font-size: .88rem;
}
.tip a { font-weight: 700; }

.actions {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px;
}
.btn {
  appearance: none; border: none; cursor: pointer;
  font-weight: 700; font-size: .9rem; padding: 11px 18px; border-radius: 10px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--teal); color: #0B1220; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

.links {
  display: flex; flex-wrap: wrap; gap: 10px 16px;
  justify-content: center; margin: 20px 0;
  font-size: .85rem;
}
.links a { color: var(--muted); text-decoration: none; font-weight: 600; }
.links a:hover { color: var(--teal); }

.disclaimer {
  margin-top: 24px; padding: 14px 16px; border-radius: 10px;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  font-size: .82rem; color: #fcd34d;
}
footer {
  text-align: center; padding: 28px 16px; color: var(--dim); font-size: .8rem;
  border-top: 1px solid var(--border); margin-top: 24px;
}
footer a { color: var(--muted); text-decoration: none; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1e293b; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: .85rem; font-weight: 600; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity .25s;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; }

@media (max-width: 420px) {
  .night { flex: 0 0 78px; }
  .result .sub { grid-template-columns: 1fr; }
}
