/* JunDesign 스타일 */
:root {
  --bg: #f3f5f8; --panel: #ffffff; --panel2: #f7f9fc; --fg: #0e1726; --muted: #5a6a80; --faint: #97a3b6;
  --line: #e3e8ef; --line2: #cfd7e3;
  --accent: #2563eb; --accent-soft: #e3ecff; --orange: #e8590c; --green: #0f9f5a; --red: #dc2626; --amber: #c27c00;
  --purple: #7c3aed; --cyan: #0891b2; --pink: #db2777;
  --canvas: #fbfcfe; --grid: #eef2f7;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .05);
  --radius: 14px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a101b; --panel: #111927; --panel2: #0d1522; --fg: #e5ecf5; --muted: #93a3b8; --faint: #5f6f86;
    --line: #1e293a; --line2: #2b3950;
    --accent: #5b9bff; --accent-soft: #16284a; --orange: #ff8a3d; --green: #34d399; --red: #f87171; --amber: #fbbf24;
    --purple: #a78bfa; --cyan: #22d3ee; --pink: #f472b6;
    --canvas: #0c1420; --grid: #142033;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a101b; --panel: #111927; --panel2: #0d1522; --fg: #e5ecf5; --muted: #93a3b8; --faint: #5f6f86;
  --line: #1e293a; --line2: #2b3950;
  --accent: #5b9bff; --accent-soft: #16284a; --orange: #ff8a3d; --green: #34d399; --red: #f87171; --amber: #fbbf24;
  --purple: #a78bfa; --cyan: #22d3ee; --pink: #f472b6;
  --canvas: #0c1420; --grid: #142033;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* 머리글 */
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1320px; margin: 0 auto; padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -.01em; margin-right: auto; }
.brand b { color: var(--accent); font-weight: 800; }
.brand .logo { width: 28px; height: 28px; flex: none; }
.menu { position: relative; }
.menu-btn, .theme-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.menu-btn:hover, .theme-btn:hover { border-color: var(--line2); }
.menu-btn svg, .theme-btn svg { width: 16px; height: 16px; flex: none; }
.menu-pop { position: absolute; right: 0; top: 44px; width: min(660px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 16px 48px rgba(2, 8, 23, .18); padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.mp-h { font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 8px 3px; }
.menu-pop a { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; text-decoration: none; font-size: 14px; font-weight: 500; }
.menu-pop a:hover { background: var(--panel2); }
.menu-pop a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 650; }
.menu-pop svg { width: 20px; height: 20px; flex: none; color: var(--accent); }

/* 페이지 */
.page { max-width: 1320px; margin: 0 auto; padding: 24px 20px 40px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 18px; border-radius: 11px; border: 1px solid var(--line2); background: var(--panel); font-weight: 650; text-decoration: none; cursor: pointer; font-size: 14.5px; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { height: 34px; padding: 0 11px; font-size: 13px; border-radius: 9px; }
.btn svg { width: 15px; height: 15px; flex: none; }

/* 도구 머리 */
.tool-head { margin: 2px 0 18px; }
.crumb { font-size: 13px; font-weight: 650; color: var(--accent); text-decoration: none; }
.crumb:hover { text-decoration: underline; }
.tool-head h1 { font-size: clamp(22px, 3vw, 30px); letter-spacing: -.02em; margin: 3px 0 6px; line-height: 1.25; }
.tool-head p { margin: 0; color: var(--muted); max-width: 72ch; }

/* 도구 배치 */
.tool-grid { display: grid; grid-template-columns: minmax(290px, 350px) minmax(0, 1fr); grid-template-areas: "in sim" "in out"; gap: 18px; align-items: start; }
.zone { display: contents; }
.area-sim { grid-area: sim; overflow: hidden; }
.area-in { grid-area: in; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow: auto; padding: 4px 16px 14px; scrollbar-width: thin; }
.area-out { grid-area: out; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.sim-bar { display: flex; align-items: center; gap: 8px 10px; padding: 7px 10px 7px 14px; border-bottom: 1px solid var(--line); min-height: 46px; flex-wrap: wrap; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); animation: pulse 1.8s ease-in-out infinite; }
.paused .live i { background: var(--faint); box-shadow: none; animation: none; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--green) 8%, transparent); } }
.sim-badge { font-size: 12px; font-weight: 650; color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent); padding: 3px 9px; border-radius: 999px; }
.sim-ctl { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.btn-icon { width: 36px; height: 32px; display: grid; place-items: center; border: 1px solid var(--line2); background: var(--panel); border-radius: 9px; cursor: pointer; }
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-icon svg { width: 14px; height: 14px; }
.cv-wrap { position: relative; line-height: 0; }
.cv-wrap canvas { display: block; width: 100%; }

/* 입력 */
.grp { padding: 10px 0 4px; border-top: 1px solid var(--line); }
.grp:first-child { border-top: 0; }
.grp-h { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; margin: 2px 0 2px; }
.field { padding: 7px 0; }
.f-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.f-top label, .f-lbl { font-size: 14px; font-weight: 600; line-height: 1.3; }
.f-num { display: flex; align-items: center; flex: none; border: 1px solid var(--line2); border-radius: 8px; background: var(--panel2); overflow: hidden; }
.f-num input { width: 82px; border: 0; background: transparent; padding: 5px 4px 5px 8px; text-align: right; font: 600 14px var(--mono); color: var(--fg); -moz-appearance: textfield; appearance: textfield; outline: none; }
.f-num input::-webkit-inner-spin-button, .f-num input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.f-num .unit { font-size: 12px; color: var(--muted); padding: 0 8px 0 3px; white-space: nowrap; min-width: 18px; }
.f-num:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.f-num .unit-sel { width: auto; height: 30px; border: 0; border-left: 1px solid var(--line); border-radius: 0; background: transparent; padding: 0 4px 0 7px; font-size: 12px; font-weight: 700; color: var(--accent); cursor: pointer; }
.f-num .unit-sel:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 5px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--line2) var(--p, 50%)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); margin-top: -6.5px; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--line2); }
input[type=range]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.seg { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; }
.seg button { flex: 1 1 auto; border: 0; background: transparent; padding: 6px 9px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--fg); }
.seg button[aria-checked=true], .seg button[aria-pressed=true] { background: var(--panel); color: var(--accent); box-shadow: 0 1px 3px rgba(15, 23, 42, .14); }
.seg-sm { padding: 2px; border-radius: 9px; }
.seg-sm button { padding: 4px 7px; font-size: 12px; flex: none; }
select { width: 100%; height: 38px; border: 1px solid var(--line2); border-radius: 9px; background: var(--panel2); padding: 0 10px; font-size: 14px; font-weight: 500; }
.in-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; margin-top: 6px; border-top: 1px solid var(--line); }

/* 결과 */
.results { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 13px 11px; min-width: 0; }
.card.primary { border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 6%, var(--panel)), var(--panel)); }
.c-lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; line-height: 1.35; }
.c-val { display: flex; align-items: baseline; gap: 5px; margin-top: 3px; flex-wrap: wrap; }
.c-val .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
.card.primary .c-val .v { font-size: 23px; color: var(--accent); }
.c-val .v.txt, .card.primary .c-val .v.txt { font-size: 17px; }
.c-val .u { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.c-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.c-sub:empty { display: none; }
.card[data-st=bad] { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); background: color-mix(in srgb, var(--red) 6%, var(--panel)); }
.card[data-st=bad] .v { color: var(--red) !important; }
.card[data-st=warn] { border-color: color-mix(in srgb, var(--amber) 45%, var(--line)); }
.card[data-st=warn] .v { color: var(--amber) !important; }
.card[data-st=ok] .v { color: var(--green) !important; }

.alerts { display: flex; flex-direction: column; gap: 8px; }
.alerts:empty { display: none; }
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; border: 1px solid; line-height: 1.5; }
.alert svg { width: 17px; height: 17px; flex: none; margin-top: 1.5px; }
.alert.bad { background: color-mix(in srgb, var(--red) 8%, var(--panel)); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert.bad svg { color: var(--red); }
.alert.warn { background: color-mix(in srgb, var(--amber) 9%, var(--panel)); border-color: color-mix(in srgb, var(--amber) 32%, transparent); }
.alert.warn svg { color: var(--amber); }
.alert.ok { background: color-mix(in srgb, var(--green) 7%, var(--panel)); border-color: color-mix(in srgb, var(--green) 28%, transparent); }
.alert.ok svg { color: var(--green); }
.alert.info { background: var(--panel); border-color: var(--line); }
.alert.info svg { color: var(--accent); }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.chart { padding: 12px 12px 8px; min-width: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 14px; margin: 0 4px 6px; }
.chart-head h3 { font-size: 14px; margin: 0; font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 12px; color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 6px; }
.lg i { width: 16px; height: 0; border-top: 2.5px solid var(--c); }
.lg i.dash { border-top-style: dashed; }

/* 계산식 */
.formulas { margin-top: 20px; padding: 18px 20px 20px; }
.formulas h2 { font-size: 17px; margin: 0 0 12px; }
.fx { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.fx > div { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
.fx b { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; font-weight: 650; }
.fx code { font-family: var(--mono); font-size: 13.5px; color: var(--fg); overflow-wrap: anywhere; }
.notes { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; }
.notes li { margin: 3px 0; }

/* 홈 */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 28px; align-items: center; padding: 22px 0 30px; }
.eyebrow { display: inline-block; font-size: 12.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; }
.hero h1 { font-size: clamp(28px, 4.2vw, 46px); line-height: 1.2; letter-spacing: -.03em; margin: 14px 0; text-wrap: balance; }
.hero p { color: var(--muted); font-size: 16px; max-width: 52ch; margin: 0 0 22px; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-sim { overflow: hidden; }
.cat { margin-top: 30px; }
.cat-head { display: flex; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.cat-head h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; }
.cat-head p { margin: 0; color: var(--muted); font-size: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.tcard { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; }
.tcard:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, .08); }
.ti { width: 42px; height: 42px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.ti svg { width: 24px; height: 24px; }
.tcard h3 { margin: 0; font-size: 16px; }
.tcard p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.go { margin-top: auto; font-size: 13px; font-weight: 700; color: var(--accent); }

/* 바닥글 */
.foot { border-top: 1px solid var(--line); margin-top: 36px; }
.foot-in { max-width: 1320px; margin: 0 auto; padding: 20px 20px 30px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.foot-in b { color: var(--fg); }

/* 반응형 */
@media (max-width: 959px) {
  .tool-grid { display: block; }
  .zone { display: block; }
  .area-sim { position: sticky; top: 56px; z-index: 10; margin: 0 -20px 14px; border-radius: 0; border-left: 0; border-right: 0; box-shadow: 0 6px 16px rgba(15, 23, 42, .08); }
  .area-in { position: static; max-height: none; overflow: visible; margin-bottom: 14px; }
  .hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .page { padding: 16px 16px 32px; }
  .top-in { padding: 0 16px; }
  .area-sim { margin: 0 -16px 14px; }
  .menu-pop { position: fixed; left: 16px; right: 16px; top: 60px; width: auto; grid-template-columns: 1fr; max-height: calc(100vh - 80px); overflow: auto; }
  .theme-btn span { display: none; }
  .theme-btn { padding: 0 10px; }
  .live { font-size: 12px; }
  .results { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .card.primary .c-val .v { font-size: 20px; }
  .c-val .v { font-size: 18px; }
  .formulas { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .tcard { transition: none; }
  .live i { animation: none; }
}
