:root {
  --paper: #f4f1ea;
  --ink: #16140f;
  --mute: #7a746a;
  --line: #d9d3c6;
  --seal: #c3301c;
  --card: #fbfaf6;
  --serif: "Noto Serif KR", serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12110e;
    --ink: #ece7dc;
    --mute: #8d867a;
    --line: #2c2a25;
    --seal: #e0533d;
    --card: #1a1915;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.7;
}
main { max-width: 640px; margin: 0 auto; padding: 72px 16px 40px; }
.mono { font-family: var(--mono); }
b { font-weight: 600; }

/* 이름 풀이 */
.derive { margin-bottom: 96px; }
.glyph {
  font-family: var(--serif);
  font-size: clamp(120px, 34vw, 220px);
  line-height: 1;
  margin-bottom: 40px;
  letter-spacing: -0.02em;
}
.steps { list-style: none; padding: 0; margin: 0 0 40px; border-top: 1px solid var(--line); }
.steps li {
  display: flex; gap: 16px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  opacity: 0; transform: translateY(6px);
  transition: opacity .5s ease, transform .5s ease;
}
.steps li.on { opacity: 1; transform: none; }
.steps .k { width: 76px; flex: none; color: var(--mute); font-size: 13px; }
.steps .v { font-size: 16px; overflow-wrap: anywhere; }
.conclusion {
  font-size: 18px; margin: 0;
  opacity: 0; transition: opacity .8s ease;
}
.conclusion.on { opacity: 1; }

/* 도장 찍기 */
.tool h2, .notes h3 { font-size: 22px; font-weight: 600; margin: 0 0 8px; }
.lead { color: var(--mute); margin: 0 0 24px; font-size: 15px; }
.lead b { color: var(--ink); }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button {
  font: 500 13px var(--mono); padding: 6px 14px; cursor: pointer;
  background: transparent; color: var(--mute);
  border: 1px solid var(--line); border-radius: 999px;
}
.tabs button[aria-selected="true"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 140px; padding: 20px;
  border: 1.5px dashed var(--line); border-radius: 12px;
  background: var(--card); color: var(--mute); cursor: pointer;
  transition: border-color .2s, color .2s;
  overflow-wrap: anywhere;
}
.drop:hover, .drop.over { border-color: var(--ink); color: var(--ink); }
textarea {
  width: 100%; padding: 16px; resize: vertical;
  font: 15px/1.6 var(--serif); color: var(--ink);
  background: var(--card); border: 1.5px solid var(--line); border-radius: 12px;
}
textarea:focus { outline: none; border-color: var(--ink); }
.hashline { display: flex; gap: 12px; align-items: baseline; margin: 16px 0 20px; font-size: 13px; }
.hashline .k { color: var(--mute); flex: none; }
.hashline code { overflow-wrap: anywhere; word-break: break-all; }
.stamp-btn {
  width: 100%; padding: 16px; cursor: pointer;
  font: 600 16px var(--serif); letter-spacing: .02em;
  color: #fff; background: var(--seal); border: 0; border-radius: 12px;
  transition: transform .1s, opacity .2s;
}
.stamp-btn:disabled { opacity: .3; cursor: default; }
.stamp-btn:not(:disabled):active { transform: scale(.98); }
.msg { min-height: 1.7em; color: var(--mute); font-size: 14px; margin: 10px 0 0; }

/* 결과 */
.result {
  display: flex; gap: 28px; align-items: flex-start;
  margin: 40px 0 0; padding: 28px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
}
.result[hidden] { display: none; }
.seal {
  flex: none; width: 104px; height: 104px; border-radius: 50%;
  border: 3px solid var(--seal); color: var(--seal);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-8deg);
  animation: thunk .45s cubic-bezier(.2, 1.6, .4, 1);
}
.seal-c { font-size: 44px; line-height: 1; }
.seal-d { font: 500 10px var(--mono); margin-top: 4px; letter-spacing: .04em; }
@keyframes thunk { from { transform: rotate(-8deg) scale(1.6); opacity: 0; } to { transform: rotate(-8deg) scale(1); opacity: 1; } }
.record { min-width: 0; flex: 1; }
.state { margin: 0 0 12px; font-weight: 600; }
dl { margin: 0 0 16px; display: grid; grid-template-columns: 72px 1fr; gap: 6px 12px; font-size: 13px; }
dt { color: var(--mute); }
dd { margin: 0; }
.wrap { word-break: break-all; }
.share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.share code { font-size: 12px; color: var(--mute); word-break: break-all; flex: 1; min-width: 0; }
.share button {
  font: 500 13px var(--mono); padding: 6px 12px; cursor: pointer;
  color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 8px;
}
.fine { font-size: 12px; color: var(--mute); margin: 12px 0 0; }

/* 알아둘 것 */
.notes { margin-top: 96px; }
.notes ul { margin: 0; padding-left: 18px; color: var(--mute); font-size: 14px; }
.notes li { margin: 4px 0; }

footer { text-align: center; padding: 48px 16px 40px; font-size: 12px; color: var(--mute); }

@media (max-width: 520px) {
  main { padding-top: 48px; }
  .result { flex-direction: column; align-items: center; text-align: left; padding: 22px 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .steps li, .conclusion { transition: none; }
  .seal { animation: none; }
}
