:root {
  color-scheme: light;
  --ink: #1e211f;
  --muted: #696d68;
  --canvas: #ebe9e3;
  --canvas-deep: #dedbd3;
  --paper: #fffdf8;
  --paper-edge: rgba(58, 55, 48, 0.13);
  --accent: #e4572e;
  --accent-dark: #be3f1c;
  --blue-ink: #244c5a;
  --glass: rgba(247, 246, 242, 0.78);
  --shadow: 0 34px 80px rgba(55, 49, 38, 0.15), 0 5px 16px rgba(55, 49, 38, 0.08);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 18%, rgba(255, 255, 255, 0.76), transparent 28rem),
    radial-gradient(circle at 91% 82%, rgba(196, 188, 171, 0.28), transparent 34rem),
    linear-gradient(135deg, var(--canvas) 0%, #f0eee9 42%, var(--canvas-deep) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select,
input {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  padding-top: env(safe-area-inset-top);
  background: var(--glass);
  border-bottom: 1px solid rgba(255, 255, 255, 0.62);
  box-shadow: 0 1px 0 rgba(80, 75, 65, 0.08);
  backdrop-filter: blur(22px) saturate(145%);
  -webkit-backdrop-filter: blur(22px) saturate(145%);
}

.topbar-inner {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(220px, 1.3fr) auto;
  gap: 24px;
  align-items: center;
  width: min(1180px, 100%);
  min-height: 82px;
  margin: 0 auto;
  padding: 12px max(22px, env(safe-area-inset-right)) 12px max(22px, env(safe-area-inset-left));
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-stamp {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--paper);
  font-family: Georgia, serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: var(--blue-ink);
  border-radius: 12px 12px 12px 3px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.22);
}

.brand strong,
.brand small,
.file-meta strong,
.file-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.file-meta {
  min-width: 0;
  padding-left: 24px;
  border-left: 1px solid rgba(71, 72, 67, 0.14);
}

.file-meta strong {
  font-size: 0.88rem;
  font-weight: 650;
}

.file-meta span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.top-actions,
.dialog-actions {
  display: flex;
  gap: 9px;
  align-items: center;
}

.button,
.pager-button,
.icon-button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 100ms ease-out, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.button {
  display: inline-flex;
  min-height: 44px;
  padding: 0 17px;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  border-radius: 14px;
}

.button-primary {
  color: #fffaf4;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(190, 63, 28, 0.19), inset 0 1px rgba(255, 255, 255, 0.22);
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-quiet {
  color: #424641;
  background: rgba(255, 255, 255, 0.64);
  box-shadow: inset 0 0 0 1px rgba(62, 65, 60, 0.1);
}

.button-quiet:hover {
  background: rgba(255, 255, 255, 0.96);
}

.button:active,
.pager-button:active,
.icon-button:active {
  transform: scale(0.96);
}

.button:disabled,
.pager-button:disabled {
  cursor: default;
  opacity: 0.38;
  transform: none;
}

.button-large {
  min-height: 52px;
  padding: 0 22px;
  font-size: 0.94rem;
  border-radius: 16px;
}

.empty-state {
  display: grid;
  grid-template-columns: minmax(280px, 480px) minmax(280px, 470px);
  gap: clamp(48px, 8vw, 112px);
  align-items: center;
  width: min(1080px, calc(100% - 48px));
  min-height: calc(100vh - 82px);
  margin: 0 auto;
  padding: 64px 0 92px;
}

.empty-paper {
  position: relative;
  width: min(100%, 430px);
  aspect-ratio: 210 / 297;
  justify-self: end;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(54, 51, 45, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 24px;
  border: 1px solid var(--paper-edge);
  box-shadow: var(--shadow);
  transform: rotate(-1.4deg);
}

.empty-paper::before {
  position: absolute;
  inset: 5.5%;
  content: "";
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid rgba(48, 47, 43, 0.18);
}

.empty-paper-kicker,
.empty-paper-page {
  position: absolute;
  z-index: 1;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.empty-paper-kicker {
  top: 3.4%;
  left: 5.5%;
}

.empty-paper-page {
  right: 5.5%;
  bottom: 3.4%;
  color: var(--muted);
}

.empty-word {
  position: absolute;
  z-index: 1;
  font-family: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: clamp(1.05rem, 2.5vw, 1.7rem);
  font-weight: 600;
}

.empty-word-one { top: 20%; left: 13%; transform: rotate(-6deg); }
.empty-word-two { top: 36%; right: 10%; transform: rotate(8deg); }
.empty-word-three { top: 61%; left: 18%; transform: rotate(5deg); }
.empty-word-four { right: 14%; bottom: 16%; transform: rotate(-9deg); }

.empty-copy {
  max-width: 460px;
}

.eyebrow {
  margin: 0 0 20px;
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.empty-copy h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(2.45rem, 5vw, 4.6rem);
  font-weight: 600;
  line-height: 1.03;
  letter-spacing: -0.055em;
}

.empty-copy > p:not(.eyebrow) {
  max-width: 38em;
  margin: 26px 0 30px;
  color: #5f625e;
  font-size: 0.98rem;
  line-height: 1.85;
}

.empty-copy > small {
  display: block;
  margin-top: 13px;
  color: var(--muted);
  font-size: 0.72rem;
}

.study-view {
  width: 100%;
  padding: 28px max(14px, env(safe-area-inset-right)) 80px max(14px, env(safe-area-inset-left));
}

.study-view[hidden],
.empty-state[hidden],
.status-bar[hidden],
.paper-stage[hidden],
.analysis-panel[hidden] {
  display: none;
}

.print-document {
  display: none;
}

.study-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 64px;
  margin: 0 auto 22px;
  padding: 6px;
  background: rgba(249, 248, 244, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.66);
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(59, 54, 43, 0.09);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.view-tabs {
  display: flex;
  margin: 0;
  padding: 3px;
  background: rgba(45, 48, 44, 0.07);
  border: 0;
  border-radius: 14px;
}

.view-tabs label {
  cursor: pointer;
}

.view-tabs span {
  display: grid;
  min-width: 88px;
  height: 42px;
  padding: 0 15px;
  place-items: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
  border-radius: 11px;
  transition: transform 100ms ease-out, color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.view-tabs input:checked + span {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 5px rgba(51, 48, 41, 0.13), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.view-tabs label:active span {
  transform: scale(0.96);
}

.view-tabs input:focus-visible + span {
  outline: 3px solid rgba(36, 76, 90, 0.34);
  outline-offset: 3px;
}

.pager {
  display: flex;
  gap: 9px;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 52px;
  margin: 0;
  padding: 0;
}

.pager-button,
.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  background: transparent;
  border-radius: 12px;
}

.pager-button:hover,
.icon-button:hover {
  background: rgba(45, 48, 44, 0.07);
}

.page-select-wrap,
.pdf-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.page-select-wrap select,
.pdf-select-wrap select {
  min-width: 126px;
  height: 42px;
  padding: 0 36px 0 15px;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 750;
  appearance: none;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(46, 49, 45, 0.09);
  border-radius: 12px;
  cursor: pointer;
}

.page-select-wrap svg,
.pdf-select-wrap svg {
  position: absolute;
  right: 11px;
  width: 16px;
  pointer-events: none;
}

.pdf-select-wrap select {
  width: min(220px, 24vw);
  min-width: 150px;
  height: 44px;
  font-weight: 650;
}

.pdf-select-wrap select:disabled {
  cursor: default;
  opacity: 0.55;
}

.page-summary {
  padding: 0 12px 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.paper-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

.paper {
  position: relative;
  width: min(760px, calc(100vw - 28px));
  aspect-ratio: 210 / 297;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.92), transparent 22%),
    linear-gradient(90deg, rgba(65, 55, 39, 0.015), transparent 10%, transparent 90%, rgba(65, 55, 39, 0.018)),
    var(--paper);
  border: 1px solid var(--paper-edge);
  box-shadow: var(--shadow);
  isolation: isolate;
}

.paper::after {
  position: absolute;
  z-index: -1;
  inset: 0;
  content: "";
  opacity: 0.18;
  background-image: radial-gradient(rgba(36, 32, 25, 0.14) 0.45px, transparent 0.55px);
  background-size: 4px 4px;
  pointer-events: none;
}

.paper-header,
.paper-footer {
  position: absolute;
  z-index: 2;
  right: 5.5%;
  left: 5.5%;
  display: flex;
  justify-content: space-between;
  color: #5f625d;
  font-size: clamp(0.55rem, 1.4vw, 0.72rem);
  font-weight: 800;
  letter-spacing: 0.14em;
}

.paper-header {
  top: 3.6%;
}

.paper-footer {
  bottom: 3.2%;
  letter-spacing: 0.05em;
}

.paper-rule {
  position: absolute;
  z-index: 2;
  top: 6.4%;
  right: 5.5%;
  left: 5.5%;
  height: 2px;
  background: var(--accent);
}

.word-layer {
  position: absolute;
  z-index: 1;
  inset: 9% 5.5% 7.2%;
}

.word-button {
  position: absolute;
  display: grid;
  width: 18%;
  height: 11.5%;
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  place-items: center;
  color: var(--ink);
  background: transparent;
  border: 0;
  cursor: pointer;
  transform: translate(-50%, -50%);
  touch-action: manipulation;
}

.word-label {
  display: inline-flex;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 5px;
  align-items: center;
  justify-content: center;
  font-family: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: clamp(0.52rem, 1.65vw, 1.02rem);
  font-weight: 600;
  line-height: 1.02;
  text-align: center;
  text-wrap: balance;
  border-radius: 10px;
  transform: rotate(var(--rotation));
  transition: transform 100ms ease-out, color 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
  animation: word-arrive 220ms both;
  animation-delay: var(--delay);
}

.word-button:hover .word-label,
.word-button:focus-visible .word-label {
  color: var(--blue-ink);
  background: rgba(36, 76, 90, 0.075);
  box-shadow: 0 0 0 1px rgba(36, 76, 90, 0.08);
}

.word-button:active .word-label {
  transform: rotate(var(--rotation)) scale(0.93);
}

.word-button.is-speaking .word-label {
  color: white;
  background: var(--blue-ink);
  box-shadow: 0 0 0 4px rgba(36, 76, 90, 0.13);
  transform: rotate(var(--rotation)) scale(1.04);
}

.analysis-panel {
  width: min(860px, calc(100vw - 28px));
  margin: 0 auto;
}

.analysis-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 8px 7px 18px;
}

.analysis-kicker {
  color: var(--accent-dark);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.analysis-header h2 {
  margin: 6px 0 0;
  font-family: Georgia, "Noto Serif SC", "Songti SC", serif;
  font-size: clamp(1.75rem, 4vw, 2.55rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.analysis-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.analysis-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.analysis-list {
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(20, auto);
  column-gap: 28px;
  margin: 0;
  padding: 8px 24px;
  list-style: none;
  background: rgba(255, 253, 248, 0.94);
  border: 1px solid var(--paper-edge);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.analysis-item {
  display: grid;
  grid-template-columns: 2.7rem minmax(0, 1fr);
  gap: 0 8px;
  align-items: center;
  min-height: 76px;
  padding: 10px 4px;
  border-top: 1px solid rgba(54, 55, 51, 0.09);
}

.analysis-item:first-child,
.analysis-item:nth-child(21) {
  border-top: 0;
}

.analysis-number {
  grid-row: 1 / 3;
  align-self: start;
  padding-top: 14px;
  color: var(--accent-dark);
  font-size: 0.67rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.analysis-word {
  width: fit-content;
  max-width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  color: var(--blue-ink);
  font-family: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: clamp(1.18rem, 2.4vw, 1.5rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: left;
  overflow-wrap: anywhere;
  background: transparent;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 100ms ease-out, color 160ms ease, background-color 160ms ease;
}

.analysis-word:hover,
.analysis-word:focus-visible {
  color: #173e4c;
  background: rgba(36, 76, 90, 0.075);
}

.analysis-word:active {
  transform: scale(0.97);
}

.analysis-word.is-speaking {
  color: white;
  background: var(--blue-ink);
  transform: scale(1.02);
}

.analysis-meaning {
  grid-column: 2;
  margin: 0;
  color: #4f534e;
  font-size: 0.91rem;
  line-height: 1.65;
  white-space: pre-line;
}

@keyframes word-arrive {
  from { opacity: 0; transform: rotate(var(--rotation)) scale(0.93); }
  to { opacity: 1; transform: rotate(var(--rotation)) scale(1); }
}

.status-bar {
  position: fixed;
  z-index: 40;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  max-width: min(420px, calc(100vw - 36px));
  min-height: 48px;
  padding: 12px 16px;
  gap: 10px;
  align-items: center;
  color: #fdfbf6;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.4;
  background: rgba(31, 34, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(21, 21, 18, 0.22);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: status-in 180ms ease-out;
}

.status-bar[data-kind="error"] .status-dot {
  background: #ff8364;
  box-shadow: 0 0 0 4px rgba(255, 131, 100, 0.17);
}

.status-bar[data-kind="success"] .status-dot {
  background: #73c496;
  box-shadow: 0 0 0 4px rgba(115, 196, 150, 0.16);
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  background: #f2b05e;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(242, 176, 94, 0.16);
}

@keyframes status-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.word-dialog {
  width: min(640px, calc(100vw - 28px));
  max-height: min(88svh, 820px);
  padding: 24px;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: 0 34px 90px rgba(27, 25, 20, 0.28);
  backdrop-filter: blur(24px) saturate(130%);
  -webkit-backdrop-filter: blur(24px) saturate(130%);
}

.word-dialog[open] {
  animation: dialog-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.word-dialog::backdrop {
  background: rgba(30, 29, 26, 0.3);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dialog-topline {
  position: sticky;
  z-index: 2;
  top: -24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 0 11px;
  background: linear-gradient(rgba(255, 253, 248, 0.99) 72%, rgba(255, 253, 248, 0));
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.18em;
}

.word-dialog h2 {
  margin: 18px 0 15px;
  font-family: "Source Han Sans CN", "Source Han Sans SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: clamp(2.6rem, 8vw, 4.7rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: -0.045em;
  overflow-wrap: anywhere;
  transition: color 160ms ease;
}

.word-dialog h2.is-speaking {
  color: var(--blue-ink);
}

.pronunciation-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 18px;
}

.dialog-phonetic {
  color: #5d615d;
  font-size: 1.08rem;
  line-height: 1.4;
}

.dialog-pos {
  padding: 5px 9px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 750;
  background: rgba(228, 87, 46, 0.08);
  border-radius: 8px;
}

.dialog-pos + .pronunciation-button,
.dialog-phonetic + .pronunciation-button {
  margin-left: auto;
}

.pronunciation-button {
  padding: 7px 13px 7px 8px;
  color: var(--blue-ink);
  font-size: 0.8rem;
  font-weight: 750;
  background: rgba(36, 76, 90, 0.075);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(36, 76, 90, 0.08);
}

.pronunciation-button:hover {
  background: rgba(36, 76, 90, 0.12);
}

.pronunciation-badge,
.pronunciation-rate {
  display: inline-grid;
  min-height: 28px;
  padding: 0 9px;
  place-items: center;
  color: white;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  background: var(--blue-ink);
  border-radius: 999px;
}

.pronunciation-rate {
  color: var(--blue-ink);
  letter-spacing: 0;
  background: rgba(255, 255, 255, 0.72);
}

.meaning-block {
  padding: 18px 19px;
  background: #f1efe8;
  border-radius: 18px;
}

.meaning-block > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.meaning-block p {
  margin: 10px 0 0;
  font-size: 1rem;
  line-height: 1.72;
  white-space: pre-line;
}

.example-block {
  margin-top: 10px;
  padding: 18px 19px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(54, 55, 51, 0.09);
  border-radius: 18px;
}

.example-block > span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.example-block p {
  margin: 10px 0 0;
  font-size: 1rem;
  font-weight: 560;
  line-height: 1.55;
}

.word-details {
  margin-top: 16px;
}

.detail-panel {
  min-height: 78px;
  padding: 17px 18px;
  background: rgba(241, 239, 232, 0.72);
  border-radius: 17px;
}

.root-list {
  display: grid;
  gap: 13px;
}

.root-item + .root-item {
  padding-top: 13px;
  border-top: 1px solid rgba(54, 55, 51, 0.1);
}

.root-heading {
  display: flex;
  gap: 9px;
  align-items: center;
}

.root-heading strong {
  font-size: 1rem;
  font-weight: 720;
}

.root-kind {
  padding: 4px 7px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 800;
  background: rgba(228, 87, 46, 0.08);
  border: 1px solid rgba(228, 87, 46, 0.13);
  border-radius: 7px;
}

.root-item p {
  margin: 7px 0 0;
  color: #50544f;
  font-size: 0.88rem;
  line-height: 1.5;
}

.root-card {
  display: grid;
  gap: 14px;
}

.root-type {
  justify-self: start;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.root-equation {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.root-segment {
  display: grid;
  flex: 1 1 118px;
  gap: 3px;
  min-width: 0;
  padding: 10px 11px;
  background: rgba(241, 239, 232, 0.8);
  border-radius: 12px;
}

.root-segment small {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
}

.root-segment strong,
.root-result {
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.root-segment > span {
  color: #535752;
  font-size: 0.78rem;
  line-height: 1.35;
}

.root-equation-sign {
  flex: 0 0 auto;
  color: #9a9b96;
  font-size: 0.9rem;
}

.root-result {
  flex: 0 1 auto;
  padding: 9px 2px;
  color: var(--blue-ink);
  overflow-wrap: anywhere;
}

.root-bridge,
.root-note {
  margin: 0;
  color: #373b37;
  font-size: 0.9rem;
  line-height: 1.62;
}

.root-bridge > span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.root-note {
  padding: 10px 11px;
  color: #665647;
  font-size: 0.8rem;
  background: rgba(228, 87, 46, 0.065);
  border-radius: 10px;
}


.detail-status {
  margin: 9px 4px 0;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.45;
}

.detail-status:empty {
  display: none;
}

.dialog-actions {
  justify-content: flex-end;
  margin-top: 12px;
}

.icon-button {
  margin: -9px -8px -9px 0;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 76, 90, 0.34);
  outline-offset: 3px;
}

@media (max-width: 960px) {
  .topbar-inner {
    grid-template-columns: 1fr auto;
    gap: 10px 14px;
    padding-block: 10px;
  }

  .file-meta {
    grid-column: 1 / -1;
    grid-row: 3;
    padding: 9px 0 0;
    border-top: 1px solid rgba(71, 72, 67, 0.1);
    border-left: 0;
  }

  .top-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-end;
  }

  .pdf-select-wrap {
    flex: 1;
  }

  .pdf-select-wrap select {
    width: 100%;
  }

  .empty-state {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 40px;
    width: min(94%, 820px);
  }

  .empty-copy h1 {
    font-size: clamp(2.25rem, 7vw, 3.8rem);
  }
}

@media (max-width: 600px) {
  .topbar-inner {
    min-height: auto;
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .brand-stamp {
    width: 38px;
    height: 38px;
  }

  .brand small {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .pdf-select-wrap select {
    min-width: 0;
  }

  .top-actions .button {
    min-height: 42px;
    padding: 0 12px;
    font-size: 0.78rem;
  }

  .top-actions .button svg {
    display: none;
  }

  .empty-state {
    display: flex;
    min-height: auto;
    padding: 42px 0 76px;
    flex-direction: column-reverse;
  }

  .empty-paper {
    width: min(88%, 350px);
    align-self: center;
    transform: rotate(-1deg);
  }

  .empty-copy {
    width: 100%;
    text-align: center;
  }

  .empty-copy h1 {
    font-size: clamp(2.35rem, 12vw, 3.35rem);
  }

  .empty-copy > p:not(.eyebrow) {
    margin-inline: auto;
    line-height: 1.7;
  }

  .study-view {
    padding-top: 18px;
  }

  .study-controls {
    width: 100%;
    max-width: 390px;
    flex-direction: column;
    gap: 6px;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs label {
    flex: 1;
  }

  .view-tabs span {
    min-width: 0;
  }

  .pager {
    gap: 4px;
    width: 100%;
    max-width: 390px;
  }

  .page-select-wrap {
    flex: 1;
  }

  .page-select-wrap select {
    width: 100%;
  }

  .page-summary {
    display: none;
  }

  .paper {
    width: 100%;
  }

  .paper-footer span:first-child {
    max-width: 68%;
  }

  .word-label {
    min-height: 28px;
    padding: 4px 0;
    font-size: clamp(0.52rem, 2.3vw, 0.7rem);
    line-height: 0.98;
    overflow-wrap: anywhere;
    border-radius: 7px;
  }

  .analysis-panel {
    width: 100%;
  }

  .analysis-header {
    align-items: flex-start;
    padding-inline: 4px;
  }

  .analysis-header p {
    margin-top: 5px;
  }

  .analysis-actions {
    gap: 6px;
    flex-direction: column;
    align-items: flex-end;
  }

  .analysis-list {
    display: block;
    padding: 6px 16px;
    border-radius: 22px;
  }

  .analysis-item {
    padding: 12px 0;
  }

  .analysis-item:nth-child(21) {
    border-top: 1px solid rgba(54, 55, 51, 0.09);
  }

  .analysis-word {
    font-size: 1.2rem;
  }

  .analysis-meaning {
    font-size: 0.86rem;
  }

  .word-dialog {
    width: calc(100% - 16px);
    max-width: none;
    max-height: calc(100svh - 16px);
    margin: auto 8px max(8px, env(safe-area-inset-bottom));
    padding: 13px 18px 18px;
    border-radius: 28px 28px 20px 20px;
  }

  .dialog-topline {
    top: -13px;
    padding-top: 12px;
  }

  .word-dialog h2 {
    margin-top: 18px;
    font-size: clamp(2.45rem, 14vw, 4rem);
  }

  .pronunciation-bar {
    flex-wrap: wrap;
  }

  .dialog-pos + .pronunciation-button,
  .dialog-phonetic + .pronunciation-button {
    margin-left: 0;
  }

  .detail-panel {
    padding: 15px;
  }

  .status-bar {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .topbar,
  .study-controls,
  .status-bar,
  .word-dialog {
    background: #f8f7f3;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .dialog-topline {
    background: linear-gradient(#f8f7f3 72%, rgba(248, 247, 243, 0));
  }

  .status-bar {
    color: var(--ink);
  }
}

@media (prefers-contrast: more) {
  .topbar,
  .study-controls,
  .paper,
  .analysis-list,
  .word-dialog {
    border: 2px solid #222;
  }

  .word-button:focus-visible .word-label {
    outline: 3px solid #000;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  html,
  body {
    min-width: 0;
    min-height: 0;
    background: #fff;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .app-shell > :not(.print-document) {
    display: none !important;
  }

  .print-document {
    display: block;
  }

  .print-page {
    display: grid;
    grid-template-rows: 14mm 1fr 7mm;
    gap: 4mm;
    width: 210mm;
    height: 297mm;
    padding: 12mm 12mm 10mm;
    color: #1e211f;
    background: #fffdf8;
    break-after: page;
    page-break-after: always;
  }

  .print-page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding-bottom: 3mm;
    border-bottom: 0.6mm solid #e4572e;
  }

  .print-header strong {
    font-family: Georgia, serif;
    font-size: 15pt;
    letter-spacing: -0.03em;
  }

  .print-header span,
  .print-page footer {
    color: #5f625d;
    font-size: 7.5pt;
    font-weight: 700;
    letter-spacing: 0.08em;
  }

  .print-entries {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(20, minmax(0, 1fr));
    column-gap: 8mm;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .print-entries .analysis-item {
    grid-template-columns: 7mm 29mm minmax(0, 1fr);
    gap: 2mm;
    min-height: 0;
    padding: 0;
    border-top: 0;
    border-bottom: 0.2mm solid rgba(54, 55, 51, 0.12);
  }

  .print-entries .analysis-number {
    grid-row: auto;
    align-self: center;
    padding: 0;
    font-size: 6.5pt;
  }

  .print-entries .analysis-word {
    width: auto;
    min-height: 0;
    padding: 0;
    color: #244c5a;
    font-size: 9.2pt;
    line-height: 1.08;
    background: transparent;
  }

  .print-entries .analysis-meaning {
    grid-column: auto;
    color: #424641;
    font-size: 7.3pt;
    line-height: 1.22;
  }

  .print-page footer {
    align-self: end;
    text-align: right;
  }
}
