:root {
  color-scheme: light;
  --paper: #f3f5f6;
  --card: #fff;
  --ink: #253440;
  --muted: #4e6070;
  --line: #dce3e8;
  --accent: #49677d;
  --accent-hover: #3b576c;
  --blue-pale: #e5edf3;
  --blue-wash: #f1f5f8;
  --focus: #567c98;
  --error: #9a403a;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 100%;
  line-height: 1.6;
  background: var(--paper);
  color: var(--ink);
}

/* 先建立正文、边框和键盘焦点规则，让表单与详情共用同一套视觉层级。 */
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, p, ul { margin: 0; }
a { color: inherit; }
input, button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
h1, h2, h3 { line-height: 1.3; font-weight: 650; }
h1 { font-size: clamp(1.7rem, 3vw, 2.125rem); letter-spacing: -.045em; }
h2 { font-size: 1.125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.container { width: min(1120px, calc(100% - 72px)); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); }
.header-nav { display: flex; align-items: center; gap: clamp(15px, 3vw, 30px); }
.nav-link { text-decoration: none; }
.nav-link[aria-current="page"] { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 5px; }
.header-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-size: 1.12rem; font-weight: 680; text-decoration: none; }
.brand-mark { position: relative; width: 29px; height: 29px; border-radius: 7px; background: var(--accent); }
.brand-mark::before { position: absolute; inset: 7px 7px 7px 8px; border: 1.5px solid #fff; border-radius: 2px; content: ""; }
.brand-mark::after { position: absolute; top: 12px; left: 12px; width: 6px; height: 1px; background: #fff; box-shadow: 0 4px #fff; content: ""; }
.quiet { padding: 8px 0; background: transparent; border: 0; color: var(--muted); font-size: .875rem; }
.quiet:hover, .back:hover { color: var(--accent-hover); text-decoration: underline; }

/* 登录页把输入入口与批次说明放在一起，窄屏保持同样的阅读顺序。 */
.guest { min-height: calc(100svh - 72px); display: grid; align-items: center; padding: 56px 0 90px; }
.guest-card { display: grid; grid-template-columns: 1fr 1fr; width: min(840px, 100%); margin-inline: auto; background: var(--card); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.guest-form, .guest-info { padding: clamp(30px, 5vw, 52px); }
.guest-form form { display: grid; gap: 16px; margin-top: 26px; }
.guest-form .button { width: 100%; }
.guest-info { display: flex; flex-direction: column; justify-content: center; gap: 14px; background: var(--blue-pale); }
.guest-info h2 { max-width: 15ch; }
.guest-info > p { color: var(--muted); }

/* 首页左栏专注提交，右栏优先显示下一批及现有练习。 */
.dashboard { padding-block: 48px 68px; }
.work-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.form-panel { padding: 30px; }
.form-fields { display: grid; gap: 24px; margin-top: 28px; }
.field { display: grid; gap: 8px; min-width: 0; }
.field > label, .quantity legend { font-weight: 620; }
input[type="password"], textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 12px 14px; font-size: 1rem; }
textarea { min-height: 122px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #596a78; opacity: 1; }
input:hover, textarea:hover { border-color: #aebecb; }
.drop { position: relative; display: flex; align-items: center; gap: 14px; min-height: 82px; padding: 12px 15px; border: 1px dashed #9fb1c0; border-radius: 8px; background: var(--blue-wash); }
.drop:hover, .drop.drag-over { background: var(--blue-pale); border-color: var(--accent); }
.drop:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 8px; background: var(--blue-pale); color: var(--accent); font-size: 1.25rem; }
.drop-text { display: grid; gap: 2px; }
.drop-text span:first-child { color: var(--accent-hover); font-weight: 620; }
.drop-text span:last-child { color: var(--muted); font-size: .875rem; }
.previews:empty { display: none; }
.previews { display: grid; gap: 8px; }
.preview { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 7px; }
.preview img { width: 42px; height: 38px; object-fit: cover; border-radius: 4px; background: var(--paper); }
.preview span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .875rem; }
.preview button { border: 0; background: transparent; color: var(--accent-hover); min-height: 36px; padding-inline: 6px; font-size: .875rem; }
.quantity { padding: 0; margin: 0; border: 0; min-width: 0; }
.quantity legend { margin-bottom: 8px; padding: 0; }
.choices { display: grid; grid-template-columns: repeat(5, minmax(0, 54px)); gap: 8px; }
.choices label { position: relative; display: grid; min-height: 42px; }
.choices input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.choices span { display: grid; place-items: center; color: var(--muted); background: #fbfcfd; border: 1px solid var(--line); border-radius: 7px; font-weight: 620; }
.choices input:hover + span { border-color: #9fb1c0; }
.choices input:checked + span { color: #28465c; background: var(--blue-pale); border-color: #7290a6; }
.choices input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.submit-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.submit-footer p, .error { font-size: .875rem; }
.submit-footer p { color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid transparent; border-radius: 8px; background: var(--accent); color: #fff; padding: 8px 18px; white-space: nowrap; font-weight: 620; transition: background-color 150ms ease; }
.button:hover { background: var(--accent-hover); }
.button:disabled { cursor: wait; opacity: .7; }
.error { color: var(--error); }

.inbox { padding: 23px 24px 12px; }
.inbox h2 { margin-bottom: 13px; }
.empty { color: var(--muted); padding: 15px 0 24px; border-top: 1px solid var(--line); }
.jobs { list-style: none; padding: 0; }
.jobs li { border-top: 1px solid var(--line); }
.job-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 12px 0; text-decoration: none; }
.job-row:hover strong { color: var(--accent-hover); text-decoration: underline; }
.job-info { min-width: 0; display: grid; gap: 3px; }
.job-info strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 610; }
.job-info > span, .detail-meta { color: var(--muted); font-size: .875rem; }
.inline-count { margin-inline-start: 5px; white-space: nowrap; }
.status { display: inline-flex; align-items: center; width: max-content; padding: 2px 8px; color: #485966; background: #edf1f3; border-radius: 6px; font-size: .875rem; white-space: nowrap; }
.status-running { color: #325c7b; background: #e6eff6; }
.status-running::before { content: ""; width: 11px; height: 11px; margin-right: 5px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rotate 900ms linear infinite; }
.status-done { color: #30584b; background: #e5f0ea; }
.status-failed { color: var(--error); background: #f7eae7; }
.back { color: var(--accent-hover); font-size: .875rem; text-decoration: none; }

/* 历史列表用分组日期和对齐的列帮助查阅，筛选与返回入口保持在内容上方。 */
.history { width: min(960px, calc(100% - 72px)); padding-block: 50px 72px; }
.history-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.history-heading h1 { font-size: clamp(1.875rem, 4vw, 2.5rem); }
.history-return, .history-pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 6px 13px;
  border: 1px solid #b9c8d3;
  border-radius: 7px;
  background: var(--card);
  color: var(--accent-hover);
  font-size: .875rem;
  font-weight: 620;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease;
}
.history-return:hover, .history-pagination a:hover { background: var(--blue-pale); }
.history-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0 clamp(10px, 3vw, 30px);
  margin-top: 19px;
  border-bottom: 1px solid var(--line);
}
.history-filters a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 2px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
}
.history-filters a:hover { color: var(--ink); }
.history-filters a[aria-current="page"] { border-color: var(--accent); color: var(--accent-hover); font-weight: 650; }
.history-days { display: grid; gap: 29px; margin-top: 29px; }
.history-day { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 24px; }
.history-date { padding-top: 15px; font-size: 1.1rem; letter-spacing: -.015em; font-variant-numeric: tabular-nums; }
.history-date time { display: flex; flex-direction: column; align-items: baseline; gap: 5px; }
.history-date span { color: var(--muted); font-size: .84rem; font-weight: 450; }
.history-records { list-style: none; padding: 0; border-top: 1px solid var(--line); }
.history-record { border-bottom: 1px solid var(--line); scroll-margin-top: 20px; }
.history-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 8.2rem 5.65rem;
  align-items: center;
  gap: 14px;
  min-height: 67px;
  padding: 12px 14px;
  text-decoration: none;
  transition: background-color 150ms ease;
}
.history-link:hover { background: #eaf0f4; }
.history-link:focus-visible { outline-offset: -3px; }
.history-record:target .history-link { background: var(--blue-pale); }
.history-link strong { font-size: 1rem; font-weight: 630; overflow-wrap: anywhere; }
.history-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: .875rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.history-status.status { justify-self: end; gap: 7px; padding: 0; background: transparent; }
.history-status:not(.status-running)::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .72; content: ""; }
.history-status.status-running::before { margin-right: 0; }
.history-empty { display: flex; flex-wrap: wrap; gap: 12px; padding-block: 28px; color: var(--muted); }
.history-empty a { color: var(--accent-hover); font-weight: 620; text-underline-offset: 4px; }
.history-pagination {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 25px;
  color: var(--muted);
  font-size: .875rem;
}
.history-pagination span { grid-column: 2; }
.history-pagination .previous { grid-column: 1; grid-row: 1; justify-self: start; }
.history-pagination .next { grid-column: 3; grid-row: 1; justify-self: end; }

/* 结果页先露出题目，解析在用户主动展开后显示。 */
.detail { width: min(800px, calc(100% - 72px)); padding-block: 32px 72px; }
.back { display: inline-flex; align-items: center; min-height: 32px; margin-bottom: 12px; }
.back::before { content: ""; width: 7px; height: 7px; margin: 0 10px 0 3px; border-left: 1.5px solid; border-bottom: 1.5px solid; transform: rotate(45deg); }
.detail-head, .question { padding: 26px 30px; }
.detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-heading h1 { min-width: 0; overflow-wrap: anywhere; }
.detail-heading .status { margin-top: 3px; }
.detail-meta, .job-note { margin-top: 8px; color: var(--muted); }
.detail-meta span { margin-left: 10px; }
.source { margin-top: 16px; border-top: 1px solid var(--line); }
.source .rich { margin-bottom: 12px; }
.source-images { display: flex; flex-wrap: wrap; gap: 10px; }
.source-images img { display: block; width: 100px; height: 86px; object-fit: contain; background: var(--paper); border: 1px solid var(--line); border-radius: 5px; }
.exercise { display: grid; gap: 14px; margin-top: 16px; }
.question h2 { color: var(--accent-hover); font-size: 1rem; }
.stem { margin-top: 9px; }
.rich { white-space: pre-wrap; overflow-wrap: anywhere; }
.rich .katex-display { overflow-x: auto; overflow-y: hidden; padding-block: .2em; }
.solution { margin-top: 14px; border-top: 1px solid var(--line); }
summary { color: var(--accent-hover); padding: 10px 0 2px; cursor: pointer; width: fit-content; }
summary:hover { text-decoration: underline; }
.solution-body { padding: 12px 14px; margin-top: 6px; border-radius: 7px; background: var(--blue-wash); }
.solution-body h3 { font-size: .875rem; color: var(--accent-hover); }
.solution-body h3 + p { margin-top: 4px; }
.solution-body p + h3 { margin-top: 12px; }
/* 支持原生详情动画的浏览器平滑展开，其他浏览器沿用原生开合。 */
@supports (interpolate-size: allow-keywords) and selector(details::details-content) {
  .source, .solution { interpolate-size: allow-keywords; }
  .source::details-content, .solution::details-content {
    block-size: 0;
    opacity: 0;
    overflow: clip;
    transition: block-size 180ms ease, opacity 150ms ease, content-visibility 180ms allow-discrete;
  }
  .source[open]::details-content, .solution[open]::details-content {
    block-size: auto;
    opacity: 1;
  }
}
@keyframes rotate { to { transform: rotate(360deg); } }

@media (max-width: 780px) {
  .container { width: calc(100% - 40px); }
  .work-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .dashboard { padding-top: 24px; }
}
@media (max-width: 660px) {
  .history { padding-top: 26px; }
  .history-filters { margin-top: 15px; }
  .history-days { gap: 22px; margin-top: 22px; }
  .history-day { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .history-date { padding-top: 0; }
  .history-date time { flex-direction: row; gap: 9px; }
  .history-link {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "title status" "meta status";
    gap: 2px 12px;
    min-height: 64px;
    padding: 10px 4px;
  }
  .history-link strong { grid-area: title; }
  .history-meta { grid-area: meta; display: flex; gap: 12px; }
  .history-status { grid-area: status; }
}
@media (max-width: 560px) {
  .container { width: calc(100% - 32px); }
  .header-inner { min-height: 60px; }
  .guest { min-height: auto; padding: 36px 0 62px; }
  .guest-card { grid-template-columns: minmax(0, 1fr); }
  .guest-form, .guest-info { padding: 23px; }
  .form-panel, .inbox, .detail-head, .question { padding: 20px; }
  .form-fields { margin-top: 21px; gap: 20px; }
  .submit-footer { display: grid; }
  .submit-footer .button { width: 100%; }
  .detail { padding-top: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
