/* 「잃지 않는 연습」 전월세 계산기 — 색은 book/tools/book.css와 같은 계열 */
:root {
  --ink: #22292b;
  --soft: #5b6567;
  --faint: #8a9294;
  --accent: #2f5d62;
  --accent-deep: #22474b;
  --accent-pale: #eaf1f0;
  --warn: #b5523b;
  --warn-deep: #8f3d2b;
  --warn-pale: #fbefeb;
  --ok: #2d6a4a;
  --ok-pale: #e4f1e9;
  --amber: #8a5a07;
  --amber-pale: #fbf1dc;
  --line: #d9dedc;
  --bg: #eef2f1;
  --surface: #ffffff;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Noto Sans KR",
    "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
b, strong { font-weight: 700; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid #e0a43a; outline-offset: 2px; }
[hidden] { display: none !important; }

/* 머리 */
.top { background: var(--accent); color: #f4f7f6; padding: 28px 0 26px; }
.eyebrow { margin: 0 0 6px; font-size: 15px; font-weight: 600; color: #bcd3d0; letter-spacing: 0.01em; }
.top h1 { margin: 0 0 10px; font-size: 27px; line-height: 1.32; letter-spacing: -0.02em; }
.lede { margin: 0; max-width: 36em; color: #dce8e6; }

/* 탭 */
.tabs-bar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(238, 242, 241, 0.94);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-top: 10px; padding-bottom: 10px; }
.tabs button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: 6px 4px;
  font: inherit; font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--soft);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; cursor: pointer;
}
.tab-no {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  font-size: 13px; background: var(--accent-pale); color: var(--accent);
}
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.tabs button[aria-selected="true"] .tab-no { background: #fff; color: var(--accent); }

/* 패널 */
main { padding-top: 18px; padding-bottom: 28px; }
.panel { display: grid; gap: 16px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px 18px; box-shadow: 0 1px 2px rgba(34, 41, 43, 0.06); }
.card h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.01em; }
.help { margin: 4px 0 0; font-size: 15px; color: var(--soft); line-height: 1.55; }
.form > .help { margin-bottom: 4px; }

.field { margin: 18px 0 0; padding: 0; border: 0; min-width: 0; }
.field > label, .field legend, .two label {
  display: block; margin-bottom: 8px; padding: 0; font-weight: 700; font-size: 17px;
}
.opt { font-weight: 500; font-size: 14px; color: var(--soft); margin-left: 4px; }
.two { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }

input[type="date"], .money input {
  width: 100%; min-height: 54px; padding: 10px 14px;
  font: inherit; font-size: 19px; color: var(--ink);
  background: #fff; border: 1.5px solid #c3cbc9; border-radius: 12px;
  -webkit-appearance: none; appearance: none;
}
input[type="date"] { display: block; }
input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(47, 93, 98, 0.18); }
input[aria-invalid="true"] { border-color: var(--warn); background: var(--warn-pale); }
.money { position: relative; }
.money input { padding-right: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.money .unit { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--soft); font-size: 16px; pointer-events: none; }
.read { margin: 6px 2px 0; min-height: 1.4em; font-size: 15px; color: var(--accent); font-weight: 600; text-align: right; }
.read.bad { color: var(--warn); }

.chips { display: grid; gap: 8px; }
.chips-2 { grid-template-columns: 1fr 1fr; }
.chip { position: relative; display: block; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 8px 12px;
  font-weight: 700; line-height: 1.3; text-align: center;
  border: 1.5px solid #c3cbc9; border-radius: 12px; background: #fff;
}
.chip small { font-weight: 500; font-size: 13px; color: var(--soft); margin-top: 2px; }
.chip input:checked + span { border-color: var(--accent); background: var(--accent-pale); color: var(--accent-deep); box-shadow: inset 0 0 0 1px var(--accent); }
.chip input:focus-visible + span { outline: 3px solid #e0a43a; outline-offset: 2px; }

.field > label.check, .check { display: flex; margin-bottom: 0; font-size: 17px; font-weight: 600; align-items: center; gap: 10px; min-height: 48px; margin-top: 6px; font-weight: 500; cursor: pointer; }
.check input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }

details.more { margin-top: 12px; border-radius: 12px; background: var(--accent-pale); }
details.more summary { min-height: 48px; padding: 12px 14px; font-weight: 700; color: var(--accent-deep); cursor: pointer; list-style-position: inside; }
details.more > p, details.more > .field { margin: 0; padding: 0 14px 14px; font-size: 15px; color: var(--ink); }
details.more > .field + .field { padding-top: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 50px; padding: 10px 18px;
  font: inherit; font-size: 16px; font-weight: 700; text-decoration: none; border-radius: 12px; cursor: pointer;
  border: 1.5px solid transparent;
}
.btn.solid { background: var(--accent); color: #fff; }
.btn.solid:hover { background: var(--accent-deep); }
.btn.ghost { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn.ghost:hover { background: var(--accent-pale); }
.btn.text { background: transparent; color: var(--soft); }
.actions .btn.ghost { flex: 1 1 auto; }

/* 결과 */
.result:empty { display: none; }
.result { display: grid; gap: 14px; align-content: start; }
.empty { color: var(--soft); text-align: center; padding: 26px 18px; }
.empty b { color: var(--ink); }
.errors { margin: 0; padding-left: 1.2em; color: var(--warn-deep); }

.verdict { border-radius: var(--radius); padding: 20px 18px; }
.verdict .kicker { margin: 0 0 2px; font-size: 15px; font-weight: 700; }
.verdict .big { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.3; letter-spacing: -0.02em; }
.verdict .sub { margin: 8px 0 0; font-size: 16px; }
.verdict.ok { background: var(--ok-pale); color: #1d4a33; }
.verdict.ok .kicker { color: var(--ok); }
.verdict.bad { background: var(--warn-pale); color: #5e2618; }
.verdict.bad .kicker { color: var(--warn); }
.verdict.neutral { background: var(--surface); }
.verdict.neutral .kicker { color: var(--soft); }
.verdict ul { margin: 10px 0 0; padding-left: 1.2em; font-size: 16px; }

.rows { margin: 0; padding: 4px 18px; }
.rows div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid #e7ebea; }
.rows div:last-child { border-bottom: 0; }
.rows dt { color: var(--soft); font-size: 16px; }
.rows dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rows dd.sub { grid-column: 1 / -1; font-weight: 500; font-size: 13px; color: var(--faint); white-space: normal; }
.rows .key dd:not(.sub) { font-size: 20px; }
.rows .minus dd:not(.sub) { color: var(--warn); }
.rows .plus dd:not(.sub) { color: var(--ok); }

.note { border-radius: var(--radius); padding: 16px 18px; font-size: 16px; }
.note p { margin: 0; }
.note p + p, .note ul { margin-top: 8px; }
.note ul { padding-left: 1.2em; margin-bottom: 0; }
.note.amber { background: var(--amber-pale); color: #4f3505; }
.note.amber b { color: var(--amber); }
.note.plain { background: var(--surface); }
.stance { background: #fff; border: 1.5px solid var(--warn); border-radius: var(--radius); padding: 18px; }
.stance h3 { margin: 0 0 8px; font-size: 19px; color: var(--warn-deep); line-height: 1.4; }
.stance ul { margin: 0; padding-left: 1.2em; font-size: 16px; }
.stance li + li { margin-top: 6px; }
.stance .after { margin: 12px 0 0; font-size: 16px; }

/* 날짜 목록 */
.timeline { list-style: none; margin: 0; padding: 6px 18px; }
.timeline li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 14px 0; border-bottom: 1px solid #e7ebea; }
.timeline li:last-child { border-bottom: 0; }
.timeline .t { font-weight: 700; line-height: 1.4; }
.timeline .d { grid-column: 1; font-size: 16px; color: var(--accent-deep); font-variant-numeric: tabular-nums; font-weight: 600; }
.timeline .n { grid-column: 1 / -1; font-size: 15px; color: var(--soft); line-height: 1.5; }
.timeline .dd {
  grid-column: 2; grid-row: 1 / span 2; align-self: start;
  min-width: 72px; padding: 4px 10px; border-radius: 999px; text-align: center;
  font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--accent-pale); color: var(--accent-deep);
}
.timeline li.soon .dd { background: var(--warn); color: #fff; }
.timeline li.past { opacity: 0.55; }
.timeline li.past .dd { background: #e7ebea; color: var(--soft); }
.timeline li.key .t::after { content: "달력"; margin-left: 6px; padding: 1px 6px; border-radius: 6px; font-size: 12px; font-weight: 700; background: var(--accent-pale); color: var(--accent); vertical-align: 2px; }
.ics-row { display: grid; gap: 6px; padding: 16px 18px; }
.ics-row .help { margin: 0; }

.basis { margin: 0; padding: 0 4px; font-size: 14px; color: var(--soft); }
.cta { background: var(--accent-deep); color: #eef4f3; border-radius: var(--radius); padding: 20px 18px; }
.cta-title { margin: 0 0 6px; font-weight: 800; font-size: 18px; line-height: 1.45; color: #fff; }
.cta-body { margin: 0 0 14px; font-size: 15px; color: #c9dad8; }
.cta-links { display: grid; gap: 8px; }
.cta .btn.solid { background: #fff; color: var(--accent-deep); }
.cta .btn.solid:hover { background: var(--accent-pale); }
.cta .btn.ghost { background: transparent; border-color: #8fb0ad; color: #fff; }
.cta .btn.ghost:hover { background: rgba(255, 255, 255, 0.08); }

.foot { padding: 8px 0 40px; font-size: 14px; color: var(--soft); }
.foot p { margin: 0 0 8px; max-width: 60em; }

@media (min-width: 560px) {
  .cta-links { grid-template-columns: auto auto; justify-content: start; }
  .top h1 br { display: none; }
}
@media (min-width: 960px) {
  .top { padding: 40px 0 34px; }
  .top h1 { font-size: 34px; }
  .tabs { grid-template-columns: repeat(3, minmax(0, 220px)); }
  .tabs button { flex-direction: row; gap: 8px; min-height: 52px; font-size: 16px; }
  main { padding-top: 26px; }
  .panel { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
  .result { position: sticky; top: 92px; }
  .card { padding: 26px 26px; }
}
@media (prefers-reduced-motion: no-preference) {
  .result > * { animation: rise 0.18s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
@media print {
  .tabs-bar, .actions, .cta-links, .ics-row button { display: none; }
  body { background: #fff; }
}
