/* Amy's Webtools 공통 스타일 — 외부 폰트·라이브러리 없음 */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1f2530;
  --muted: #5d6675;
  --line: #e1e5ec;
  --brand: #3b6df0;
  --brand-dark: #2a53c4;
  --accent-bg: #eef3ff;
  --warn-bg: #fff8e6;
  --warn-line: #f0d38a;
  --ok: #1d8a4e;
  --radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  line-height: 1.7;
  font-size: 16px;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px; }

/* 헤더 */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; }
.brand span { color: var(--brand); }
.site-nav a { margin-left: 16px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.site-nav a:hover { color: var(--brand); }

/* 본문 */
main { padding: 24px 0 40px; }
h1 { font-size: 1.7rem; line-height: 1.3; margin: 0 0 8px; }
h2 { font-size: 1.25rem; margin: 32px 0 10px; }
h3 { font-size: 1.05rem; margin: 20px 0 6px; }
.lead { color: var(--muted); margin: 0 0 20px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }

.notice { background: var(--accent-bg); border: 1px solid #cfdcff; border-radius: 8px; padding: 10px 14px; font-size: .9rem; margin: 12px 0; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); }

/* 폼 */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .95rem; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid #c7cdd8;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
textarea { min-height: 220px; resize: vertical; }

.btn { display: inline-block; padding: 10px 18px; border: 0; border-radius: 8px; background: var(--brand); color: #fff; font-size: 1rem; font-weight: 700; cursor: pointer; font-family: inherit; }
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #e9edf5; color: var(--text); }
.btn.secondary:hover { background: #dce2ee; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* 결과 표시 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.stat { background: var(--accent-bg); border-radius: 10px; padding: 12px 14px; }
.stat .num { font-size: 1.6rem; font-weight: 800; color: var(--brand-dark); line-height: 1.2; }
.stat .name { font-size: .85rem; color: var(--muted); }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.tool-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tool-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--text); }
.tool-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(59,109,240,.12); }
.tool-card h3 { margin: 0 0 6px; color: var(--brand-dark); }
.tool-card p { margin: 0; color: var(--muted); font-size: .92rem; }

/* 풀이 과정 */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 10px 12px 10px 44px; margin-bottom: 8px; background: #fafbfd; border: 1px solid var(--line); border-radius: 8px; }
.steps li::before { content: counter(s); position: absolute; left: 12px; top: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .8rem; font-weight: 700; text-align: center; line-height: 24px; }
.answer { background: #eefaf2; border: 1px solid #bfe5cd; border-radius: 10px; padding: 14px 16px; font-weight: 700; color: var(--ok); }
.err { color: #c0392b; font-weight: 600; }

table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
th { background: #f0f3f8; }

details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; background: #fff; }
summary { cursor: pointer; font-weight: 700; }

.h1-sub { font-size: 1.1rem; font-weight: 600; color: var(--muted); }
.eq-big { text-align: center; font-size: 2.1rem; font-weight: 800; line-height: 1.3; padding: 14px 8px 18px; margin-bottom: 14px; background: var(--accent-bg); border-radius: 10px; color: var(--brand-dark); overflow-wrap: anywhere; }
.coef-row { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 10px; align-items: end; }
.calc-btn { height: 44px; padding: 0 28px; }
.graph-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.stale { opacity: .4; }
dialog { border: 0; border-radius: 12px; padding: 22px 24px; max-width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog p { margin: 0 0 14px; font-weight: 600; white-space: pre-line; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 14px; }
.chips button { padding: 5px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); font-size: .88rem; font-weight: 600; cursor: pointer; font-family: inherit; }
.chips button:hover { border-color: var(--brand); color: var(--brand); }
.seg { display: inline-flex; border: 1px solid #c7cdd8; border-radius: 8px; overflow: hidden; margin-bottom: 14px; }
.seg button { border: 0; background: #fff; padding: 8px 18px; font-size: .95rem; font-weight: 700; color: var(--muted); cursor: pointer; font-family: inherit; }
.seg button + button { border-left: 1px solid #c7cdd8; }
.seg button.active { background: var(--brand); color: #fff; }
.coef-flex { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.coef-flex > div { flex: 1 1 90px; min-width: 80px; }
.answer.multi { white-space: pre-line; line-height: 1.9; }
.eqrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; font-weight: 700; }
.eqrow input { width: 78px; }
.eqrow .lbl { min-width: 1.2em; white-space: nowrap; }
@media (max-width: 600px) {
  .eqrow { flex-wrap: nowrap; gap: 4px; }
  .eqrow input { flex: 1 1 0; width: auto; min-width: 0; padding: 8px 6px; }
}
.out-card { background: var(--accent-bg); border-radius: 10px; padding: 12px 14px; }
.out-card .num { font-size: 1.25rem; font-weight: 800; color: var(--brand-dark); overflow-wrap: anywhere; }
.out-card .name { font-size: .85rem; color: var(--muted); }
.out-card .sub { font-size: .8rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.res-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
table.mini td, table.mini th { padding: 5px 8px; font-size: .9rem; }
.table-wrap { overflow-x: auto; }
.formula-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; }
.formula-nav a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600; }
.formula-nav a:hover { border-color: var(--brand); color: var(--brand); }
.card[id] { scroll-margin-top: 12px; }
.card h2 { margin-top: 0; }
.frow { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.card h2 + .frow { border-top: 0; }
.fname { font-weight: 700; color: var(--muted); font-size: .92rem; }
.fexp { font-family: "Cambria Math", "Cambria", "STIX Two Math", Georgia, "Noto Serif KR", serif; font-size: 1.08rem; line-height: 1.8; overflow-wrap: anywhere; }
@media (max-width: 600px) { .frow { grid-template-columns: 1fr; } }
.qr-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; }
input[type="color"] { width: 100%; height: 42px; padding: 3px; border: 1px solid #c7cdd8; border-radius: 8px; background: #fff; cursor: pointer; }
.qr-preview { display: flex; justify-content: center; align-items: center; min-height: 120px; margin-top: 16px; }
#qr-canvas { width: 280px; max-width: 100%; height: auto; cursor: default; touch-action: auto; image-rendering: pixelated; }
@media (max-width: 600px) { .qr-options { grid-template-columns: repeat(2, 1fr); } }
.dialog-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.graph-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.graph-tools select { width: auto; padding: 5px 8px; font-size: .9rem; }
.muted-note { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }
canvas { display: block; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; touch-action: auto; cursor: pointer; }
/* 그래프 선택됨: 휠 확대·드래그 이동·두 손가락 확대 가능 */
canvas.active { touch-action: none; cursor: grab; border-color: var(--brand); box-shadow: 0 0 0 2px rgba(59,109,240,.25); }
canvas.active:active { cursor: grabbing; }
.range-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
@media (max-width: 600px) { .range-grid { grid-template-columns: repeat(2, 1fr); } }

.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

/* 푸터 */
.site-footer { border-top: 1px solid var(--line); background: var(--card); padding: 24px 0; font-size: .88rem; color: var(--muted); }
.site-footer a { color: var(--muted); margin-right: 14px; }
.site-footer p { margin: 8px 0 0; }

@media (max-width: 600px) {
  h1 { font-size: 1.4rem; }
  .site-nav a:first-child { margin-left: 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .coef-row { grid-template-columns: repeat(3, 1fr); }
  .calc-btn { grid-column: 1 / -1; }
  .eq-big { font-size: 1.5rem; }
  .card { padding: 16px; }
}

.figure { max-width: 460px; margin: 14px auto 0; }
.figure svg { width: 100%; height: auto; display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.figure:empty { display: none; }
.figure-wrap { position: relative; max-width: 460px; margin: 14px auto 0; }
.figure-wrap .figure { margin: 0; max-width: none; }
.fig-save { position: absolute; top: 8px; right: 8px; }

.chips button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.feedback textarea { margin-top: 4px; }
.feedback .btn[disabled] { pointer-events: none; }

/* 공정능력 계산기 경고 목록 */
.warn-list { margin: 10px 0 0; padding-left: 20px; font-size: .92rem; color: var(--muted); }
.warn-list li { margin: 4px 0; }

/* 언어 추천 배너·전환 링크 */
.lang-banner { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 8px 12px; background: var(--accent-bg); border-bottom: 1px solid var(--line); font-size: .92rem; }
.lang-banner a { font-weight: 700; }
.lang-banner button { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 2px 6px; }
.site-nav .lang-sw { margin-left: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.site-nav .lang-sw + .lang-sw { margin-left: 0; padding-left: 6px; border-left: 0; }

/* 날짜 입력 */
input[type="date"] { width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit; border: 1px solid #c7cdd8; border-radius: 8px; background: #fff; color: var(--text); }
.inline-check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin-top: 10px; }
.inline-check input { width: auto; }

/* IEEE-754 비트 상자 · 복사용 출력칸 */
.bits { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0; }
.bit { width: 24px; height: 32px; padding: 0; border: 1px solid #c7cdd8; border-radius: 5px; background: #fff; font: 600 .9rem ui-monospace, Menlo, Consolas, monospace; cursor: pointer; }
.bit.s { background: #fde8e8; } .bit.e { background: #e6f0ff; } .bit.m { background: #e9f7ec; }
.bit:hover { outline: 2px solid var(--brand); }
.mono-wrap { font-family: ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; word-break: break-all; }
input.out-field { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f5f7fb; }
.copy-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; align-items: center; margin: 8px 0; }
.copy-row .lbl { font-weight: 700; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92rem; min-height: 200px; white-space: pre; }
.swatch { height: 56px; border: 1px solid #c7cdd8; border-radius: 10px; margin: 10px 0; }
@media (max-width: 520px) { .bit { width: 19px; height: 28px; font-size: .8rem; } .copy-row { grid-template-columns: 1fr auto; } .copy-row .lbl { grid-column: 1 / -1; } }

/* 홈 구역 제목 옆 "전체 보기" 링크 */
.h2-more { font-size: .85rem; font-weight: 600; margin-left: 8px; white-space: nowrap; }

/* 상단 메뉴: 도구 드롭다운 */
.nav-menu { display: inline-block; position: relative; margin: 0 0 0 16px; padding: 0; border: 0; background: none; }
.nav-menu summary { cursor: pointer; list-style: none; color: var(--muted); font-weight: 600; font-size: .95rem; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: " ▾"; font-size: .8em; }
.nav-menu summary:hover, .nav-menu[open] summary { color: var(--brand); }
.nav-pop { position: absolute; top: 100%; left: -8px; z-index: 20; min-width: 160px; margin-top: 8px; padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
.nav-pop a { display: block; margin: 0; padding: 8px 10px; border-radius: 6px; white-space: nowrap; }
.nav-pop a:hover { background: var(--accent-bg); }
.site-nav > :first-child { margin-left: 0; }

/* ===== 게임 공통 ===== */
.g-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.g-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.g-stat { background: var(--accent-bg); border-radius: 8px; padding: 6px 12px; font-weight: 700; min-width: 64px; text-align: center; line-height: 1.2; }
.g-stat small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; }
.g-msg { min-height: 1.5em; text-align: center; font-weight: 700; margin: 8px 0 0; }
.g-msg.win { color: var(--ok); }
.g-msg.lose { color: #c0392b; }
.g-ctl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.g-sel { width: auto; padding: 8px 10px; border: 1px solid #c7cdd8; border-radius: 8px; background: #fff; font-family: inherit; font-size: .95rem; }
.g-wrap { max-width: 460px; margin: 0 auto; }
.g-help { text-align: center; color: var(--muted); font-size: .88rem; margin: 8px 0 0; }
.btn[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* 스도쿠 */
.sd-grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); width: 100%; max-width: 450px; margin: 0 auto; border: 2px solid #333b4a; background: #333b4a; gap: 1px; user-select: none; }
.sd-cell { position: relative; aspect-ratio: 1; padding: 0; border: 0; background: #fff; font-family: inherit; font-size: clamp(1rem, 5vw, 1.5rem); color: #2a53c4; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.sd-cell.given { color: #1f2530; font-weight: 700; background: #f3f5f9; }
.sd-cell.peer { background: #eaf0ff; }
.sd-cell.given.peer { background: #dfe7f8; }
.sd-cell.same { background: #cfe0ff; }
.sd-cell.sel { background: #b8d0ff; }
.sd-cell.bad { color: #d6372b; }
.sd-cell.wrong { background: #ffd9d4; }
.sd-cell.bx-r { border-right: 2px solid #333b4a; }
.sd-cell.bx-b { border-bottom: 2px solid #333b4a; }
.sd-notes { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; font-size: clamp(.45rem, 2vw, .66rem); color: #5d6675; line-height: 1; font-weight: 400; }
.sd-notes span { display: flex; align-items: center; justify-content: center; }
.sd-pad { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 6px; max-width: 450px; margin: 12px auto 0; }
.sd-pad button { padding: 10px 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 1.15rem; font-weight: 700; font-family: inherit; cursor: pointer; color: var(--brand-dark); }
.sd-pad button:hover { border-color: var(--brand); }
.sd-pad button:disabled { opacity: .35; cursor: default; }

/* 타자 연습 */
.ty-target { font-size: 1.35rem; line-height: 1.7; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 3.4em; word-break: break-all; }
.ty-target .ok { color: var(--ok); }
.ty-target .bad { color: #d6372b; background: #ffe3df; }
.ty-target .cur { background: #fff1b8; border-radius: 3px; }
.ty-sub { color: var(--muted); font-size: .95rem; margin: 0 0 6px; }
.ty-next { color: var(--muted); font-size: .95rem; margin: 8px 2px 10px; min-height: 1.4em; word-break: break-all; }
.ty-in { width: 100%; padding: 12px 14px; font-size: 1.2rem; font-family: inherit; border: 2px solid #c7cdd8; border-radius: 10px; }
.ty-in:focus { outline: 0; border-color: var(--brand); }
.ty-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 14px; }
.ty-result div { background: var(--accent-bg); border-radius: 10px; padding: 12px; text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--brand-dark); }
.ty-result small { display: block; font-size: .78rem; font-weight: 400; color: var(--muted); }

/* 뱀 */
.sn-canvas { display: block; width: 100%; max-width: 420px; aspect-ratio: 1; margin: 0 auto; border: 2px solid #333b4a; border-radius: 8px; background: #f3f7ee; touch-action: none; }
.sn-pad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 54px); gap: 6px; justify-content: center; margin-top: 12px; }
.sn-pad button { border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 1.4rem; cursor: pointer; }
.sn-pad .u { grid-column: 2; grid-row: 1; } .sn-pad .l { grid-column: 1; grid-row: 2; } .sn-pad .d { grid-column: 2; grid-row: 2; } .sn-pad .r { grid-column: 3; grid-row: 2; }

/* 2048 */
.t48-board { position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 420px; margin: 0 auto; padding: 8px; background: #b9ad9f; border-radius: 10px; touch-action: none; user-select: none; }
.t48-cell { aspect-ratio: 1; border-radius: 6px; background: #cdc1b4; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: clamp(1.3rem, 7vw, 2rem); color: #776e65; }
.t48-cell.pop { animation: t48pop .15s ease-out; }
@keyframes t48pop { from { transform: scale(.6); } to { transform: scale(1); } }
.t48-cell.v2 { background: #eee4da; } .t48-cell.v4 { background: #ede0c8; } .t48-cell.v8 { background: #f2b179; color: #fff; } .t48-cell.v16 { background: #f59563; color: #fff; }
.t48-cell.v32 { background: #f67c5f; color: #fff; } .t48-cell.v64 { background: #f65e3b; color: #fff; } .t48-cell.v128 { background: #edcf72; color: #fff; font-size: clamp(1.1rem, 6vw, 1.7rem); }
.t48-cell.v256 { background: #edcc61; color: #fff; font-size: clamp(1.1rem, 6vw, 1.7rem); } .t48-cell.v512 { background: #edc850; color: #fff; font-size: clamp(1.1rem, 6vw, 1.7rem); }
.t48-cell.v1024 { background: #edc53f; color: #fff; font-size: clamp(.95rem, 5vw, 1.4rem); } .t48-cell.v2048 { background: #edc22e; color: #fff; font-size: clamp(.95rem, 5vw, 1.4rem); }
.t48-cell.vbig { background: #3c3a32; color: #fff; font-size: clamp(.85rem, 4.4vw, 1.2rem); }

/* 지뢰찾기 */
.ms-scroll { overflow-x: auto; padding-bottom: 6px; text-align: center; }
.ms-board { display: inline-grid; gap: 1px; background: #8a93a3; border: 2px solid #8a93a3; user-select: none; touch-action: manipulation; }
.ms-c { width: 28px; height: 28px; padding: 0; border: 0; background: #d5dbe6; font-weight: 800; font-size: .95rem; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.ms-c:hover { background: #c4ccdb; }
.ms-c.open { background: #f4f6fa; cursor: default; }
.ms-c.boom { background: #ff9d92; }
.ms-c.n1 { color: #2a53c4; } .ms-c.n2 { color: #1d8a4e; } .ms-c.n3 { color: #d6372b; } .ms-c.n4 { color: #1f2f8a; } .ms-c.n5 { color: #8a2b1f; } .ms-c.n6 { color: #138a8a; } .ms-c.n7 { color: #222; } .ms-c.n8 { color: #777; }

/* 입력칸 세로 배치, 단위 토글 */
.form-stack { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.form-stack label small { font-weight: 400; }
.form-stack input, .form-stack select { width: 100%; }
.term-row { display: flex; gap: 10px; align-items: stretch; }
.term-row input { flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid #c7cdd8; border-radius: 8px; overflow: hidden; flex: none; }
.seg button { padding: 0 16px; border: 0; background: #fff; color: var(--text); font-size: .95rem; font-weight: 700; font-family: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid #c7cdd8; }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
[hidden] { display: none !important; }
.lbl-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lbl-row label { margin-bottom: 4px; }
.amt-read { color: var(--brand-dark); font-weight: 700; font-size: .92rem; text-align: right; min-height: 1.2em; }
.unit-tag { align-self: center; min-width: 46px; text-align: center; font-weight: 700; color: var(--muted); }

/* 탭 */
.tabs { display: flex; gap: 6px; margin: 14px 0 12px; border-bottom: 2px solid var(--line); }
.tabs button { padding: 10px 18px; border: 0; border-bottom: 3px solid transparent; margin-bottom: -2px; background: transparent; color: var(--muted); font-size: 1rem; font-weight: 700; font-family: inherit; cursor: pointer; }
.tabs button:hover { color: var(--brand); }
.tabs button[aria-selected="true"] { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* 부동산 계산기: 촘촘한 격자, 도움말(?) */
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fgrid input, .fgrid select { width: 100%; }
.lbl-left { display: inline-flex; align-items: center; gap: 6px; }
.fgrid label { font-size: .88rem; }
.help { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--brand); background: #fff; color: var(--brand); font-size: .72rem; font-weight: 800; line-height: 1; cursor: pointer; padding: 0; flex: none; font-family: inherit; }
.help[aria-expanded="true"] { background: var(--brand); color: #fff; }
.help-pop { position: absolute; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .86rem; color: var(--text); line-height: 1.55; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.re-form h2 { font-size: 1.02rem; margin: 16px 0 8px; }
.re-form h2:first-child { margin-top: 0; }
.loan-box { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fafbfd; }
.loan-del { display: flex; align-items: flex-end; }
.re-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.re-result .res-grid { grid-template-columns: 1fr; margin-top: 0; }
@media (min-width: 880px) { .re-layout { grid-template-columns: minmax(0, 1.2fr) minmax(260px, 1fr); align-items: start; } .re-result { position: sticky; top: 12px; } }
@media (max-width: 480px) { .fgrid3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.fgrid-fin { max-width: 600px; }
.out-card.bad { background: #ffeceb; }
.out-card.bad .num { color: #d6372b; }
.tabs { overflow-x: auto; flex-wrap: nowrap; }
.tabs button { white-space: nowrap; }

.fgrid > div { position: relative; }

/* 기간 입력칸과 년/개월 토글의 높이를 맞춘다 */
.fgrid input, .fgrid select, .term-row input, .form-stack input, .form-stack select { height: 44px; box-sizing: border-box; }
.term-row { align-items: stretch; }
.term-row .seg { align-self: stretch; display: flex; }
.term-row .seg button { display: flex; align-items: center; justify-content: center; }
.term-row .seg { height: 44px; }
.term-row .seg button { height: 100%; }
.chk-row { display: flex; align-items: center; gap: 8px; }
.chk-row .inline-check { margin: 0; font-size: .92rem; }
.tax-notes { margin: 10px 0 0; padding-left: 18px; font-size: .86rem; color: var(--muted); }
.tax-notes li { margin: 3px 0; }
input[type="date"] { height: 44px; }
.fgrid .inline-check input[type="checkbox"], .chk-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; padding: 0; }
.chk-row .inline-check { align-items: flex-start; line-height: 1.35; }

/* 탭: 스크롤 없이 모두 보이게, 좁은 화면에서는 줄바꿈 */
.tabs { overflow: visible; flex-wrap: wrap; gap: 6px; border-bottom: 0; margin: 14px 0 12px; }
.tabs button { margin: 0; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); font-size: .95rem; white-space: normal; text-align: center; }
.tabs button:hover { border-color: var(--brand); color: var(--brand); }
.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (max-width: 600px) { .tabs button { flex: 1 1 auto; padding: 8px 10px; font-size: .9rem; } }
@media (max-width: 600px) {
  .tabs { display: grid; grid-template-columns: repeat(6, 1fr); }
  .tabs button { padding: 8px 4px; font-size: .86rem; }
  .tabs button:nth-child(-n+3) { grid-column: span 2; }
  .tabs button:nth-child(n+4) { grid-column: span 3; }
}

/* 기간 단위 드롭다운: 입력칸은 넓게, 단위는 고정 폭 */
.term-row .unit-sel { flex: 0 0 96px; width: 96px; height: 44px; padding: 0 8px; }
.term-row input { min-width: 0; }
@media (max-width: 600px) { .fgrid > div:has(> .term-row) { grid-column: 1 / -1; } .term-row .unit-sel { flex-basis: 110px; width: 110px; } }
@media (max-width: 600px) { .fgrid > div:has(> select) { grid-column: 1 / -1; } }

/* 단위 변환기: 종류 탭 + 양방향 입력 */
.uc-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.uc-tabs button { padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: .95rem; font-weight: 700; font-family: inherit; cursor: pointer; }
.uc-tabs button:hover { border-color: var(--brand); color: var(--brand); }
.uc-tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.uc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: center; }
.uc-side { display: flex; flex-direction: column; gap: 8px; }
.uc-side input { width: 100%; height: 56px; padding: 0 14px; font-size: 1.5rem; font-weight: 700; border: 1px solid #c7cdd8; border-radius: 10px; font-family: inherit; box-sizing: border-box; }
.uc-side input:focus { outline: 0; border-color: var(--brand); }
.uc-side select { width: 100%; height: 44px; }
.uc-swap { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--brand); font-size: 1.2rem; cursor: pointer; }
.uc-swap:hover { border-color: var(--brand); background: var(--accent-bg); }
@media (max-width: 600px) { .uc-row { grid-template-columns: 1fr; } .uc-swap { justify-self: center; transform: rotate(90deg); } }
.uc-actions { justify-content: space-between; align-items: center; }
.uc-actions #reset { margin-left: auto; }
#all-wrap { margin-top: 12px; }

/* BMI 계산기: 칸 수에 맞춰 넓게 */
.bmi-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.bmi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.bmi-2 .full { grid-column: 1 / -1; }
.bmi-2 select, .bmi-3 select { width: 100%; }
h2.bmi-sec { margin: 26px 0 0; font-size: 1.1rem; }
@media (max-width: 600px) { .bmi-top { grid-template-columns: minmax(0, 1fr); } }

.bmi-3 .full { grid-column: 1 / -1; }

/* 퍼센트 계산기: 입력과 결과를 한 줄에 */
.pc-card { padding: 14px 18px; margin-bottom: 10px; }
.pc-card h2 { margin: 0 0 8px; font-size: 1.05rem; }
.pc-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; align-items: center; }
.pc-f { display: flex; align-items: center; gap: 6px; margin: 0; min-width: 0; }
.pc-l { white-space: nowrap; font-weight: 700; font-size: .92rem; }
.pc-f input { flex: 1; min-width: 0; width: 100%; height: 44px; box-sizing: border-box; }
.pc-u { font-weight: 700; color: var(--muted); }
.pc-out { display: flex; justify-content: flex-end; align-items: center; gap: 18px; min-height: 44px; background: var(--accent-bg); border-radius: 10px; padding: 2px 14px; }
.pc-r { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; min-width: 0; }
.pc-r small { font-size: .74rem; color: var(--muted); white-space: nowrap; }
.pc-r b { font-size: 1.2rem; color: var(--brand-dark); overflow-wrap: anywhere; text-align: right; }
@media (max-width: 600px) { .pc-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .pc-out { grid-column: 1 / -1; } }
/* 결과가 두 개면 상자를 나눠 구분 */
.pc-out { background: none; padding: 0; gap: 8px; align-items: stretch; }
.pc-out:empty, .pc-out:has(> .err) { background: var(--accent-bg); padding: 2px 14px; align-items: center; }
.pc-r { flex: 1; justify-content: center; background: var(--accent-bg); border-radius: 10px; padding: 3px 12px; }
.pc-r + .pc-r { background: #fff4e0; }
.pc-r + .pc-r b { color: #9a5b00; }
/* 입력 이름 폭을 맞추고 가운데 정렬 */
.pc-l { flex: 0 0 5.8em; text-align: center; }
html[lang="en"] .pc-l { flex-basis: 7.4em; }
@media (max-width: 600px) { .pc-l, html[lang="en"] .pc-l { flex-basis: 4.8em; white-space: normal; line-height: 1.2; } }
.pc-f:not(:has(.pc-u))::after { content: "%"; visibility: hidden; font-weight: 700; }
@media (min-width: 601px) { .pc-row { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.25fr) minmax(0, 1.1fr); gap: 8px; } .pc-l { flex-basis: 5.4em; } .pc-out { gap: 6px; } .pc-r { padding: 3px 8px; } }
/* 입력칸 넓히기: PC는 결과 칸을 줄이고, 좁은 화면은 A·B를 한 줄씩 전체 폭으로 */
.pc-l { font-size: .86rem; flex-basis: 5.4em; }
.pc-f input { padding: 0 10px; }
@media (min-width: 601px) {
  .pc-row { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(0, 1fr); }
  .pc-card { padding: 12px 12px; }
  .pc-l { flex-basis: 5.2em; }
  .pc-r { padding: 3px 6px; } .pc-r b { font-size: 1.05rem; } .pc-r small { font-size: .68rem; }
}
@media (max-width: 600px) {
  .pc-row { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .pc-out { grid-column: auto; }
  .pc-l, html[lang="en"] .pc-l { flex-basis: 6.2em; white-space: nowrap; }
}

/* 타자 연습: 기록 저장·기록판 */
.ty-save { display: flex; gap: 8px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.ty-name { height: 44px; padding: 0 12px; border: 1px solid #c7cdd8; border-radius: 8px; font-size: 1rem; font-family: inherit; width: 200px; }
.ty-h { margin: 24px 0 10px; font-size: 1.1rem; }
.ty-season { font-size: .86rem; color: var(--muted); margin: 6px 0; }
.ty-local { font-size: .86rem; color: #9a5b00; margin: 6px 0; }
.ty-board tr.first td { background: #fff7d6; font-weight: 800; }

/* 지뢰찾기: 칸 크기를 화면에 맞춤 */
.ms-c { width: var(--ms, 28px); height: var(--ms, 28px); font-size: calc(var(--ms, 28px) * .56); }
.lb-card .ty-h { margin-top: 0; }
.lb-save { margin-bottom: 12px; }
.lb-offer { text-align: center; font-weight: 700; margin: 0 0 4px; }

/* 캔버스 게임, 카드 짝맞추기 */
.cv-game { display: block; width: 100%; margin: 0 auto; border-radius: 10px; border: 2px solid #333b4a; touch-action: none; user-select: none; }
.mm-board { display: grid; gap: 8px; max-width: 440px; margin: 0 auto; }
.mm-card { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--brand); color: #fff; font-size: clamp(1.2rem, 7vw, 2.1rem); cursor: pointer; font-family: inherit; padding: 0; }
.mm-card.up { background: #fff; border: 2px solid var(--brand); }
.mm-card.done { background: #e7f6ec; border: 2px solid #9fd3b1; cursor: default; }
.ty-save .ty-name { width: 220px; max-width: 100%; }

/* IEEE-754: 칸 맞춤, 보기 전용 비트, 고정 폭 표 */
.ieee-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ieee-grid .full { grid-column: 1 / -1; max-width: 50%; }
.ieee-grid input, .ieee-grid select { width: 100%; height: 44px; box-sizing: border-box; }
.ieee-grid input { font-family: ui-monospace, Menlo, Consolas, monospace; }
.bit-title { font-weight: 700; margin: 16px 0 6px; }
#bits.bits { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; min-height: 58px; }
.bit-grp { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; max-width: 100%; }
.bit-grp.s { background: #fde8e8; } .bit-grp.e { background: #e6f0ff; } .bit-grp.m { background: #e9f7ec; }
.bit-lbl { display: block; font-size: .72rem; color: var(--muted); }
.bit-val { font: 600 1rem ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; word-break: break-all; }
.bit-val i { font-style: normal; margin-right: .5em; }
.ieee-table { table-layout: fixed; width: 100%; }
.ieee-table col.k { width: 11em; }
.ieee-table th, .ieee-table td { overflow-wrap: anywhere; word-break: break-all; vertical-align: top; }
.ieee-table th { word-break: keep-all; }
@media (max-width: 600px) { .ieee-grid { grid-template-columns: minmax(0, 1fr); } .ieee-grid .full { max-width: none; } .ieee-table col.k { width: 7em; } }

/* 진법 변환기: 칸 크기 맞춤 */
.bc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.bc-grid .full { grid-column: 1 / -1; }
.bc-grid input, .bc-grid select { width: 100%; height: 44px; box-sizing: border-box; }
.bc-card .copy-row { grid-template-columns: 7.5em minmax(0, 1fr) 72px; }
.bc-card .copy-row input { width: 100%; height: 40px; box-sizing: border-box; }
.bc-card .copy-row button { width: 72px; height: 40px; padding: 0; }
@media (max-width: 520px) { .bc-card .copy-row { grid-template-columns: minmax(0, 1fr) 64px; } .bc-card .copy-row button { width: 64px; } .bc-card .copy-row > span:empty { display: none; } .bc-card .copy-row input#info { grid-column: 1 / -1; } }

/* 첫 화면: 설명 없이 한눈에 */
.home h1 { font-size: 1.35rem; margin-bottom: 4px; }
.home h2 { margin: 18px 0 8px; font-size: 1.05rem; }
.home .tool-list { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.home .tool-card { padding: 10px 12px; }
.home .tool-card h3 { margin: 0; font-size: .95rem; }
.home details { margin-top: 24px; }
@media (max-width: 600px) { .home .tool-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } .home .tool-card h3 { font-size: .88rem; word-break: keep-all; } }
/* 첫 화면 카드: 도구에 맞는 배경 그림 */
.home .tool-card[data-icon] { position: relative; overflow: hidden; min-height: 84px; display: flex; align-items: center; }
.home .tool-card[data-icon]::before { content: attr(data-icon); position: absolute; right: 6px; top: 50%; transform: translateY(-50%) rotate(-8deg); font-size: 3.6rem; line-height: 1; opacity: .42; pointer-events: none; transition: opacity .15s, transform .15s; }
.home .tool-card[data-icon]:hover::before, .home .tool-card[data-icon]:focus-visible::before { opacity: .75; transform: translateY(-50%) rotate(0) scale(1.08); }
.home .tool-card h3 { position: relative; text-shadow: 0 0 6px #fff, 0 0 3px #fff; }
/* 허브(전체 보기) 페이지: 홈과 같은 배경 그림 */
.hub .tool-card[data-icon] { position: relative; overflow: hidden; padding-right: 76px; }
.hub .tool-card[data-icon]::before { content: attr(data-icon); position: absolute; right: 8px; top: 50%; transform: translateY(-50%) rotate(-8deg); font-size: 3.6rem; line-height: 1; opacity: .42; pointer-events: none; transition: opacity .15s, transform .15s; }
.hub .tool-card[data-icon]:hover::before, .hub .tool-card[data-icon]:focus-visible::before { opacity: .75; transform: translateY(-50%) rotate(0) scale(1.08); }
.hub-title[data-icon]::after { content: attr(data-icon); display: inline-block; margin-left: 12px; font-size: 2.2rem; line-height: 1; vertical-align: middle; transform: rotate(-8deg); opacity: .8; }

/* 숫자 입력칸의 위·아래 화살표 숨기기 (.no-spin 영역) */
.no-spin input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.no-spin input[type="number"]::-webkit-outer-spin-button, .no-spin input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* 연립방정식: 입력식·버튼·결과 가운데 정렬 */
#eqs .eqrow { justify-content: center; }
#eqs input { text-align: center; }
#eqs ~ .btn-row, #eqs ~ #answer-area .btn-row { justify-content: center; }
#eqs ~ .muted-note, #eqs ~ #answer-area .answer { text-align: center; }
.no-spin .card > .seg { display: flex; width: max-content; margin-left: auto; margin-right: auto; }

/* 순열·조합: 어떤 계산인지 잘 보이게 */
.out-card.cb { border-top: 5px solid var(--cb); --cb: #7a8294; }
.out-card.cb.perm { --cb: #2f6fe4; } .out-card.cb.comb { --cb: #1d8a4e; } .out-card.cb.rperm { --cb: #7b4fc9; } .out-card.cb.rcomb { --cb: #d97706; }
.cb-title { font-size: 1.15rem; font-weight: 800; color: var(--cb); line-height: 1.3; }
.cb-title span { font-size: .95rem; font-weight: 600; color: var(--muted); margin-left: 2px; white-space: nowrap; }
.cb-tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.cb-tags i { font-style: normal; font-size: .76rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.cb-tags i.on { background: var(--cb); border-color: var(--cb); color: #fff; }
.out-card.cb .num { font-size: 1.5rem; }
.cb-title span { display: block; font-size: 1.9rem; font-weight: 800; color: var(--cb); margin: 2px 0 0; line-height: 1.2; }
.cb-title span sub { font-size: .6em; }
#grid { align-items: start; }
#grid .out-card { min-width: 0; }
.cb-full { margin: 6px 0 0; padding: 4px 8px; background: #fff; }
.cb-full summary { font-size: .8rem; }
.cb-full div { max-height: 140px; overflow-y: auto; font: .78rem ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; word-break: break-all; margin-top: 4px; }
.out-card.cb .num { white-space: nowrap; font-size: 1.35rem; }
