:root {
  --bg: #fff5e9;
  --dot: #f1dcc3;
  --card: #fffdf8;
  --ink: #4b3428;
  --muted: #86695a; /* 4.5:1 넘게: 글자로도 쓰이니까 */
  --line: #f0dfcb;
  --coral: #ff8a65;
  --coral-text: #b8482a; /* 코랄 글씨용. 배경 코랄은 그대로 */
  --peach: #ffcdb5;
  --butter: #ffe39a;
  --sage: #cde5bb;
  --sky: #c6e1f5;
  --pink: #fbcadb;
  --lilac: #ddd2f5;
  --on-pastel: #4b3428;
  --pop: 0 4px 0 var(--ink);
  --pop-lg: 0 6px 0 var(--ink);
  --soft: 0 14px 30px -14px rgb(120 70 40 / 0.35);
  --round: 'Zen Maru Gothic', 'Apple SD Gothic Neo', system-ui, sans-serif;
  --display: 'Jua', 'Zen Maru Gothic', 'Apple SD Gothic Neo', sans-serif;
  --gutter: 18px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2b211c;
    --dot: #3e3029;
    --card: #372a23;
    --ink: #fbeee0;
    --muted: #b49c8a;
    --line: #4a3a31;
    --coral: #ff9a78;
    --coral-text: #ff9a78;
    --peach: #f2b59a;
    --butter: #f3d27c;
    --sage: #b5d29f;
    --sky: #a9cbe6;
    --pink: #eeafc3;
    --lilac: #c6b8ea;
    --on-pastel: #2b211c;
    --pop: 0 4px 0 #170f0b;
    --pop-lg: 0 6px 0 #170f0b;
    --soft: 0 14px 30px -14px rgb(0 0 0 / 0.7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.4px, transparent 1.6px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--round);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

main {
  max-width: 680px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) 130px;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px dashed var(--coral); outline-offset: 3px; }

/* ───────── 공용 ───────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 14px;
  padding: 5px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--butter);
  color: var(--on-pastel);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--ink);
  transform: rotate(-2deg);
}

.home-head { padding: 30px 0 26px; }
.home-head h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(32px, 9vw, 46px);
  line-height: 1.22;
}
mark {
  padding: 0 4px;
  background: linear-gradient(transparent 58%, color-mix(in srgb, var(--coral) 45%, transparent) 58% 92%, transparent 92%);
  color: inherit;
}
.lead { margin: 14px 0 0; color: var(--muted); font-size: 14px; }

.primary {
  padding: 13px 28px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--coral);
  color: var(--on-pastel);
  font-family: var(--display);
  font-size: 17px;
  box-shadow: var(--pop);
  transition: transform 0.12s, box-shadow 0.12s;
}
.primary:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }

.text-btn {
  padding: 8px 6px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--card);
  font-size: 18px;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 0 calc(var(--gutter) * -1) 22px;
  padding: calc(env(safe-area-inset-top) + 8px) var(--gutter) 8px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-title {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ───────── 하단 탭 ───────── */

.tabs,
.pager {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--pop), var(--soft);
  transform: translateX(-50%);
}
.tabs a {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--display);
  font-size: 16px;
  transition: background 0.2s, color 0.2s;
}
.tabs a span { font-family: var(--round); font-weight: 900; }
body[data-view='home'] .tabs [data-tab='home'],
body[data-view='quiz'] .tabs [data-tab='quiz'] { background: var(--butter); color: var(--on-pastel); }
body[data-view='book'] .tabs,
body[data-view='new'] .tabs { display: none; }

/* ───────── 책장 ───────── */

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 34px 20px;
}

.book { display: flex; flex-direction: column; gap: 6px; }

.cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 12 / 17;
  margin-bottom: 8px;
  object-fit: cover;
  border: 2px solid var(--ink);
  border-radius: 10px 18px 18px 10px;
  box-shadow: inset 6px 0 0 rgb(0 0 0 / 0.07), var(--pop-lg);
  transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.2s;
}
.book:focus-visible .cover { transform: translateY(-6px) rotate(-2.5deg); }
.book:active .cover { transform: translateY(2px); box-shadow: inset 6px 0 0 rgb(0 0 0 / 0.07), 0 1px 0 var(--ink); }

/* 표지 없는 책: 파스텔 표지 + 세로쓰기 라벨 */
.cover-blank {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden; /* 긴 제목이 표지 비율을 늘리지 않게 */
  padding: 10px;
  background: var(--peach);
  color: var(--on-pastel);
}
.book:nth-child(4n + 2) .cover-blank { background: var(--sky); }
.book:nth-child(4n + 3) .cover-blank { background: var(--sage); }
.book:nth-child(4n + 4) .cover-blank { background: var(--lilac); }
.cover-blank span {
  max-height: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 10px 6px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  writing-mode: vertical-rl;
}
.has-img span { box-shadow: 0 3px 0 var(--ink); }

.cover-add {
  display: grid;
  place-items: center;
  border: 2.5px dashed var(--muted);
  background: color-mix(in srgb, var(--card) 60%, transparent);
  box-shadow: none;
  color: var(--muted);
  font-size: 34px;
}

.book-title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 700;
  min-height: 2.7em; /* 항상 2줄 높이 → 1줄 제목이어도 진도 바가 옆 책과 나란히 */
  font-size: 15px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.book-meta { color: var(--coral-text); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.book-meta em { color: var(--muted); font-style: normal; font-weight: 500; }
.bar { height: 8px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--butter); }

.backup {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 60px;
  color: var(--muted);
  font-size: 13px;
}
.link { padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: underline wavy; text-underline-offset: 4px; }

/* ───────── 페이지 ───────── */

.sheet {
  position: relative;
  min-height: 60dvh;
  margin-top: 8px;
  padding: 34px 20px 26px;
  border: 2px solid var(--ink);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--pop-lg), var(--soft);
  touch-action: pan-y;
}

.tape {
  position: absolute;
  top: -15px;
  left: 50%;
  width: 116px;
  height: 28px;
  background: repeating-linear-gradient(-45deg, var(--pink) 0 8px, color-mix(in srgb, var(--pink) 55%, #fff) 8px 16px);
  opacity: 0.92;
  transform: translateX(-50%) rotate(-3deg);
  clip-path: polygon(3% 0, 97% 0, 100% 20%, 97% 45%, 100% 70%, 97% 100%, 3% 100%, 0 75%, 3% 50%, 0 25%);
}

.page-badge {
  position: absolute;
  top: -16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--butter);
  color: var(--on-pastel);
  font-family: var(--display);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 3px 0 var(--ink);
  transform: rotate(8deg);
}
.page-badge small { display: block; margin-bottom: -10px; font-size: 11px; }

.chapter {
  display: inline-block;
  margin: 0 0 4px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--sage);
  color: var(--on-pastel);
  font-size: 12px;
  font-weight: 700;
}
.page-no { margin: 0 0 10px; color: var(--muted); font-size: 13px; font-weight: 700; }

.words { margin: 0; padding: 0; list-style: none; }

.word {
  display: grid;
  grid-template-columns: 30px 1fr;
  grid-template-areas: 'idx jp' '. mean';
  column-gap: 12px;
  row-gap: 2px;
  padding: 16px 0;
  border-bottom: 2px dotted var(--line);
}
.word:last-child { border-bottom: 0; }
.sheet .word { animation: rise 0.4s cubic-bezier(0.3, 1.4, 0.5, 1) backwards; animation-delay: calc(var(--i, 0) * 35ms); }

.idx {
  grid-area: idx;
  align-self: end;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-bottom: 3px;
  border-radius: 50%;
  background: var(--peach);
  color: var(--on-pastel);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.word:nth-child(5n + 2) .idx { background: var(--sky); }
.word:nth-child(5n + 3) .idx { background: var(--sage); }
.word:nth-child(5n + 4) .idx { background: var(--butter); }
.word:nth-child(5n + 5) .idx { background: var(--lilac); }

.jp { grid-area: jp; display: flex; flex-direction: column; }
.yomi { color: var(--coral-text); font-size: 13px; font-weight: 700; letter-spacing: 0.05em; }
.yomi:empty { display: none; }
.kanji { font-size: 26px; font-weight: 900; line-height: 1.3; }
.mean { grid-area: mean; margin-left: -8px; padding: 2px 8px; border-radius: 10px; font-size: 15px; line-height: 1.55; transition: color 0.2s, background-color 0.2s; }
.hide .word { cursor: pointer; }
.hide .mean { color: transparent; background: repeating-linear-gradient(-45deg, var(--line) 0 6px, transparent 6px 12px); }
.hide .word.open .mean { color: inherit; background: var(--bg); }

.top-actions { display: flex; align-items: center; gap: 2px; }
.toggle {
  padding: 5px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
}
.toggle:active { transform: translateY(2px); box-shadow: none; }
.toggle[aria-pressed='true'] { background: var(--lilac); color: var(--on-pastel); }
.mean small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.empty {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 70px 0 50px;
  color: var(--muted);
  text-align: center;
}
.empty-face {
  margin-bottom: 12px;
  padding: 10px 18px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--lilac);
  color: var(--on-pastel);
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 3px 0 var(--ink);
  animation: doze 3.2s ease-in-out infinite;
}
.empty p { margin: 0; color: var(--ink); font-family: var(--display); font-size: 24px; }

.pager { padding: 6px; }
.pg-btn {
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--peach);
  color: var(--on-pastel);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  transition: transform 0.12s, background 0.15s;
}
.pg-btn:active:not(:disabled) { transform: scale(0.88); }
.pg-btn:disabled { border-style: dashed; border-color: var(--muted); background: transparent; color: var(--muted); cursor: default; opacity: 0.6; }

.pg-count {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pg-count span { color: var(--muted); font-size: 14px; font-weight: 700; }
.pg-count input {
  width: 3.4ch;
  padding: 0;
  border: 0;
  border-bottom: 2.5px dashed var(--muted);
  background: none;
  font-family: var(--display);
  font-size: 24px;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}
.pg-count input::-webkit-inner-spin-button,
.pg-count input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pg-count input:focus { outline: none; border-bottom: 2.5px solid var(--coral); }

/* ───────── 편집 ───────── */

.edit { display: grid; gap: 22px; }
.edit-top { display: grid; grid-template-columns: 110px 1fr; gap: 20px; align-items: start; }
.cover-pick { display: grid; gap: 6px; cursor: pointer; text-align: center; }
.cover-pick .cover { margin: 0; }
.cover-hint { color: var(--coral-text); font-size: 12px; font-weight: 700; }
.fields { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; }
.field small { color: var(--coral-text); }
.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  transition: box-shadow 0.15s;
}
.field input:focus,
.field textarea:focus { outline: none; box-shadow: 0 0 0 5px var(--butter); }
.field textarea {
  min-height: 46dvh;
  resize: vertical;
  font-size: 16px; /* 16px 미만이면 iOS 가 포커스 때 확대한다 */
  line-height: 1.9;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.4px);
  background-size: 18px 18px;
  background-attachment: local;
}

.managed { color: var(--muted); font-size: 12px; font-style: normal; }
.managed code { padding: 1px 6px; border-radius: 6px; background: var(--line); color: var(--ink); }
.field textarea[readonly] { opacity: 0.75; }

.edit-actions { display: flex; justify-content: space-between; align-items: center; }
.danger { padding: 8px 0; border: 0; background: none; color: var(--muted); font-size: 13px; text-decoration: underline wavy; text-underline-offset: 4px; }

/* ───────── 퀴즈 ───────── */

.picks {
  display: flex;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 26px;
  padding: 4px var(--gutter) 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.picks::-webkit-scrollbar { display: none; }
.pick {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 8px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s;
}
.pick span { overflow: hidden; text-overflow: ellipsis; }
.pick small { padding: 0 7px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 11px; }
.pick:active { transform: translateY(3px); box-shadow: none; }
.pick[aria-pressed='true'] { background: var(--butter); color: var(--on-pastel); }
.pick[aria-pressed='true'] small { background: var(--card); color: var(--ink); }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode {
  display: grid;
  align-content: space-between;
  gap: 4px;
  min-height: 168px;
  padding: 18px;
  border: 2px solid var(--ink);
  border-radius: 26px;
  background: var(--peach);
  color: var(--on-pastel);
  text-align: left;
  box-shadow: var(--pop-lg);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.12s;
}
.mode.alt { background: var(--sky); transform: translateY(16px); }
.mode:active { box-shadow: 0 1px 0 var(--ink); }
.mode-face { margin-bottom: auto; font-size: 18px; font-weight: 700; }
.mode-jp { font-size: 20px; font-weight: 900; }
.mode-ko { font-family: var(--display); font-size: 17px; }

.notice { margin-top: 44px; padding: 14px 16px; border: 2px dashed var(--coral); border-radius: 18px; font-size: 14px; }

.quiz { display: grid; gap: 18px; padding-top: 8px; }
.q-top { display: flex; justify-content: space-between; align-items: center; }
.q-count { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.q-count b { color: var(--ink); font-family: var(--display); font-size: 22px; font-weight: 400; }
.q-progress { height: 14px; overflow: hidden; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); }
.q-progress i {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(-45deg, var(--butter) 0 8px, color-mix(in srgb, var(--butter) 60%, var(--coral)) 8px 16px);
  transition: width 0.4s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.q-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 220px;
  padding: 32px 20px;
  border: 2px solid var(--ink);
  border-radius: 28px;
  background: var(--card);
  box-shadow: var(--pop-lg);
  text-align: center;
}
.q-word { margin: 0; font-size: clamp(40px, 13vw, 58px); font-weight: 900; line-height: 1.2; }
/* 정답 풀이·다음 버튼은 처음부터 자리를 차지하고 보이기만 바뀐다 → 고를 때 아래가 밀리지 않음 */
.q-reveal { display: grid; gap: 2px; margin: 0; visibility: hidden; }
.done .q-reveal { visibility: visible; animation: pop-in 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.q-reveal .yomi { font-size: 16px; }
.q-reveal small { color: var(--muted); font-size: 12px; }

.stamp {
  position: absolute;
  top: -14px;
  right: 14px;
  padding: 4px 14px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sage);
  color: var(--on-pastel);
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--ink);
  transform: rotate(6deg);
}
.stamp.miss { background: var(--pink); transform: rotate(-6deg); }

.choices { display: grid; gap: 11px; }
.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background: var(--card);
  text-align: left;
  line-height: 1.45;
  box-shadow: var(--pop);
  transition: transform 0.12s, box-shadow 0.12s, background 0.2s, opacity 0.25s;
}
.choice .num {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.choice:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.choice:disabled { cursor: default; opacity: 0.45; box-shadow: none; transform: translateY(4px); }
.choice.right { opacity: 1; background: var(--sage); color: var(--on-pastel); box-shadow: var(--pop); transform: none; animation: bounce 0.45s cubic-bezier(0.3, 1.4, 0.5, 1); }
.choice.wrong { opacity: 1; background: var(--pink); color: var(--on-pastel); animation: shake 0.35s; }
.choice.right .num,
.choice.wrong .num { background: var(--card); color: var(--ink); }
.q-next { justify-self: center; min-width: 180px; transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1), box-shadow 0.12s; }
.quiz:not(.done) .q-next { visibility: hidden; opacity: 0; transform: translateY(8px); }

.result { padding-top: 34px; text-align: center; }
.result-face { margin: 0 0 6px; font-size: 26px; font-weight: 700; animation: bounce 0.6s; }
.score {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  padding: 18px 34px;
  border: 2px solid var(--ink);
  border-radius: 40px;
  background: var(--butter);
  color: var(--on-pastel);
  box-shadow: var(--pop-lg);
  transform: rotate(-2deg);
}
.score b { font-family: var(--display); font-size: 80px; font-weight: 400; line-height: 1; }
.score span { font-size: 22px; font-weight: 700; }
.score-msg { margin: 22px 0 26px; font-size: 17px; font-weight: 700; }
.result-actions { display: flex; justify-content: center; align-items: center; gap: 18px; }
.wrong-title { margin: 54px 0 6px; font-family: var(--display); font-size: 20px; font-weight: 400; text-align: left; }
.wrong-list { padding: 4px 20px; border: 2px solid var(--ink); border-radius: 24px; background: var(--card); text-align: left; }
.wrong-list .word { grid-template-columns: 1fr; grid-template-areas: 'jp' 'mean'; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.85); } }
@keyframes bounce { 40% { transform: translateY(-6px); } }
@keyframes shake { 25% { transform: translate(-5px, 4px); } 75% { transform: translate(5px, 4px); } }
@keyframes doze { 50% { transform: translateY(-4px) rotate(-2deg); } }

/* ───────── 앱처럼 ───────── */

/* 터치 기기에서 hover 가 눌린 채로 남지 않게 */
@media (hover: hover) {
  .primary:hover { transform: translateY(-2px); box-shadow: var(--pop-lg); }
  .text-btn:hover { color: var(--coral-text); }
  .book:hover .cover { transform: translateY(-6px) rotate(-2.5deg); }
  .book:nth-child(even):hover .cover { transform: translateY(-6px) rotate(2.5deg); }
  .book.add:hover .cover-add { border-color: var(--coral); color: var(--coral-text); box-shadow: none; }
  .link:hover { color: var(--coral-text); }
  .pg-btn:hover:not(:disabled) { background: var(--butter); }
  .cover-pick:hover .cover { transform: rotate(-3deg); }
  .danger:hover { color: var(--coral-text); }
  .mode:hover { transform: translateY(-4px) rotate(-1.5deg); }
  .mode.alt:hover { transform: translateY(12px) rotate(1.5deg); }
  .choice:hover:not(:disabled) { background: color-mix(in srgb, var(--butter) 35%, var(--card)); }
}

body { overscroll-behavior-y: none; }
button, a, label, .tabs, .pager { -webkit-user-select: none; user-select: none; touch-action: manipulation; }

.tabs { view-transition-name: tabs; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.22s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@media (min-width: 640px) {
  :root { --gutter: 32px; }
  .sheet { padding: 44px 36px 32px; }
  .word { grid-template-columns: 30px minmax(150px, 0.9fr) 1.1fr; grid-template-areas: 'idx jp mean'; align-items: end; }
  .mean { padding-bottom: 4px; }
}

/* 보이는 크기는 그대로, 누르는 영역만 44px 안팎으로 */
.toggle, .text-btn, .link, .danger { position: relative; }
.toggle::after, .text-btn::after, .danger::after { content: ''; position: absolute; inset: -8px 0; }
.link::after { content: ''; position: absolute; inset: -12px -4px; }
