:root {
  --ink: #17212b;
  --muted: #66717f;
  --line: #d8dee6;
  --paper: #fbf6ee;
  --surface: #ffffff;
  --accent: #276d61;
  --accent-strong: #174f47;
  --header-accent: #137587;
  --header-accent-strong: #0f5f6d;
  --sky: #d9edf2;
  --peach: #ffe4cd;
  --lavender: #eee5ff;
  --amber: #bf7a22;
  --rose: #a73f55;
  --blue: #315f9e;
  --shadow: 0 18px 45px rgba(82, 70, 58, 0.12);
}

body[data-theme="dark"] {
  --ink: #edf3f7;
  --muted: #aab8c2;
  --line: #31414d;
  --paper: #111820;
  --surface: #18232d;
  --accent: #67c7b6;
  --accent-strong: #9ee0d5;
  --header-accent: #63c7d8;
  --header-accent-strong: #a6e6ef;
  --sky: #203544;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 228, 205, 0.95), transparent 290px),
    radial-gradient(circle at top right, rgba(217, 237, 242, 0.8), transparent 330px),
    linear-gradient(180deg, rgba(39, 109, 97, 0.07), transparent 270px),
    var(--paper);
}

body[data-theme="dark"] {
  background:
    radial-gradient(circle at top left, rgba(103, 199, 182, 0.18), transparent 310px),
    radial-gradient(circle at top right, rgba(111, 99, 200, 0.18), transparent 330px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 270px),
    var(--paper);
}

button,
input,
select,
a,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 30px clamp(16px, 4vw, 44px) 22px;
}

.top-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.theme-toggle,
.about-button {
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--header-accent) 22%, transparent);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--header-accent-strong);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 950;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.sheet-button {
  align-items: center;
  border: 1px solid color-mix(in srgb, var(--header-accent) 22%, transparent);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--header-accent-strong);
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  font-weight: 900;
  height: 44px;
  padding: 0 10px 0 14px;
}

.sheet-button strong {
  align-items: center;
  background: var(--header-accent);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 0.8rem;
  height: 24px;
  justify-content: center;
  min-width: 24px;
  padding: 0 7px;
}

.about-button {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
  font-style: italic;
  line-height: 1;
  padding-bottom: 2px;
}

.theme-toggle .moon-icon,
body[data-theme="dark"] .theme-toggle .sun-icon {
  display: none;
}

body[data-theme="dark"] .theme-toggle .moon-icon {
  display: inline;
}

.brand-block {
  align-items: center;
  display: flex;
  gap: 16px;
}

.globe-icon {
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid color-mix(in srgb, var(--header-accent) 16%, transparent);
  border-radius: 999px;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--header-accent) 18%, transparent);
  display: inline-flex;
  flex: 0 0 auto;
  height: 64px;
  justify-content: center;
  overflow: hidden;
  width: 64px;
}

body[data-theme="dark"] .globe-icon,
body[data-theme="dark"] .theme-toggle,
body[data-theme="dark"] .about-button,
body[data-theme="dark"] .sheet-button,
body[data-theme="dark"] .stats {
  background: rgba(24, 35, 45, 0.92);
  border-color: var(--line);
}

.globe-icon img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.eyebrow,
.viewer-kicker {
  margin: 0 0 5px;
  color: var(--header-accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(1.8rem, 3vw, 3rem);
  line-height: 1.05;
}

.subtitle {
  color: #4d5a63;
  font-size: clamp(0.98rem, 1.5vw, 1.16rem);
  line-height: 1.45;
  margin: 0;
  max-width: 680px;
}

body[data-theme="dark"] .subtitle {
  color: #c5d0d8;
}

.stats {
  min-width: 132px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--header-accent) 22%, transparent);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--header-accent-strong);
  font-weight: 700;
  text-align: center;
}

.mobile-stats-slot {
  display: none;
}

.list-layout {
  display: grid;
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 44px) 36px;
}

.search-banner {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
}

body[data-theme="dark"] .search-banner {
  background: rgba(24, 35, 45, 0.94);
}

.search-banner-field {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 110px minmax(0, 1fr);
}

.search-banner-field span {
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 900;
}

.search-banner-field input {
  min-height: 48px;
  font-size: 1rem;
}

.banner-controls {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: 1.15fr 1fr 0.85fr 1fr auto;
  margin-top: 14px;
}

.banner-reset {
  min-width: 138px;
}

.search-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.search-legend-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  margin-right: 2px;
  text-transform: uppercase;
}

.search-legend-item {
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
  padding: 4px 8px;
}

.app-shell {
  display: block;
}

.detail-page {
  padding: 0 clamp(16px, 4vw, 44px) 36px;
}

.results,
.viewer {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

body[data-theme="dark"] .results,
body[data-theme="dark"] .viewer,
body[data-theme="dark"] .resource-panel,
body[data-theme="dark"] .correction-panel {
  background: rgba(24, 35, 45, 0.94);
}

label,
.filter-group {
  display: grid;
  gap: 8px;
}

.favorite-filter {
  align-items: center;
  border: 1px solid #e4c46a;
  border-radius: 8px;
  background: #fff8df;
  color: #6d5012;
  display: flex;
  font-weight: 900;
  gap: 9px;
  min-height: 42px;
  padding: 0 11px;
}

body[data-theme="dark"] .favorite-filter {
  background: #332914;
  border-color: #846914;
  color: #ffe08a;
}

.favorite-filter input {
  accent-color: #d7a612;
  min-height: auto;
  width: auto;
}

label span,
.filter-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 11px;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select,
body[data-theme="dark"] .segment-button,
body[data-theme="dark"] .secondary-button,
body[data-theme="dark"] .back-button,
body[data-theme="dark"] .pdf-card-link,
body[data-theme="dark"] .secondary-resource,
body[data-theme="dark"] .resource-link {
  background: #111820;
  color: var(--ink);
  border-color: var(--line);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(39, 109, 97, 0.2);
  outline-offset: 2px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.segment-button,
.secondary-button,
.correction-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.segment-button[aria-pressed="true"],
.correction-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-button:hover,
.segment-button:hover,
.correction-button:hover {
  filter: brightness(0.97);
}

.results {
  overflow: hidden;
}

.list-head,
.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.list-head h2,
.viewer-toolbar h2 {
  margin: 0;
  font-size: 1.08rem;
}

.list-head select {
  max-width: 160px;
}

.exercise-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.exercise-card {
  --year-color: var(--accent);
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--year-color) 24%, var(--line));
  border-left: 8px solid var(--year-color);
  border-radius: 8px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--year-color) 13%, #fff) 0, #fff 34%),
    #fff;
  color: var(--ink);
  min-height: 100px;
  padding: 14px 14px 14px 16px;
  position: relative;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

body[data-theme="dark"] .exercise-card {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--year-color) 18%, #18232d) 0, #18232d 38%),
    #18232d;
}

.exercise-card:hover {
  border-color: color-mix(in srgb, var(--year-color) 55%, var(--line));
  box-shadow: 0 12px 26px rgba(82, 70, 58, 0.13);
  transform: translateY(-1px);
}

.exercise-card[aria-current="true"] {
  border-color: var(--year-color);
  box-shadow: inset 0 0 0 1px var(--year-color);
}

.card-topline {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin: 0 0 10px;
}

.card-title {
  display: block;
  margin: 0 0 8px;
  font-weight: 900;
  line-height: 1.25;
}

.year-ribbon {
  align-items: center;
  background: var(--year-color);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-size: 0.82rem;
  font-weight: 950;
  min-height: 30px;
  padding: 0 11px;
}

.favorite-button {
  align-items: center;
  border: 1px solid #e4c46a;
  border-radius: 999px;
  background: #fff8df;
  color: #6d5012;
  cursor: pointer;
  display: inline-flex;
  font-size: 1.05rem;
  font-weight: 950;
  justify-content: center;
  min-height: 30px;
  padding: 0;
  width: 34px;
}

.favorite-button[aria-pressed="true"] {
  background: #ffd95b;
  border-color: #d7a612;
  color: #4f3908;
}

body[data-theme="dark"] .favorite-button {
  background: #332914;
  border-color: #846914;
  color: #ffe08a;
}

body[data-theme="dark"] .favorite-button[aria-pressed="true"] {
  background: #ffd95b;
  border-color: #ffd95b;
  color: #2a2108;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  border: 0;
  background: #edf1f4;
  color: #405061;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

.tag-tone-analysis {
  background: #e8f1ff;
  color: #1e4f86;
}

.tag-tone-development {
  background: #fef0df;
  color: #9a4d0d;
}

.tag-tone-repere-history {
  background: #efe7ff;
  color: #6944b8;
}

.tag-tone-repere-geo {
  background: #e1f7ef;
  color: #1d7a59;
}

.tag-tone-emc {
  background: #ffe7ef;
  color: #a33d67;
}

button.tag {
  cursor: pointer;
  line-height: 1.2;
  text-align: left;
}

button.tag:hover {
  background: color-mix(in srgb, var(--year-color) 16%, #fff);
  color: color-mix(in srgb, var(--year-color) 76%, #17212b);
}

.detail-chapter-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--year-color) 36%, #fff);
  filter: saturate(1.05) brightness(0.98);
}

body[data-theme="dark"] .tag {
  background: #263441;
  color: #d7e1e8;
}

body[data-theme="dark"] .tag-tone-analysis {
  background: #1f3045;
  color: #c6dcff;
}

body[data-theme="dark"] .tag-tone-development {
  background: #3a2918;
  color: #ffd8ad;
}

body[data-theme="dark"] .tag-tone-repere-history {
  background: #312645;
  color: #d9c9ff;
}

body[data-theme="dark"] .tag-tone-repere-geo {
  background: #17372d;
  color: #bef0de;
}

body[data-theme="dark"] .tag-tone-emc {
  background: #402333;
  color: #ffc8db;
}

body[data-theme="dark"] button.tag:hover {
  background: color-mix(in srgb, var(--year-color) 28%, #18232d);
  color: #fff;
}

body[data-theme="dark"] .detail-chapter-button[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--year-color) 42%, #18232d);
  filter: saturate(1.08) brightness(1.04);
}

.year-tag {
  background: color-mix(in srgb, var(--year-color) 16%, #fff);
  color: color-mix(in srgb, var(--year-color) 72%, #17212b);
}

body[data-theme="dark"] .year-tag {
  background: color-mix(in srgb, var(--year-color) 26%, #18232d);
  color: #f6f8fb;
}

.place-tag {
  background: #e7f0ff;
  border: 1px solid #b8cff7;
  color: #254f8e;
}

body[data-theme="dark"] .place-tag {
  background: #19314f;
  border-color: #3d6aa5;
  color: #cbe0ff;
}

.repere-tag {
  background: #eef6de;
  border: 1px solid #c8dda0;
  color: #49651c;
}

body[data-theme="dark"] .repere-tag {
  background: #233519;
  border-color: #55762c;
  color: #d7efaa;
}

.type-tag {
  background: #f7ebd8;
  color: #75481d;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 11px;
}

.open-card-button,
.pdf-card-link,
.sheet-select-button,
.primary-resource,
.secondary-resource {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 38px;
  padding: 0 12px;
  text-decoration: none;
}

.open-card-button {
  background: var(--year-color);
  border: 1px solid var(--year-color);
  color: #fff;
}

.pdf-card-link {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--year-color) 45%, var(--line));
  color: color-mix(in srgb, var(--year-color) 72%, #17212b);
}

.sheet-select-button {
  background: color-mix(in srgb, var(--year-color) 86%, #0f172a);
  border: 2px solid color-mix(in srgb, var(--year-color) 78%, #0f172a);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--year-color) 22%, transparent);
  color: #fff;
  letter-spacing: 0.01em;
}

.sheet-select-button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--year-color) 14%, #fff);
  border-color: var(--year-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--year-color) 28%, transparent);
  color: color-mix(in srgb, var(--year-color) 72%, #17212b);
}

.open-card-button:hover,
.pdf-card-link:hover,
.sheet-select-button:hover,
.primary-resource:hover,
.secondary-resource:hover {
  filter: brightness(0.97);
}

.sheet-select-button:hover {
  transform: translateY(-1px);
}

.viewer {
  --year-color: var(--accent);
  max-width: 1040px;
  margin: 14px auto 0;
  overflow: hidden;
  border-top: 8px solid var(--year-color);
}

.back-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
  display: block;
  font-weight: 900;
  margin: 0 auto;
  max-width: 1040px;
  padding: 0 14px;
  text-align: left;
  width: 100%;
}

.back-button::before {
  content: "< ";
}

.back-button:hover {
  border-color: var(--accent);
  background: #eef6f3;
}

.viewer-toolbar {
  align-items: start;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--year-color) 12%, #fff), #fff 48%);
}

body[data-theme="dark"] .viewer-toolbar {
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--year-color) 18%, #18232d), #18232d 52%);
}

.viewer-year {
  background: var(--year-color);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  font-weight: 950;
  margin-right: 7px;
  padding: 3px 8px;
}

.correction-button {
  flex: 0 0 auto;
  padding: 0 14px;
}

.markdown-view {
  max-width: 850px;
  padding: 18px clamp(18px, 4vw, 42px) 24px;
  line-height: 1.68;
}

.quick-access {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 850px;
  padding: 22px clamp(18px, 4vw, 42px) 0;
}

.detail-favorite {
  max-width: 850px;
  padding: 20px clamp(18px, 4vw, 42px) 0;
}

.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 850px;
  padding: 14px clamp(18px, 4vw, 42px) 0;
}

.primary-resource {
  background: var(--year-color);
  border: 1px solid var(--year-color);
  color: #fff;
}

.secondary-resource {
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--year-color) 48%, var(--line));
  color: color-mix(in srgb, var(--year-color) 70%, #17212b);
}

.export-menu {
  position: relative;
}

.export-menu-button {
  list-style: none;
}

.export-menu-button::-webkit-details-marker {
  display: none;
}

.export-menu-button::after {
  content: "⌄";
  font-weight: 900;
  margin-left: 8px;
}

.export-options {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  left: 0;
  min-width: 210px;
  padding: 6px;
  position: absolute;
  top: calc(100% + 6px);
  z-index: 10;
}

.export-option {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  padding: 9px 10px;
  text-align: left;
}

.export-option:hover,
.export-option:focus {
  background: #eef6f3;
  color: var(--accent-strong);
}

.export-option:disabled {
  cursor: wait;
  opacity: 0.65;
}

body[data-theme="dark"] .export-option:hover,
body[data-theme="dark"] .export-option:focus {
  background: #21362f;
}

.markdown-view h1,
.markdown-view h2,
.markdown-view h3 {
  margin: 1.25em 0 0.45em;
  line-height: 1.15;
}

.markdown-view h1:first-child,
.markdown-view h2:first-child,
.markdown-view h3:first-child {
  margin-top: 0;
}

.markdown-view h3 {
  background: #edf3ff;
  border-left: 5px solid #4d73b9;
  border-radius: 8px;
  color: #244c91;
  font-size: 1.06rem;
  padding: 10px 12px;
}

body[data-theme="dark"] .markdown-view h3 {
  background: #1b2b43;
  border-left-color: #7ca7e8;
  color: #b7d1ff;
}

.markdown-view .cleaned-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 14px;
}

.markdown-view .cleaned-note strong {
  color: var(--accent-strong);
}

.markdown-view .exercise-note {
  background: color-mix(in srgb, #f3f4f6 88%, #fff);
  border: 1px solid color-mix(in srgb, #d1d5db 78%, var(--line));
  border-radius: 8px;
  color: #6b7280;
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 10px 0 16px;
  padding: 10px 12px;
}

.markdown-view .exercise-note strong {
  color: #4b5563;
}

.markdown-view .document-label {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.4;
  margin: 18px 0 8px;
}


.markdown-view .exercise-part-title {
  align-items: baseline;
  background: color-mix(in srgb, var(--year-color, var(--accent)) 12%, #fff);
  border-left: 5px solid var(--year-color, var(--accent));
  border-radius: 8px;
  color: var(--accent-strong);
  display: flex;
  flex-wrap: nowrap;
  font-size: 1.02rem;
  font-weight: 950;
  gap: 8px;
  line-height: 1.35;
  margin: 22px 0 12px;
  padding: 10px 12px;
}

.markdown-view .exercise-part-title span {
  align-items: center;
  background: var(--year-color, var(--accent));
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.86rem;
  margin-top: 1px;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.markdown-view .exercise-part-title small {
  align-self: baseline;
  color: var(--muted);
  display: inline-block;
  font-size: 0.88rem;
  font-weight: 800;
  margin-top: 0;
  white-space: nowrap;
}

.markdown-view .exercise-part-title.blue-title {
  background: color-mix(in srgb, var(--blue) 12%, #fff);
  border-left-color: var(--blue);
  color: var(--blue);
}

.markdown-view .exercise-part-title.blue-title span {
  background: var(--blue);
}

.markdown-view .question-title span {
  font-size: 0.95rem;
}

.markdown-view .helper-note {
  align-items: flex-start;
  background: color-mix(in srgb, var(--year-color, var(--accent)) 8%, #fff);
  border: 1px solid color-mix(in srgb, var(--year-color, var(--accent)) 22%, var(--line));
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  gap: 10px;
  line-height: 1.5;
  margin: 14px 0 16px;
  padding: 10px 12px;
}

.markdown-view .helper-note strong {
  color: var(--accent-strong);
  display: inline-block;
  margin-bottom: 2px;
}

.markdown-view .helper-note-icon {
  align-items: center;
  color: var(--year-color, var(--accent));
  display: inline-flex;
  flex: 0 0 auto;
  justify-content: center;
  margin-top: 1px;
}

.markdown-view .helper-note-icon svg {
  display: block;
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 18px;
}

.markdown-view .helper-note + .exercise-part-title {
  margin-top: 28px;
}

.markdown-view .answer-hint {
  background: #f1f3f5;
  border: 1px solid #dde3e8;
  border-radius: 999px;
  color: #5f6b76;
  display: inline-block;
  font-size: 0.86em;
  font-weight: 500;
  line-height: 1.35;
  margin-left: 4px;
  padding: 2px 8px;
  vertical-align: baseline;
}

.markdown-view .response-tag {
  background: #f1f3f5;
  border: 1px solid #dde3e8;
  border-radius: 999px;
  color: #5f6b76;
  display: inline-block;
  font-size: 0.86em;
  font-weight: 500;
  line-height: 1.35;
  margin-left: 4px;
  padding: 2px 8px;
  vertical-align: baseline;
}

body[data-theme="dark"] .markdown-view .exercise-part-title {
  background: color-mix(in srgb, var(--year-color, var(--accent)) 16%, #18232d);
}

body[data-theme="dark"] .markdown-view .exercise-part-title.blue-title {
  background: color-mix(in srgb, var(--blue) 18%, #18232d);
  border-left-color: #7ea6e8;
  color: #c6dcff;
}

body[data-theme="dark"] .markdown-view .exercise-part-title.blue-title span {
  background: #5f89c9;
}

body[data-theme="dark"] .markdown-view .helper-note {
  background: color-mix(in srgb, var(--year-color, var(--accent)) 14%, #18232d);
}

body[data-theme="dark"] .markdown-view .answer-hint {
  background: #24313b;
  border-color: #344450;
  color: #c2ced7;
}

body[data-theme="dark"] .markdown-view .response-tag {
  background: #24313b;
  border-color: #344450;
  color: #c2ced7;
}

body[data-theme="dark"] .markdown-view .document-label {
  color: #edf3f7;
}

.markdown-view blockquote {
  margin: 18px 0;
  border-left: 4px solid var(--accent);
  background: #f0f5f2;
  padding: 12px 16px;
}

body[data-theme="dark"] .markdown-view blockquote {
  background: #1d342f;
}

.markdown-view table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.markdown-view th,
.markdown-view td {
  border: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: top;
}

.markdown-view code {
  border-radius: 5px;
  background: #edf1f4;
  padding: 2px 5px;
}

body[data-theme="dark"] .markdown-view code {
  background: #263441;
}

.markdown-view img {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  height: auto;
  margin: 16px 0;
  max-width: 100%;
}

.markdown-view .image-center img {
  margin-left: auto;
  margin-right: auto;
}

.correction-panel {
  margin: 0 18px 22px;
  border: 1px solid #cfd9d6;
  border-radius: 8px;
  background: #fbfffd;
}

.resource-panel {
  max-width: 850px;
  margin: 18px clamp(18px, 4vw, 42px) 28px;
  border: 1px solid #d9dde3;
  border-radius: 8px;
  background: #fff;
}

.panel-title {
  border-bottom: 1px solid #cfd9d6;
  padding: 11px 16px;
  color: var(--accent-strong);
  font-weight: 900;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
}

.resource-link {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  font-weight: 850;
  text-decoration: none;
}

.resource-link:hover {
  border-color: var(--accent);
  background: #eef6f3;
}

.about-overlay {
  align-items: center;
  background: rgba(17, 24, 32, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.sheet-overlay {
  align-items: center;
  background: rgba(17, 24, 32, 0.52);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 21;
}

.sheet-overlay[hidden] {
  display: none;
}

.sheet-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: min(88vh, 900px);
  max-width: 1180px;
  overflow: hidden;
  width: min(100%, 1180px);
}

.sheet-head {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px 18px;
}

.sheet-head h2 {
  color: var(--accent-strong);
  font-size: 1.2rem;
  margin: 0 0 4px;
}

.sheet-head p {
  color: var(--muted);
  margin: 0;
}

.sheet-body {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 0;
}

.sheet-sidebar {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.sheet-actions {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.sheet-export-menu {
  width: 100%;
}

.sheet-export-menu .export-menu-button {
  background: color-mix(in srgb, var(--header-accent) 88%, #0f172a);
  border: 2px solid color-mix(in srgb, var(--header-accent) 76%, #0f172a);
  box-shadow: 0 10px 22px color-mix(in srgb, var(--header-accent) 22%, transparent);
  color: #fff;
  font-weight: 950;
  min-height: 40px;
  width: 100%;
}

.sheet-export-menu .export-menu-button:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.sheet-selection {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 0 16px 16px;
}

.sheet-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.sheet-item-main {
  display: grid;
  gap: 4px;
}

.sheet-item-main strong {
  font-size: 0.95rem;
}

.sheet-item-main span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.sheet-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sheet-move-button,
.sheet-remove-button {
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
}

.sheet-preview {
  margin: 0 auto;
  overflow: auto;
  padding-top: 20px;
  width: 100%;
}

.sheet-preview blockquote {
  background: transparent;
  border-left: 2px solid #c9d1d8;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 8px 0 14px;
  padding: 4px 0 4px 10px;
}

body[data-theme="dark"] .sheet-preview blockquote {
  background: transparent;
  border-left-color: #3d4a55;
}

.sheet-preview h2:not(:first-of-type) {
  margin-top: 36px;
  padding-top: 16px;
}

.about-overlay[hidden] {
  display: none;
}

.about-dialog {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--ink);
  max-width: 620px;
  overflow: hidden;
  width: min(100%, 620px);
}

.about-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
}

.about-head h2 {
  color: var(--accent-strong);
  font-size: 1.2rem;
  margin: 0;
}

.about-close {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  cursor: pointer;
  display: inline-flex;
  font-size: 1.25rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  line-height: 1;
  width: 34px;
}

.about-content {
  display: grid;
  gap: 14px;
  padding: 20px 20px 22px;
}

.about-lead {
  color: var(--accent-strong);
  font-size: 1.08rem;
  font-weight: 900;
  margin: 0;
}

.about-content p {
  line-height: 1.5;
  margin: 0;
}

.about-content a {
  color: var(--accent-strong);
  font-weight: 850;
}

@media print {
  @page {
    margin: 8mm 9mm 10mm;
  }

  :root,
  body,
  body[data-theme="dark"] {
    --ink: #111;
    --muted: #444;
    --line: #cfcfcf;
    --paper: #fff;
    --surface: #fff;
    background: #fff;
    color: #111;
  }

  .topbar,
  .site-footer,
  .back-button,
  .viewer-toolbar,
  .detail-favorite,
  .chapter-nav,
  .quick-access,
  .resource-panel,
  .correction-panel {
    display: none !important;
  }

  body.printing-sheet .topbar,
  body.printing-sheet .list-page,
  body.printing-sheet .detail-page,
  body.printing-sheet .site-footer,
  body.printing-sheet .about-overlay {
    display: none !important;
  }

  body.printing-sheet .sheet-overlay {
    background: #fff;
    display: block !important;
    inset: auto;
    padding: 0;
    position: static;
  }

  body.printing-sheet .sheet-head,
  body.printing-sheet .sheet-sidebar,
  body.printing-sheet .sheet-actions {
    display: none !important;
  }

  body.printing-sheet .sheet-dialog,
  body.printing-sheet .sheet-body,
  body.printing-sheet .sheet-preview {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    display: block;
    height: auto;
    margin: 0;
    max-width: none;
    min-height: 0;
    overflow: visible;
    padding: 0;
    width: 100%;
  }

  .detail-page,
  .viewer,
  .markdown-view {
    border: 0;
    box-shadow: none;
    margin: 0;
    max-width: none;
    padding: 0;
    width: 100%;
  }

  .viewer {
    overflow: visible;
  }

  .markdown-view {
    color: #111;
    font-size: 9.9pt;
    line-height: 1.26;
  }

  .markdown-view > * {
    break-inside: auto;
    orphans: 3;
    widows: 3;
  }

  .markdown-view p,
  .markdown-view ul,
  .markdown-view ol,
  .markdown-view blockquote,
  .markdown-view table,
  .markdown-view img,
  .markdown-view .cleaned-note {
    margin-top: 0;
    margin-bottom: 5px;
  }

  .markdown-view ul,
  .markdown-view ol {
    padding-left: 18px;
  }

  .markdown-view li {
    margin-bottom: 1px;
  }

  .markdown-view h1 {
    font-size: 14pt;
    margin: 0 0 6px;
    page-break-after: avoid;
  }

  .markdown-view h2 {
    font-size: 11.8pt;
    margin: 10px 0 5px;
    page-break-after: avoid;
  }

  .markdown-view h2:not(:first-of-type) {
    margin-top: 8mm;
  }

  .sheet-preview h2:not(:first-of-type) {
    margin-top: 14mm;
    padding-top: 3mm;
  }

  .markdown-view h3 {
    font-size: 10.8pt;
    border-left-width: 4px;
    margin: 8px 0 5px;
    padding: 5px 7px;
    page-break-after: avoid;
  }

  .markdown-view .cleaned-note {
    font-size: 8.4pt;
    line-height: 1.2;
  }

  .markdown-view .document-label {
    font-size: 10pt;
    margin: 8px 0 4px;
    page-break-after: avoid;
  }

  .markdown-view .exercise-part-title {
    border-left-width: 4px;
    border-radius: 4px;
    font-size: 10.1pt;
    gap: 6px;
    margin: 8px 0 5px;
    padding: 5px 7px;
    page-break-after: avoid;
    page-break-inside: avoid;
  }

  .markdown-view .question-title {
    background: #eceff2;
    border-left-color: #6b7280;
  }

  .markdown-view .exercise-part-title span {
    font-size: 0.68rem;
    height: 18px;
    margin-top: 0;
    width: 18px;
  }

  .markdown-view .exercise-part-title small {
    font-size: 0.74rem;
  }

  .markdown-view blockquote {
    background: #fff;
    border-left: 3px solid #777;
    margin: 6px 0;
    padding: 5px 8px;
  }

  .sheet-preview blockquote {
    border-left: 1.5px solid #aaa;
    color: #555;
    font-size: 0.82rem;
    margin: 4px 0 7px;
    padding: 2px 0 2px 7px;
  }

  .markdown-view img {
    border: 1px solid #aaa;
    display: block;
    margin: 6px auto;
    max-height: 208mm;
    max-width: 100%;
    object-fit: contain;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .markdown-view table,
  .markdown-view tr,
  .markdown-view td,
  .markdown-view th {
    break-inside: avoid;
  }
}

.correction-content {
  padding-top: 18px;
}

.empty-state {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  color: #5c6872;
  font-size: 0.9rem;
  line-height: 1.5;
  padding: 0 clamp(16px, 4vw, 44px) 28px;
  text-align: center;
}

body[data-theme="dark"] .site-footer {
  color: #aab8c2;
}

.site-footer p {
  margin: 0 auto;
  max-width: 980px;
}

.site-footer a {
  color: var(--accent-strong);
  font-weight: 850;
}

.license-icons {
  display: inline-flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  width: 100%;
}

.license-icon {
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  letter-spacing: 0;
  min-width: 24px;
  padding: 0 7px;
}

@media (max-width: 1050px) {
  .banner-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .exercise-list {
    grid-template-columns: 1fr;
  }

  .sheet-body {
    grid-template-columns: 1fr;
  }

  .sheet-sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
  }
}

@media (max-width: 720px) {
  .topbar,
  .list-head,
  .viewer-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .list-layout {
    gap: 12px;
    padding-bottom: 28px;
  }

  .search-banner {
    padding: 14px;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .search-banner-field {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .banner-controls {
    grid-template-columns: 1fr;
  }

  .sheet-dialog {
    height: min(92vh, 980px);
  }

  .exercise-list {
    max-height: none;
  }

  .stats,
  .list-head select {
    width: 100%;
    max-width: none;
  }

  .mobile-stats-slot {
    display: block;
  }
}
