:root {
  --ink: #242421;
  --ink-soft: #4e4b45;
  --muted: #716d64;
  --paper: #f6f2e9;
  --paper-deep: #ebe4d8;
  --panel: #fffdf8;
  --line: #dcd4c7;
  --line-strong: #c8bdad;
  --amber: #c7803f;
  --amber-soft: #f1dfc8;
  --red: #a75542;
  --red-soft: #f3ddd6;
  --green: #47745b;
  --green-soft: #dcebdd;
  --blue: #4f6d82;
  --blue-soft: #dfe9ef;
  --shadow: 0 16px 38px rgba(65, 49, 29, 0.1);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.62;
}

button,
input {
  font: inherit;
}

button,
a,
input,
label {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(199, 128, 63, 0.46);
  outline-offset: 2px;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: -56px;
  left: 14px;
  padding: 9px 13px;
  border-radius: 5px;
  background: var(--ink);
  color: white;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  gap: 20px;
  align-items: center;
  min-height: 66px;
  padding: 10px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(36, 36, 33, 0.98);
  color: var(--panel);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--amber);
  color: #2a1d12;
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
  font-weight: 900;
}

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

.brand strong {
  font-size: 15px;
  line-height: 1.25;
}

.brand small {
  margin-top: 2px;
  color: #cfc7ba;
  font-size: 11px;
  line-height: 1.25;
}

.current-position {
  color: #d9d1c6;
  font-size: 12px;
  white-space: nowrap;
}

.topbar-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-track {
  width: 118px;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}

.progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: var(--amber);
  transition: width 180ms ease;
}

.progress-label {
  min-width: 78px;
  color: #d9d1c6;
  font-size: 11px;
  white-space: nowrap;
}

.topbar-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.23);
  border-radius: 6px;
  padding: 6px 10px;
  background: transparent;
  color: #f2e8db;
  cursor: pointer;
  font-size: 12px;
}

.topbar-button:hover {
  border-color: var(--amber);
  color: white;
}

.topbar-button svg {
  flex: 0 0 auto;
}

.persistence-status {
  width: min(1560px, calc(100% - 32px));
  margin: 12px auto 0;
  border: 1px solid var(--red);
  border-radius: 5px;
  padding: 8px 12px;
  background: var(--red-soft);
  color: #71382d;
  font-size: 12px;
}

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

.app-shell {
  display: grid;
  width: min(1600px, 100%);
  min-height: calc(100vh - 66px);
  margin: 0 auto;
  grid-template-columns: 260px minmax(0, 1fr) 390px;
  align-items: start;
}

.chapter-sidebar,
.entry-panel {
  position: sticky;
  top: 66px;
  min-width: 0;
  height: calc(100vh - 66px);
  overflow-y: auto;
}

.chapter-sidebar {
  padding: 24px 17px 34px 20px;
  border-right: 1px solid var(--line);
}

.sidebar-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.section-label,
.chapter-kicker,
.panel-label {
  color: var(--amber);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-heading h1 {
  margin: 1px 0 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: 25px;
  line-height: 1.1;
}

.map-count {
  min-width: 32px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-align: right;
}

.search-field {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--muted);
}

.search-field:focus-within {
  border-color: var(--amber);
  background: var(--panel);
}

.search-field input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.search-field input::placeholder {
  color: #918b82;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 9px;
}

.filter-check {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 5px 8px;
  background: rgba(255, 253, 248, 0.45);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 11px;
}

.filter-check:has(input:checked) {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
}

.filter-check input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--amber);
}

.chapter-map {
  margin-top: 21px;
}

.chapter-group + .chapter-group {
  margin-top: 20px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.group-title::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
}

.chapter-group.is-active .group-title::before {
  background: var(--amber);
}

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

.chapter-button {
  display: grid;
  width: 100%;
  min-height: 38px;
  grid-template-columns: 28px minmax(0, 1fr) 14px;
  gap: 7px;
  align-items: center;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 5px 5px 0;
  padding: 6px 5px 6px 7px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.chapter-button:hover {
  background: rgba(199, 128, 63, 0.08);
}

.chapter-button[aria-current="page"] {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.chapter-number {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 800;
}

.chapter-button.is-complete .chapter-number {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.chapter-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.35;
}

.important-dot,
.complete-mark {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  color: var(--amber);
  font-size: 11px;
  font-weight: 900;
}

.complete-mark {
  color: var(--green);
}

.map-empty {
  margin: 18px 2px;
  color: var(--muted);
  font-size: 12px;
}

.chapter-main {
  min-width: 0;
  padding: 35px 42px 80px;
}

.chapter-inner {
  width: min(820px, 100%);
  margin: 0 auto;
}

.chapter-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding-bottom: 23px;
  border-bottom: 1px solid var(--line);
}

.chapter-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
  margin-top: 4px;
}

.chapter-title-row h2 {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Songti SC", serif;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.22;
}

.weight-tag {
  flex: 0 0 auto;
  border: 1px solid var(--amber);
  border-radius: 4px;
  padding: 2px 6px;
  color: #8a5428;
  font-size: 10px;
  font-weight: 800;
}

.chapter-goal {
  max-width: 640px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.chapter-index-large {
  color: var(--amber);
  font-family: Georgia, serif;
  font-size: 47px;
  font-weight: 700;
  line-height: 1;
}

.level-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 24px 0 0;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 253, 248, 0.5);
  overflow: hidden;
}

.level-tab {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.level-tab:last-child {
  border-right: 0;
}

.level-tab:hover {
  color: var(--ink);
}

.level-tab[aria-selected="true"] {
  background: var(--ink);
  color: var(--panel);
}

.level-panel {
  padding: 19px 0 22px;
  border-bottom: 1px solid var(--line);
}

.level-panel h3 {
  margin: 0 0 10px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
}

.point-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.point-list li {
  display: grid;
  grid-template-columns: 21px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  color: var(--ink-soft);
  font-size: 13px;
}

.point-index {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--amber-soft);
  color: #8a5428;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 800;
}

.content-section {
  margin-top: 28px;
}

.section-heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.section-heading h3 {
  margin: 0;
  font-size: 15px;
}

.section-heading span {
  color: var(--muted);
  font-size: 11px;
}

.case-tabs {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 7px;
  margin-bottom: 15px;
}

.case-tab {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 6px 10px;
  background: rgba(255, 253, 248, 0.56);
  color: var(--ink-soft);
  text-align: left;
  white-space: normal;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.45;
}

.case-tab[aria-selected="true"] {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
  font-weight: 800;
}

.case-title {
  margin: 0 0 8px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 23px;
  line-height: 1.35;
}

.scenario {
  margin: 0;
  color: var(--ink-soft);
}

.assumption-band {
  margin-top: 15px;
  border-left: 3px solid var(--amber);
  padding: 11px 14px;
  background: var(--amber-soft);
}

.assumption-band strong {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
}

.assumption-band ul,
.trap-band ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
}

.assumption-band li + li,
.trap-band li + li {
  margin-top: 4px;
}

.step-list {
  display: grid;
  gap: 0;
  margin: 17px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: case-step;
}

.step-item {
  position: relative;
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 10px;
  min-height: 48px;
  padding: 7px 0 12px;
  counter-increment: case-step;
}

.step-item:not(:last-child)::before {
  position: absolute;
  top: 31px;
  bottom: -2px;
  left: 14px;
  width: 1px;
  background: var(--line-strong);
  content: "";
}

.step-item::after {
  display: grid;
  z-index: 1;
  width: 29px;
  height: 29px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  content: counter(case-step);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  grid-column: 1;
  grid-row: 1;
}

.step-copy {
  min-width: 0;
  padding-top: 3px;
  color: var(--ink-soft);
  font-size: 13px;
  grid-column: 2;
  overflow-wrap: anywhere;
}

.step-copy strong {
  display: block;
  color: var(--ink);
}

.formula-line {
  display: block;
  margin-top: 6px;
  border-left: 2px solid var(--blue);
  padding: 6px 9px;
  background: var(--blue-soft);
  color: #334b5b;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.case-conclusion {
  margin-top: 15px;
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--ink);
  color: #e9e1d7;
  font-size: 13px;
}

.case-conclusion strong {
  color: #efc58c;
}

.trap-band {
  border-left: 3px solid var(--red);
  padding: 13px 15px;
  background: var(--red-soft);
}

.trap-band h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

.quiz-grid {
  display: grid;
  gap: 10px;
}

.quiz-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 253, 248, 0.66);
}

.quiz-question {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.quiz-option {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 5px 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
}

.quiz-option:hover,
.quiz-option.is-selected {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.quiz-option.is-correct {
  border-color: var(--green);
  background: var(--green-soft);
}

.quiz-option.is-wrong {
  border-color: var(--red);
  background: var(--red-soft);
}

.quiz-feedback {
  margin: 10px 0 0;
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  background: var(--green-soft);
  font-size: 11px;
}

.chapter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  padding-top: 19px;
  border-top: 1px solid var(--line);
}

.source-note {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.source-note a {
  color: var(--blue);
  text-underline-offset: 3px;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 5px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.primary-action {
  border: 1px solid var(--amber);
  background: var(--amber);
  color: #281d13;
}

.primary-action.is-complete {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

.secondary-action {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.entry-panel {
  border-left: 1px solid var(--line);
  padding: 27px 20px 40px;
  background: rgba(255, 253, 248, 0.42);
}

.entry-panel-inner {
  width: 100%;
  max-width: 350px;
  margin: 0 auto;
}

.entry-panel h2 {
  margin: 3px 0 4px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 22px;
  line-height: 1.3;
}

.entry-intro {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
}

.entry-picker {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.entry-picker-button {
  display: grid;
  width: 100%;
  min-height: 38px;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(255, 253, 248, 0.55);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.entry-picker-button[aria-current="true"] {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.entry-picker-number {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 4px;
  background: var(--paper-deep);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 800;
}

.entry-picker-title {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 10px;
  line-height: 1.35;
}

.entry-sheet {
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.entry-sheet-header {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.scope-label {
  display: inline-block;
  border-radius: 4px;
  padding: 3px 6px;
  background: var(--ink);
  color: white;
  font-size: 9px;
}

.entry-sheet-header h3 {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.4;
}

.entry-lines {
  padding: 7px 14px 9px;
}

.entry-line {
  display: grid;
  min-width: 0;
  grid-template-columns: 27px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #eee8de;
}

.entry-line:last-child {
  border-bottom: 0;
}

.direction {
  color: var(--red);
  font-size: 10px;
  font-weight: 900;
}

.account-block {
  min-width: 0;
}

.account-name {
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 700;
}

.account-type {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.line-source {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
  line-height: 1.4;
}

.amount {
  padding-top: 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.balance-strip {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px 14px;
  background: #f3ede4;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.balance-state {
  color: var(--green);
  font-family: inherit;
  font-weight: 900;
}

.balance-state.is-error {
  color: var(--red);
}

.entry-explanation {
  padding: 12px 14px 2px;
}

.explanation-row {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 10px;
}

.explanation-row strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 10px;
}

.statement-impact {
  padding: 3px 14px 14px;
}

.statement-impact h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 10px;
}

.impact-list {
  display: grid;
  gap: 7px;
}

.impact-row {
  border-left: 3px solid var(--blue);
  padding: 7px 9px;
  background: var(--blue-soft);
}

.impact-row strong {
  display: block;
  margin-bottom: 2px;
  color: #355163;
  font-size: 9px;
}

.impact-row p {
  margin: 0;
  color: #3d4d57;
  font-size: 10px;
  line-height: 1.45;
}

.entry-empty {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.entry-empty strong {
  display: block;
  margin-bottom: 4px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 17px;
}

.entry-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.loading-state,
.fatal-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  align-content: center;
  color: var(--muted);
  text-align: center;
}

.loading-state.compact {
  min-height: 160px;
}

.loading-rule {
  display: block;
  width: 60px;
  height: 3px;
  background: var(--amber);
  animation: load-rule 1.2s ease-in-out infinite alternate;
}

.fatal-state strong {
  color: var(--red);
}

.fatal-state p {
  max-width: 520px;
  margin: 8px auto 0;
  font-size: 12px;
}

.data-warning {
  margin: 0 auto 22px;
  border-left: 3px solid var(--red);
  padding: 10px 12px;
  background: var(--red-soft);
  color: #71392d;
  font-size: 11px;
}

noscript {
  display: block;
  padding: 18px;
  background: var(--red-soft);
  color: var(--red);
  text-align: center;
}

@keyframes load-rule {
  from { transform: scaleX(0.42); }
  to { transform: scaleX(1); }
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr) 350px;
  }

  .chapter-main {
    padding-right: 28px;
    padding-left: 28px;
  }

  .topbar {
    gap: 14px;
  }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(180px, 1fr) auto auto;
  }

  .current-position {
    display: none;
  }

  .app-shell {
    grid-template-columns: 224px minmax(0, 1fr);
  }

  .entry-panel {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    grid-column: 2;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding: 28px;
  }

  .entry-panel-inner {
    max-width: 820px;
  }

  .chapter-sidebar {
    grid-row: 1 / span 2;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    min-height: 62px;
    padding: 9px 13px;
  }

  .topbar-progress {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
  }

  .progress-track {
    width: 100%;
  }

  .topbar-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .topbar-button {
    width: 36px;
    padding: 0;
  }

  .app-shell {
    display: block;
    min-height: 0;
  }

  .chapter-sidebar {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    padding: 17px 14px 13px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-heading {
    margin-bottom: 11px;
  }

  .sidebar-heading h1 {
    font-size: 21px;
  }

  .chapter-map {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 12px;
    margin-top: 14px;
  }

  .chapter-group,
  .chapter-group + .chapter-group {
    min-width: 0;
    margin-top: 0;
  }

  .group-title {
    align-items: flex-start;
    line-height: 1.35;
  }

  .chapter-main {
    padding: 27px 18px 52px;
  }

  .chapter-header {
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 10px;
  }

  .chapter-title-row {
    display: block;
  }

  .chapter-title-row h2 {
    font-size: 27px;
  }

  .weight-tag {
    display: inline-block;
    margin-top: 7px;
  }

  .chapter-index-large {
    font-size: 39px;
  }

  .level-tab {
    padding-right: 7px;
    padding-left: 7px;
    font-size: 11px;
  }

  .case-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
    padding-bottom: 0;
  }

  .case-tab {
    min-width: 0;
    white-space: normal;
    text-align: left;
    line-height: 1.45;
  }

  .case-title {
    font-size: 20px;
  }

  .chapter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .action-buttons {
    width: 100%;
  }

  .primary-action,
  .secondary-action {
    flex: 1 1 auto;
  }

  .entry-panel {
    padding: 25px 18px 42px;
  }
}

@media (max-width: 420px) {
  .brand strong {
    font-size: 14px;
  }

  .brand small {
    font-size: 10px;
  }

  .filter-row {
    gap: 6px;
  }

  .chapter-main,
  .entry-panel {
    padding-right: 14px;
    padding-left: 14px;
  }

  .entry-line {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .amount {
    padding-top: 3px;
    grid-column: 2;
  }

  .balance-strip {
    grid-template-columns: 1fr 1fr;
  }

  .balance-state {
    grid-column: 1 / -1;
  }
}

@media (max-width: 360px) {
  .chapter-map,
  .case-tabs {
    grid-template-columns: minmax(0, 1fr);
  }
}

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