:root {
  --bg: #f6efe6; --card: #ffffff; --ink: #2b2420; --muted: #7a6d64; --line: #e6dbcf;
  --accent: #e9774f; --accent-ink: #ffffff; --ok: #3f8f5a; --warn: #c0392b; --soft: #fbe3d6;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d1916; --card: #2a2420; --ink: #f3ece6; --muted: #b3a69c; --line: #3d342e;
          --accent: #f08a63; --accent-ink: #1d1916; --ok: #6cc28a; --warn: #ff7b6b; --soft: #4a2e22; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 18px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 120px; }
.center { text-align: center; padding-top: 12vh; }
.logo { font-size: 64px; }
h1 { font-size: 26px; margin: 8px 0; }
h2 { font-size: 22px; margin: 20px 0 8px; }
.muted { color: var(--muted); font-size: 16px; }
.err { color: var(--warn); font-weight: 600; }
.btn { appearance: none; border: 2px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 14px; padding: 12px 16px; font-size: 18px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; padding: 18px; font-size: 21px; margin-top: 12px; }
.btn:disabled { opacity: .45; }
.btn.small { padding: 8px 12px; font-size: 16px; }
.pin { font-size: 32px; letter-spacing: 10px; text-align: center; width: 100%; max-width: 320px;
  padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin: 12px 0; }
.step { color: var(--accent); font-weight: 800; font-size: 15px; letter-spacing: .5px; }
.list-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.list-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { display: inline-block; font-size: 14px; padding: 2px 10px; border-radius: 99px; background: var(--soft);
  white-space: nowrap; font-weight: 700; }
.badge.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.err { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.classes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.classes button { padding: 14px 6px; line-height: 1.3; }
.classes button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.classes small { display: block; font-weight: 500; font-size: 14px; }
textarea, input[type=text], input[type=datetime-local], select {
  width: 100%; font-size: 18px; padding: 12px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); color: var(--ink); font-family: inherit; }
textarea { min-height: 110px; resize: vertical; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs .th { position: relative; border-radius: 12px; overflow: hidden; background: var(--line); aspect-ratio: 1; }
.thumbs canvas, .thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .n { position: absolute; left: 6px; top: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 99px;
  font-size: 13px; padding: 0 8px; }
.thumbs .f { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: 99px;
  font-size: 13px; padding: 0 8px; }
.editor-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 10; display: flex; flex-direction: column; }
.editor-wrap .bar { display: flex; gap: 8px; padding: 12px; justify-content: space-between; align-items: center; color: #fff; }
.editor-wrap .bar .btn { white-space: nowrap; flex: none; }
.editor-wrap .bar span { font-size: 15px; text-align: center; }
.editor-wrap .stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0 8px; }
.editor-wrap canvas { max-width: 100%; max-height: 100%; touch-action: none; }
.editor-wrap .hint { color: #ddd; text-align: center; font-size: 15px; padding: 8px 16px 16px; }
.preview { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.preview h3 { font-size: 21px; margin: 0 0 12px; }
.preview .pblock { white-space: pre-wrap; margin: 10px 0; }
.preview .pheading { font-weight: 800; font-size: 19px; border-left: 4px solid var(--accent); padding-left: 10px; margin: 18px 0 8px; }
.preview img { width: 100%; border-radius: 10px; display: block; margin: 10px 0; }
.preview [contenteditable] { outline: 1px dashed transparent; border-radius: 6px; }
.preview [contenteditable]:focus { outline-color: var(--accent); background: var(--soft); }
.preview .footer { color: var(--muted); white-space: pre-wrap; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 16px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--soft); border-radius: 99px; padding: 2px 10px; font-size: 15px; }
.titles label { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 2px solid var(--line);
  border-radius: 12px; margin: 8px 0; cursor: pointer; }
.titles input { margin-top: 6px; transform: scale(1.4); }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > .btn { flex: 1; }
.sticky { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.sticky .inner { max-width: 640px; margin: 0 auto; }
.spinner { width: 56px; height: 56px; border: 6px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 1s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; }
.check input { transform: scale(1.5); }
.hidden { display: none !important; }
