:root {
  --paper: #f8f5ea;
  --ink: #19352f;
  --muted: #4c5d56;
  --line: #c8d0be;
  --accent: #174b3b;
  --accent-hover: #103d31;
  --warm: #a75c2b;
  --soft: #edf0e3;
  --panel: #fffdf7;
  --ep-color-brand: #174b3b;
  --ep-color-brand-hover: #103d31;
  --ep-color-accent: #ad6330;
  --ep-color-focus: #8e4f14;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--paper); scroll-behavior: smooth; }
body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.7 system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, select, textarea { color: inherit; font: inherit; }
button { cursor: pointer; }
img, video { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
a { color: #15533f; text-underline-offset: .18em; }
a:hover { color: #8e4b20; }
:focus-visible { outline: 3px solid #96501e; outline-offset: 4px; }

/* EdgePress default theme shell and real home block layout. */
.ep-header {
  position: sticky;
  z-index: 20;
  top: 0;
  background: #193f34;
  border-bottom: 3px solid #b66b32;
}
.ep-header-inner { min-height: 76px; gap: clamp(12px, 2vw, 28px); }
.ep-brand { gap: 10px; color: #fbf6e9; font-size: 1.05rem; font-weight: 780; }
.ep-brand:hover { color: #fff; }
.ep-brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid #d3ddce;
  border-radius: 50%;
  background: #f5efdf;
}
.ep-brand-mark img { object-fit: cover; }
.ep-nav { gap: clamp(2px, .7vw, 12px); }
.ep-nav-link {
  padding: 9px 10px;
  color: #f5f0e5;
  font-size: .9rem;
  font-weight: 650;
  white-space: nowrap;
}
.ep-nav-link:hover,
.ep-nav-link[aria-current="page"] { color: #fff; text-decoration: underline; text-decoration-color: #d9985b; text-decoration-thickness: 2px; text-underline-offset: 7px; }
.ep-header-actions .ep-btn { color: #fff8e9; border-color: #ffffff45; background: #ffffff0b; }
.ep-header-actions .ep-btn:hover { border-color: #e5c99e; background: #ffffff19; }
.ep-main { width: auto; max-width: none; margin: 0; padding-block: clamp(26px, 4.5vw, 54px) clamp(48px, 7vw, 84px); }
.ep-container { width: min(calc(100% - 48px), 1160px); }
.ep-prose { max-width: 100%; }
.ep-prose > :first-child { margin-top: 0; }
.ep-page-header { align-items: flex-end; margin-block-end: clamp(24px, 4vw, 42px); }
.ep-page-header h1 { color: #1c4739; font-size: clamp(2rem, 4vw, 2.8rem); }
.ep-page-header p { color: #46574e; }
.ep-footer { margin-top: auto; padding-block: 22px; background: #eeeadd; border-top-color: #c8cfbf; color: #44554b; }
.ep-footer-inner { align-items: center; }
.ep-footer a { color: #244c3d; text-decoration-thickness: .06em; }
.ep-footer a:hover { color: #8e4b20; }

.ep-home-content { max-width: none; margin-block: 0 clamp(34px, 5vw, 60px); }
.ep-home-content > .ep-elements { display: grid; gap: clamp(22px, 3.8vw, 40px); }
#xuefa-home-hero { min-width: 0; }
#xuefa-home-title { text-wrap: pretty; }
#xuefa-home-mascot-frame { justify-self: end; }
#xuefa-home-mascot { object-position: center; }
#xuefa-capture-section { scroll-margin-top: 106px; }
#xuefa-capture-section > [data-ep-id="xuefa-capture-title"] { display: flex; align-items: center; gap: 13px; }
#xuefa-capture-section > [data-ep-id="xuefa-capture-title"]::before { width: 5px; height: 32px; flex: none; background: #b66b32; content: ""; }
#xuefa-home-app { width: 100%; }
#xuefa-capture-section [data-ep-id="xuefa-home-app"] > .alternate-entry { display: none; }
#xuefa-home-app:has(.capture-area) + [data-ep-id="xuefa-camera-fallback"] { display: none; }
#xuefa-camera-fallback { text-decoration-thickness: .06em; }

.ep-section-heading { color: #174b3b; }
.ep-prose h2, .ep-prose h3, .ep-prose h4 { color: #174b3b; }
.ep-home-content > h2 { margin-block: clamp(34px, 5vw, 56px) 12px; padding-inline-start: 14px; border-inline-start: 4px solid #b66b32; font-size: clamp(1.4rem, 2.7vw, 1.9rem); }
.ep-home-content > h3 { margin-block: 22px 6px; font-size: 1.12rem; }
.ep-home-content > p,
.ep-home-content > ul { max-width: 78ch; }
.ep-home-content > ul { padding-inline-start: 1.4rem; }
.ep-home-content > ul li { margin-block: 7px; }
.ep-home-content > blockquote { max-width: 78ch; margin-inline: 0; padding: 13px 16px; border-inline-start: 4px solid #60856c; background: #edf0e3; }
.ep-home-content > blockquote p { margin: 0; color: #29453b; }

/* Real camera, image selection, OCR and question-bank controls. */
.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 7px;
  font: 650 15px/1.45 system-ui, sans-serif;
  text-decoration: none;
}
.button.primary { background: var(--accent); color: #fff; }
.button.primary:hover { background: var(--accent-hover); color: #fff; }
.button.secondary { border: 1px solid #668175; background: #fff; color: #1b4739; }
.button.secondary:hover { background: #edf2e9; color: #173c30; }
.button:disabled { cursor: wait; opacity: .6; }
.local-tool { min-width: 0; }
.local-tool button, .local-tool input, .local-tool textarea, .local-tool select { font: inherit; }
.local-tool :focus-visible { outline: 3px solid #8e4f14; outline-offset: 3px; }
.local-tool input[type="radio"], .local-tool input[type="checkbox"] { accent-color: var(--accent); }
.capture-area {
  display: flex;
  min-height: 232px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px 18px;
  border: 2px dashed #8ca993;
  border-radius: 12px;
  background: #f4f5e9;
  text-align: center;
  transition: background-color .16s ease, border-color .16s ease;
}
.capture-area.dragging { border-color: #174b3b; background: #e5eddf; }
.photo-symbol { margin: 0 0 15px; color: #174b3b; }
.photo-symbol .ui-icon { width: 46px; height: 46px; }
.capture-actions { display: flex; width: min(100%, 660px); gap: 12px; margin: 3px auto; }
.capture-actions .button { min-height: 58px; flex: 1; font-size: 1rem; }
.capture-actions .primary { box-shadow: 0 4px 12px #174b3b26; }
.capture-area .quiet { margin: 10px 0 0; font-size: .83rem; }
.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.capture-area:has(#image-input:focus-visible) label[for="image-input"] { outline: 3px solid #8e4f14; outline-offset: 4px; }
.alternate-entry { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 22px; padding-block: 14px 2px; color: #4c5d56; }
.alternate-entry a { min-height: 42px; align-content: center; color: #214e3e; font-weight: 700; }
.status { min-height: 1.6em; margin: 12px 0; color: #334f43; font-size: .9rem; }
.status:empty { display: none; }
.quiet { color: #4c5d56; font-size: .9rem; line-height: 1.75; }
.photo-preview-wrap, .camera-preview-wrap { display: flex; min-height: 180px; justify-content: center; overflow: hidden; border: 1px solid #c8d0be; border-radius: 10px; background: #f0f1e7; }
.photo-preview-wrap canvas { display: block; max-width: 100%; max-height: 470px; object-fit: contain; }
.camera-preview-wrap video { display: block; width: 100%; max-height: 520px; object-fit: contain; }
.crop-controls { margin-block: 15px; padding: 11px 14px; border: 1px solid #c8d0be; border-radius: 8px; font-size: .9rem; }
.crop-controls summary, .source-details summary, .library-answer summary, .supplemental-notes summary { min-height: 42px; align-content: center; color: #214c3c; font-weight: 680; cursor: pointer; }
.minor-actions, .main-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-block: 13px; }
.minor-actions .button { min-height: 40px; padding: 7px 12px; font-size: .85rem; }
.main-actions .primary { flex: 1; }
.crop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-block: 15px 4px; }
.crop-grid label { display: grid; min-width: 0; grid-template-columns: 34px minmax(0, 1fr) 38px; align-items: center; gap: 6px; }
.crop-grid input { width: 100%; min-width: 0; accent-color: var(--accent); }
.crop-grid output { color: #4c5d56; text-align: end; font-size: .8rem; }
progress { width: 100%; height: 8px; accent-color: var(--accent); }
.local-tool textarea, .local-tool input[type="search"], .library-filter select {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #849b8b;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}
.local-tool textarea { line-height: 1.75; resize: vertical; }
.library-filter { margin-block: 15px; color: #4c5d56; }
.library-filter select { max-width: 360px; margin-block-start: 8px; }

.match-card, .library-card, .question, .review-question { min-width: 0; overflow-wrap: anywhere; }
.match-card, .library-card { margin-block: 15px; padding: clamp(16px, 3vw, 24px); border: 1px solid #c8d0be; border-radius: 9px; background: var(--panel); }
.match-card h2, .library-card h3, .review-question h3 { margin-block: 8px 14px; font-size: 1.08rem; line-height: 1.75; }
.question-title { margin-block: 12px 18px; font-size: 1.18rem; font-weight: 720; line-height: 1.75; }
.visual-match, .text-match { display: inline-flex; margin-block-end: 6px; padding: 4px 9px; border-radius: 4px; background: #e5efe4; color: #214c3c; font-size: .78rem; }
.type-badge { display: inline-flex; padding: 3px 8px; border-radius: 4px; background: #eee7d5; color: #69471e; font-size: .78rem; }
.question-images { display: grid; width: 100%; min-width: 0; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); align-items: start; gap: 12px; margin: 14px 0 18px; }
.question-figure { display: flex; width: 100%; min-width: 0; min-height: 110px; max-height: 336px; align-items: center; justify-content: center; overflow: hidden; margin: 0; padding: 12px; border: 1px solid #c8d0be; border-radius: 8px; background: #fff; }
.question-figure img { display: block; width: auto; max-width: 100%; height: auto; max-height: 310px; border-radius: 4px; object-fit: contain; }
.candidate-options { display: grid; gap: 6px; margin: 12px 0; padding: 0; color: #344f45; font-size: .94rem; list-style: none; }
.candidate-options li { min-width: 0; padding: 9px 12px; border: 1px solid #d5dbcf; border-radius: 5px; background: #fbfaf4; overflow-wrap: anywhere; }
.answer-review { margin-block-start: 14px; padding: 14px 16px; border-radius: 7px; background: #e8f0e6; color: #224639; }
.answer-review h3 { margin: 0 0 8px; font-size: .95rem; }
.answer-review p { margin: 6px 0; color: inherit; line-height: 1.75; }
.answer-review.incorrect { background: #f5eadd; color: #724419; }
.source-details, .library-answer, .supplemental-notes { margin-block-start: 14px; color: #495b53; font-size: .88rem; }
.source-details pre { overflow: auto; padding: 12px; border-radius: 5px; background: #f0f0e8; font: inherit; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.exam-rules { margin: 0 0 22px; padding-inline-start: 1.4rem; font-size: .98rem; line-height: 1.9; }
.exam-rules li { margin-block: 7px; }
.exam-heading { margin: 0 0 12px; color: #45594f; font-size: .9rem; font-weight: 700; }
.exam-timers { display: flex; justify-content: space-between; gap: 12px; margin-block-end: 22px; padding: 10px 12px; border-radius: 6px; background: #e8eddf; color: #365446; font-size: .85rem; font-variant-numeric: tabular-nums; }
.answer-options { display: grid; min-width: 0; gap: 9px; margin: 0 0 18px; padding: 0; border: 0; }
.answer-options legend { margin-block-end: 12px; color: #4c5d56; font-size: .8rem; }
.answer-option { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border: 1px solid #c8d0be; border-radius: 6px; font-size: .96rem; cursor: pointer; }
.answer-option:has(input:checked) { border-color: #32654e; background: #edf2e6; box-shadow: inset 3px 0 #32654e; }
.answer-option input { width: 18px; min-width: 18px; height: 18px; flex: none; margin: 4px 0; accent-color: #174b3b; }
.option-text { min-width: 0; overflow-wrap: anywhere; }
.question form > button.primary { width: 100%; }
.exam-result h2 { margin-block: 8px; font-size: 1.55rem; }
.exam-result .button { margin: 10px 10px 0 0; }
.wrong-review { margin-block-start: 24px; }
.wrong-review summary { min-height: 44px; color: #214c3c; font-weight: 700; cursor: pointer; }
.review-question { margin-block-start: 15px; padding-block: 16px; border-top: 1px solid #c8d0be; }
.media-text-block video { width: 100%; max-height: 650px; border-radius: 8px; background: #eceee3; object-fit: contain; }
.browser-upgrade { padding: 20px; border: 1px solid #c8d0be; border-radius: 9px; background: #fffdf7; }
.browser-upgrade h2 { margin: 0 0 10px; font-size: 1.2rem; }
.ui-icon { display: inline-block; width: 20px; height: 20px; flex: none; background-color: currentColor; mask: var(--icon-url) center / contain no-repeat; -webkit-mask: var(--icon-url) center / contain no-repeat; }

@media (max-width: 780px) {
  .ep-header-inner { min-height: 0; flex-wrap: wrap; padding-block: 10px; }
  .ep-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; padding-block: 5px; }
  .ep-header-actions { margin-inline-start: auto; }
  .ep-container { width: min(calc(100% - 36px), 1160px); }
  .ep-page-header { align-items: flex-start; }
  .ep-article-layout { grid-template-columns: minmax(0, 1fr); }
  .ep-article-layout aside:empty { display: none; }
  .ep-toc { position: sticky; top: 104px; max-height: calc(100dvh - 124px); overflow: auto; margin-block: 22px; }
}
@media (max-width: 620px) {
  .ep-container { width: min(calc(100% - 28px), 1160px); }
  .ep-brand { font-size: .98rem; }
  .ep-brand-mark { width: 39px; height: 39px; }
  #xuefa-home-hero { grid-template-columns: minmax(0, 1fr) 84px !important; gap: 10px !important; padding: 20px 16px !important; }
  #xuefa-home-title { font-size: clamp(1.7rem, 7.3vw, 2.15rem) !important; line-height: 1.32 !important; }
  #xuefa-home-mascot-frame { width: 84px !important; }
  #xuefa-capture-section { padding: 18px 14px !important; }
  .capture-area { min-height: 218px; padding: 18px 10px; }
  .capture-actions { flex-direction: column; gap: 9px; }
  .capture-actions .button { width: 100%; min-height: 52px; }
  .alternate-entry { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .alternate-entry a { padding-block: 5px; }
  .crop-grid { grid-template-columns: minmax(0, 1fr); }
  .question-images { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .question-figure { min-height: 96px; max-height: 274px; padding: 10px; }
  .question-figure img { max-height: 250px; }
  .match-card h2, .library-card h3, .review-question h3 { font-size: 1rem; }
  .question-title { font-size: 1.05rem; }
  .exam-timers { flex-wrap: wrap; gap: 6px 12px; font-size: .78rem; }
  .ep-footer-inner { align-items: flex-start; }
  .ep-toc { position: static; max-height: none; }
}
@media (max-width: 780px) {
  .ep-consent-banner:not([hidden]) {
    position: relative;
    inset: auto;
    display: grid;
    width: min(calc(100% - 28px), 1160px);
    max-width: none;
    margin: 8px auto calc(16px + env(safe-area-inset-bottom));
    padding: 12px;
    border-radius: 8px;
  }
  .ep-consent-banner > div { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
  .ep-consent-banner button { min-height: 42px; padding: 8px; font-size: .84rem; }
  .ep-consent-banner [data-consent-action="accept"] { grid-column: 1 / -1; }
}
@media (max-width: 360px) {
  .ep-container { width: min(calc(100% - 22px), 1160px); }
  #xuefa-home-hero { grid-template-columns: minmax(0, 1fr) 70px !important; padding-inline: 12px !important; }
  #xuefa-home-mascot-frame { width: 70px !important; }
  #xuefa-home-title { font-size: 1.55rem !important; }
}
@media (prefers-contrast: more) {
  :root { --line: #566c5d; --muted: #364b41; }
  .capture-area { border-style: solid; border-width: 2px; }
  .button.secondary, .local-tool textarea, .local-tool input[type="search"], .library-filter select { border-width: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
@media (forced-colors: active) {
  .ep-header, .button, .capture-area, .local-tool, .answer-option, .match-card, .library-card, .question-figure { border: 1px solid CanvasText; }
  .ep-header { border-block-end-width: 3px; }
  .ui-icon { background: CanvasText; }
}
