@font-face {
  font-family: "Figtree";
  src: url("assets/fonts/figtree-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("assets/fonts/figtree-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "EditorialSerif";
  src: url("assets/fonts/editorial-serif-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F8F8F8;
  --sand: #EFECE6;
  --book-well: #FFFFFF;
  --paper: #FFFFFF;
  --jp-font: "IBM Plex Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  --ink: #18181C;
  --ink-2: #3E3E48;
  --ink-3: #565662;
  --fill-1: #F2F3F7;
  --fill-2: #E5E7EF;
  --fill-3: #C9CCD6;
  --input-border: #969AA6;
  --rule: rgba(24, 24, 28, 0.10);

  --jp: #DF4034;
  --jp-fill: #C8352B;
  --jp-hover: #B42C22;
  --jp-text: #B6281F;
  --jp-bg: #FDECE9;

  --subj-jp: #C8352B;
  --subj-sogo: #524A42;
  --subj-sci: #0E5A3E;
  --subj-math1: #1464A5;
  --subj-math2: #3730A3;

  --cover-jp-sub: #FFEAE7;
  --cover-sogo-sub: #F2ECE4;
  --cover-sci-sub: #E4F5EC;
  --cover-math1-sub: #E6F2FC;
  --cover-math2-sub: #ECEEFF;

  --ok: #167943;
  --ok-bg: #E8F6EE;
  --insight: #FAF4E6;
  --insight-ink: #665327;
  --amber-ink: #845205;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-row: 0 1px 2px rgba(40, 40, 43, 0.03), 0 8px 20px -12px rgba(40, 40, 43, 0.10);
  --shadow-plate: 0 1px 2px rgba(40, 40, 43, 0.03), 0 16px 34px -10px rgba(40, 40, 43, 0.06), 0 28px 54px -18px rgba(40, 40, 43, 0.08);
  --shadow-pop: 0 4px 12px rgba(18, 20, 28, 0.08), 0 20px 44px -12px rgba(18, 20, 28, 0.22);
  --sans: "Figtree", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "EditorialSerif", "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;
  --font-ja: "Figtree", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  color-scheme: light;
}

[data-subj-theme="日本語"] {
  --cover-bg: var(--subj-jp);
  --cover-sub: var(--cover-jp-sub);
  --subj-accent: var(--subj-jp);
}
[data-subj-theme="総合科目"] {
  --cover-bg: var(--subj-sogo);
  --cover-sub: var(--cover-sogo-sub);
  --subj-accent: var(--subj-sogo);
}
[data-subj-theme="理科"] {
  --cover-bg: var(--subj-sci);
  --cover-sub: var(--cover-sci-sub);
  --subj-accent: var(--subj-sci);
}
[data-subj-theme="数学"] {
  --cover-bg: var(--subj-math1);
  --cover-sub: var(--cover-math1-sub);
  --subj-accent: var(--subj-math1);
}
[data-subj-theme="数学2"] {
  --cover-bg: var(--subj-math2);
  --cover-sub: var(--cover-math2-sub);
  --subj-accent: var(--subj-math2);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--fill-3) var(--bg);
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--fill-3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-3); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.6 var(--sans);
  caret-color: var(--jp-fill);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
img { display: block; max-width: 100%; height: auto; }
[lang="ja"] { font-family: var(--font-ja); }
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: rgba(200, 53, 43, 0.16); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 8px; }

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip {
  position: absolute;
  left: -999px;
  top: 10px;
  z-index: 120;
  background: var(--ink);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 700;
}
.skip:focus { left: 16px; }

/* ═══════════ Single-Level Top Header ═══════════ */
.mock-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
body[data-screen="runner"] :is(.brand-link, #open-auth-btn, #course-switch) {
  display: none;
}
body[data-screen="mistakes"] #course-switch {
  display: none;
}
.mock-header-inner {
  max-width: 1320px;
  margin: 0 auto;
  min-height: 54px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1 1 auto;
}
.brand-link {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 4px 2px;
}
.brand-div {
  width: 1px;
  height: 15px;
  background: var(--rule);
}
.brand-desk {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

/* Single-Button 文科/理科 Course Toggle */
.btn-course-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
@media (hover: hover) {
  .btn-course-toggle:hover { background: #2A2A32; }
}

/* Merged Single-Bar Runner Controls */
.runner-head-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.btn-ghost-sm {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
@media (hover: hover) {
  .btn-ghost-sm:hover { background: var(--fill-2); color: var(--ink); }
}

.runner-title-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.runner-title-meta strong {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mode-badge {
  flex: none;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--insight);
  color: var(--insight-ink);
  font-size: 12px;
  font-weight: 700;
}
.mode-badge.is-mock { background: var(--jp-bg); color: var(--jp-text); }
.mode-badge.is-review { background: var(--ok-bg); color: var(--ok); }
.mode-badge.is-drill { background: #E9F0FA; color: #145A9E; }
.mode-badge.is-mistake { background: var(--jp-bg); color: var(--jp-text); }

.sec-tabs {
  display: flex;
  align-items: stretch;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 0 1 auto;
  flex-wrap: nowrap;
}
.sec-tabs::-webkit-scrollbar { display: none; }
.sec-tabs button {
  position: relative;
  flex: none;
  min-height: 53px;
  padding: 0 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.sec-tabs button[aria-selected="true"] { color: var(--ink); }
.sec-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 8px 0;
  border-block-end: 2.5px solid var(--jp-fill);
}

.header-right {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
.runner-controls {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.timer-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--fill-1);
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.timer-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}
.timer-pill.is-warning { background: var(--jp-bg); color: var(--jp-text); }
.timer-pill.is-warning .timer-dot { background: var(--jp); }

.btn-tool-pill,
.btn-runner-prefs,
.btn-hdr-vocab,
.btn-hdr-auth {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-hdr-vocab,
.btn-hdr-auth {
  border-radius: 999px;
  padding: 0 12px;
}
body[data-screen="runner"] .btn-hdr-mistakes { display: none; }
body[data-screen="runner"] .btn-hdr-essays { display: none; }
.btn-hdr-essays.has-essays {
  background: #EDF4FC;
  color: #13468E;
}
.btn-hdr-essays.has-essays .vocab-count {
  background: #13468E;
  color: #FFFFFF;
}
.btn-hdr-mistakes.has-pending {
  background: #FFF2F0;
  color: var(--jp-text);
}
.btn-hdr-mistakes.has-pending .vocab-count {
  background: var(--jp-fill);
  color: #FFFFFF;
}
.btn-tool-pill[aria-pressed="true"] {
  background: var(--ink);
  color: #FFFFFF;
}
.draft-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--jp);
}
@media (hover: hover) {
  .btn-tool-pill:hover,
  .btn-runner-prefs:hover,
  .btn-hdr-vocab:hover,
  .btn-hdr-auth:hover { background: var(--fill-2); }
  .btn-tool-pill[aria-pressed="true"]:hover { background: #2A2A32; }
}

/* Mojitest-Style Prominent Quick-Jump Button */
.btn-palette-hero {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
@media (hover: hover) {
  .btn-palette-hero:hover { background: var(--ink); color: #FFFFFF; }
  .btn-palette-hero:hover .palette-stat { color: #FFFFFF; }
}
.palette-stat { color: var(--jp-text); font-weight: 700; }

.vocab-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.btn-hdr-auth.is-authed {
  padding-inline: 6px 11px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(24, 24, 28, 0.14);
}
.hdr-avatar {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  overflow: clip;
  flex: none;
  display: inline-grid;
  place-items: center;
}
.hdr-avatar[hidden] { display: none !important; }
.hdr-avatar svg, .hdr-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.btn-hdr-submit {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--jp-fill);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
@media (hover: hover) {
  .btn-hdr-submit:hover { background: var(--jp-hover); }
}

/* ═══════════ Reader Prefs & Palette Popovers ═══════════ */
.runner-prefs-pop[popover] {
  position: fixed;
  top: calc(58px + env(safe-area-inset-top, 0px));
  right: max(14px, calc((100vw - 1320px) / 2 + 24px));
  left: auto;
  bottom: auto;
  margin: 0;
  padding: 16px 18px;
  width: min(312px, calc(100dvw - 24px));
  max-height: min(76dvh, 480px);
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.runner-prefs-pop:is(:popover-open, .\:popover-open) {
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pref-lbl {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.pref-sep {
  height: 1px;
  background: var(--rule);
}

.seg-mini {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: var(--fill-1);
}
.seg-mini button {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.seg-mini button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(40, 40, 43, 0.08);
}

/* EJU Switch (App-Parity Toggle) */
.eju-switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--fill-2);
  transition: background-color 0.16s ease;
}
.eju-switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s var(--ease);
}
.eju-switch[aria-checked="true"] { background: var(--jp-fill); }
.eju-switch[aria-checked="true"]::after { transform: translateX(18px); }

/* Tethered Mojitest-Style Quick-Jump Popover */
.palette-pop[popover] {
  position: fixed;
  top: calc(58px + env(safe-area-inset-top, 0px));
  right: max(10px, calc((100vw - 1320px) / 2 + 24px));
  left: auto;
  bottom: auto;
  margin: 0;
  padding: 16px 18px 18px;
  width: min(392px, calc(100dvw - 20px));
  max-height: min(74dvh, 520px);
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overscroll-behavior: contain;
}
.palette-pop:is(:popover-open, .\:popover-open) { display: block; }
.pal-pop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.pal-pop-head strong { font-size: 15px; font-weight: 700; color: var(--ink); }
.pal-pop-stat { font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.palette-body { margin-top: 14px; display: flex; flex-direction: column; gap: 16px; }
.pal-sec-row { display: flex; flex-direction: column; gap: 8px; }
.pal-sec-label { margin: 0; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
.pal-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pal-cell {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--fill-2);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
@media (hover: hover) {
  .pal-cell:hover { border-color: var(--ink); color: var(--ink); }
}
.pal-cell.is-done { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.pal-cell.is-current { border-color: var(--jp); color: var(--jp-text); background: #FFF2F0; box-shadow: 0 0 0 2px rgba(223, 64, 52, 0.16); }
.pal-cell.is-current.is-done { background: var(--jp-fill); border-color: var(--jp-fill); color: #FFFFFF; }
.pal-cell.is-right { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.pal-cell.is-wrong { background: var(--jp-bg); border-color: var(--jp); color: var(--jp-text); }

/* ═══════════ View 1: Redesigned Hub (Shelf + Ticket + Right Data Stack) ═══════════ */
.view-hub {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px 72px;
}
#hub-h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.15;
}

.hub-right-rail {
  grid-column: 2;
  grid-row: 1;
  position: sticky;
  top: 68px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  z-index: 2;
}
.study-plate {
  background: var(--paper);
  border: 1px solid rgba(24, 24, 28, 0.08);
  border-radius: 18px;
  padding: 12px 16px;
  box-shadow: var(--shadow-row);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.insights-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.insights-tabs {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: var(--fill-1);
}
.insights-tabs button {
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
  white-space: nowrap;
}
.insights-tabs button[aria-selected="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.08);
}
.insights-topic-ctrl {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.insights-topic-ctrl .btn-deck-ghost {
  white-space: nowrap;
  flex: none;
  padding: 0 4px;
  font-size: 12px;
}
.pro-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 5px;
  border-radius: 6px;
  background: #F6DC8C;
  color: #5E4303;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  flex: none;
}
.btn-scores-entry,
.btn-topic-win {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  flex: none;
}
@media (hover: hover) {
  .btn-scores-entry:hover,
  .btn-topic-win:hover {
    background: var(--fill-1);
    color: var(--ink);
  }
}
.topic-win-pop,
.year-filter-pop {
  position: fixed;
  inset: auto;
  margin: 0;
  padding: 6px;
  min-width: 144px;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  box-shadow: var(--shadow-pop);
  color: var(--ink);
  z-index: 40;
}
.topic-win-pop:popover-open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topic-win-pop button {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 9px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topic-win-pop button[aria-checked="true"] {
  background: var(--fill-1);
  color: var(--ink);
  font-weight: 700;
}
.topic-win-pop button.is-danger {
  color: var(--jp-text);
}
@media (hover: hover) {
  .topic-win-pop button:hover { background: var(--fill-1); }
}
.pop-sep {
  height: 1px;
  background: var(--rule);
  margin: 4px 2px;
}
.insights-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.insights-panel[hidden] { display: none; }
.trend-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 24px;
}

/* Graphical Score Trend Card */
.trend-series-seg {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--fill-1);
}
.trend-series-seg[hidden] { display: none; }
.trend-series-seg button {
  flex: 1 1 0;
  min-height: 25px;
  padding: 0 6px;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-align: center;
}
.trend-series-seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.08);
}
.trend-series-seg:has(> button:only-child) {
  width: fit-content;
  background: transparent;
  padding: 0;
}
.trend-series-seg:has(> button:only-child) button {
  flex: 0 0 auto;
  min-height: 22px;
  padding: 0 9px;
  border-radius: 6px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 11.5px;
  box-shadow: none;
}
.trend-series-pill {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}
.trend-win-seg button {
  min-height: 24px;
  padding: 0 7px;
  font-size: 11.5px;
}
.trend-meta-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.trend-score-big {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.trend-score-unit {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  margin-left: 2px;
}
.trend-delta-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.trend-delta.is-up { color: var(--ok); }
.trend-delta.is-down { color: var(--jp-text); }
.trend-chart-wrap {
  position: relative;
  width: 100%;
  padding: 8px 10px 6px;
  border-radius: 12px;
  background: #F8F8FA;
  border: 1px solid rgba(24, 24, 28, 0.05);
}
.trend-svg {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 340 / 88;
  overflow: visible;
}
.trend-empty-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%);
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--rule);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  pointer-events: none;
}
.trend-empty-cap {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  text-align: center;
}
.trend-tooltip {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 3px 8px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}

/* Mistake Distribution Bar & Mini Topic Bars */
.mistake-dist-bar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 10px;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: var(--fill-1);
}
.mistake-dist-seg {
  min-width: 6px;
  height: 100%;
}
.mistake-dist-seg:first-child { border-radius: 6px 0 0 6px; }
.mistake-dist-seg:last-child { border-radius: 0 6px 6px 0; }
.mistake-dist-seg:only-child { border-radius: 6px; }

/* Free-User Plus Lock Card (No Weak-Point Leakage) */
.tag-lock-card {
  padding: 12px 13px;
  border-radius: 12px;
  background: var(--fill-1);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.tag-lock-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.tag-lock-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lock-ghost-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.lock-ghost-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--fill-2);
}
.lock-ghost-dot {
  width: 28px;
  height: 7px;
  border-radius: 999px;
  background: var(--fill-2);
  margin-left: auto;
}
.btn-lock-upgrade {
  align-self: flex-start;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 700;
}

/* Mistake Book Top Visualization Card */
.mistakes-viz-card {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.mv-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
}
.mv-stat strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-right: 4px;
}
.mv-stat span {
  font-size: 12.5px;
  color: var(--ink-3);
}
.mv-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--ink-2);
  font-weight: 600;
}
.mv-leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.mv-leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sp-title-grp {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.sp-title-grp h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.deck-pill {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.deck-pill.is-alert { background: var(--jp-bg); color: var(--jp-text); }
.sp-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.btn-deck-ghost {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 700;
}
.btn-deck-accent {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--jp-fill);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 700;
}
@media (hover: hover) {
  .btn-deck-ghost:hover { background: var(--fill-2); }
  .btn-deck-accent:hover { background: var(--jp-hover); }
}

.sp-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.sp-muted {
  margin: 0;
  font-size: 13px;
  color: var(--ink-3);
}
.sp-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}
.sp-chip strong { color: var(--ink); font-weight: 700; }
.sp-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.sp-preview-line {
  margin: 0;
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.sp-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
}
.sp-tag-pill em {
  font-style: normal;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--jp-text);
}
.sp-tag-pill.is-catalog em { color: var(--ink-3); }
@media (hover: hover) {
  .sp-tag-pill:hover { background: var(--fill-2); }
}

/* Course Subject Tablist + Filter Row in Hub */
.hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.subj-tabs {
  display: flex;
  align-items: stretch;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
  min-width: 0;
}
.subj-tabs::-webkit-scrollbar { display: none; }
.subj-tabs button {
  position: relative;
  flex: none;
  min-height: 44px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.subj-tabs button[data-subj="日本語"] { --tab-accent: var(--subj-jp); }
.subj-tabs button[data-subj="総合科目"] { --tab-accent: var(--subj-sogo); }
.subj-tabs button[data-subj="理科"] { --tab-accent: var(--subj-sci); }
.subj-tabs button[data-subj="数学"] { --tab-accent: var(--subj-math1); }
.subj-tabs button[data-subj="数学2"] { --tab-accent: var(--subj-math2); }
@media (hover: hover) {
  .subj-tabs button:hover { color: var(--ink); }
}
.subj-tabs button[aria-selected="true"] {
  color: var(--tab-accent, var(--ink));
  font-weight: 700;
}
.subj-tabs button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 8px -1px;
  border-block-end: 2.5px solid var(--tab-accent, var(--ink));
}

.hub-filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: nowrap;
}
.status-filter {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--fill-1);
}
.status-filter button {
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.status-filter button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.08);
}
.btn-year-filter {
  flex: none;
  min-height: 34px;
  min-width: 34px;
  padding: 0 9px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.04);
}
.btn-year-filter.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
@media (hover: hover) {
  .btn-year-filter:not(.is-active):hover {
    border-color: rgba(24, 24, 28, 0.22);
    color: var(--ink);
  }
}
.year-filter-pop {
  width: 248px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}
.year-filter-pop:popover-open {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.year-pop-opt {
  min-height: 32px;
  padding: 0 6px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.year-pop-opt.is-all {
  grid-column: 1 / -1;
}
.year-pop-opt[aria-checked="true"] {
  background: var(--ink);
  color: #FFFFFF;
  font-weight: 700;
}
@media (hover: hover) {
  .year-pop-opt:not([aria-checked="true"]):hover { background: var(--fill-1); color: var(--ink); }
}

.hub-desk-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  grid-template-rows: auto;
  align-items: start;
  gap: 18px 28px;
}

.shelf-col { grid-column: 1; grid-row: 1; min-width: 0; }
.shelf-section + .shelf-section { margin-top: 26px; }
.shelf-h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  text-wrap: balance;
}
.free-shelf-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.archive-shelf-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.booklet-tile {
  width: 100%;
  padding: 15px 16px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.booklet-tile.is-free-spot { padding: 18px 20px; }
@media (prefers-reduced-motion: no-preference) {
  .booklet-tile { transition: transform 0.16s var(--ease), box-shadow 0.16s var(--ease), border-color 0.16s; }
  .subj-tabs button, .sec-tabs button, .btn-hdr-vocab, .btn-hdr-auth, .btn-hdr-submit { transition: background-color 0.14s, color 0.14s; }
}
@media (hover: hover) {
  .booklet-tile:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-row);
    border-color: rgba(24, 24, 28, 0.22);
  }
}
.booklet-tile.is-doing {
  border-color: rgba(180, 122, 16, 0.48);
  background: linear-gradient(180deg, rgba(250, 244, 230, 0.42), var(--paper) 65%);
}
.booklet-tile[aria-pressed="true"] {
  border-color: var(--subj-accent);
  box-shadow: inset 0 0 0 1.5px var(--subj-accent), var(--shadow-row);
}

.bt-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
}
.bt-yr-grp { display: flex; align-items: baseline; gap: 7px; min-width: 0; padding-top: 2px; }
.bt-year { font-size: 20px; font-weight: 700; line-height: 1.05; letter-spacing: -0.025em; color: var(--ink); }
.booklet-tile.is-free-spot .bt-year { font-size: 26px; }
.bt-round { font-size: 13.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

.bt-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.bt-pill.is-free-neutral { background: var(--fill-1); color: var(--ink-2); }
.bt-pill.is-plus { background: var(--fill-1); color: var(--ink-3); font-weight: 600; }

/* Teacher's Red Grading Score & Seal Practice Mark */
.bt-score-mark {
  flex: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0 2px;
  line-height: 1;
  transform: rotate(-4deg);
  transform-origin: center;
  user-select: none;
}
.bt-score-num {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 700;
  font-size: 20px;
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--jp);
  font-variant-numeric: tabular-nums;
}
.booklet-tile.is-free-spot .bt-score-num { font-size: 22px; }
.bt-score-strokes {
  display: block;
  width: 100%;
  min-width: 36px;
  height: 7px;
  margin-top: 2px;
  color: var(--jp);
  overflow: visible;
}
.bt-practice-mark {
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(215, 57, 43, 0.72);
}
.bt-sub-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--ink-3);
}
.bt-sub-state.is-practiced { color: var(--jp-text); }
.bt-sub-state.is-doing { color: #9E6800; }
.bt-sub-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #B98114;
  flex: none;
}

.bt-sub { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 28px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); }

.shelf-empty-state {
  margin-top: 20px;
  padding: 28px 20px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--rule);
  text-align: center;
}
.shelf-empty-state p { margin: 0 0 12px; font-size: 14px; color: var(--ink-2); }
.btn-secondary-sm {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) {
  .btn-secondary-sm:hover { background: var(--fill-2); }
}

/* Right Zone Top: Authentic EJU+ Exam Cover Ticket */
.cover-ticket {
  border-radius: 22px;
  background: var(--paper);
  border: 1px solid rgba(24, 24, 28, 0.06);
  box-shadow: var(--shadow-plate);
  overflow: hidden;
}
.ticket-cover {
  background: var(--cover-bg, var(--subj-jp));
  color: #FFFFFF;
  padding: 22px 24px 20px;
}
.ticket-cover-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ticket-heading { margin: 0; display: flex; align-items: baseline; gap: 10px; font-size: 52px; font-weight: 700; line-height: 0.96; color: #FFFFFF; }
.ticket-year { font-size: 52px; font-weight: 700; line-height: 0.96; letter-spacing: -0.035em; }
.ticket-round { font-size: 18px; font-weight: 700; line-height: 1.2; }
.ticket-badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(24, 24, 28, 0.24);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
}
@media (hover: hover) {
  .ticket-record-btn:hover { background: rgba(24, 24, 28, 0.36); }
}
.sr-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.sr-stat-box {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--fill-1);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sr-stat-box span { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.sr-stat-box strong { font-size: 20px; font-weight: 700; color: var(--ink); }
.sr-attempt-row {
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sr-att-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sr-att-left strong { font-size: 14px; color: var(--ink); }
.sr-att-left span { font-size: 12px; color: var(--ink-3); }
.sr-att-right { text-align: right; flex: none; }
.sr-att-right strong { display: block; font-size: 16px; color: var(--ink); }
.sr-att-right span { font-size: 12px; color: var(--ink-3); }
.ticket-cover-sub { margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.ticket-subj-pill {
  padding: 2px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
}
.ticket-meta { font-size: 13px; font-weight: 600; color: var(--cover-sub, #FFEAE7); }

.ticket-sheet { padding: 18px 22px 22px; background: var(--paper); }
.ticket-mod-list { display: flex; flex-direction: column; }
.ticket-mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}
.ticket-mod-row:last-child { border-bottom: 0; }
.tm-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tm-num {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
}
.tm-copy { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.tm-copy strong { font-size: 15px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.tm-copy span { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
.tm-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}
@media (hover: hover) {
  .tm-btn:hover:not(:disabled) { background: var(--ink); color: #FFFFFF; }
}
.tm-btn:disabled { color: var(--ink-3); cursor: default; }

.ticket-practice-picker {
  margin: 4px 0 10px;
  padding: 11px 12px;
  border-radius: 12px;
  background: var(--fill-1);
  border: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.tpp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.tpp-note {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-3);
}
.tpp-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.tpp-presets {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tpp-chip {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.tpp-chip.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
.tpp-custom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-2);
}
.tpp-input {
  width: 52px;
  height: 30px;
  padding: 0 6px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  font-size: 13px;
  text-align: center;
}
.tpp-go {
  margin-left: auto;
  min-height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.cover-ticket { position: relative; }
.ticket-practice-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  border-radius: inherit;
  background: rgba(24, 24, 28, 0.24);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  padding: 14px;
}
.tpo-card {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
}
.tpo-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.tpo-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--ink);
}
.tpo-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--ink-3);
}
.tpo-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 0;
  background: var(--fill-1);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tpo-controls { margin: 14px 0 16px; }
.tpo-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.tpo-btn-cancel {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 0;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tpo-btn-start {
  min-height: 36px;
  padding: 0 18px;
  border-radius: 999px;
  border: 0;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.tpo-btn-start:hover { opacity: 0.9; }

.ticket-dock {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.btn-ticket-primary {
  flex: 1;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 12px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 14.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
@media (hover: hover) {
  .btn-ticket-primary:hover { background: var(--cover-bg, var(--jp-fill)); }
}
.btn-ticket-secondary {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (hover: hover) {
  .btn-ticket-secondary:hover { background: var(--fill-2); }
}

/* ═══════════ View 1B: Synced Mistake Book ═══════════ */
.view-mistakes {
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 24px 120px;
}
.mistakes-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}
.mistakes-title-block {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.mistakes-title-block h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.mistakes-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}
.mistakes-top-acts { display: flex; align-items: center; gap: 8px; }

.mistakes-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.subj-chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.subj-chip-btn {
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}
.subj-chip-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
.active-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--jp-bg);
  color: var(--jp-text);
  font-size: 12.5px;
  font-weight: 700;
}
.active-tag-chip button { font-size: 14px; line-height: 1; padding: 0 2px; }

.mistakes-list { display: flex; flex-direction: column; gap: 10px; }
.mistake-grp-head {
  margin: 14px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-3);
}
.mistake-card {
  width: 100%;
  text-align: left;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
}
@media (hover: hover) {
  .mistake-card:hover { border-color: rgba(24, 24, 28, 0.24); box-shadow: var(--shadow-row); }
}
.mistake-card.is-checked {
  border-color: var(--jp);
  background: #FFF9F8;
}
.m-check-box {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 6px;
  border: 1.5px solid var(--input-border);
  background: var(--paper);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #FFFFFF;
}
.mistake-card.is-checked .m-check-box { background: var(--jp-fill); border-color: var(--jp-fill); }

.m-card-body { flex: 1; min-width: 0; }
.m-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.m-card-lead {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--jp-text);
}
.m-subj-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.m-card-paper { font-size: 12px; font-weight: 600; color: var(--ink-3); flex: none; }
.m-card-stem {
  margin: 6px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.m-card-foot {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.m-foot-left { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.m-picked-badge {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--jp-bg);
  color: var(--jp-text);
  font-size: 12px;
  font-weight: 700;
}
.m-tag-badge {
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.m-date { font-size: 12px; color: var(--ink-3); }
.m-streak-pips { display: inline-flex; align-items: center; gap: 4px; }
.m-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fill-2);
}
.m-pip.is-on { background: var(--ok); }

.mistakes-empty {
  padding: 42px 24px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  text-align: center;
}
.mistakes-empty strong { display: block; font-size: 16px; color: var(--ink); margin-bottom: 6px; }
.mistakes-empty p { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-3); }

.mistakes-dock {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 30;
  width: min(640px, calc(100dvw - 24px));
  background: var(--paper);
  border: 1px solid rgba(24, 24, 28, 0.12);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow-pop);
}
.dock-normal,
.dock-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.drill-count-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 9px;
  background: var(--fill-1);
}
.drill-count-seg button {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
}
.drill-count-seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(40, 40, 43, 0.08);
}

/* ═══════════ View 2: Vertical Exam Booklet Stage (Novel-Reader Comfort) ═══════════ */
.view-runner {
  --exam-jp-size: 17.5px;
  min-height: calc(100dvh - 55px);
  background: var(--bg);
}
.view-runner[data-font-step="0"], .exam-shadow-root[data-font-step="0"] { --exam-jp-size: 16px; }
.view-runner[data-font-step="1"], .exam-shadow-root[data-font-step="1"] { --exam-jp-size: 17.5px; }
.view-runner[data-font-step="2"], .exam-shadow-root[data-font-step="2"] { --exam-jp-size: 19.5px; }

.exam-paper-stage {
  max-width: 740px;
  margin: 0 auto;
  padding: 24px 20px 84px;
}
.exam-paper-stage[lang="ja"],
.exam-unit-sheet[lang="ja"] {
  font-family: var(--jp-font);
}
.exam-unit-sheet {
  background: #FFFFFF;
  border-radius: 20px;
  border: 1px solid rgba(24, 24, 28, 0.07);
  box-shadow: var(--shadow-plate);
  padding: 36px 40px 28px;
  font-size: var(--exam-jp-size);
  font-weight: 400;
  line-height: 2;
  letter-spacing: 0.035em;
  color: #262626;
}

.exam-skeleton-sheet { display: flex; flex-direction: column; gap: 14px; }
.sk-bar {
  height: 16px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--fill-1) 0%, var(--fill-2) 50%, var(--fill-1) 100%);
  background-size: 200% 100%;
  animation: skShimmer 1.4s ease-in-out infinite;
}
.sk-bar.is-title { width: 42%; height: 22px; margin-bottom: 6px; }
.sk-bar.is-short { width: 68%; }
@keyframes skShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk-bar { animation: none; background: var(--fill-1); }
}

/* Pure White Editorial Passage Well (Zero Yellow Tint, 32-36 Chars/Line) */
.unit-material {
  background: #FFFFFF;
  max-width: 660px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
}
.unit-material.is-math-material {
  background: #FFFFFF;
  border: 0;
  border-radius: 0;
  padding: 0 0 20px;
  margin: 0 auto 22px;
  border-bottom: 1px solid var(--rule);
}
.unit-material.is-audio-material {
  padding-block-end: 20px;
  margin-block-end: 22px;
  border-block-end: 1px solid var(--rule);
}

.unit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.unit-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  text-wrap: balance;
}
.sheet-head-actions { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-zh-toggle {
  min-height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}
.btn-zh-toggle[aria-pressed="true"] {
  background: var(--insight);
  border-color: transparent;
  color: var(--insight-ink);
}

.passage-lead {
  margin: 0 0 1.2em;
  padding: 11px 14px;
  border-radius: 10px;
  background: #F5F6F8;
  color: #3E424D;
  font-size: 14.5px;
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: 0.03em;
}

.para-block { margin: 0 0 1.05em; transition: opacity 0.2s var(--ease); }
.para-block:last-child { margin-bottom: 0; }
.view-runner.is-focus-para .para-block:not(.is-focused),
.exam-shadow-root.is-focus-para .para-block:not(.is-focused) { opacity: 0.3; }
.view-runner.is-focus-para .para-block,
.exam-shadow-root.is-focus-para .para-block { cursor: pointer; }
.view-runner.hide-furigana rt,
.exam-shadow-root.hide-furigana rt { display: none; }

.para-text {
  margin: 0;
  max-width: 660px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--jp-font);
  font-size: var(--exam-jp-size);
  font-weight: 400;
  line-height: 2;
  letter-spacing: 0.035em;
  color: #262626;
  text-indent: 1em;
  text-wrap: pretty;
}
.para-text.no-indent { text-indent: 0; }
.para-block.is-dialogue {
  margin-bottom: 0.9em;
  padding-left: 0;
}
.dialogue-speaker {
  display: inline-block;
  font-weight: 700;
  color: #18181C;
  margin-right: 4px;
}
.para-zh {
  margin: 8px 0 0;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.72;
}

.passage-footnotes {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--rule);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.footnote-item {
  font-size: 14px;
  line-height: 1.78;
  color: var(--ink-2);
  white-space: pre-wrap;
  word-break: break-word;
}
.passage-source {
  margin: 18px 0 0;
  padding: 0;
  border-top: 0;
  text-align: right;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* Interactive Japanese Markup, Seamless Exam Underlines & Wide AB Blanks */
ruby { ruby-align: center; }
rt { font-size: 0.65em; font-weight: 600; color: var(--ink-3); line-height: 1; }

.jp-u {
  text-decoration: underline solid var(--ink) 1.6px;
  text-underline-offset: 5px;
  text-decoration-skip-ink: none;
  padding-inline: 1px;
}
.jp-u.is-active-ref {
  background: #FFF1EA;
  text-decoration: underline solid var(--jp-fill) 2px;
  border-radius: 4px;
}
.jp-u-badge {
  display: inline-block;
  font-family: var(--num-font, inherit);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
  padding: 0 5px;
  margin-right: 4px;
  border-radius: 4px;
  background: #EEF0F4;
  color: #525663;
  vertical-align: 1px;
  user-select: none;
}
.jp-u-badge.is-active-ref {
  background: #FFE8DF;
  color: var(--jp-fill);
}
@keyframes citeFlash {
  0% { background: rgba(223, 64, 52, 0.34); }
  100% { background: #FFF1EA; }
}
.jp-u.is-cite-flash { animation: citeFlash 1.1s var(--ease); }

/* Generous AB Blank Underlines (Sogo & Reading) */
.jp-blank {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 3.4em;
  padding: 0 0.85em;
  margin: 0 0.2em;
  border-bottom: 1.8px solid var(--ink);
  text-decoration: none !important;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}

.jp-fn { color: var(--jp-text); font-weight: 700; }

/* Zero Grammar Dotted Underlines — Keep Lookup Interaction Quiet & Clean */
.jp-w {
  display: inline;
  border-radius: 4px;
  cursor: pointer;
}
@media (hover: hover) {
  .jp-w:hover { background: rgba(24, 24, 28, 0.07); }
}
.jp-w:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.jp-w.is-selected {
  background: transparent;
  text-decoration: none;
}

/* Markdown Tables Inside Passages / Stems / Explanations */
.exam-table-wrap {
  margin: 14px 0 16px;
  overflow-x: auto;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(24, 24, 28, 0.14);
  background: var(--paper);
}
.exam-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.exam-md-table th,
.exam-md-table td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--rule);
  border-right: 1px solid rgba(24, 24, 28, 0.06);
  white-space: nowrap;
}
.exam-md-table th:last-child,
.exam-md-table td:last-child { border-right: 0; }
.exam-md-table tbody tr:last-child td,
.exam-md-table tbody tr:last-child th { border-bottom: 0; }
.exam-md-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--fill-1);
  font-weight: 700;
  color: var(--ink);
  text-align: center;
}
.exam-md-table th.exam-th-group {
  background: #EAECEF;
  font-weight: 700;
  color: var(--ink);
}
.exam-md-table tbody th.exam-row-head {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #F7F8FA;
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  border-right: 1px solid rgba(24, 24, 28, 0.12);
}
.exam-md-table td.is-num { text-align: right; }
.exam-md-table td.is-center { text-align: center; }

/* Frameless Embedded Figures (Click to Zoom, Zero Card-in-Card) */
.r2-figure-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}
.r2-figure-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
  cursor: zoom-in;
}
.r2-figure-btn img,
.r2-figure-btn canvas {
  margin: 0 auto;
  max-height: 460px;
  max-width: 100%;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.r2-figure-btn.is-doc-figure img,
.r2-figure-btn.is-doc-figure canvas {
  width: 100%;
  max-width: 620px;
  max-height: none;
  height: auto;
}
.zoom-stage canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
}
.opt-fig-canvas {
  display: block;
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  margin-top: 8px;
}
.captcha-body { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.captcha-row { display: flex; align-items: center; gap: 12px; }
.captcha-svg-box { line-height: 0; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; background: #f8fafc; }
.captcha-input { width: 100%; padding: 10px 12px; border: 1px solid var(--rule); border-radius: 8px; font-size: 16px; letter-spacing: 0.16em; text-transform: uppercase; background: var(--paper); color: var(--ink); }
.captcha-err { margin: 0; font-size: 13px; color: var(--bad, #dc2626); }

.audio-deck { padding: 14px 16px; border-radius: 12px; background: var(--paper); border: 1px solid var(--rule); }
.audio-deck-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.audio-deck-title { display: flex; flex-direction: column; gap: 2px; }
.audio-deck-title strong { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.audio-deck-title span { font-size: 12.5px; color: var(--ink-3); }
.audio-controls-row { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.btn-audio-play {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--ink);
  color: #FFFFFF;
  display: grid;
  place-items: center;
}
@media (hover: hover) { .btn-audio-play:hover { background: var(--jp-fill); } }
.btn-audio-skip {
  flex: none;
  min-height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
}
.audio-seek { flex: 1; min-width: 80px; accent-color: var(--jp-fill); cursor: pointer; }
.audio-time { flex: none; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.audio-script-panel { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--rule); }
.audio-script-panel h3 { margin: 0 0 10px; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.script-line { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.script-line:last-child { border-bottom: 0; }
.script-ja { margin: 0; font-size: 15px; line-height: 1.85; color: var(--ink); }
.script-zh { margin: 4px 0 0; font-size: 13px; line-height: 1.65; color: var(--ink-2); }

/* Single Active Question Section (Clear Hierarchy Above Options) */
.unit-questions-list { display: flex; flex-direction: column; }
.exam-q-block { scroll-margin-top: 76px; max-width: 660px; margin: 0 auto; padding-bottom: 6px; }
.q-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.q-num-group { display: flex; align-items: center; gap: 8px; }
.q-num-tag {
  padding: 2px 9px;
  border-radius: 6px;
  background: var(--fill-1);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
.q-step-meta {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
}
.btn-locate-u {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--jp-bg);
  color: var(--jp-text);
  font-size: 12px;
  font-weight: 700;
}

.q-stem {
  margin: 10px 0 0;
  max-width: 660px;
  font-family: var(--jp-font);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.95;
  letter-spacing: 0.035em;
  color: #262626;
  white-space: pre-wrap;
  text-wrap: pretty;
}
.stem-cite-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0 5px;
  margin: 0 2px;
  border-radius: 6px;
  background: rgba(200, 53, 43, 0.08);
  color: var(--jp-text);
  font-weight: 700;
  text-decoration: underline solid rgba(200, 53, 43, 0.55) 1.5px;
  text-underline-offset: 4px;
  vertical-align: baseline;
}
@media (hover: hover) {
  .stem-cite-link:hover { background: rgba(200, 53, 43, 0.16); }
}

.q-stem-zh {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 9px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* Spacious, Calm Option Cards */
.options-list { margin-top: 18px; display: flex; flex-direction: column; gap: 9px; }
.options-grid-fig { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.opt-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 1.5px solid rgba(24, 24, 28, 0.09);
  background: var(--paper);
  color: var(--ink);
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: background-color 140ms ease, border-color 140ms ease;
}
@media (hover: hover) {
  .opt-btn:hover { background: var(--fill-1); border-color: rgba(24, 24, 28, 0.18); }
}
.opt-key {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1.5px solid var(--input-border);
  background: var(--paper);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 1px;
}
.opt-txt {
  flex: 1;
  min-width: 0;
  font-family: var(--jp-font);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: 0.03em;
  color: #262626;
}
.opt-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 14px; }
.opt-col-cell { padding: 2px 0; }
.opt-zh { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-3); }
.opt-fig-card { flex-direction: column; align-items: stretch; gap: 8px; }
.opt-fig-card img { border-radius: 8px; max-height: 160px; margin: 0 auto; object-fit: contain; }

.opt-btn[aria-pressed="true"] { background: #F3F4F8; border-color: var(--ink); color: var(--ink); }
.opt-btn[aria-pressed="true"] .opt-key { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.opt-btn.is-correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ink); }
.opt-btn.is-correct .opt-key { background: var(--ok); border-color: var(--ok); color: #FFFFFF; }
.opt-btn.is-wrong { background: var(--jp-bg); border-color: var(--jp); color: var(--ink); }
.opt-btn.is-wrong .opt-key { background: var(--jp); border-color: var(--jp); color: #FFFFFF; }
.opt-btn:is(.is-correct, .is-wrong) .opt-zh { color: var(--ink-2); }

/* Math Formatting, Geometry & Cell Keypad */
.math-block { margin: 10px 0; padding: 0; border-radius: 0; background: transparent; text-align: center; font-size: 16.5px; line-height: 1.75; overflow-x: auto; }
.math-block + .math-block { margin-top: 6px; }
.math-tex { font-family: var(--serif); font-size: 1.04em; }
.math-tex .katex { font-size: 1.06em; }
.q-stem .katex,
.opt-txt .katex,
.para-text .katex,
.inline-stem-prose .katex {
  white-space: nowrap;
}
.katex .math-cell-group { display: inline-flex; align-items: center; gap: 2px; vertical-align: middle; }
.katex .math-cell-btn {
  font-family: var(--sans);
  min-width: 1.42em;
  height: 1.42em;
  padding: 0 0.25em;
  font-size: 0.78em;
  line-height: 1.25;
  vertical-align: middle;
  margin: 0;
}
.math-note-line {
  font-size: 13.5px;
  font-weight: 400;
  color: #6B6E7A;
  line-height: 1.65;
}
.q-stem.is-math-stem,
.q-stem.is-light-stem,
.unit-material.is-math-material .q-stem,
.unit-material.is-math-material { font-weight: 400; }
.jp-gloss {
  font-size: 0.86em;
  font-weight: 400;
  color: #787B87;
  letter-spacing: 0.01em;
}
.inline-stem-prose {
  margin: 12px 0 0;
  padding: 13px 16px;
  border-radius: 12px;
  background: #F7F8FA;
  border: 1px solid rgba(24, 24, 28, 0.06);
  font-family: var(--jp-font);
  font-size: var(--exam-jp-size);
  font-weight: 400;
  line-height: 1.95;
  letter-spacing: 0.035em;
  color: #262626;
  white-space: pre-wrap;
  text-indent: 1em;
}
.inline-stem-prose.no-indent,
.inline-stem-prose .exam-table-wrap { text-indent: 0; }
.math-ul { text-decoration: underline solid currentColor 1.5px; text-underline-offset: 3px; }
.math-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 3px; font-size: 0.9em; line-height: 1.15; }
.math-frac-num { padding: 0 4px 2px; border-bottom: 1.3px solid currentColor; }
.math-frac-den { padding: 2px 4px 0; }
.math-sqrt { display: inline-flex; align-items: baseline; line-height: 1.15; }
.math-sqrt-body { border-top: 1.2px solid currentColor; padding: 1px 3px 0; }
.math-cell-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  margin: 0 2px;
  border-radius: 6px;
  background: #E6F3FA;
  color: var(--subj-math1);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 700;
  vertical-align: middle;
}
.math-cell-btn.is-filled { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.math-cell-btn.is-active { background: var(--subj-math1); color: #FFFFFF; }
.math-cell-btn.is-ref { background: var(--fill-2); color: var(--ink-3); cursor: default; }
.math-cell-btn.is-right { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1.5px var(--ok); }
.math-cell-btn.is-wrong { background: var(--jp-bg); color: var(--jp-text); box-shadow: inset 0 0 0 1.5px var(--jp); }

.math-fig-wrap { margin: 14px 0; padding: 0; border: 0; background: transparent; display: grid; place-items: center; }
.math-dock { margin-top: 16px; padding: 16px; border-radius: 12px; background: var(--fill-1); }
.math-cell-strip { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.math-keypad { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.math-keypad button { min-height: 44px; border-radius: 9px; background: var(--paper); color: var(--ink); font-size: 16px; font-weight: 700; }
.math-keypad button.is-op { color: var(--subj-math1); }

/* ═══════════ Scratchpad Canvas & Redesigned Scientific Calculator ═══════════ */
.draft-overlay {
  position: fixed;
  inset: 55px 0 0 0;
  z-index: 35;
  touch-action: none;
}
.draft-grid-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-size: 24px 24px;
  background-image:
    linear-gradient(to right, rgba(20, 100, 165, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20, 100, 165, 0.08) 1px, transparent 1px);
}
.draft-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}
.draft-toolbar {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 36;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(24, 24, 28, 0.92);
  color: #FFFFFF;
  box-shadow: var(--shadow-pop);
}
.draft-colors {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-right: 1px solid rgba(255, 255, 255, 0.16);
}
.draft-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dot-c, #2563EB);
  border: 2px solid rgba(255, 255, 255, 0.35);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.draft-color-dot[aria-pressed="true"] {
  border-color: #FFFFFF;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.55);
  transform: scale(1.12);
}
.draft-tool-btn {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.84);
  white-space: nowrap;
}
.draft-tool-btn[aria-pressed="true"] { background: #FFFFFF; color: var(--ink); }
.draft-tool-btn.is-close { background: var(--jp-fill); color: #FFFFFF; margin-left: 2px; }

.calc-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 38;
  width: min(352px, calc(100dvw - 20px));
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid rgba(24, 24, 28, 0.14);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  user-select: none;
}
.calc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--fill-1);
  border-bottom: 1px solid var(--rule);
  cursor: grab;
  touch-action: none;
}
.calc-head:active { cursor: grabbing; }
.calc-title { font-size: 13px; font-weight: 700; color: var(--ink); }
.calc-head-acts { display: inline-flex; align-items: center; gap: 6px; }
.calc-mode-pill {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--ink);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 700;
}
.calc-mode-pill[aria-pressed="false"] { background: var(--paper); color: var(--ink-2); border: 1px solid var(--rule); }
.calc-close-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--paper);
  color: var(--ink-2);
  display: grid;
  place-items: center;
}

.calc-screen {
  padding: 12px 14px 10px;
  background: var(--book-well);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-expr {
  min-height: 18px;
  font-size: 13px;
  color: var(--ink-3);
  text-align: right;
  word-break: break-all;
}
.calc-readout-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.calc-exact-badge {
  padding: 3px 8px;
  border-radius: 7px;
  background: #E6F2FC;
  color: var(--subj-math1);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 700;
}
.calc-val {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  max-width: 100%;
  overflow-x: auto;
}
.calc-fill-btn {
  align-self: flex-end;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--subj-math1);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 700;
}

.calc-keypad-wrap {
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--paper);
}
.calc-sci-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
.calc-num-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.calc-key {
  min-height: 36px;
  border-radius: 8px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.calc-sci-grid .calc-key { min-height: 31px; font-size: 12px; color: var(--ink-2); }
.calc-key.is-op { background: #EAEFF6; color: var(--subj-math1); }
.calc-key.is-eq { background: var(--ink); color: #FFFFFF; }
.calc-key.is-clr { background: var(--jp-bg); color: var(--jp-text); }
@media (hover: hover) {
  .calc-key:hover { filter: brightness(0.95); }
}

/* ═══════════ 記述 (Kijutsu) Squared Notebook & AI Review ═══════════ */
.kijutsu-pick-list { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.kj-topic-card {
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: var(--book-well);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.kj-topic-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kj-topic-tag { padding: 2px 9px; border-radius: 999px; background: var(--paper); border: 1px solid var(--rule); font-size: 12.5px; font-weight: 700; color: var(--ink); }
.kj-topic-ja { font-size: 16.5px; line-height: 1.9; color: var(--ink); }

/* Dedicated Writing Studio Canvas (Paper sits directly on stage, no outer card wrapper) */
.exam-unit-sheet.is-kijutsu-studio {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.kj-studio-header {
  position: sticky;
  top: 55px;
  z-index: 18;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid rgba(24, 24, 28, 0.08);
  box-shadow: 0 6px 20px -10px rgba(24, 24, 28, 0.12);
  margin-bottom: 16px;
}
.kj-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: 0;
}
.kj-topbar-left,
.kj-topbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.kj-studio-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.kj-autosave-lbl {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}
.kj-prompt-pin {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #F8F8F6;
  border: 1px solid rgba(24, 24, 28, 0.08);
}
.kj-prompt-pin.is-collapsed {
  padding: 7px 12px;
}
.kj-prompt-pin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kj-prompt-pin-lbl {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-3);
}
.kj-prompt-pin-toggle {
  border: 0;
  background: transparent;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.kj-prompt-pin-toggle:hover {
  background: rgba(24, 24, 28, 0.06);
  color: var(--ink);
}
.kj-prompt-pin-body {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink);
  max-height: 128px;
  overflow-y: auto;
}
.kj-counter-pill {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}
.kj-counter-pill.is-target { background: var(--ok-bg); color: var(--ok); }
.kj-counter-pill.is-min { background: var(--insight); color: var(--amber-ink); }

.kj-notebook {
  --kj-cell: 28px;
  --kj-pitch: 38px;
  --kj-font: 21px;
  position: relative;
  width: 100%;
  padding: 0;
}
.kj-paper-surface {
  background: #FDFCF8;
  border: 1px solid rgba(24, 24, 28, 0.10);
  border-radius: 8px;
  box-shadow: 0 10px 34px -14px rgba(24, 24, 28, 0.14), 0 1px 3px rgba(24, 24, 28, 0.04);
  padding: 28px 20px 32px;
}
.kj-grid-stage {
  position: relative;
  width: calc(20 * var(--kj-cell) + 1px);
  margin: 0 auto;
  padding-left: 12px;
  padding-right: 54px;
  box-sizing: content-box;
}
/* Vertical 400-cell milestone line along the right edge of rows 1–20 */
.kj-row20-rule {
  position: absolute;
  right: 43px;
  top: 4px;
  height: calc(20 * var(--kj-pitch) - 8px);
  width: 2px;
  border-radius: 2px;
  background: rgba(223, 64, 52, 0.36);
  pointer-events: none;
}
.kj-row20-rule.is-done {
  background: rgba(22, 121, 67, 0.55);
}
.kj-gutter-right {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  pointer-events: none;
}
.kj-gutter-num,
.kj-marker-400 {
  position: absolute;
  left: 4px;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  line-height: 1;
}
.kj-gutter-num.is-r10 { top: calc(9.5 * var(--kj-pitch)); }
.kj-marker-400.is-r20 {
  top: calc(19.5 * var(--kj-pitch));
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--jp-bg);
  color: var(--jp-text);
  font-weight: 700;
}
.kj-marker-400.is-done {
  background: var(--ok-bg);
  color: var(--ok);
}
.kj-gutter-num.is-r30 { top: calc(29.5 * var(--kj-pitch)); }
.kj-gutter-num.is-r40 { top: calc(39.5 * var(--kj-pitch)); }

.kj-statusbar {
  position: sticky;
  bottom: 10px;
  z-index: 16;
  margin-top: 14px;
  padding: 10px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(24, 24, 28, 0.08);
  box-shadow: 0 6px 20px -8px rgba(24, 24, 28, 0.14);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.kj-statusbar-left,
.kj-statusbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.kj-sb-meta { color: var(--ink-2); font-weight: 600; }
.kj-sb-target { color: var(--jp-text); font-weight: 600; }
.kj-sb-target.is-done { color: var(--ok); }
.kj-notebook-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(24, 24, 28, 0.08);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}
.kj-notebook-head-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kj-edit-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 6px;
  border: 1px solid rgba(24, 24, 28, 0.14);
  background: #FFFFFF;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.kj-edit-menu-btn:hover {
  background: var(--fill-1);
  border-color: rgba(24, 24, 28, 0.24);
  color: var(--ink);
}
.kj-ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 196px;
  padding: 5px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid rgba(24, 24, 28, 0.12);
  box-shadow: 0 16px 38px -10px rgba(15, 18, 22, 0.24), 0 2px 6px rgba(15, 18, 22, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1px;
  user-select: none;
}
.kj-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background 100ms ease;
}
.kj-ctx-item:hover:not(:disabled) {
  background: var(--fill-1);
}
.kj-ctx-item:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}
.kj-ctx-item-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.kj-ctx-kbd {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.kj-ctx-sep {
  height: 1px;
  margin: 4px 6px;
  background: rgba(24, 24, 28, 0.08);
}
.kj-marker-400 {
  padding: 1px 8px;
  border-radius: 6px;
  background: var(--jp-bg);
  color: var(--jp-text);
  font-weight: 700;
}
.kj-marker-400.is-done { background: var(--ok-bg); color: var(--ok); }
.kj-textarea {
  display: block;
  width: calc(20 * var(--kj-cell) + 1px);
  min-height: calc(40 * var(--kj-pitch));
  border: 0;
  padding: 0 0 0 calc((var(--kj-cell) - var(--kj-font)) / 2);
  margin: 0;
  box-sizing: border-box;
  background-color: transparent;
  background-image:
    linear-gradient(to bottom, #FDFCF8 0 4.5px, transparent 4.5px calc(var(--kj-pitch) - 4.5px), #FDFCF8 calc(var(--kj-pitch) - 4.5px) var(--kj-pitch)),
    linear-gradient(to bottom, transparent 0 4.5px, rgba(24, 24, 28, 0.14) 4.5px 5.5px, transparent 5.5px calc(var(--kj-pitch) - 5.5px), rgba(24, 24, 28, 0.14) calc(var(--kj-pitch) - 5.5px) calc(var(--kj-pitch) - 4.5px), transparent calc(var(--kj-pitch) - 4.5px) var(--kj-pitch)),
    linear-gradient(to right, rgba(24, 24, 28, 0.12) 0 1px, transparent 1px var(--kj-cell));
  background-size: 100% var(--kj-pitch), 100% var(--kj-pitch), var(--kj-cell) var(--kj-pitch);
  background-position: 0 0, 0 0, 0 0;
  background-repeat: repeat, repeat, repeat;
  resize: none;
  overflow: hidden;
  font-family: 'Noto Sans JP', 'Yu Gothic', 'Meiryo', 'Hiragino Sans', var(--font-ja), monospace;
  font-size: var(--kj-font);
  line-height: var(--kj-pitch);
  letter-spacing: calc(var(--kj-cell) - var(--kj-font));
  font-variant-east-asian: full-width;
  word-break: break-all;
  white-space: pre-wrap;
  color: #1E242A;
  caret-color: #DF4034;
  outline: none;
}
.kj-textarea::placeholder {
  color: #9AA2A9;
}
@media (max-width: 700px) {
  .exam-unit-sheet.is-kijutsu-studio { padding: 0; }
  .kj-studio-header { padding: 10px 12px; }
  .kj-paper-surface { padding: 14px 8px 18px; }
  .kj-notebook {
    --kj-cell: clamp(14px, calc((100vw - 92px) / 20), 28px);
    --kj-pitch: calc(var(--kj-cell) + 10px);
    --kj-font: calc(var(--kj-cell) * 0.75);
  }
  .kj-grid-stage { padding-left: 6px; padding-right: 40px; }
  .kj-row20-rule { right: 34px; }
  .kj-gutter-right { width: 32px; }
  .kj-statusbar { padding: 10px 12px; }
}
.kj-punct-hint {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--insight);
  color: var(--amber-ink);
  font-size: 12.5px;
  font-weight: 600;
}
.kj-status-bar {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ok);
}
.kj-status-bar.is-err { color: var(--jp-text); }

/* Kijutsu AI Review View (App-Parity) */
.kj-review-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-radius: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  margin-bottom: 14px;
}
.kj-score-left { display: flex; flex-wrap: wrap; align-items: baseline; gap: 16px; }
.kj-score-big { display: flex; align-items: baseline; gap: 4px; }
.kj-score-big strong { font-size: 46px; font-weight: 700; line-height: 1; letter-spacing: -1.5px; color: var(--ink); }
.kj-score-big span { font-size: 15px; font-weight: 600; color: var(--ink-3); }
.kj-score-tip { font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.kj-review-actions { display: flex; align-items: center; gap: 10px; }
.kj-style-chip { padding: 4px 10px; border-radius: 999px; background: var(--fill-1); font-size: 12px; font-weight: 700; color: var(--ink-2); }
.kj-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.kj-leg-item { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--fill-1); }
.kj-leg-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.kj-leg-cnt { color: var(--ink-3); font-weight: 700; }

.kj-annotated-paper {
  position: relative;
  padding: 20px 24px;
  border-radius: 16px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--font-ja);
  font-size: 17.5px;
  line-height: 2.1;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
  word-break: break-word;
}
.kj-mark {
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 2px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
  transition: background 140ms ease;
}
.kj-mark.kind-error { background: rgba(223, 64, 52, 0.12); text-decoration-color: #DF4034; }
.kj-mark.kind-unnatural { background: rgba(20, 100, 165, 0.12); text-decoration-color: #1464A5; }
.kj-mark.kind-colloquial { background: rgba(227, 162, 26, 0.18); text-decoration-color: #E3A21A; }
.kj-mark.kind-style_mix { background: rgba(122, 111, 208, 0.16); text-decoration-color: #7A6FD0; }
.kj-mark.kind-good { background: rgba(22, 121, 67, 0.12); text-decoration-color: #167943; }
.kj-mark.kind-error.is-selected { background: rgba(223, 64, 52, 0.25); }
.kj-mark.kind-unnatural.is-selected { background: rgba(20, 100, 165, 0.24); }
.kj-mark.kind-colloquial.is-selected { background: rgba(227, 162, 26, 0.34); }
.kj-mark.kind-style_mix.is-selected { background: rgba(122, 111, 208, 0.30); }
.kj-mark.kind-good.is-selected { background: rgba(22, 121, 67, 0.24); }

.kj-mark-card {
  margin-top: 14px;
  padding: 16px 18px 18px;
  border-radius: 18px;
  background: var(--paper);
  border: 1px solid rgba(24, 24, 28, 0.10);
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.16);
}
.kj-mc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.kj-mc-kind-wrap { display: inline-flex; align-items: center; gap: 7px; }
.kj-mc-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.kj-mc-label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.kj-mc-nav { display: inline-flex; align-items: center; gap: 6px; }
.kj-mc-step {
  width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--rule);
  background: var(--paper); color: var(--ink-2); font-size: 15px; line-height: 1;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.kj-mc-step:hover { background: var(--fill-1); }
.kj-mc-idx { font-size: 12px; font-weight: 600; color: var(--ink-3); min-width: 34px; text-align: center; }
.kj-mc-del {
  font-size: 14px; color: var(--ink-3); margin-bottom: 6px;
  text-decoration: line-through; text-decoration-color: #DF4034; text-decoration-thickness: 1.5px;
}
.kj-mc-fix-row { display: flex; align-items: flex-start; gap: 10px; }
.kj-mc-check { margin-top: 4px; flex-shrink: 0; }
.kj-mc-fix { font-size: 19px; line-height: 1.5; font-weight: 600; color: var(--ink); }
.kj-mc-want { margin: 8px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-2); font-weight: 500; }
.kj-mc-note { margin: 6px 0 0; font-size: 13px; line-height: 1.55; color: var(--ink-3); }

/* Explanations & Nav Footer */
.explain-box { margin-top: 18px; padding: 16px 18px; border-radius: 12px; background: var(--sand); }
.explain-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.explain-status { padding: 3px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 700; }
.explain-status.is-right { background: var(--ok-bg); color: var(--ok); }
.explain-status.is-wrong { background: var(--jp-bg); color: var(--jp-text); }
.explain-topic { font-size: 12px; font-weight: 600; color: var(--ink-3); }
.explain-body { margin: 0; font-size: 14px; line-height: 1.75; color: var(--ink-2); white-space: pre-wrap; text-wrap: pretty; }

.q-nav-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.exam-unit-sheet > .q-nav-foot {
  max-inline-size: 660px;
  margin-inline: auto;
  margin-block-start: 20px;
  padding-block-start: 16px;
}

/* Sticky Bottom Answer Dock (Draggable, Non-Intrusive, Mini-Preview) */
.runner-dock {
  position: sticky;
  bottom: 10px;
  z-index: 25;
  max-width: 720px;
  margin: 16px auto 0;
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(24, 24, 28, 0.12);
  border-radius: 16px;
  box-shadow: 0 -2px 14px rgba(24, 24, 28, 0.05), 0 8px 24px rgba(24, 24, 28, 0.09);
  padding: 6px 18px 12px;
}
.runner-dock-grip {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 26px;
  margin-bottom: 4px;
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}
.runner-dock-pill {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--fill-3);
  transition: background-color 140ms ease, width 140ms ease;
}
.runner-dock-grip:hover .runner-dock-pill {
  background: var(--ink-3);
  width: 48px;
}
.runner-dock.is-collapsed .runner-dock-scroll { display: none; }
.runner-dock:not(.is-collapsed) .dock-mini-panel { display: none; }
.runner-dock.is-collapsed .q-nav-foot { margin-top: 8px; padding-top: 8px; }

.btn-dock-toggle {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
@media (hover: hover) {
  .btn-dock-toggle:hover { background: var(--fill-2); color: var(--ink); }
}

.dock-mini-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 2px;
}
.dock-mini-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dock-mini-stem {
  flex: 1;
  min-width: 0;
  font-family: var(--jp-font);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  color: #262626;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dock-mini-preview {
  padding: 6px 10px;
  border-radius: 9px;
  background: #F6F7F9;
  font-family: var(--jp-font);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  color: #262626;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.dock-mini-preview.is-hint { color: var(--ink-3); }
.dock-mini-preview-key {
  flex: none;
  font-weight: 700;
  color: var(--ink);
}

.dock-quick-opts { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.dock-quick-btn {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1.5px solid var(--input-border);
  background: #FFFFFF;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 700;
}
@media (hover: hover) {
  .dock-quick-btn:hover { border-color: var(--ink); color: var(--ink); }
}
.dock-quick-btn[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}
.dock-quick-btn.is-correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.dock-quick-btn.is-wrong { background: var(--jp-bg); border-color: var(--jp); color: var(--jp-text); }

.runner-dock-scroll {
  height: auto;
  max-height: 62dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}
.runner-dock.is-user-sized .runner-dock-scroll {
  height: var(--dock-scroll-h, 240px);
  min-height: 96px;
}
.runner-dock.is-flow-dock {
  position: static;
  margin-top: 18px;
  box-shadow: var(--shadow-plate);
}
.runner-dock.is-flow-dock .runner-dock-grip { display: none; }
.runner-dock.is-flow-dock .runner-dock-scroll {
  height: auto;
  max-height: none;
  overflow-y: visible;
  padding-right: 0;
}
.runner-dock:not(.has-passage) .runner-dock-scroll { height: auto; max-height: none; overflow-y: visible; }
@media (max-width: 640px) {
  .runner-dock {
    bottom: 6px;
    border-radius: 14px;
    padding: 6px 12px 10px;
  }
  .dock-mini-top { flex-wrap: wrap; gap: 8px; }
  .runner-dock-scroll { max-height: 58dvh; }
}
.nav-foot-stat { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.btn-nav-step {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
}
.btn-nav-step:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-nav-next { background: var(--ink); color: #FFFFFF; }
@media (hover: hover) {
  .btn-nav-step:hover:not(:disabled) { background: var(--fill-2); }
  .btn-nav-next:hover:not(:disabled) { background: var(--jp-fill); }
}

/* ═══════════ View 3: Settlement & Word Review Sheet ═══════════ */
.view-result { max-width: 940px; margin: 0 auto; padding: 28px 24px 72px; }
.res-shell { background: var(--paper); border-radius: 22px; border: 1px solid rgba(24, 24, 28, 0.06); box-shadow: var(--shadow-plate); overflow: hidden; }
.res-cover { background: var(--cover-bg, var(--subj-jp)); color: #FFFFFF; padding: 26px 30px 24px; }
.res-cover-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
.res-cover h1 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.15; color: #FFFFFF; text-wrap: balance; }
.res-paper-sub { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: var(--cover-sub, #FFEAE7); }
.res-score-num { display: flex; align-items: baseline; gap: 6px; }
.res-score-num strong { font-size: 52px; font-weight: 700; line-height: 0.96; letter-spacing: -0.03em; color: #FFFFFF; }
.res-score-num span { font-size: 16px; font-weight: 700; color: var(--cover-sub, #FFEAE7); }
.res-cover-bottom { margin-top: 18px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.22); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.res-band-note { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--cover-sub, #FFEAE7); }
.res-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-cover-ghost, .btn-cover-white, .btn-cover-solid { min-height: 38px; padding: 0 15px; border-radius: 9px; font-size: 13px; font-weight: 700; }
.btn-cover-ghost { background: rgba(24, 24, 28, 0.24); color: #FFFFFF; }
.btn-cover-white { background: #FFFFFF; color: var(--ink); }
.btn-cover-solid { background: var(--ink); color: #FFFFFF; }

.res-body { padding: 24px 30px 30px; }
.res-pools { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.pool-tile { padding: 15px 17px; border-radius: 12px; background: var(--fill-1); display: flex; flex-direction: column; justify-content: space-between; }
.pool-tile span { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.pool-tile strong { margin-top: 5px; font-size: 24px; font-weight: 700; color: var(--ink); }
.pool-tile em { margin-top: 3px; font-style: normal; font-size: 12.5px; color: var(--ink-2); }
.res-meta-bar { margin-top: 14px; padding: 11px 16px; border-radius: 10px; background: var(--fill-1); display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.res-palette-panel { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--rule); }
.res-palette-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.res-palette-head h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.res-palette-legend { display: flex; align-items: center; gap: 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.leg-item { display: inline-flex; align-items: center; gap: 6px; }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid transparent; display: inline-block; }
.leg-dot.is-right { background: var(--ok-bg); border-color: var(--ok); }
.leg-dot.is-wrong { background: var(--jp-bg); border-color: var(--jp); }
.res-vocab-panel { margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--rule); }
.res-vocab-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.res-vocab-head h2 { margin: 0; font-size: 17px; font-weight: 700; color: var(--ink); }
.res-vocab-list { margin-top: 14px; display: flex; flex-direction: column; }

.voc-row { padding: 12px 4px; border-bottom: 1px solid var(--rule); display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.voc-row:last-child { border-bottom: 0; }
.voc-row-main { min-width: 0; flex: 1; }
.voc-row-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.voc-row-head strong { font-size: 16px; font-weight: 700; color: var(--ink); }
.voc-row-head span { font-size: 13px; color: var(--ink-3); }
.voc-row-def { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); }
.voc-row-ctx { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }
.btn-voc-star { flex: none; min-height: 32px; padding: 0 12px; border-radius: 999px; background: var(--fill-1); color: var(--ink-2); font-size: 12.5px; font-weight: 700; }
.btn-voc-star[aria-pressed="true"] { background: var(--jp-bg); color: var(--jp-text); }

/* ═══════════ Word Lookup Floating Popover ═══════════ */
.word-pop[popover] {
  position: fixed;
  margin: 0;
  padding: 16px 18px 14px;
  width: min(360px, calc(100dvw - 24px));
  max-height: min(460px, 68dvh);
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overscroll-behavior: contain;
}
.word-pop:is(:popover-open, .\:popover-open) { display: block; }
.wp-tabs { display: inline-flex; align-items: center; gap: 3px; padding: 3px; margin-bottom: 10px; border-radius: 9px; background: var(--fill-1); }
.wp-tabs[hidden] { display: none; }
.wp-tabs [role="tab"] { position: relative; min-height: 30px; padding: 0 14px; border-radius: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.wp-tabs [role="tab"][hidden] { display: none; }
.wp-tabs [role="tab"][aria-selected="true"] { background: var(--paper); color: var(--ink); }
.wp-tabs [role="tab"][aria-selected="true"]::after { content: ""; position: absolute; inset: auto 10px 3px; border-block-end: 2px solid var(--jp); }
.wp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.wp-head-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 7px; min-width: 0; }
.wp-jp { font-size: 20px; font-weight: 700; color: var(--ink); line-height: 1.25; }
.wp-kana { font-size: 13.5px; font-weight: 600; color: var(--ink-3); }
.wp-accent, .wp-lvl { padding: 2px 6px; border-radius: 6px; background: var(--fill-1); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.wp-tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.wp-dict-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--insight); color: var(--insight-ink); font-size: 11.5px; font-weight: 700; }
.wp-conn-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--fill-1); color: var(--ink-2); font-size: 12px; font-weight: 600; }
.wp-collect-btn { flex: none; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 11px; border-radius: 999px; background: var(--fill-1); color: var(--ink-2); font-size: 12.5px; font-weight: 700; }
.wp-collect-btn[aria-pressed="true"] { background: var(--jp-fill); color: #FFFFFF; }
.wp-collect-btn[aria-pressed="true"] svg { fill: currentColor; }
.wp-meta { margin-top: 8px; font-size: 12px; font-weight: 600; color: var(--jp-text); }
.wp-meanings { margin-top: 10px; font-size: 14px; line-height: 1.65; color: var(--ink); }
.wp-sense-row + .wp-sense-row { margin-top: 6px; }
.wp-pos { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 5px; background: var(--fill-1); color: var(--ink-3); font-size: 12px; font-weight: 700; }
.wp-short-title { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ink); }
.wp-note-list { margin-top: 8px; max-height: 210px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; }
.wp-note-seg { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.wp-note-tag { display: inline-block; padding: 2px 7px; border-radius: 5px; background: var(--insight); color: var(--insight-ink); font-size: 11.5px; font-weight: 700; user-select: none; }
.wp-note-txt { font-size: 13.5px; line-height: 1.6; color: var(--ink-2); }
.wp-pending-zh { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-left: 6px; }
.wp-example { margin-top: 10px; padding: 9px 11px; border-radius: 8px; background: var(--fill-1); font-size: 12.5px; line-height: 1.55; color: var(--ink-2); }
.wp-example p { margin: 0; }
.wp-example .wp-ex-cn { margin-top: 3px; color: var(--ink-3); }

/* ═══════════ Modals (Favorites, TAG Stats, Kijutsu History, Science, Submit, Zoom, Login) ═══════════ */
.desk-dialog {
  width: min(460px, calc(100dvw - 24px));
  max-height: 88dvh;
  margin: auto;
  padding: 24px;
  border: 0;
  border-radius: 22px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.desk-dialog-wide { width: min(720px, calc(100dvw - 24px)); }
.zoom-dialog { width: min(960px, calc(100dvw - 24px)); padding: 16px 20px 20px; }
.desk-dialog:modal { overscroll-behavior: contain; }
.desk-dialog::backdrop {
  background: rgba(16, 20, 30, 0.56);
  backdrop-filter: blur(4px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dlg-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--ink); text-wrap: balance; }
.dlg-sub { margin: 5px 0 0; font-size: 13px; line-height: 1.5; color: var(--ink-3); }
.dlg-close-form { margin: 0; flex: none; }
.dlg-close-btn { width: 38px; height: 38px; border-radius: 9px; background: var(--fill-1); color: var(--ink-2); display: grid; place-items: center; }

#membership-dialog [hidden] { display: none; }
#membership-dialog .dlg-status { margin: 14px 0 0; }
#membership-dialog .dlg-status.is-info { background: var(--fill-1); color: var(--ink-2); }
#membership-form, #membership-order, #membership-dialog .membership-action { margin-top: 16px; }
#membership-dialog .membership-action { min-height: 44px; }
#membership-plan {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
.membership-actions, .membership-account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.membership-actions .btn-lock-upgrade, .membership-actions .btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  flex: 1 0 max-content;
  text-decoration: none;
}
#membership-form .membership-actions { margin-top: 12px; }
#membership-qr { margin: 0 0 16px; text-align: center; }
#membership-qr img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto 8px;
  image-rendering: pixelated;
}
#membership-qr figcaption { color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.membership-qr-mobile { display: none; }
@media (pointer: coarse) {
  .membership-qr-mobile { display: block; margin-top: 4px; }
}

.voc-tabs { margin-top: 14px; display: flex; flex-wrap: nowrap; gap: 8px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.voc-tabs button { position: relative; min-height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.voc-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 700; }
.voc-tabs button[aria-selected="true"]::after { content: ""; position: absolute; inset: auto 10px -9px; border-block-end: 2.5px solid var(--jp); }
.voc-list { margin-top: 12px; max-height: 52dvh; overflow-y: auto; }
.voc-empty { padding: 32px 12px; text-align: center; font-size: 13.5px; color: var(--ink-3); }

/* TAG Stats Dialog */
.ts-head-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.ts-freq-meta {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
}
.ts-controls {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.ts-subj-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.ts-subj-pills.is-seg {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: var(--fill-1);
}
.ts-subj-pill {
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.ts-subj-pills.is-seg .ts-subj-pill {
  min-height: 30px;
  padding: 0 6px;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-3);
  font-size: 12.5px;
  text-align: center;
}
.ts-subj-pill[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.ts-subj-pills.is-seg .ts-subj-pill[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.08);
}
.ts-search-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ts-search-row[hidden] { display: none; }
.ts-search-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--fill-1);
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
}
.ts-search-input:focus {
  outline: none;
  background: var(--paper);
  border-color: var(--input-border);
}
.ts-body { margin-top: 12px; max-height: 54dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 0; }
.ts-grp-title { margin: 12px 0 4px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); }

/* Weak Topics Ranked Rows (App topic_errors_page parity) */
.ts-rank-row {
  width: 100%;
  padding: 11px 4px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  background: transparent;
}
@media (hover: hover) {
  .ts-rank-row:hover { background: rgba(24, 24, 28, 0.025); }
}
.ts-rank-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.ts-rank-num {
  width: 20px;
  flex: none;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ts-row-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ts-row-area { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-left: 6px; }
.ts-row-stat {
  flex: none;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ts-row-stat strong {
  color: var(--jp);
  font-weight: 700;
}

/* Inline Right-Rail Topics Summary (App stats_page parity) */
.ts-mini-list { display: flex; flex-direction: column; }
.ts-mini-row {
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
}
.ts-mini-row:last-of-type { border-bottom: none; }
.ts-mini-left { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.ts-mini-num { width: 14px; flex: none; font-size: 12px; font-weight: 700; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.ts-mini-name { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-mini-stat { flex: none; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-mini-stat strong { color: var(--jp); font-weight: 700; }
.ts-mini-all-btn {
  margin-top: 2px;
  padding: 6px 0 4px;
  width: 100%;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
}
@media (hover: hover) {
  .ts-mini-all-btn:hover { color: var(--ink); }
}
.ts-freq-entry-btn {
  margin-top: 4px;
  padding: 9px 2px 2px;
  border-top: 1px solid var(--rule);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}
.ts-freq-entry-t { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.ts-freq-entry-sub { display: block; margin-top: 2px; font-size: 11.5px; font-weight: 500; color: var(--ink-3); }
.ts-freq-entry-arr { font-size: 15px; color: var(--ink-3); flex: none; }

/* 3-Column Sortable Historical Frequency Table (App topic_table_page parity) */
.ts-table-wrap { display: flex; flex-direction: column; width: 100%; }
.ts-table-head,
.ts-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 78px;
  align-items: center;
  gap: 8px;
  padding: 9px 4px;
}
.ts-table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  border-bottom: 1.5px solid var(--rule);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}
.ts-sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  width: 100%;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-3);
}
.ts-sort-btn.is-active { color: var(--ink); }
.ts-table-row {
  border-bottom: 1px solid var(--rule);
  font-size: 13.5px;
}
.ts-table-row.is-low .ts-table-topic { color: var(--ink-3); }
.ts-table-topic {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  font-weight: 600;
  color: var(--ink);
}
.low-freq-tag {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-3);
  line-height: 1.3;
  white-space: nowrap;
}
.ts-table-count {
  text-align: right;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ts-table-row.is-low .ts-table-count { font-weight: 600; color: var(--ink-3); }
.ts-table-rate {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.ts-table-foot {
  margin: 10px 4px 2px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.ts-low-divider {
  margin-top: 14px;
  padding: 12px 4px 4px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}
.ts-rank-row.is-low .ts-rank-num { visibility: hidden; }
.ts-rank-row.is-low .ts-row-name,
.ts-rank-row.is-low .ts-row-stat,
.ts-rank-row.is-low .ts-row-stat strong {
  color: var(--ink-3);
  font-weight: 500;
}

/* Japanese Reading TAG Strategy Accordion */
.ts-acc-item,
.ts-table-item {
  border-bottom: 1px solid var(--rule);
}
.ts-acc-item > .ts-rank-row {
  border-bottom: 0;
}
.ts-table-item > .ts-table-row {
  width: 100%;
  border-bottom: 0;
  text-align: left;
  background: transparent;
  cursor: pointer;
}
.ts-row-right {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ts-acc-chev {
  flex: none;
  color: var(--ink-3);
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), color 150ms ease;
}
:is(.ts-acc-item, .ts-table-item).is-open .ts-acc-chev {
  transform: rotate(180deg);
  color: var(--ink);
}
.ts-acc-panel {
  padding: 0 4px 12px 30px;
}
.ts-acc-panel.is-table {
  padding: 0 4px 11px;
}
.ts-tip-prose {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--fill-1);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
  font-weight: 400;
}
.ts-tip-jump {
  margin-top: 7px;
  padding: 2px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--jp-text);
  background: transparent;
}
@media (hover: hover) {
  .ts-table-row.has-tip:hover { background: rgba(24, 24, 28, 0.025); }
  .ts-tip-jump:hover { text-decoration: underline; }
}

/* Algorithm Explanation Help Button & Modal */
.btn-algo-help {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  flex: none;
  transition: background-color 140ms ease, color 140ms ease;
}
.btn-algo-help[hidden] { display: none; }
@media (hover: hover) {
  .btn-algo-help:hover {
    background: var(--fill-1);
    color: var(--ink);
  }
}
.desk-dialog-sm { width: min(420px, calc(100dvw - 24px)); }
.algo-formula-box {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--fill-1);
  border: 1px solid rgba(24, 24, 28, 0.06);
  text-align: center;
}
.algo-frac-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}
.algo-eq-lhs { white-space: nowrap; }
.algo-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  line-height: 1.35;
}
.algo-num {
  padding: 0 6px 3px;
  border-bottom: 1.5px solid var(--ink-2);
}
.algo-den {
  padding: 3px 6px 0;
  font-weight: 600;
  color: var(--ink-2);
}
.algo-param-note {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--ink-3);
}
.algo-points {
  margin: 14px 0 4px;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink-2);
}
.algo-points li::marker { color: var(--ink-3); }
.algo-points strong { color: var(--ink); font-weight: 700; }
.btn-secondary-md.is-full { width: 100%; }

/* Mistake Queue Review Badge */
.runner-mode-pill.is-mistake {
  background: var(--jp-bg);
  color: var(--jp-text);
  border-color: rgba(200, 53, 43, 0.25);
}

/* Kijutsu History Row */
.kj-hist-row {
  padding: 12px 4px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kj-hist-row:last-child { border-bottom: 0; }
.kj-hist-info { min-width: 0; flex: 1; }
.kj-hist-info strong { display: block; font-size: 14.5px; color: var(--ink); }
.kj-hist-info span { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.kj-hist-acts { display: flex; gap: 6px; flex: none; }

.sci-grid { margin-top: 18px; display: grid; gap: 10px; }
.sci-pick-btn { padding: 14px 16px; border-radius: 12px; background: var(--fill-1); text-align: left; display: flex; flex-direction: column; gap: 3px; }
.sci-pick-btn strong { font-size: 15px; color: var(--ink); }
.sci-pick-btn span { font-size: 12.5px; color: var(--ink-3); }
.sci-pick-btn[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
.sci-pick-btn[aria-pressed="true"] strong { color: #FFFFFF; }
.sci-pick-btn[aria-pressed="true"] span { color: rgba(255, 255, 255, 0.80); }

.btn-secondary-md, .btn-vermilion-md {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-secondary-md { background: var(--fill-1); color: var(--ink); }
.btn-vermilion-md { background: var(--jp-fill); color: #FFFFFF; }
.btn-vermilion-md:disabled { opacity: 0.45; cursor: not-allowed; }
.dlg-actions-row { margin-top: 20px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.sci-pick-hint { margin-right: auto; font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* Question Report Dialog */
.report-reasons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.report-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1.5px solid transparent;
  background: var(--fill-1);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.report-opt[aria-checked="true"] {
  background: rgba(223, 64, 52, 0.06);
  border-color: var(--jp);
  color: var(--jp-text);
}
.report-radio {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--fill-3);
  background: transparent;
  position: relative;
  transition: border-color 140ms ease, background-color 140ms ease;
}
.report-opt[aria-checked="true"] .report-radio {
  border-color: var(--jp);
  background: var(--jp);
}
.report-opt[aria-checked="true"] .report-radio::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #FFFFFF;
}
.report-detail-wrap { margin-top: 14px; }
.report-detail-input {
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.5;
  resize: vertical;
}
.report-detail-input:focus {
  outline: none;
  border-color: var(--jp);
}
.desk-toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 950;
  padding: 10px 18px;
  border-radius: 999px;
  background: #1C1C22;
  color: #FFFFFF;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.24);
  pointer-events: none;
}

.zoom-bar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--rule); }
.zoom-cap { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.zoom-stage { margin-top: 14px; display: grid; place-items: center; }
.zoom-stage img { max-height: 75dvh; width: auto; object-fit: contain; }

/* Login Modal Fields */
.authed-card { margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--fill-1); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.authed-card[hidden], .dlg-mode-seg[hidden], .dlg-form[hidden], .dlg-field[hidden], .guest-reset-row[hidden] { display: none !important; }
.authed-profile-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.authed-avatar { width: 50px; height: 50px; border-radius: 12px; overflow: clip; flex: none; box-shadow: inset 0 0 0 1px rgba(24, 24, 28, 0.08); }
.authed-avatar svg, .authed-avatar img { width: 100%; height: 100%; display: block; object-fit: cover; }
.authed-card-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.authed-card-info strong { font-size: 15px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.authed-uid-row { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.btn-copy-uid-sm { padding: 1.5px 7px; border-radius: 5px; background: var(--paper); color: var(--ink-2); font-size: 11px; font-weight: 700; box-shadow: inset 0 0 0 1px var(--rule); }
.btn-copy-uid-sm:hover { background: var(--ink); color: #FFFFFF; }
#authed-plan-badge { font-size: 12px; color: var(--ok); font-weight: 700; }

.mock-captcha-row { display: grid; grid-template-columns: 1fr 116px; gap: 8px; align-items: stretch; }
.mock-captcha-btn { min-height: 44px; border-radius: 10px; background: #F5F1EA; border: 1.5px solid var(--input-border); overflow: clip; display: grid; place-items: center; padding: 0; }
.mock-captcha-btn:hover { border-color: var(--ink); }
#mock-captcha-slot { font-size: 12px; font-weight: 600; color: var(--ink-3); line-height: 1; }
#mock-captcha-slot svg { display: block; width: 112px; height: 40px; }

.guest-reset-row { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.btn-guest-reset { padding: 4px 10px; border-radius: 7px; background: var(--fill-1); color: var(--ink-2); font-size: 12px; font-weight: 700; }
.btn-guest-reset:hover { background: var(--jp-bg); color: var(--jp-text); }

.dlg-mode-seg { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 3px; border-radius: 10px; background: var(--fill-1); }
.dlg-mode-seg button { min-height: 36px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.dlg-mode-seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); }

.dlg-form { margin-top: 16px; display: flex; flex-direction: column; gap: 14px; }
.dlg-field { display: flex; flex-direction: column; gap: 4px; }
.dlg-field label { font-size: 13px; font-weight: 700; color: var(--ink); }
.dlg-field label span { color: var(--jp-text); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.dlg-field input { width: 100%; min-height: 44px; padding: 0 13px; border-radius: 10px; border: 1.5px solid var(--input-border); font: inherit; font-size: 15px; }
.dlg-field input:focus-visible { outline: 2px solid var(--ink); outline-offset: 0; border-color: var(--ink); }
.pw-label-row { display: flex; align-items: center; justify-content: space-between; }
.pw-row-actions { display: inline-flex; gap: 8px; }
.pw-forgot-btn { font-size: 12px; font-weight: 600; color: var(--ink-3); text-decoration: underline; }
.pw-eye-btn { padding: 2px 9px; border-radius: 6px; background: var(--fill-1); font-size: 12px; font-weight: 600; }
.code-input-row { display: flex; gap: 8px; }
.btn-send-code { min-height: 44px; padding: 0 12px; border-radius: 10px; background: var(--fill-1); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.domain-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.domain-chips button { padding: 4px 9px; border-radius: 7px; background: var(--fill-1); font-size: 12px; font-weight: 600; }
.dlg-status { padding: 10px 12px; border-radius: 10px; background: var(--jp-bg); color: var(--jp-text); font-size: 13px; font-weight: 600; }
.dlg-status.is-ok { background: var(--ok-bg); color: var(--ok); }
#mock-confirm-pw-error { color: var(--jp-text); }
#mock-confirm-pw-error:empty { height: 0; overflow: hidden; }
#mock-password-confirm[aria-invalid="true"] { border-color: var(--jp); }
.btn-login-submit { width: 100%; min-height: 44px; border-radius: 12px; background: var(--jp-fill); color: #FFFFFF; font-size: 14.5px; font-weight: 700; }

/* Responsive Breakpoints */
@media (max-width: 960px) {
  .runner-title-meta { max-width: 170px; }
  .sec-tabs { min-width: 140px; }
  .sec-tabs button { padding: 0 8px; font-size: 13px; }
}
@media (pointer: coarse) {
  .runner-controls button, .subj-tabs button, .sec-tabs button, .tm-btn { min-height: 44px; min-width: 44px; }
}

/* Auto-compact sticky right rail on shorter viewports or tablet widths */
@media (min-width: 761px) and (max-height: 790px), (min-width: 761px) and (max-width: 1080px) {
  .view-hub { padding-top: 12px; }
  .hub-right-rail { top: 66px; gap: 10px; }
  .cover-ticket { border-radius: 20px; }
  .ticket-cover { padding: 12px 18px 11px; }
  .ticket-heading, .ticket-year { font-size: 38px; }
  .ticket-round { font-size: 15px; }
  .ticket-cover-sub { margin-top: 6px; gap: 8px; }
  .ticket-meta { font-size: 12.5px; }
  .ticket-sheet { padding: 9px 18px 11px; }
  .ticket-mod-row { padding: 6px 0; gap: 10px; }
  .ticket-dock { margin-top: 7px; padding-top: 8px; }
  .study-plate { padding: 10px 14px; gap: 5px; }
  .trend-chart-wrap { padding: 6px 8px 5px; }
  .trend-svg { aspect-ratio: 340 / 74; }
}

@media (max-width: 1080px) {
  .hub-desk-grid { grid-template-columns: minmax(0, 1fr) 340px; gap: 16px 20px; }
  .archive-shelf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mock-header-inner { padding: 0 18px; gap: 12px; }
}

@media (max-width: 900px) {
  .hub-desk-grid { grid-template-columns: minmax(0, 1fr) 316px; gap: 14px 16px; }
  .bt-year { font-size: 18px; }
  .insights-tabs button { padding: 0 8px; font-size: 12px; }
  .trend-series-seg { gap: 3px; }
  .trend-series-seg button { padding: 0 6px; font-size: 11px; }
  .trend-win-seg button { padding: 0 5px; font-size: 11px; }
  .runner-title-meta { display: none; }
  .exam-paper-stage { padding: 18px 16px 64px; }
  .exam-unit-sheet { padding: 24px 22px 24px; }
}

@media (max-width: 760px) {
  .hub-desk-grid { grid-template-columns: 1fr; grid-template-rows: auto auto; gap: 16px; }
  .hub-right-rail { grid-column: 1; grid-row: 1; position: static; }
  .shelf-col { grid-column: 1; grid-row: 2; }
}

@media (max-width: 640px) {
  body:not([data-screen="runner"]) .mock-header-inner { padding: 6px 12px; gap: 6px; }
  body:not([data-screen="runner"]) .brand-desk { display: none; }
  body:not([data-screen="runner"]) .header-left { gap: 8px; }
  body:not([data-screen="runner"]) .header-right { gap: 5px; }
  body:not([data-screen="runner"]) .btn-hdr-vocab > span:not(.vocab-count),
  body:not([data-screen="runner"]) .btn-hdr-auth > span { display: none; }
  body:not([data-screen="runner"]) :is(.btn-hdr-vocab, .btn-hdr-auth) { padding: 0 8px; gap: 4px; min-height: 32px; }

  body[data-screen="runner"] .mock-header-inner { flex-wrap: nowrap; min-height: 50px; padding: 0 8px; gap: 5px; }
  body[data-screen="runner"] .header-left { flex: 1 1 auto; min-width: 0; gap: 4px; }
  body[data-screen="runner"] .header-right { flex: none; gap: 4px; }
  body[data-screen="runner"] .runner-controls { gap: 4px; }
  body[data-screen="runner"] :is(#btn-back-lbl, .prefs-lbl, .tool-lbl) { display: none; }
  body[data-screen="runner"] .btn-hdr-vocab > span:not(.vocab-count) { display: none; }
  body[data-screen="runner"] :is(.btn-ghost-sm, .btn-tool-pill, .btn-runner-prefs, .btn-palette-hero, .btn-hdr-vocab) {
    padding: 0 7px;
    gap: 4px;
    min-height: 36px;
  }
  body[data-screen="runner"] .btn-hdr-submit { padding: 0 10px; min-height: 36px; font-size: 12.5px; }
  body[data-screen="runner"] .timer-pill { min-height: 36px; padding: 8px 10px; font-size: 12px; }
  body[data-screen="runner"] .vocab-count { min-width: 18px; height: 18px; padding: 0 5px; font-size: 11.5px; }
  body[data-screen="runner"] .sec-tabs button { min-height: 49px; padding: 0 6px; font-size: 13px; }
  body[data-screen="runner"] .sec-tabs button[aria-selected="true"]::after { inset: auto 4px 0; }

  .view-hub { padding: 14px 14px 52px; }
  .view-mistakes { padding: 16px 14px 110px; }
  .hub-toolbar { gap: 8px; }
  .subj-tabs button { min-height: 40px; padding: 0 10px; font-size: 14px; }
  .hub-filter-bar { width: 100%; justify-content: space-between; gap: 6px; }
  .status-filter button { padding: 0 8px; font-size: 12px; }
  .ts-table-head, .ts-table-row { grid-template-columns: minmax(0, 1fr) 64px 64px; gap: 6px; }
  .ts-acc-panel { padding-left: 4px; }
  .free-shelf-grid, .archive-shelf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .booklet-tile, .booklet-tile.is-free-spot { padding: 13px 12px; }
  .booklet-tile.is-free-spot .bt-year { font-size: 22px; }
  .ticket-year { font-size: 44px; }
  .exam-paper-stage { padding: 12px 10px 48px; }
  .exam-unit-sheet { padding: 20px 16px 20px; border-radius: 16px; }
  .unit-material { padding: 16px 16px; border-radius: 12px; }
  .options-grid-fig { grid-template-columns: 1fr; }
  .res-cover { padding: 20px 18px; }
  .res-body { padding: 18px; }
  .calc-panel { right: 10px; bottom: 10px; }
}

/* Content Protection: Disable copy/selection on exam runner/review/mistake surfaces & block PDF printing */
#view-runner,
#view-result .res-shell,
#view-mistakes .mistake-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
#view-runner :is(input, textarea, [contenteditable="true"]),
.exam-shadow-root :is(input, textarea, [contenteditable="true"]),
.kj-textarea,
.kj-annotated-paper {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
#view-runner img,
#view-result img,
#view-mistakes img {
  -webkit-user-drag: none;
  user-drag: none;
}

@media print {
  html, body {
    background: #FFFFFF !important;
  }
  body > *,
  #view-runner,
  #view-result,
  #view-mistakes,
  #view-hub {
    display: none !important;
  }
  body::before {
    content: "EJU+ 历年真题受版权保护，不支持打印或导出 PDF。";
    display: block;
    padding: 64px 24px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #18181C;
  }
}

/* ── 作文总台 (WeChat-style Sidebar History Console) ───────────────── */
.view-essays {
  min-height: calc(100vh - 60px);
  padding: 20px 24px 36px;
  background: var(--bg-app);
}
.essays-shell {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.essays-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.essays-filter-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: var(--fill-1);
  border: 1px solid var(--rule);
  gap: 2px;
}
.essays-filter-seg button {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-3);
  transition: background-color 0.14s, color 0.14s;
}
.essays-filter-seg button[aria-pressed="true"] {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(24, 24, 28, 0.06);
}
.essays-split {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: calc(100vh - 156px);
  min-height: 540px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  overflow: hidden;
}
.essays-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--rule);
  background: #FAFAFB;
  min-height: 0;
}
.essays-search-wrap {
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
}
.essays-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--bg-app);
  font-size: 13px;
  color: var(--ink);
}
.essays-search-input:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--paper);
}
.essays-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.essay-nav-item {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border: 1px solid transparent;
  transition: background-color 0.12s, border-color 0.12s;
}
.essay-nav-item:hover {
  background: rgba(24, 24, 28, 0.035);
}
.essay-nav-item.is-active {
  background: var(--paper);
  border-color: var(--rule);
  box-shadow: 0 1px 3px rgba(24, 24, 28, 0.05);
}
.essay-nav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.essay-nav-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.essay-nav-time {
  flex: none;
  font-size: 11px;
  color: var(--ink-4);
}
.essay-nav-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.essay-nav-preview {
  font-size: 12px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.essay-nav-badge {
  flex: none;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.essay-nav-badge.is-graded {
  background: #FFF2F0;
  color: var(--jp-text);
}
.essay-nav-badge.is-draft {
  background: var(--fill-1);
  color: var(--ink-3);
}
.essay-nav-badge.is-local {
  background: #FDF4E3;
  color: #8A5D0A;
}
.essays-detail {
  overflow-y: auto;
  padding: 24px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  background: var(--paper);
}
.essays-detail > * {
  width: 100%;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.essays-detail .kj-review-hero {
  margin-bottom: 0;
}
.essays-detail .kj-annotated-paper {
  font-size: 15.5px;
  line-height: 1.9;
  padding: 20px 24px;
  white-space: normal;
}
.kj-annotated-paper.is-para-mode {
  white-space: normal;
}
.kj-rev-para {
  margin: 0;
}
.kj-rev-para + .kj-rev-para {
  margin-top: 14px;
}
.essays-detail .kj-mark-card {
  margin-top: 0;
  box-shadow: none;
  border-color: var(--rule);
}
.btn-vermilion-sm {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--jp-fill);
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.14s;
}
.btn-vermilion-sm:hover { background: var(--jp); }
.essays-empty-pane {
  margin: auto;
  max-width: 360px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--ink-3);
  padding: 40px 16px;
}
.essays-empty-pane h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.essays-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}
.essays-detail-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.essays-detail-meta {
  margin-top: 4px;
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--ink-3);
}
.essays-detail-acts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.essays-detail-acts .btn-secondary-sm {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
}
.essays-detail-body {
  padding: 20px 24px;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: "Noto Serif JP", "Yu Mincho", serif;
  font-size: 15.5px;
  line-height: 1.9;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}
.essays-marks-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.essays-mark-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.essays-mark-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
}
.essays-mark-quote {
  font-family: "Noto Serif JP", "Yu Mincho", serif;
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}
.essays-mark-fix {
  font-size: 13px;
  color: #167943;
  font-weight: 600;
}
.essays-mark-note {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
}
@media (max-width: 860px) {
  .view-essays { padding: 14px 12px 28px; }
  .essays-split {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }
  .essays-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--rule);
    max-height: 280px;
  }
  .essays-detail { padding: 18px 16px; }
}
