/* Toolpenny — "workbench" identity: drafting-paper ground, ink text, tape-measure yellow for actions. */
:root {
  --paper: #f2f4ef;
  --surface: #fbfcf9;
  --sunk: #e7ebe3;
  --ink: #17262b;
  --muted: #5a686b;
  --line: #d3d9d0;
  --signal: #f5b800;
  --signal-ink: #17262b;
  --green: #24785f;
  --amber: #a45a00;
  --red: #b3353b;
  --focus: #1f6feb;
  --display: "Bricolage Grotesque", "IBM Plex Sans KR", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "IBM Plex Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r-sm: 4px;
  --r-md: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121c1f; --surface: #182428; --sunk: #0e1619; --ink: #e6ebe4; --muted: #9aa8a8;
    --line: #2b3b3f; --signal: #f5b800; --signal-ink: #121c1f; --green: #5cc49f; --amber: #f0a84a; --red: #ff7a7f; --focus: #79a8ff;
  }
}
:root[data-theme="dark"] {
  --paper: #121c1f; --surface: #182428; --sunk: #0e1619; --ink: #e6ebe4; --muted: #9aa8a8;
  --line: #2b3b3f; --signal: #f5b800; --signal-ink: #121c1f; --green: #5cc49f; --amber: #f0a84a; --red: #ff7a7f; --focus: #79a8ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
:lang(ko) body, body:lang(ko) { word-break: keep-all; }
a { color: inherit; text-underline-offset: 3px; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.015em; line-height: 1.15; }
.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 30; }
.site-header .container { display: flex; align-items: center; gap: 28px; min-height: 62px; }
.logo { display: flex; align-items: center; gap: 9px; font-family: var(--display); font-weight: 800; font-size: 21px; text-decoration: none; }
.logo svg { flex-shrink: 0; }
.nav { display: flex; gap: 22px; flex: 1; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 700; font-size: 15.5px; padding: 19px 0 17px; border-bottom: 3px solid transparent; }
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); border-bottom-color: var(--signal); }
.lang-switch { display: flex; gap: 2px; background: var(--sunk); padding: 3px; border-radius: var(--r-md); }
.lang-switch button { border: 0; background: transparent; color: var(--muted); padding: 5px 10px; font: inherit; font-size: 13.5px; font-weight: 700; border-radius: 6px; cursor: pointer; }
.lang-switch button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
@media (max-width: 720px) {
  .site-header .container { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .logo { flex: 1; }
  .nav { order: 3; width: 100%; flex: none; gap: 18px; overflow-x: auto; }
  .nav a { padding: 10px 0 9px; }
}

/* ---------- home hero with live converter ---------- */
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; padding: 64px 0 56px; }
.hero h1 { font-size: clamp(38px, 5.6vw, 64px); font-weight: 800; margin: 0 0 18px; max-width: 12ch; }
.hero .lead { font-size: 19px; color: var(--muted); max-width: 46ch; margin: 0 0 22px; }
.promise { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; font-weight: 700; font-size: 15px; }
.promise li { display: flex; align-items: center; gap: 7px; }
.promise li::before { content: ""; width: 9px; height: 9px; background: var(--green); border-radius: 50%; }
@media (max-width: 880px) { .hero { grid-template-columns: 1fr; gap: 28px; padding: 36px 0; } }

.demo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.demo-title { font-family: var(--display); font-weight: 700; font-size: 18px; margin: 0 0 12px; }
.shrink { margin-top: 14px; display: grid; gap: 8px; }
.shrink .bar-row { display: grid; grid-template-columns: 70px 1fr 82px; gap: 10px; align-items: center; font-size: 14px; }
.shrink .bar { height: 14px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.shrink .bar i { display: block; height: 100%; background: var(--muted); width: 0; transition: width .7s cubic-bezier(.2, .8, .2, 1); }
.shrink .bar.after i { background: var(--green); }
.shrink .result-line { font-weight: 700; color: var(--green); font-size: 15px; }
/* the ruler: the one decorative device, used only under the hero */
.ruler { height: 14px; border-top: 1px solid var(--ink); background:
  repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 10px) top / 100% 5px no-repeat,
  repeating-linear-gradient(90deg, var(--ink) 0 1px, transparent 1px 50px) top / 100% 11px no-repeat; opacity: .55; }

/* ---------- tool index (drawers) ---------- */
.drawer { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 34px 0; border-bottom: 1px solid var(--line); }
.drawer h2 { font-size: 26px; margin: 4px 0 6px; }
.drawer .drawer-note { color: var(--muted); font-size: 15px; margin: 0; }
.tool-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.tool-row { display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: start; padding: 16px 0; border-top: 1px solid var(--line); text-decoration: none; }
.tool-row:nth-child(-n+2) { border-top: 0; }
.tool-row .glyph { width: 40px; height: 40px; border-radius: var(--r-md); background: var(--sunk); display: grid; place-items: center; }
.tool-row h3 { font-size: 18px; margin: 2px 0 3px; }
.tool-row p { margin: 0; color: var(--muted); font-size: 15px; }
.tool-row:hover h3 { text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 3px; text-underline-offset: 4px; }
@media (max-width: 880px) {
  .drawer { grid-template-columns: 1fr; gap: 6px; }
  .tool-rows { grid-template-columns: 1fr; }
  .tool-row:nth-child(2) { border-top: 1px solid var(--line); }
}

/* ---------- tool pages ---------- */
.page-head { padding: 38px 0 6px; max-width: 760px; }
.page-head h1 { font-size: clamp(30px, 4.4vw, 44px); margin: 0 0 10px; font-weight: 800; }
.page-head p { margin: 0; color: var(--muted); font-size: 18px; }
.privacy-note { display: flex; gap: 8px; align-items: center; color: var(--green); font-weight: 700; font-size: 15px; margin-top: 12px; }
.workbench { display: grid; grid-template-columns: 330px 1fr; gap: 22px; margin-top: 26px; align-items: start; }
.workbench > .panel { position: sticky; top: 80px; }
@media (max-width: 920px) { .workbench { grid-template-columns: 1fr; } .workbench > .panel { position: static; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px; }
.panel h2 { font-size: 18px; margin: 0 0 14px; }
.panel + .panel { margin-top: 14px; }

.field { margin-bottom: 15px; }
.field label, .field .label { display: block; font-weight: 700; font-size: 14.5px; margin-bottom: 5px; }
.field .hint { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.field .val { float: right; font-weight: 700; color: var(--muted); }
input[type=number], input[type=text], input[type=password], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper); color: var(--ink); font: inherit; font-size: 16px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
input[type=range] { width: 100%; accent-color: var(--ink); }
.input-unit { position: relative; }
.input-unit input { padding-right: 46px; }
.input-unit span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14.5px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink); }
.btn.go { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.go:hover { filter: brightness(1.05); border-color: var(--signal); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 11px; font-size: 13.5px; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.dropzone { border: 2px dashed var(--line); border-radius: var(--r-md); background: var(--paper); padding: 34px 18px; text-align: center; cursor: pointer; display: block; }
.dropzone:hover, .dropzone.drag { border-color: var(--ink); background: var(--sunk); }
.dropzone strong { display: block; font-family: var(--display); font-size: 19px; margin: 8px 0 3px; }
.dropzone span { color: var(--muted); font-size: 14.5px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.file-list { display: flex; flex-direction: column; margin-top: 16px; border-top: 1px solid var(--line); }
.file-item { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.file-item img { width: 52px; height: 52px; object-fit: cover; border-radius: var(--r-sm); background: var(--sunk); }
.file-item .name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item .meta { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.saving { color: var(--green); font-weight: 700; }
.saving.neg { color: var(--amber); }
.list-summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.list-summary .total { font-weight: 700; }
.empty-state { color: var(--muted); padding: 22px 0 4px; }

/* results */
.headline-result { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--signal); border-radius: var(--r-md); padding: 18px 20px; }
.headline-result .big { font-family: var(--display); font-size: clamp(30px, 4vw, 44px); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.headline-result p { margin: 6px 0 0; color: var(--muted); }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); margin-top: 14px; border-top: 1px solid var(--line); }
.figure { padding: 12px 14px 12px 0; border-bottom: 1px solid var(--line); }
.figure dt { color: var(--muted); font-size: 14px; }
.figure dd { margin: 2px 0 0; font-weight: 700; font-size: 21px; font-variant-numeric: tabular-nums; }
.verdict { padding: 12px 14px; border-radius: var(--r-sm); font-weight: 700; margin-top: 12px; }
.verdict.good { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); }
.verdict.warn { background: color-mix(in srgb, var(--amber) 13%, transparent); color: var(--amber); }
.chart-box { position: relative; height: 320px; margin-top: 18px; }
.legend-note { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--muted); font-weight: 700; font-size: 13.5px; position: sticky; top: 0; background: var(--surface); }
.table-wrap { max-height: 400px; overflow: auto; margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
details.more summary { cursor: pointer; font-weight: 700; margin-top: 18px; }

/* ---------- editor ---------- */
.stage { background: repeating-conic-gradient(var(--sunk) 0% 25%, var(--surface) 0% 50%) 50% / 18px 18px; border: 1px solid var(--line); border-radius: var(--r-md); min-height: 380px; display: grid; place-items: center; padding: 14px; position: relative; overflow: hidden; }
.stage canvas { max-width: 100%; max-height: 72vh; touch-action: none; }
.stage canvas.crosshair { cursor: crosshair; }
.seg { display: flex; gap: 2px; background: var(--sunk); padding: 3px; border-radius: var(--r-md); }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 7px 6px; font: inherit; font-size: 14px; font-weight: 700; border-radius: 6px; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-hint { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* ---------- articles / guides ---------- */
.prose { max-width: 70ch; margin-top: 54px; }
.prose h2 { font-size: 27px; margin: 40px 0 10px; }
.prose h3 { font-size: 20px; margin: 28px 0 8px; }
.prose p, .prose li { font-size: 17.5px; }
.prose blockquote { margin: 18px 0; padding: 4px 18px; border-left: 4px solid var(--signal); color: var(--muted); }
.prose code { background: var(--sunk); padding: 1px 5px; border-radius: 3px; font-size: .92em; }
.prose img { border-radius: var(--r-md); }
.prose table { border-collapse: collapse; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 10px; }
.faq details { border-top: 1px solid var(--line); padding: 14px 0; }
.faq details:last-child { border-bottom: 1px solid var(--line); }
.faq summary { font-weight: 700; cursor: pointer; font-size: 17.5px; }
.faq p { margin: 8px 0 0; color: var(--muted); }
.disclaimer { font-size: 14px; color: var(--muted); margin-top: 18px; max-width: 70ch; }

/* Manual ad boxes stay invisible unless a manual ad unit (ADSENSE_SLOT) is filled in.
   With Auto ads only, Google places ads itself and these boxes never show. */
.ad-slot { display: none; margin: 30px 0; }
.ad-slot.filled { display: block; }

.post-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 28px 24px; margin-top: 24px; }
.post-card { text-decoration: none; display: block; }
.post-card .cover { aspect-ratio: 16 / 9; width: 100%; object-fit: cover; border-radius: var(--r-md); background: var(--sunk); display: block; margin-bottom: 12px; }
.post-card h3 { font-size: 21px; margin: 0 0 6px; }
.post-card:hover h3 { text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 3px; }
.post-card p { margin: 0; color: var(--muted); font-size: 15.5px; }
.post-date { color: var(--muted); font-size: 14px; }
.article-head { max-width: 70ch; padding: 40px 0 0; }
.article-head h1 { font-size: clamp(32px, 4.6vw, 48px); margin: 6px 0 12px; }
.article-cover { width: 100%; max-width: 880px; border-radius: var(--r-md); margin-top: 22px; }

.site-footer { border-top: 1px solid var(--line); margin-top: 72px; padding: 28px 0 44px; color: var(--muted); font-size: 15px; }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* "Why I built this" note on tool pages: the maker's own story */
.maker-note { max-width: 70ch; margin-top: 48px; padding: 4px 22px 8px; border-left: 4px solid var(--signal); background: var(--surface); border-radius: 0 var(--r-md) var(--r-md) 0; }
.maker-note h2 { font-size: 20px; margin: 16px 0 6px; }
.maker-note p { margin: 0 0 12px; font-size: 17px; }
.maker-note + .prose { margin-top: 32px; }

/* "Request a tool" strip shown above the footer on every page */
.request-strip { margin-top: 72px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.request-strip .container { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-top: 28px; padding-bottom: 28px; }
.request-strip h2 { font-size: 22px; margin: 0 0 6px; }
.request-strip p { margin: 0; color: var(--muted); max-width: 70ch; }
.request-strip .btn { flex-shrink: 0; }
.request-strip + .site-footer { margin-top: 0; }
@media (max-width: 720px) { .request-strip .container { flex-direction: column; align-items: flex-start; } }

/* Number box + preset list side by side (e.g. max width) */
.width-pick { display: grid; grid-template-columns: 1fr 1.15fr; gap: 8px; }
input[data-wheel-step] { cursor: ns-resize; }
input[data-wheel-step]:focus { cursor: text; }

/* Preset list under a calculator field */
.preset-pick { margin-top: 6px; font-size: 14px; padding: 7px 10px; color: var(--muted); }
.preset-pick:focus, .preset-pick:hover { color: var(--ink); }

/* Currency converter */
.fx-grid { display: grid; grid-template-columns: 1fr 1.4fr auto 1.4fr; gap: 10px; align-items: end; }
.fx-grid .field { margin-bottom: 0; }
.fx-swap { height: 44px; font-size: 20px; padding: 0 14px; }
.fx-result { font-family: var(--display); font-size: clamp(24px, 3.6vw, 38px); font-weight: 800; margin-top: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.fx-flag { font-size: 18px; }
.fx-name { color: var(--muted); font-size: 13.5px; margin-left: 4px; }
.fx-table td { white-space: normal; }
.chips .btn.on { border-color: var(--ink); background: var(--sunk); }
@media (max-width: 720px) { .fx-grid { grid-template-columns: 1fr auto 1fr; } .fx-grid .field:first-child { grid-column: 1 / -1; } }

/* Exchange-rate bar above the header on every page */
.fx-bar { background: var(--sunk); border-bottom: 1px solid var(--line); font-size: 13.5px; min-height: 38px; }
.fx-bar-in { display: flex; align-items: center; gap: 16px; min-height: 38px; }
.fx-ticker { flex: 1; min-width: 0; display: flex; gap: 18px; overflow-x: auto; white-space: nowrap; text-decoration: none; color: var(--muted); scrollbar-width: none; padding: 6px 0; }
.fx-ticker::-webkit-scrollbar { display: none; }
.fx-ticker:hover .fx-tk b { text-decoration: underline; }
.fx-tk-label { font-weight: 700; color: var(--ink); }
.fx-tk b { color: var(--ink); font-weight: 700; }
.fx-mini { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.fx-mini input, .fx-mini select { width: auto; padding: 4px 8px; font-size: 13.5px; border-radius: var(--r-sm); background: var(--surface); }
.fx-mini input { width: 96px; }
.fx-mini button { border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-sm); padding: 3px 8px; cursor: pointer; font: inherit; }
.fx-mini output { font-weight: 700; color: var(--ink); min-width: 90px; text-align: right; white-space: nowrap; }
@media (max-width: 720px) {
  .fx-bar-in { flex-wrap: wrap; gap: 4px 12px; padding-top: 4px; padding-bottom: 6px; }
  .fx-ticker { flex-basis: 100%; }
  .fx-mini { width: 100%; }
  .fx-mini { gap: 4px; }
  .fx-mini input { flex: 0 0 78px; width: 78px; }
  .fx-mini select { padding: 4px 4px; }
  .fx-mini output { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* Light / dark toggle (sun / moon) */
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 34px; border: 0; border-radius: var(--r-md); background: var(--sunk); color: var(--ink); cursor: pointer; flex-shrink: 0; }
.theme-toggle:hover { color: var(--signal); }
@media (max-width: 720px) { .theme-toggle { order: 1; } .site-header .lang-switch { order: 2; } }
