:root {
  --ink: #13233f;
  --ink-soft: #41506a;
  --paper: #ffffff;
  --canvas: #f3f6fb;
  --line: #dbe2ed;
  --primary: #2256d9;
  --primary-dark: #173fa8;
  --accent: #f1b84b;
  --success: #137a55;
  --danger: #bb3346;
  --shadow: 0 16px 40px rgba(19, 35, 63, 0.10);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  font-family: Inter, Pretendard, "Noto Sans KR", "Apple SD Gothic Neo",
    "Malgun Gothic", "Noto Sans CJK KR", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(34, 86, 217, 0.10), transparent 30rem),
    var(--canvas);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(34, 86, 217, 0.28);
  outline-offset: 2px;
}
.hidden { display: none !important; }

.topbar {
  min-height: 72px;
  padding: 12px max(18px, env(safe-area-inset-left));
  padding-right: max(18px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.90);
  border-bottom: 1px solid rgba(219, 226, 237, 0.95);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 14px;
  display: grid; place-items: center;
  background: var(--ink);
  color: white;
  font-family: "Noto Serif CJK KR", "Batang", serif;
  font-size: 27px;
  box-shadow: 0 8px 18px rgba(19, 35, 63, 0.20);
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -0.03em; }
.brand p { margin: 2px 0 0; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.trial-badge {
  flex: 0 0 auto;
  border: 1px solid #ecd28d;
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff8df;
  color: #76510b;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.page-shell { width: min(100%, 1080px); margin: 0 auto; padding: 0 16px 44px; }
.hero { padding: 42px 3px 24px; text-align: center; }
.eyebrow, .step {
  margin: 0;
  color: var(--primary);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.hero h2 {
  margin: 12px 0 14px;
  font-size: clamp(30px, 7vw, 50px);
  line-height: 1.12;
  letter-spacing: -0.055em;
}
.hero-copy {
  max-width: 660px;
  margin: 0 auto;
  color: var(--ink-soft);
  line-height: 1.7;
  font-size: 14px;
}
.hero-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; flex-wrap: wrap; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.editor-card, .composer-card, .keyboard-card, .notice-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.editor-card, .composer-card { padding: 20px; }
.keyboard-card { grid-column: 1 / -1; padding: 18px; }

.section-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.section-heading > div { display: flex; align-items: baseline; gap: 9px; min-width: 0; }
.section-heading h3 { margin: 0; font-size: 17px; letter-spacing: -0.03em; }
.section-heading.compact { margin-bottom: 10px; }
.save-state, .status-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
}
.save-state { background: #eef2f8; color: var(--ink-soft); }
.status-ready { background: #eef2f8; color: var(--ink-soft); }
.status-good { background: #e6f7ef; color: var(--success); }
.status-wait { background: #fff5d9; color: #845b0d; }
.status-bad { background: #fdecef; color: var(--danger); }

.editor {
  width: 100%;
  min-height: 190px;
  padding: 16px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fbfcfe;
  color: var(--ink);
  font-family: "Noto Sans CJK KR", "Noto Sans CJK SC", "Noto Sans CJK JP", sans-serif;
  font-size: 21px;
  line-height: 1.65;
}
.editor::placeholder { color: #97a2b4; font-size: 14px; }
.editor-actions, .composer-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

.button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  padding: 10px 15px;
  cursor: pointer;
  font-weight: 850;
  letter-spacing: -0.02em;
}
.button:disabled { opacity: 0.44; cursor: not-allowed; }
.button-primary { background: var(--primary); color: white; box-shadow: 0 7px 16px rgba(34, 86, 217, 0.20); }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { background: var(--ink); color: white; }
.button-quiet { background: #eef2f8; color: var(--ink); }
.button-danger-quiet { background: #fff0f2; color: var(--danger); }
.button-wide { flex: 1; min-width: 140px; }

.composition-grid { display: grid; grid-template-columns: 0.72fr 1.28fr; gap: 12px; }
.display-panel, .code-panel, .parts-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fbfcfe;
}
.display-panel { min-height: 162px; padding: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.display-label { display: block; color: var(--ink-soft); font-size: 11px; font-weight: 850; }
.candidate-char {
  margin: 8px 0 5px;
  font-family: "Noto Serif CJK KR", "Batang", serif;
  font-size: 64px;
  line-height: 1;
}
.candidate-name { min-height: 20px; color: var(--ink-soft); font-size: 12px; text-align: center; }
.code-panel { padding: 14px; }
.code-panel label { display: block; margin-bottom: 8px; font-size: 12px; font-weight: 900; }
.code-input-row { display: flex; gap: 7px; }
.code-input {
  width: 100%;
  min-width: 0;
  height: 48px;
  border: 1px solid #bfc9d8;
  border-radius: 13px;
  padding: 0 13px;
  background: white;
  color: var(--ink);
  font-size: 22px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}
.icon-button {
  width: 50px; height: 48px; flex: 0 0 50px;
  border: 0; border-radius: 13px;
  background: #e9eef6; color: var(--ink);
  font-size: 20px; cursor: pointer;
}
.code-help { margin: 10px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }

.parts-panel { margin-top: 12px; padding: 12px; }
.parts-view { min-height: 52px; margin-top: 9px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.part {
  min-width: 48px; min-height: 48px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 13px; border: 1px solid var(--line);
  background: white;
}
.part strong { font-family: "Noto Serif CJK KR", serif; font-size: 24px; line-height: 1; }
.part small { margin-top: 3px; color: var(--ink-soft); font-size: 9px; }
.part-plus { color: #99a3b2; font-weight: 900; }
.part-placeholder { color: #98a2b2; font-size: 12px; }

.examples { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.examples-title { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.examples-title strong { font-size: 13px; }
.examples-title span { color: var(--ink-soft); font-size: 10px; }
.chip-list { display: flex; gap: 7px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip {
  flex: 0 0 auto;
  min-height: 38px;
  border: 1px solid #cbd5e3;
  border-radius: 999px;
  padding: 7px 11px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}
.chip strong { margin-right: 5px; font-family: "Noto Serif CJK KR", serif; font-size: 17px; }
.chip span { color: var(--ink-soft); font-size: 10px; font-weight: 800; }

.text-button { border: 0; background: none; color: var(--primary); font-size: 12px; font-weight: 900; cursor: pointer; }
.virtual-keyboard { display: flex; flex-direction: column; gap: 7px; }
.key-row { display: flex; justify-content: center; gap: 6px; }
.key {
  width: min(8.2vw, 58px);
  min-width: 30px;
  height: 48px;
  border: 1px solid #cbd5e3;
  border-radius: 12px;
  background: linear-gradient(#ffffff, #f3f6fa);
  color: var(--ink);
  box-shadow: 0 3px 0 #d6deea;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
}
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #d6deea; }
.key-special { width: min(16vw, 94px); background: #e8eef8; }
.keyboard-note { margin: 12px 0 0; color: var(--ink-soft); font-size: 11px; text-align: center; }

.feature-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.feature-grid article {
  min-height: 160px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.80);
}
.feature-grid article > span {
  width: 27px; height: 27px; display: grid; place-items: center;
  border-radius: 9px; background: #e7eefc; color: var(--primary); font-weight: 900;
}
.feature-grid h3 { margin: 14px 0 7px; font-size: 14px; }
.feature-grid p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.6; }
.notice-card { margin-top: 16px; padding: 20px; }
.notice-card h3 { margin: 0 0 8px; font-size: 15px; }
.notice-card p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.7; }

footer {
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; align-items: center; gap: 9px; flex-wrap: wrap;
  color: var(--ink-soft); font-size: 11px; text-align: center;
}
footer strong { color: var(--ink); }

.guide-dialog {
  width: min(calc(100% - 28px), 520px);
  max-height: calc(100dvh - 28px);
  border: 0;
  border-radius: 24px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(19,35,63,.28);
}
.guide-dialog::backdrop { background: rgba(19, 35, 63, 0.56); backdrop-filter: blur(4px); }
.guide-dialog form { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dialog-heading > div { display: flex; align-items: baseline; gap: 8px; }
.dialog-heading h2 { margin: 0; font-size: 22px; }
.dialog-close {
  width: 38px; height: 38px; border: 0; border-radius: 12px;
  background: #eef2f8; color: var(--ink); font-size: 25px; cursor: pointer;
}
.guide-dialog ol { margin: 22px 0; padding-left: 22px; color: var(--ink-soft); font-size: 13px; line-height: 1.75; }
.guide-dialog li + li { margin-top: 8px; }
.guide-samples { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 18px; }
.guide-samples code {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #f7f9fc;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%; bottom: max(22px, calc(env(safe-area-inset-bottom) + 12px));
  z-index: 50;
  transform: translate(-50%, 18px);
  min-width: 180px; max-width: calc(100% - 32px);
  padding: 11px 16px;
  border-radius: 999px;
  background: var(--ink); color: white;
  text-align: center; font-size: 12px; font-weight: 800;
  opacity: 0; pointer-events: none;
  transition: .22s ease;
  box-shadow: 0 14px 34px rgba(19,35,63,.24);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .page-shell { padding-left: 12px; padding-right: 12px; }
  .hero { padding-top: 30px; }
  .workspace { grid-template-columns: 1fr; }
  .keyboard-card { grid-column: auto; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-card, .composer-card { padding: 16px; }
  .composition-grid { grid-template-columns: 0.8fr 1.2fr; }
}

@media (max-width: 430px) {
  .topbar { min-height: 66px; }
  .brand-mark { width: 40px; height: 40px; flex-basis: 40px; font-size: 24px; }
  .brand p { display: none; }
  .hero h2 { font-size: 32px; }
  .hero-copy { font-size: 13px; }
  .composition-grid { grid-template-columns: 1fr; }
  .display-panel { min-height: 132px; }
  .candidate-char { font-size: 58px; }
  .feature-grid { grid-template-columns: 1fr; }
  .feature-grid article { min-height: 132px; }
  .editor-actions .button { flex: 1; padding-left: 9px; padding-right: 9px; }
  .key { width: calc((100vw - 50px) / 10); min-width: 27px; height: 46px; border-radius: 10px; }
  .key-row:nth-child(2) { padding: 0 12px; }
  .key-row:nth-child(3) { padding: 0 3px; }
  .key-special { width: 66px; }
}

@media (display-mode: standalone) {
  .topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .hero-actions #installButton { display: none !important; }
}
