/* ============================================================
   2425 SCI_CALC — SciKey
   베이스: kit-console 을 평면·절제형으로 변형
   · 콘솔의 모노 타이포·각진 5px 모서리·상태 표시줄 모티프만 남기고
     모눈/라디얼 배경·블러 헤더·글로우·신호등 점은 제거
   · 실물 공학용 계산기: 평면 LCD 한 장 + 단정한 키 그리드, 2nd 보조 라벨은 키 위 작은 글씨
   · 색: 따뜻한 무채(종이·잉크) + 단색 액센트(주황) 1색. 그라디언트·그림자·다색 없음
   ============================================================ */
:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #eeede8;
  --body: #e4e2dc;
  --ink: #1d1c1a;
  --ink-2: #45433e;
  --ink-3: #75726a;
  --line: #d3d0c8;
  --line-2: #e3e1db;
  --lcd: #edeee8;
  --lcd-ink: #1d1c1a;
  --key: #ffffff;
  --key-fn: #f7f6f2;
  --key-dark: #3a3935;
  --key-dark-ink: #f4f3f0;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbece4;
  --err: #a1260d;
  --r: 5px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #141413;
  --surface: #1c1c1a;
  --surface-2: #232320;
  --body: #252522;
  --ink: #ebe9e3;
  --ink-2: #c3c0b8;
  --ink-3: #8f8c84;
  --line: #3a3935;
  --line-2: #2c2c29;
  --lcd: #10100f;
  --lcd-ink: #ebe9e3;
  --key: #2f2f2c;
  --key-fn: #292926;
  --key-dark: #484843;
  --key-dark-ink: #f4f3f0;
  --accent: #ec7a3f;
  --accent-ink: #141413;
  --accent-soft: #2e2119;
  --err: #f0876b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── header ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.header-inner { max-width: 1120px; margin: 0 auto; padding: 0 16px; height: 54px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font: 700 16px var(--mono); letter-spacing: -.02em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 24px; height: 24px; flex: none; }
.brand svg .c { fill: var(--accent); }
.brand small { font: 500 11px var(--sans); color: var(--ink-3); letter-spacing: .02em; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav a { white-space: nowrap; color: var(--ink-2); font-size: 14px; padding: 6px 10px; border-radius: var(--r); }
.nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.lang-select { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 5px 6px; font-size: 13px; max-width: 110px; margin-left: 6px; }
.icon-btn { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 17px; height: 17px; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .brand small { display: none; }
  .nav a.nav-link { display: none; }
  .menu-btn { display: inline-grid; }
  .nav.open { position: absolute; top: 54px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; padding: 8px 12px 12px; }
  .nav.open a.nav-link { display: block; width: 100%; }
  .nav.open a[aria-current="page"] { box-shadow: inset 3px 0 0 var(--accent); }
}

main { flex: 1; width: 100%; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 20px 16px 40px; }
.calc-wrap { padding-top: 16px; }

/* ── calculator ── */
.calc-grid { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .calc-grid { grid-template-columns: minmax(0, 1fr); } .calc { max-width: 520px; margin: 0 auto; width: 100%; } }
.calc { background: var(--body); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.lcd { background: var(--lcd); color: var(--lcd-ink); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px 8px; margin-bottom: 12px; }
.lcd-bar { display: flex; align-items: center; gap: 6px; font: 600 11px var(--mono); color: var(--ink-3); min-height: 24px; }
.ind { font: 700 10.5px var(--mono); letter-spacing: .06em; color: var(--ink-2); }
.ind.ang { border: 1px solid var(--line); background: transparent; border-radius: 3px; padding: 2px 6px; cursor: pointer; color: var(--lcd-ink); }
.ind.ang:hover { border-color: var(--ink-3); }
#indShift, #indSto { color: var(--accent); }
.lcd-sp { flex: 1; }
.fmt { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.fmt button { border: 0; background: transparent; font: 700 10.5px var(--mono); padding: 3px 6px; cursor: pointer; color: var(--ink-3); letter-spacing: .04em; }
.fmt button + button { border-left: 1px solid var(--line); }
.fmt button[aria-pressed="true"] { background: var(--lcd-ink); color: var(--lcd); }
.dig select { border: 1px solid var(--line); background: transparent; border-radius: 3px; font: 700 10.5px var(--mono); padding: 2px 2px; color: var(--lcd-ink); }
.expr {
  display: block; width: 100%; border: 0; background: transparent; outline: none; padding: 8px 0 4px;
  font: 400 19px/1.4 var(--mono); color: var(--lcd-ink); caret-color: var(--accent);
}
.expr::placeholder { color: var(--ink-3); }
.res-line { display: flex; align-items: flex-end; gap: 8px; border-top: 1px dashed var(--line); padding-top: 4px; }
.result { flex: 1; min-width: 0; text-align: right; font: 600 32px/1.25 var(--mono); font-variant-numeric: tabular-nums; word-break: break-all; }
.result.preview { color: var(--ink-3); font-weight: 500; }
.result.error { color: var(--err); font-size: 17px; font-weight: 600; padding: 10px 0 6px; }
.result .x10 { font-size: .62em; margin-left: 2px; }
.result sup { font-size: .8em; }
.copy-btn { border: 1px solid var(--line); background: transparent; border-radius: 3px; width: 28px; height: 28px; cursor: pointer; color: var(--ink-3); margin-bottom: 4px; flex: none; }
.copy-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.extra { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px 12px; min-height: 34px; align-content: flex-start; font: 12px var(--mono); color: var(--ink-3); margin-top: 2px; }
.extra b { font-weight: 700; color: var(--ink-2); margin-right: 4px; letter-spacing: .04em; }
.extra span { word-break: break-all; }

.keys { display: grid; gap: 6px; }
.fn-keys { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 12px; }
.num-keys { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.key {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-width: 0; padding: 2px 2px 6px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--key-fn); color: var(--ink); cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; height: 46px;
}
.key b { font: 600 14px/1 var(--mono); white-space: nowrap; }
.key .s2 { font: 600 9.5px/1 var(--mono); color: var(--accent); font-style: normal; min-height: 10px; margin-bottom: 5px; white-space: nowrap; }
.key:hover { border-color: var(--ink-3); }
.key:active, .key.down { transform: translateY(1px); background: var(--surface-2); }
.num-keys .key { height: 54px; }
.num-keys .key .s2 { display: none; }
.num-keys .key { justify-content: center; padding: 0; }
.key.k-num { background: var(--key); }
.key.k-num b { font-size: 20px; font-weight: 500; }
.key.k-op b { font-size: 21px; font-weight: 500; }
.key.k-op { background: var(--key-fn); }
.key.k-del, .key.k-mod { background: var(--key-dark); color: var(--key-dark-ink); border-color: var(--key-dark); }
.key.k-del b { font-size: 15px; font-weight: 700; }
.key.k-mod b { font-size: 13px; }
.key.k-eq { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.key.k-eq b { font-size: 24px; font-weight: 600; }
.key.k-mem b, .key.k-var b { font-size: 13px; }
.key.k-var b { font-style: italic; font-size: 15px; }
.key.on { outline: 2px solid var(--accent); outline-offset: -2px; }
.calc.shift-on .key[data-k2] .s2 { background: var(--accent); color: var(--accent-ink); border-radius: 2px; padding: 1px 3px; margin-bottom: 4px; }
.calc.shift-on .key[data-k2] b { opacity: .45; }
.calc.hyp-on .key[data-k^="f:"] b::after { content: 'h'; }
.calc.sto-on .key.k-var { outline: 2px solid var(--accent); outline-offset: -2px; }
@media (max-width: 380px) {
  .calc { padding: 8px; }
  .key { height: 42px; } .num-keys .key { height: 50px; }
  .key b { font-size: 12.5px; } .key .s2 { font-size: 8.5px; }
  .fn-keys { gap: 4px; } .num-keys { gap: 6px; }
}

/* ── side panel ── */
.side { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.side-tabs { display: flex; border-bottom: 1px solid var(--line); }
.side-tabs button { flex: 1; border: 0; background: transparent; padding: 11px 8px; font-size: 14px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.side-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.side-pane { padding: 12px 14px 14px; }
.hist { list-style: none; margin: 0 0 10px; padding: 0; max-height: 470px; overflow-y: auto; }
.hist li { border-bottom: 1px solid var(--line-2); }
.hist button { display: block; width: 100%; text-align: right; background: transparent; border: 0; padding: 8px 6px; cursor: pointer; border-radius: var(--r); }
.hist button:hover { background: var(--surface-2); }
.hist .he { display: block; font: 13px var(--mono); color: var(--ink-3); word-break: break-all; }
.hist .hv { display: block; font: 600 17px var(--mono); color: var(--ink); word-break: break-all; }
.hist .hv sup { font-size: .75em; }
.hist .hm { font: 600 10px var(--mono); color: var(--ink-3); float: left; margin-top: 3px; }
.vars { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0 0 10px; border-top: 1px solid var(--line-2); }
.vars dt, .vars dd { margin: 0; padding: 9px 6px; border-bottom: 1px solid var(--line-2); }
.vars dt { font: 700 14px var(--mono); color: var(--ink-2); }
.vars dd { text-align: right; }
.vars dd button { background: transparent; border: 0; font: 600 15px var(--mono); cursor: pointer; color: var(--ink); word-break: break-all; text-align: right; padding: 0; }
.vars dd button:hover { color: var(--accent); }
.const-list { display: flex; flex-direction: column; max-height: 460px; overflow-y: auto; margin-bottom: 8px; }
.const-row { display: grid; grid-template-columns: 44px 1fr auto; align-items: baseline; gap: 8px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line-2); padding: 8px 4px; cursor: pointer; }
.const-row:hover { background: var(--surface-2); }
.const-row .cs { font: 600 14px var(--mono); color: var(--ink); }
.const-row .cn { font-size: 13.5px; color: var(--ink-2); }
.const-row code { font: 12px var(--mono); color: var(--ink-3); }
.note { font-size: 12.5px; color: var(--ink-3); margin: 6px 0 10px; }
.empty { color: var(--ink-3); font-size: 13.5px; padding: 18px 4px; text-align: center; margin: 0; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 8px 14px; font-size: 14px; cursor: pointer; color: var(--ink-2); }
.btn:hover { border-color: var(--ink-3); color: var(--ink); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* ── content pages ── */
.page-head { margin: 6px 0 18px; }
.page-head .eyebrow { font: 700 11.5px var(--mono); color: var(--accent); letter-spacing: .08em; }
.page-head h1 { font-size: clamp(22px, 3.2vw, 30px); line-height: 1.3; margin: 6px 0 8px; letter-spacing: -.015em; }
.page-head p { color: var(--ink-2); margin: 0; max-width: 760px; }
.crumb { font-size: 12.5px; color: var(--ink-3); margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.crumb a { color: var(--ink-3); }
.crumb span.sep { color: var(--line); }
.prose { max-width: 780px; }
.prose.wide { max-width: 980px; }
.prose h2 { font-size: 20px; margin: 30px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); letter-spacing: -.01em; }
.prose h3 { font-size: 16.5px; margin: 22px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { padding-inline-start: 22px; margin: 0 0 14px; }
.prose li { margin: 3px 0; }
.prose code { font: 13px var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 3px; color: var(--ink); }
.prose strong { color: var(--ink); }
.prose blockquote { margin: 14px 0; padding: 10px 14px; border-inline-start: 3px solid var(--accent); background: var(--accent-soft); color: var(--ink); }
.prose blockquote p { color: var(--ink); margin: 0; }
.scroll-x { overflow-x: auto; margin-bottom: 14px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
table.data th, table.data td { border: 1px solid var(--line); padding: 7px 9px; text-align: start; vertical-align: top; }
table.data th { background: var(--surface-2); font: 600 12px var(--mono); color: var(--ink-2); white-space: nowrap; }
table.data td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.sym { font: 600 14px var(--mono); white-space: nowrap; }
table.data td code { white-space: nowrap; }
.tool-link { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); padding: 9px 14px; border-radius: var(--r); font-weight: 600; font-size: 14px; margin: 6px 6px 4px 0; }
.tool-link:hover { text-decoration: none; background: var(--accent-soft); }
.tool-link.ghost { border-color: var(--line); color: var(--ink-2); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 18px; }
.link-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; color: var(--ink); }
.link-card:hover { border-color: var(--ink-3); text-decoration: none; }
.link-card .no { font: 700 11px var(--mono); color: var(--accent); }
.link-card h3 { font-size: 15.5px; margin: 4px 0 6px; line-height: 1.4; }
.link-card p { font-size: 13.5px; color: var(--ink-3); margin: 0; }
.faq-item { border-top: 1px solid var(--line); padding: 12px 0; }
.faq-item h3 { margin: 0 0 6px; font-size: 15.5px; }
.faq-item p { margin: 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 780px; margin-top: 26px; }
.pager a { border: 1px solid var(--line); background: var(--surface); padding: 10px 14px; border-radius: var(--r); font-size: 12.5px; color: var(--ink-3); }
.pager a b { display: block; color: var(--ink); font-size: 14px; margin-top: 2px; }
.pager a.next { text-align: end; }
.pager a:hover { border-color: var(--ink-3); text-decoration: none; }
.meta-line { font: 12px var(--mono); color: var(--ink-3); margin-top: 18px; }

/* ── ad (architecture.md §4 — 래퍼에 radius·overflow 금지) ── */
.ad-wrap { margin: 22px auto 0; }
.ad-grid { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; max-width: 672px; margin-left: auto; margin-right: auto; }
.ad-grid[data-ad-layout="mixed"] { max-width: 760px; }
.ad-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
.ad-cell { min-height: 50px; max-width: 100%; }
.ad-row.ad-pc { display: none; }
@media (min-width: 720px) { .ad-row.ad-pc { display: flex; } .ad-row.ad-mo { display: none; } }

/* ── footer ── */
.site-footer { background: var(--surface); border-top: 1px solid var(--line); margin-top: 20px; }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 26px 16px 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.footer-inner h4 { font: 700 11.5px var(--mono); letter-spacing: .06em; color: var(--ink-3); margin: 0 0 8px; text-transform: uppercase; }
.footer-inner a { display: block; color: var(--ink-2); font-size: 13.5px; padding: 3px 0; }
.footer-base { max-width: 1120px; margin: 0 auto; padding: 12px 16px 22px; font: 12px var(--mono); color: var(--ink-3); border-top: 1px solid var(--line-2); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: var(--r); font-size: 13.5px; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
[dir="rtl"] .expr, [dir="rtl"] .result, [dir="rtl"] .hist button, [dir="rtl"] .vars dd { direction: ltr; }
[dir="rtl"] .result, [dir="rtl"] .hist button { text-align: right; }
@media print { .site-header, .ad-wrap, .site-footer, .keys, .side { display: none !important; } }
/* RTL: 계산기 본체·수식은 실물처럼 항상 LTR */
[dir="rtl"] .calc { direction: ltr; }
[dir="rtl"] code, [dir="rtl"] .const-row code, [dir="rtl"] td.num { direction: ltr; unicode-bidi: isolate; }
