:root {
  --paper: #eaf0dd;
  --paper-2: #f6f9ee;
  --ink: #17351f;
  --ink-2: #4a6150;
  --leaf: #1f8a4c;
  --leaf-dark: #146338;
  --sun: #f6c324;
  --sun-dark: #d9a50c;
  --berry: #c8443a;
  --berry-bg: #fbe7e3;
  --line: #c9d6b6;
  --sky: #2f7fae;
  --radius-lg: 22px;
  --radius-sm: 12px;
  --display: 'Jua', 'Apple SD Gothic Neo', 'Noto Sans KR', system-ui, sans-serif;
  --body: -apple-system, 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--body); font-size: 17px; line-height: 1.6; -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

#app { max-width: 520px; margin: 0 auto; padding: 16px 16px 112px; }
h1, h2, h3, .display { font-family: var(--display); font-weight: 400; line-height: 1.25; margin: 0; }
h1 { font-size: 30px; }
h2 { font-size: 24px; margin-bottom: 8px; }
h3 { font-size: 19px; margin-bottom: 4px; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-2); font-size: 15px; }
.small { font-size: 14px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar .back { border: 0; background: var(--paper-2); width: 44px; height: 44px; border-radius: 50%; font-size: 22px; cursor: pointer; }
.brand { font-family: var(--display); font-size: 22px; }
.brand small { display: block; font-family: var(--body); font-size: 13px; color: var(--ink-2); }

.mockbar { background: repeating-linear-gradient(-45deg, #fff6d6, #fff6d6 10px, #fdeeb6 10px, #fdeeb6 20px); border: 1.5px solid var(--sun-dark); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 14px; margin-bottom: 12px; }

/* hero: the lens */
.hero { text-align: center; padding: 8px 0 18px; }
.lens {
  width: 196px; height: 196px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 50% 50%, var(--sun) 0 56%, #fff3c4 57% 63%, var(--sun) 64%);
  box-shadow: 0 0 0 8px var(--paper-2), 0 0 0 10px var(--line), 0 10px 0 6px var(--sun-dark);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--display); font-size: 27px; color: var(--ink); margin: 18px 0 26px;
}
.lens:active { transform: translateY(4px); box-shadow: 0 0 0 8px var(--paper-2), 0 0 0 10px var(--line), 0 5px 0 6px var(--sun-dark); }
.lens .ico { font-size: 44px; line-height: 1; }
.linkish { background: none; border: 0; color: var(--leaf-dark); font-family: var(--display); font-size: 20px; text-decoration: underline; text-underline-offset: 5px; padding: 10px; cursor: pointer; }

/* buttons */
.btn { display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 12px 18px; border-radius: 999px; border: 2px solid var(--ink); background: var(--paper-2); font-family: var(--display); font-size: 20px; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--leaf); color: #fff; border-color: var(--leaf-dark); box-shadow: 0 4px 0 var(--leaf-dark); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--leaf-dark); }
.btn.sun { background: var(--sun); border-color: var(--sun-dark); box-shadow: 0 4px 0 var(--sun-dark); }
.btn.quiet { border-color: var(--line); background: transparent; font-size: 18px; }
.btn[disabled] { opacity: .5; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* notebook panels */
.note { background: var(--paper-2); border-radius: var(--radius-lg); padding: 16px 18px; margin: 14px 0; border: 1.5px solid var(--line); }
.note.safety { background: var(--berry-bg); border-color: #e9b4ad; }
.note.safety h3 { color: var(--berry); }
.note.good { border-color: var(--leaf); }
.note ul { margin: 6px 0 0; padding-left: 20px; }
.note li { margin: 4px 0; }
.tip { display: flex; gap: 12px; align-items: flex-start; }
.tip .t-ico { font-size: 28px; line-height: 1.2; }

.rules { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: center; background: var(--paper-2); border-radius: var(--radius-sm); padding: 12px 14px; border: 1.5px solid var(--line); }
.rules .r-ico { font-size: 28px; width: 36px; text-align: center; }

/* photo & target */
.photo-frame { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; touch-action: none; user-select: none; -webkit-user-select: none; }
.photo-frame img { width: 100%; pointer-events: none; }
.sel { position: absolute; border: 3px solid var(--sun); box-shadow: 0 0 0 9999px rgba(0,0,0,.45); border-radius: 8px; pointer-events: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { border: 2px solid var(--line); background: var(--paper-2); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 16px; }
.chip[aria-pressed="true"] { border-color: var(--leaf); background: var(--leaf); color: #fff; }

/* result */
.state-badge { display: inline-block; font-family: var(--display); font-size: 18px; padding: 4px 14px; border-radius: 999px; background: var(--paper-2); border: 2px solid var(--ink); margin-bottom: 10px; }
.state-ALMOST_SURE { background: var(--leaf); color: #fff; border-color: var(--leaf-dark); }
.state-SIMILAR_EXISTS { background: var(--sun); border-color: var(--sun-dark); }
.state-NEED_MORE_PHOTO { background: #dbe9f4; border-color: var(--sky); }
.big-name { font-family: var(--display); font-size: 40px; line-height: 1.15; margin: 4px 0; }
.cand { display: flex; gap: 12px; align-items: center; background: var(--paper-2); border: 2px solid var(--line); border-radius: var(--radius-lg); padding: 12px; }
.cand + .cand { margin-top: 10px; }
.cand .c-body { flex: 1; }
.cand .c-name { font-family: var(--display); font-size: 22px; }
details.parent { margin-top: 18px; border-top: 1.5px dashed var(--line); padding-top: 10px; font-size: 15px; }
details.parent summary { cursor: pointer; color: var(--ink-2); }
table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.plain td, table.plain th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }

/* stickers / dex */
.dex-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.sticker { background: #fff; border-radius: 20px; padding: 10px 10px 12px; border: 2px solid var(--line); text-decoration: none; color: var(--ink); display: block; position: relative; box-shadow: 0 3px 0 var(--line); }
.sticker .art { aspect-ratio: 1; border-radius: 14px; background: var(--paper-2); display: grid; place-items: center; overflow: hidden; }
.sticker .art img { width: 100%; height: 100%; object-fit: cover; }
.sticker .art.char img { object-fit: contain; padding: 8px; }
.sticker .s-name { font-family: var(--display); font-size: 19px; margin-top: 8px; }
.sticker .s-meta { font-size: 13px; color: var(--ink-2); }
.count { position: absolute; top: 6px; right: 6px; background: var(--ink); color: #fff; font-size: 13px; border-radius: 999px; padding: 1px 9px; }
.badge-likely { display: inline-block; font-size: 12px; background: var(--sun); border-radius: 999px; padding: 0 8px; margin-left: 4px; vertical-align: middle; }
.stamp-missing { border: 3px dashed var(--line); border-radius: 50%; width: 76%; aspect-ratio: 1; display: grid; place-items: center; text-align: center; font-family: var(--display); color: var(--ink-2); font-size: 15px; line-height: 1.3; }
.stamp-missing .leafy { font-size: 34px; display: block; opacity: .5; }

.char-hero { background: #fff; border-radius: 28px; border: 2px solid var(--line); padding: 16px; text-align: center; }
.char-hero img { width: 62%; margin: 0 auto; }
.char-hero .stamp-missing { width: 52%; margin: 0 auto; }
.sample-tag { font-size: 12px; color: var(--ink-2); }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 6px 0; }
.strip img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; flex: none; }

.field { margin: 18px 0; }
.field h3 { color: var(--leaf-dark); }
.field ul { margin: 4px 0; padding-left: 20px; }
.compare { background: #fff; border: 2px solid var(--sun-dark); border-radius: var(--radius-lg); padding: 14px 16px; margin: 12px 0; }
.foot { font-size: 13px; color: var(--ink-2); border-top: 1.5px dashed var(--line); padding-top: 10px; margin-top: 20px; }

/* tabs */
.tabs { display: flex; gap: 8px; margin: 6px 0 14px; }
.tab { flex: 1; text-align: center; padding: 10px; border-radius: 999px; border: 2px solid var(--line); background: transparent; font-family: var(--display); font-size: 18px; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* quiz */
.q-progress { display: flex; gap: 6px; margin: 4px 0 16px; }
.q-progress span { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.q-progress span.on { background: var(--leaf); }
.choice { display: block; width: 100%; text-align: left; padding: 14px 16px; border-radius: var(--radius-lg); border: 2px solid var(--line); background: #fff; font-size: 18px; margin-bottom: 10px; cursor: pointer; }
.choice.right { border-color: var(--leaf); background: #e2f3e6; }
.choice.wrong { border-color: var(--berry); background: var(--berry-bg); }

/* forms */
label.opt { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: #fff; margin-bottom: 8px; cursor: pointer; }
input[type=text], textarea, select { width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 2px solid var(--line); background: #fff; }
textarea { min-height: 88px; }

/* list rows */
.pending { display: flex; gap: 12px; align-items: center; padding: 10px; background: var(--paper-2); border-radius: var(--radius-sm); border: 1.5px solid var(--line); margin-top: 8px; }
.pending img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; }
.pending .p-body { flex: 1; font-size: 15px; }
.pending button { min-height: 44px; border-radius: 999px; border: 2px solid var(--leaf); background: #fff; padding: 0 14px; font-family: var(--display); font-size: 16px; cursor: pointer; }

/* bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper-2); border-top: 1.5px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.nav a { flex: 1; max-width: 170px; text-align: center; text-decoration: none; color: var(--ink-2); font-family: var(--display); font-size: 16px; padding: 6px 0; border-radius: 14px; }
.nav a .n-ico { display: block; font-size: 24px; line-height: 1.2; }
.nav a[aria-current="page"] { color: var(--ink); background: var(--paper); }

/* overlay */
.loading { position: fixed; inset: 0; background: rgba(234, 240, 221, .94); display: grid; place-items: center; z-index: 20; text-align: center; padding: 24px; }
.loading .spin { width: 70px; height: 70px; border-radius: 50%; border: 8px solid var(--line); border-top-color: var(--leaf); margin: 0 auto 16px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.celebrate { animation: pop .5s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 22px; z-index: 30; font-size: 15px; width: max-content; max-width: min(90vw, 440px); text-wrap: balance; word-break: keep-all; text-align: center; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-2); }
.empty .e-ico { font-size: 48px; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
