@font-face {
  font-family: 'Ireum Hangul';
  src: url('../fonts/nanumgothic/NanumGothic-Regular.ttf') format('truetype');
  font-display: swap;
  unicode-range: U+1100-11FF, U+3130-318F, U+A960-A97F, U+AC00-D7A3, U+D7B0-D7FF;
}

:root {
  --paper: #f7f2e8;
  --surface: #fffdf8;
  --surface-2: #f1ead9;
  --ink: #1d1b19;
  --muted: #6c655c;
  --line: rgba(29, 27, 25, 0.14);
  --line-strong: rgba(29, 27, 25, 0.3);
  --red: #c2362b;
  --jade: #4e7d6b;
  --shadow: 0 1px 2px rgba(29, 27, 25, 0.06), 0 12px 28px -18px rgba(29, 27, 25, 0.45);
  --radius: 14px;
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --hangul: 'Ireum Hangul', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181a;
    --surface: #1e2124;
    --surface-2: #262a2e;
    --ink: #ece6da;
    --muted: #9b958a;
    --line: rgba(236, 230, 218, 0.16);
    --line-strong: rgba(236, 230, 218, 0.32);
    --red: #e0675a;
    --jade: #7fb49c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 32px -18px rgba(0, 0, 0, 0.8);
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.85rem, 6vw, 3.3rem); }
h2 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: inherit; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 10px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { display: block; width: 34px; height: 34px; }
.brand b { font-family: var(--serif); font-size: 1.2rem; font-weight: 400; letter-spacing: 0.01em; }
.site-nav { display: flex; gap: 18px; font-size: 0.92rem; }
.site-nav a { color: var(--muted); text-decoration: none; }
.site-nav a:hover { color: var(--ink); }

/* ---------- hero ---------- */

.hero { padding: 14px 0 4px; max-width: 46rem; }
.hero p.lede { font-size: 1.02rem; color: var(--muted); margin-bottom: 0.3em; }
@media (min-width: 760px) { .hero p.lede { font-size: 1.12rem; } }
.hero .kicker {
  display: inline-block; font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--red); margin-bottom: 12px;
}

/* ---------- studio ---------- */

.studio {
  display: grid;
  gap: 18px;
  grid-template-areas: "name" "stage" "style" "out";
  margin: 14px 0 8px;
}
@media (min-width: 940px) {
  .studio {
    grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
    grid-template-areas: "name stage" "style stage" "out stage";
    align-items: start;
    gap: 18px 28px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card > h3 { margin-bottom: 10px; }
.card-step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; margin-right: 8px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 0.74rem; font-family: var(--sans);
  vertical-align: 2px;
}

#name-card { grid-area: name; }
#style-card { grid-area: style; }
#out-card { grid-area: out; }
.stage { grid-area: stage; }

label.field { display: block; font-size: 0.84rem; color: var(--muted); margin: 10px 0 5px; }

input[type="text"] {
  width: 100%; padding: 12px 13px; font: inherit; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line-strong); border-radius: 10px;
}
input[type="text"]:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
#name { font-size: 1.1rem; }
#hangul-edit { font-family: var(--hangul); }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; align-items: center; }
.examples span { font-size: 0.8rem; color: var(--muted); }
.tiny-btn {
  font: inherit; font-size: 0.82rem; padding: 4px 10px; cursor: pointer;
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 99px;
}
.tiny-btn:hover { border-color: var(--line-strong); }

/* candidate chips */

#candidates { margin-top: 14px; display: grid; gap: 10px; }
.part { display: grid; gap: 5px; }
.part-latin { font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.part-hint { font-size: 0.74rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; cursor: pointer;
  padding: 7px 11px; font: inherit; text-align: left;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
}
.chip:hover { border-color: var(--red); }
.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.chip-hangul { font-family: var(--hangul); font-size: 1.05rem; line-height: 1.25; }
.chip-note { font-size: 0.7rem; opacity: 0.75; }

#pronounce { font-size: 0.9rem; color: var(--muted); margin-top: 12px; }
#breakdown { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.syl {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 4px 9px; border-radius: 8px; background: var(--surface-2);
}
.syl b { font-family: var(--hangul); font-weight: 400; font-size: 1rem; }
.syl i { font-style: normal; font-size: 0.78rem; color: var(--muted); }

/* style tabs and palettes */

#styles { display: flex; flex-wrap: wrap; gap: 7px; }
.style-tab {
  font: inherit; font-size: 0.92rem; padding: 7px 13px; cursor: pointer;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 99px;
}
.style-tab:hover { border-color: var(--ink); }
.style-tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
#style-blurb { font-size: 0.88rem; color: var(--muted); margin: 11px 0 0; min-height: 2.6em; }

.palette-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
#palettes { display: flex; gap: 7px; }
.swatch {
  width: 34px; height: 24px; padding: 0; cursor: pointer; border-radius: 7px;
  border: 1px solid var(--line-strong);
}
.swatch[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
#palette-name { font-size: 0.84rem; color: var(--muted); }

.sw-brush-hanji { background: linear-gradient(135deg, #f7f2e8 55%, #1d1b19 55%, #1d1b19 78%, #c2362b 78%); }
.sw-brush-night { background: linear-gradient(135deg, #17191b 55%, #efe8da 55%, #efe8da 78%, #d4553f 78%); }
.sw-brush-jade { background: linear-gradient(135deg, #f1f1ea 55%, #21312c 55%, #21312c 78%, #c2362b 78%); }
.sw-modern-seal { background: linear-gradient(135deg, #f7f2e8 55%, #1d1b19 55%, #1d1b19 78%, #c2362b 78%); }
.sw-modern-deep { background: linear-gradient(135deg, #0f1a17 55%, #f2f5f1 55%, #f2f5f1 78%, #4e7d6b 78%); }
.sw-modern-blush { background: linear-gradient(135deg, #efe3da 55%, #2a1d1a 55%, #2a1d1a 78%, #c2362b 78%); }
.sw-jamo-warm { background: linear-gradient(90deg, #c2362b 25%, #d9922f 25% 50%, #4e7d6b 50% 75%, #2f4858 75%); }
.sw-jamo-mono { background: linear-gradient(90deg, #1d1b19 25%, #4a443d 25% 50%, #7c7368 50% 75%, #afa596 75%); }
.sw-jamo-night { background: linear-gradient(90deg, #c2362b 25%, #4e7d6b 25% 50%, #d9c9a3 50% 75%, #334a5c 75%); }
.sw-seal-carved { background: #c2362b; }
.sw-seal-relief { background: repeating-linear-gradient(45deg, #c2362b 0 4px, #fffdf8 4px 8px); }
.sw-seal-ink { background: #23201d; }
.sw-tattoo-ink { background: linear-gradient(135deg, #f7f2e8 60%, #1d1b19 60%); }
.sw-tattoo-noir { background: linear-gradient(135deg, #131415 60%, #f4f1ea 60%); }
.sw-tattoo-jade { background: linear-gradient(135deg, #f2f4f1 60%, #22312c 60%); }

/* ---------- stage ---------- */

.stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow);
  padding: 20px 20px 38px;
  min-height: 320px;
  display: grid;
  place-items: center;
}
@media (min-width: 940px) { .stage { position: sticky; top: 16px; padding: 26px 26px 42px; } }

#canvas {
  display: block;
  max-width: 100%;
  max-height: min(64vh, 600px);
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 22px 44px -26px rgba(0, 0, 0, 0.6);
  background-image: linear-gradient(45deg, rgba(128, 128, 128, 0.14) 25%, transparent 25% 75%, rgba(128, 128, 128, 0.14) 75%),
                    linear-gradient(45deg, rgba(128, 128, 128, 0.14) 25%, transparent 25% 75%, rgba(128, 128, 128, 0.14) 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
}

.stage-note {
  position: absolute; left: 0; right: 0; bottom: 13px;
  text-align: center; font-size: 0.78rem; color: var(--muted);
}
.stage-msg { text-align: center; max-width: 24rem; color: var(--muted); }
.stage-msg strong { display: block; color: var(--ink); font-family: var(--serif); font-size: 1.2rem; margin-bottom: 6px; }

.stage.is-ready #canvas { visibility: visible; }
.stage.is-empty #canvas, .stage.is-busy #canvas, .stage.is-error #canvas { display: none; }
.stage #empty-msg, .stage #busy-msg, .stage #stage-error { display: none; }
.stage.is-empty #empty-msg { display: block; }
.stage.is-busy #busy-msg { display: block; }
.stage.is-error #stage-error { display: block; color: var(--red); }
.stage.is-empty .stage-note, .stage.is-busy .stage-note, .stage.is-error .stage-note { display: none; }
body.unlocked .stage-note { visibility: hidden; }

.spin {
  display: inline-block; width: 15px; height: 15px; margin-right: 7px; vertical-align: -2px;
  border: 2px solid var(--line-strong); border-top-color: var(--ink); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* ---------- downloads ---------- */

#exports { display: grid; grid-template-columns: repeat(auto-fit, minmax(152px, 1fr)); gap: 8px; }
.dl {
  display: grid; gap: 2px; text-align: left; cursor: pointer;
  padding: 10px 12px; font: inherit;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
}
.dl:hover { border-color: var(--ink); }
.dl-label { font-size: 0.92rem; }
.dl-hint { font-size: 0.73rem; color: var(--muted); }
.dl::after { content: '\1F512'; position: absolute; }
.dl { position: relative; padding-right: 30px; }
.dl::after { right: 10px; top: 10px; font-size: 0.8rem; opacity: 0.45; }
body.unlocked .dl::after { content: '\2193'; opacity: 0.8; }
.dl.working { opacity: 0.6; }

#lock-state { font-size: 0.84rem; color: var(--muted); margin: 0 0 12px; }
body.unlocked #lock-state { color: var(--jade); }

/* ---------- unlock card ---------- */

#unlock-card { margin: 10px 0 34px; display: grid; gap: 14px; }
@media (min-width: 760px) { #unlock-card { grid-template-columns: 1fr 1fr; align-items: start; } }
#unlock-card.flash { outline: 2px solid var(--red); outline-offset: 3px; }
body.unlocked #unlock-buy { display: none; }
.unlock-row { display: flex; gap: 8px; flex-wrap: wrap; }
.unlock-row input { flex: 1 1 200px; }
.unlock-msg { font-size: 0.88rem; margin: 9px 0 0; }
.unlock-msg.ok { color: var(--jade); }
.unlock-msg.err { color: var(--red); }
.unlock-msg.warn { color: var(--muted); }
.unlock-msg.busy { color: var(--muted); }

.btn {
  display: inline-block; font: inherit; cursor: pointer; text-decoration: none; text-align: center;
  padding: 11px 20px; border-radius: 10px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper);
}
.btn:hover { opacity: 0.9; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.buy { background: var(--red); border-color: var(--red); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* ---------- landing ---------- */

section.band { padding: 44px 0; border-top: 1px solid var(--line); }
section.band > .wrap > h2 { margin-bottom: 10px; }
.band-lede { color: var(--muted); max-width: 44rem; }

.gallery { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-top: 24px; }
.gallery figure { margin: 0; }
.gallery img {
  display: block; width: 100%; height: auto; border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 20px 40px -26px rgba(0, 0, 0, 0.55);
}
.gallery figcaption { font-size: 0.86rem; color: var(--muted); margin-top: 10px; }
.gallery figcaption b { font-family: var(--hangul); font-weight: 400; color: var(--ink); }

.cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); margin-top: 20px; }
.cols .card h3 { margin-bottom: 6px; }
.cols .card p { font-size: 0.92rem; color: var(--muted); margin: 0; }

.table-scroll { overflow-x: auto; margin-top: 20px; }
table.compare { width: 100%; min-width: 580px; border-collapse: collapse; font-size: 0.92rem; }
table.compare th, table.compare td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.compare thead th { font-family: var(--serif); font-weight: 400; font-size: 1rem; }
table.compare tbody th { font-weight: 400; color: var(--muted); }
table.compare .mine { background: var(--surface); }
table.compare thead .mine { border-radius: 10px 10px 0 0; }

.price-row { display: grid; gap: 18px; margin-top: 22px; align-items: start; }
@media (min-width: 820px) { .price-row { grid-template-columns: 24rem minmax(0, 1fr); gap: 28px; } }
.price { text-align: left; }
.after h3 { margin-bottom: 10px; }
.after ol { margin: 0 0 14px; padding-left: 1.2em; color: var(--muted); font-size: 0.93rem; }
.after li { margin-bottom: 8px; }
.after .fine { font-size: 0.84rem; color: var(--muted); margin: 0; }
.price .amount { font-family: var(--serif); font-size: 3rem; line-height: 1; }
.price .was { color: var(--muted); text-decoration: line-through; margin-left: 8px; font-size: 1.2rem; }
.price .until { color: var(--red); font-size: 0.86rem; margin: 8px 0 14px; }
.price ul { margin: 0 0 18px; padding-left: 1.1em; color: var(--muted); font-size: 0.93rem; }
.price li { margin-bottom: 4px; }
.price .btn { width: 100%; }
.price .fine { font-size: 0.8rem; color: var(--muted); margin: 10px 0 0; }

.faq { margin-top: 20px; display: grid; gap: 2px; }
.faq details { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 0 14px; }
.faq summary { cursor: pointer; padding: 13px 0; font-family: var(--serif); font-size: 1.02rem; }
.faq details[open] summary { border-bottom: 1px solid var(--line); }
.faq details p { font-size: 0.93rem; color: var(--muted); margin: 12px 0; }

/* ---------- footer ---------- */

.site-foot { border-top: 1px solid var(--line); padding: 30px 0 48px; font-size: 0.85rem; color: var(--muted); }
.site-foot p { margin: 0 0 8px; }
.site-foot a { color: var(--muted); }

/* ---------- toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  padding: 11px 18px; border-radius: 99px; font-size: 0.9rem;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--red); color: #fff; }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; position: fixed; z-index: 30; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 8px; }

/* ---------- simple pages ---------- */

.simple { max-width: 34rem; margin: 0 auto; padding: 60px 16px; }
.simple h1 { margin-bottom: 14px; }
.simple ol { color: var(--muted); padding-left: 1.2em; }
.simple li { margin-bottom: 10px; }
