.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 28px 22px;
  align-items: start;
}

.notebook-card {
  min-width: 0;
}

.cover {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4.15;
  border-radius: 3px 10px 10px 3px;
  background-color: var(--cover);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 34%),
    radial-gradient(rgba(73, 68, 62, 0.045) 0.5px, transparent 0.5px);
  background-size: auto, 4px 4px;
  box-shadow: 0 8px 18px rgba(73, 68, 62, 0.05);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 11px;
  background: rgba(73, 68, 62, 0.07);
}

.cover::after {
  content: "";
  position: absolute;
  inset: 10px 10px 10px 18px;
  border: 1px solid rgba(73, 68, 62, 0.12);
  pointer-events: none;
}

.notebook-card:hover .cover,
.notebook-card:focus-within .cover {
  transform: translateY(-3px);
  box-shadow: 0 12px 22px rgba(73, 68, 62, 0.08);
}

.cover-open:focus {
  outline: none;
}

.notebook-card:has(.cover-open:focus-visible) .cover {
  outline: 2px solid var(--sage-deep);
  outline-offset: 3px;
}

.cover-open {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 22px 16px 16px 26px;
  color: inherit;
  text-decoration: none;
}

.cover-plate {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  margin: 0;
  padding: 8px 4px;
  background: none;
}

.cover-title {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
}

.cover-meta {
  margin-top: auto;
  padding-top: 14px;
}

.cover-stats {
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.card-actions {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  margin-top: 8px;
}

.text-button {
  min-height: 44px;
  padding: 0 10px;
  color: var(--ink-soft);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.text-button:hover,
.text-button:focus,
.text-button:active {
  text-decoration: none;
}

.text-button:hover {
  color: var(--ink);
}

.back-link {
  display: inline-flex;
  align-items: center;
  align-self: center;
  min-height: 44px;
  padding: 0 8px;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #8d8174;
  font-size: 14px;
  line-height: 1;
  text-decoration: none;
}

.back-link:hover {
  background: rgba(141, 129, 116, 0.1);
  color: var(--ink);
  text-decoration: none;
}

.back-link:focus,
.back-link:active {
  text-decoration: none;
}

.cover-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1.5px dashed #c9c1b4;
  background: transparent;
  background-image: none;
  color: var(--ink-soft);
  box-shadow: none;
  cursor: pointer;
}

.cover-new::before,
.cover-new::after {
  display: none;
}

.cover-plus {
  font-family: var(--font-hand);
  font-size: 32px;
  line-height: 1;
}

.cover-new-label {
  font-size: 18px;
}

.cover-new:hover {
  border-color: var(--sage-deep);
  background: rgba(255, 254, 248, 0.82);
  color: var(--ink);
}

.notebook-card.is-new .cover {
  animation: rise-in 360ms ease;
}

.notebook-screen {
  width: min(1040px, 100%);
  margin: 8px auto 0;
}

.notebook-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.notebook-heading {
  flex: 1;
  min-width: 0;
  text-align: right;
}

.notebook-heading h2 {
  font-size: 32px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

#notebook-title:focus {
  outline: none;
}

.notebook-summary {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 13px;
}

.spread {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid #e6e0d4;
  border-radius: 8px;
  background: #f3efe6;
  box-shadow: 0 10px 28px rgba(73, 68, 62, 0.06);
}

.spread::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 2;
  width: 16px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, rgba(73, 68, 62, 0.05), rgba(255, 254, 248, 0) 46%, rgba(73, 68, 62, 0.055));
  pointer-events: none;
}

.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px 18px 6px;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(73, 68, 62, 0.03) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
}

.page-left {
  padding-right: 24px;
}

.page-right {
  padding-left: 24px;
  border-left: 1px solid #e7e2d6;
}

.page-head {
  display: block;
  width: 100%;
  min-width: 0;
  height: 32px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 32px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.word-lines {
  height: calc(var(--row-h) * 14);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-position: 0 0;
  background-size: var(--row-h) var(--row-h);
}

.word-line {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.2fr) minmax(4.5em, 0.9fr) auto;
  column-gap: 8px;
  align-items: center;
  height: var(--row-h);
  padding: 0 4px 0 2px;
}

.word-line.is-katakana {
  grid-template-columns: minmax(0, 1.15fr) minmax(4.5em, 0.9fr) minmax(4.5em, 0.9fr) auto;
}

.word-line.is-study {
  position: relative;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.45fr) minmax(0, 0.62fr);
}

.word-line.is-gloss-open,
.focus-sheet.is-gloss-open {
  z-index: 4;
}

.word-line.is-study .word-kanji[data-gloss-toggle],
.focus-prompt[data-gloss-toggle] {
  cursor: pointer;
}

.gloss-pop {
  position: absolute;
  z-index: 5;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 175px;
  height: 48px;
  padding: 4px 8px;
  border: 1px solid #efe6d8;
  border-radius: 6px;
  background: rgba(255, 252, 245, 0.96);
  box-shadow: 0 1px 3px rgba(73, 68, 62, 0.08);
  color: var(--ink);
  pointer-events: auto;
  overflow: hidden;
}

.gloss-pop-text {
  display: block;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.gloss-pop-text.is-scroll {
  align-self: stretch;
  height: 100%;
  overflow-y: auto;
}

.word-line .word-kanji { grid-column: 1; }
.word-line .word-reading { grid-column: 2; }
.word-line .line-gloss { grid-column: 3; }
.word-line .line-tools { grid-column: 4; }

.word-line.is-katakana .line-gloss { grid-column: 2; }
.word-line.is-katakana .line-origin { grid-column: 3; }

.word-line.is-study .word-kanji {
  display: flex;
  align-items: center;
  overflow: hidden;
  -webkit-line-clamp: unset;
}

.word-line.is-study .word-reading {
  grid-column: 2;
  width: 100%;
  min-width: 0;
}
.word-line.is-study .answer-tools {
  grid-column: 3;
  min-width: 0;
  max-width: 100%;
}

.line-gloss,
.line-origin {
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: #8d8174;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.15;
}

.line-origin {
  font-family: var(--font-hand);
}

.vocab-translation,
.vocab-translation .gloss-input {
  font-family: var(--font-zh);
  font-weight: 400;
}

.line-gloss.has-gloss-view {
  position: relative;
  min-height: 22px;
  max-height: 100%;
}

.gloss-view {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-width: 0;
  max-height: 100%;
  overflow: hidden;
  font: inherit;
  line-height: 1.15;
  white-space: normal;
  pointer-events: none;
}

.gloss-line {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.line-gloss.is-concealed,
.line-origin.is-concealed {
  visibility: hidden;
  pointer-events: none;
}

.gloss-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 22px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  color: #8d8174;
  font: inherit;
  font-weight: 400;
  line-height: 22px;
  white-space: nowrap;
  text-overflow: ellipsis;
  caret-color: var(--ink);
}

.line-gloss.has-gloss-view .gloss-input {
  position: absolute;
  inset: 0;
  height: auto;
  margin: 0;
  opacity: 0;
}

.line-gloss.has-gloss-view .gloss-input:focus {
  height: 22px;
  margin: auto 0;
  opacity: 1;
}

.line-gloss.has-gloss-view:focus-within .gloss-view {
  visibility: hidden;
}

.gloss-input:focus {
  overflow: auto;
  background: rgba(168, 185, 165, 0.18);
  box-shadow: inset 0 -1px 0 rgba(73, 68, 62, 0.22);
  text-overflow: clip;
}

.practice-prompt {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.practice-meaning,
.practice-origin {
  overflow: hidden;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.practice-meaning {
  color: #8d8174;
  font-size: 15px;
}

.practice-origin {
  color: #a3988c;
  font-size: 13px;
}

.gloss-action {
  flex: none;
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #8d8174;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.word-kanji,
.word-reading {
  display: -webkit-box;
  overflow: hidden;
  min-width: 0;
  font-size: 22px;
  line-height: 1.25;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.word-reading:has(.answer-field),
.word-kanji:has(.paper-field),
.word-reading:has(.paper-field) {
  display: flex;
  align-items: center;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.paper-field {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  vertical-align: middle;
}

.paper-input {
  box-sizing: border-box;
  display: inline-block;
  max-width: 100%;
  margin: 0;
  padding: 0 1px;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: inherit;
  line-height: 1.15;
  white-space: nowrap;
  text-overflow: ellipsis;
  caret-color: var(--ink);
}

.paper-input:focus {
  outline: none;
  overflow: auto;
  background: rgba(168, 185, 165, 0.22);
  box-shadow: inset 0 -1px 0 rgba(73, 68, 62, 0.28);
  text-overflow: clip;
}

.paper-input.is-invalid {
  box-shadow: inset 0 -1px 0 #e0a8b6;
}

.reading-suggest {
  flex: none;
  margin-left: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #b3a89c;
  font-family: var(--font-hand);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

.reading-suggest.is-prompt {
  pointer-events: none;
}

.line-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  width: 52px;
  gap: 2px;
}

.note-slot {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: none;
}

.note-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  background: var(--sage-deep);
  cursor: pointer;
}

.row-more {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
}

.word-line:hover .row-more,
.word-line:focus-within .row-more,
.row-more[aria-expanded="true"] {
  opacity: 1;
}

.row-popover,
.note-popover,
.note-tip {
  position: fixed;
  z-index: 40;
}

.row-popover,
.note-popover {
  padding: 6px;
  border: 1px solid var(--milk);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(73, 68, 62, 0.08);
}

.row-popover {
  width: 168px;
}

.row-popover-item {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.row-popover-item:hover,
.row-popover-item:focus-visible {
  background: var(--bg);
}

.note-popover-label {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
}

.note-popover-input {
  display: block;
  width: 220px;
  max-width: 70vw;
  min-height: 72px;
  margin-top: 4px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  outline: none;
  background: rgba(168, 185, 165, 0.16);
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 16px;
  resize: vertical;
}

.note-tip {
  max-width: 220px;
  padding: 6px 8px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.word-actions,
.answer-tools {
  display: flex;
  gap: 0;
}

.word-actions {
  justify-content: flex-end;
}

.answer-tools {
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  overflow: hidden;
}

.word-actions .text-button,
.answer-tools .text-button {
  min-height: 28px;
  max-width: 100%;
  padding: 0 4px;
  overflow: hidden;
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.answer-field {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.reading-input {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 0 2px;
  border: 0;
  border-bottom: 1.5px solid #d4cdc2;
  border-radius: 0;
  background: transparent;
  font-family: var(--font-hand);
  font-size: 16px;
  line-height: 1.3;
  pointer-events: auto;
}

.reading-input:focus {
  outline: none;
  border-bottom-color: var(--ink-soft);
}

.reading-input.is-correct {
  background: #e7f3e4;
  border-bottom-color: #8fb58a;
}

.reading-input.is-incorrect {
  background: #f8e4ea;
  border-bottom-color: #e0a8b6;
}

.judge {
  flex: none;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
}

.answer-field .judge {
  position: absolute;
  top: 50%;
  right: 4px;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateY(-50%);
}

.judge.is-correct {
  color: #4f7d4a;
}

.judge.is-incorrect {
  color: #9a5564;
}

.revealed {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.25;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.mark {
  position: relative;
  z-index: 0;
  isolation: isolate;
}

.mark::before {
  content: "";
  position: absolute;
  right: -4px;
  bottom: 0.04em;
  left: -4px;
  z-index: -1;
  height: 0.68em;
  border-radius: 0;
  pointer-events: none;
  transform: rotate(-0.4deg);
  transform-origin: center;
  clip-path: polygon(
    4px 16%,
    36% 10%,
    calc(100% - 3px) 14%,
    calc(100% - 1px) 86%,
    64% 92%,
    1px 84%
  );
}

.paper-field.mark .paper-input,
.mark {
  position: relative;
}

.paper-field.mark .paper-input {
  z-index: 1;
}

.mark[data-ink="1"]::before {
  height: 0.64em;
  bottom: 0.06em;
  transform: rotate(0.35deg);
  clip-path: polygon(
    3px 14%,
    48% 8%,
    calc(100% - 4px) 16%,
    calc(100% - 1px) 84%,
    52% 94%,
    0 88%
  );
}

.mark[data-ink="2"]::before {
  height: 0.7em;
  bottom: 0.02em;
  transform: rotate(-0.2deg);
  clip-path: polygon(
    5px 18%,
    32% 10%,
    calc(100% - 2px) 14%,
    calc(100% - 1px) 88%,
    68% 94%,
    1px 86%
  );
}

.mark[data-ink="3"]::before {
  height: 0.62em;
  bottom: 0.08em;
  transform: rotate(0.5deg);
  clip-path: polygon(
    3px 12%,
    44% 8%,
    calc(100% - 4px) 16%,
    100% 82%,
    46% 92%,
    1px 86%
  );
}

.mark-yellow::before {
  background: rgba(224, 184, 68, 0.5);
}

.mark-pink::before {
  background: rgba(212, 138, 160, 0.48);
}

.mark-green::before {
  background: rgba(124, 172, 134, 0.5);
}

.mark.is-fresh::before {
  animation: mark-in 420ms ease;
}

.page-number {
  display: flex;
  align-items: center;
  height: 32px;
  color: var(--ink-soft);
  font-size: 16px;
}

.page-left .page-number {
  justify-content: flex-start;
  padding-left: 4px;
}

.page-right .page-number {
  justify-content: flex-end;
  padding-right: 4px;
}

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.pager .btn:first-child {
  justify-self: start;
}

.pager .btn:last-child {
  justify-self: end;
}

.pager-status {
  min-width: 4.5ch;
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-size: 18px;
  text-align: center;
}

.pager-jump {
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.pager-jump:hover,
.pager-jump:focus-visible,
.pager-jump[aria-expanded="true"] {
  background: rgba(168, 185, 165, 0.28);
  color: var(--ink);
}

.page-jump {
  position: fixed;
  z-index: 45;
  width: min(220px, calc(100vw - 16px));
  padding: 12px;
  border: 1px solid var(--milk);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 10px 24px rgba(73, 68, 62, 0.08);
}

.page-jump-title {
  margin: 0 0 8px;
  font-size: 18px;
  text-align: center;
}

.page-jump-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(73, 68, 62, 0.18);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  text-align: center;
}

.page-jump-total,
.page-jump-error {
  margin: 6px 0 0;
  font-size: 13px;
  text-align: center;
}

.page-jump-total {
  color: var(--ink-soft);
}

.page-jump-error {
  color: #6f4550;
}

.page-jump-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.notebook-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: -4px 0 12px;
}

.notebook-transfer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.tool-status {
  flex: 1 0 100%;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
}

.is-pen-mode .notebook-tools {
  margin-top: 36px;
}

.pen-wrap {
  position: relative;
  flex: none;
}

.lock-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #e4ddd2;
  border-radius: 10px;
  background: var(--paper);
  color: #6d7b6a;
  cursor: pointer;
}

.lock-toggle.is-locked {
  background: #f3f6f1;
  border-color: #d5e0d2;
}

.pen-toggle {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #e4ddd2;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.pen-toggle.is-active {
  background: var(--yellow);
  border-color: #e6d98a;
}

.notebook-screen.is-pen-mode {
  --pen-cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path d='M19 3l9 9-12 12H8V15L19 3z' fill='%23F3E2A0' stroke='%2349443E' stroke-width='1.3' stroke-linejoin='round'/><path d='M8 24L4 31l8-5z' fill='%23D4B85A'/></svg>") 4 30, auto;
}

.notebook-screen.is-pen-mode[data-pen="pink"] {
  --pen-cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path d='M19 3l9 9-12 12H8V15L19 3z' fill='%23F3C9D4' stroke='%2349443E' stroke-width='1.3' stroke-linejoin='round'/><path d='M8 24L4 31l8-5z' fill='%23D48AA0'/></svg>") 4 30, auto;
}

.notebook-screen.is-pen-mode[data-pen="green"] {
  --pen-cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><path d='M19 3l9 9-12 12H8V15L19 3z' fill='%23CFE0CF' stroke='%2349443E' stroke-width='1.3' stroke-linejoin='round'/><path d='M8 24L4 31l8-5z' fill='%238FB08F'/></svg>") 4 30, auto;
}

.notebook-screen.is-pen-mode .word-line.is-study .word-kanji,
.notebook-screen.is-pen-mode .word-line.is-study .word-kanji *,
.notebook-screen.is-pen-mode .word-line.has-word .word-kanji,
.notebook-screen.is-pen-mode .word-line.has-word .word-kanji *,
.notebook-screen.is-pen-mode .word-line.has-word:not(:has(.reading-input)) .word-reading,
.notebook-screen.is-pen-mode .word-line.has-word:not(:has(.reading-input)) .word-reading *,
.notebook-screen.is-pen-mode .focus-prompt,
.notebook-screen.is-pen-mode .focus-prompt *,
.notebook-screen.is-pen-mode .practice-prompt,
.notebook-screen.is-pen-mode .practice-prompt * {
  cursor: var(--pen-cursor);
}

.pen-palette {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 8px 10px;
  border: 1px solid var(--milk);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 8px 20px rgba(73, 68, 62, 0.08);
}

.pen-choice {
  box-sizing: border-box;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1 / 1;
  flex: none;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid rgba(73, 68, 62, 0.12);
  border-radius: 50%;
  cursor: pointer;
}

.pen-choice[data-tool="yellow"] { background: #f3e2a0; }
.pen-choice[data-tool="pink"] { background: #f3c9d4; }
.pen-choice[data-tool="green"] { background: #cfe0cf; }

.pen-choice.is-selected {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.focus-sheet {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 460px;
  padding: 28px 20px;
}

.focus-count {
  color: var(--ink-soft);
  font-family: var(--font-hand);
  font-size: 16px;
}

.focus-kanji {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  font-size: 48px;
  line-height: 1.3;
  text-align: center;
}

.focus-prompt {
  display: inline-block;
  max-width: 100%;
}

.focus-gloss {
  width: min(320px, 100%);
  height: 2.4em;
  margin: 8px 0 0;
  overflow: hidden;
  color: #8d8174;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
}

.focus-gloss.is-concealed {
  visibility: hidden;
}

.focus-input {
  width: min(280px, 100%);
  font-size: 22px;
  text-align: center;
}

.focus-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(280px, 100%);
  max-width: 100%;
}

.focus-field .answer-field,
.focus-field .focus-input {
  width: 100%;
}

.focus-reveal {
  max-width: 100%;
  border: 1px solid var(--milk);
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
}

.focus-reveal:hover {
  background: #fff;
}

.focus-expected {
  margin: 0;
  max-width: 100%;
  color: #4f7d4a;
  font-size: 16px;
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.focus-expected .hand,
.focus-expected .vocab-translation {
  color: var(--ink);
}

.focus-field .judge {
  min-height: 1em;
  text-align: center;
}

.focus-field .judge:empty {
  display: none;
}

.result-panel {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--paper);
}

.result-line {
  font-size: 18px;
}

@keyframes turn-next {
  from { opacity: 0.55; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes turn-prev {
  from { opacity: 0.55; transform: translateX(-10px); }
  to { opacity: 1; transform: none; }
}

.is-turning-next .page { animation: turn-next 280ms ease; }
.is-turning-prev .page { animation: turn-prev 280ms ease; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes mark-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
