:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --line: #d8e0ea;
  --text: #202936;
  --muted: #66758a;
  --accent: #2563eb;
  --ok: #14804a;
  --warn: #a05a00;
  --bad: #b42318;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0; font-size: 20px; }
h2 { margin: 0 0 12px; font-size: 16px; }
h3 { margin: 12px 0 8px; font-size: 14px; }
button, input, select, textarea {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
input, select, textarea { padding: 6px 8px; }
button { min-height: 34px; padding: 6px 12px; cursor: pointer; }
button.primary, .daily-form button, .auth-card button { border-color: var(--accent); background: var(--accent); color: #fff; }
button:disabled { opacity: .55; cursor: not-allowed; }
label { display: grid; gap: 5px; color: var(--muted); }
section, .card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.muted, .meta { color: var(--muted); }
.error { color: var(--bad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #405066;
  white-space: nowrap;
}
.pill.ok, .ok { background: #e7f6ee; color: var(--ok); }
.pill.warn, .warn { background: #fff4df; color: var(--warn); }
.pill.bad, .bad { background: #feeceb; color: var(--bad); }
.empty { border: 1px dashed var(--line); border-radius: 8px; background: var(--surface); padding: 24px; text-align: center; color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.helper-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid #d6e3f0;
  border-radius: 6px;
  background: #f4f8fd;
  color: #2c4a6b;
}
.helper-note.ok { border-color: #b7ebc8; background: #ecfdf3; color: var(--ok); }

.auth-page { min-height: 100vh; display: grid; place-items: center; }
.auth-card { width: min(420px, calc(100vw - 32px)); padding: 28px; }
.auth-card h1 { margin-bottom: 6px; font-size: 22px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); }
.auth-card form { display: grid; gap: 14px; }
.auth-card input, .auth-card button { min-height: 40px; }
.auth-card .error { padding: 10px 12px; border: 1px solid #f5b5af; border-radius: 6px; background: #fff1f0; }
.auth-card .hint { margin-top: 16px; font-size: 12px; color: var(--muted); }

.portal-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.portal-shell { width: min(880px, 100%); }
.portal-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: 28px; align-items: center; padding: 28px; }
.portal-hero h1 { margin: 0 0 10px; font-size: 28px; }
.portal-actions { display: grid; gap: 10px; }
.portal-action {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.portal-action:hover { text-decoration: none; border-color: #b7c6dc; }
.portal-action.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.portal-action span { font-size: 17px; font-weight: 700; }
.portal-action small { color: inherit; opacity: .78; }

.daily-shell header, .archive-shell header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.daily-shell main { max-width: 980px; margin: 0 auto; padding: 22px 18px; }
.daily-shell section { margin-bottom: 18px; padding: 16px; }
.daily-shell .grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .7fr); gap: 18px; }
.daily-hero, .problem-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.daily-hero h2, .problem-hero h2 { margin: 0 0 8px; font-size: 22px; line-height: 1.35; }
.hero-action { display: grid; justify-items: end; gap: 8px; min-width: 150px; }
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.primary-link:hover { text-decoration: none; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat-tile { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.stat-tile span { display: block; color: var(--muted); font-size: 12px; }
.stat-tile strong { display: block; margin-top: 4px; font-size: 24px; }
.history-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 0; border-bottom: 1px solid #edf1f6; }
.history-row:last-child { border-bottom: 0; }
.problem-surface { overflow-x: auto; font-size: 16px; line-height: 1.75; }
.daily-render { display: grid; gap: 8px; }
.daily-render-block { margin: 0; }
.daily-render-paragraph { overflow-wrap: anywhere; }
.daily-render-paragraph[lang="en"] { color: #172033; }
.daily-render-paragraph[lang="zh-CN"] { color: #4b5563; }
.daily-render-inline-math { display: inline-block; margin: 0 3px; }
.daily-render-display-math { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.daily-render-figure { margin: 8px 0; }
.daily-render-figure img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.daily-render-figure figcaption { margin-top: 5px; color: var(--muted); font-size: 13px; }
.daily-render-choices { display: grid; gap: 8px; margin-top: 8px; }
.daily-render-choice { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; }
.daily-render-choice-label { display: inline-flex; width: 24px; height: 24px; align-items: center; justify-content: center; border-radius: 50%; background: #eef4ff; color: var(--brand); font-weight: 700; }
.daily-render-choice-body { min-width: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: baseline; }
.daily-stem { overflow-wrap: anywhere; }
.daily-stem p { margin: 0 0 12px; }
.daily-stem .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.daily-stem .katex { font-size: 1.08em; }
.submit-panel form { display: grid; gap: 12px; }
.daily-auth .wrap { max-width: 520px; margin: 48px auto; padding: 0 18px; }
.daily-auth .wrap.narrow { max-width: 420px; margin-top: 64px; }
.daily-auth section { padding: 20px; }
.daily-auth h1 { margin-bottom: 16px; }
.daily-auth label { margin-bottom: 12px; }
.daily-auth input, .daily-auth select, .daily-auth button { min-height: 36px; }
.daily-auth .row { align-items: end; }
.daily-auth .row label { flex: 1; }
.daily-auth .error { margin: 0 0 12px; }
.problem-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 7px 0; border-bottom: 1px solid #edf1f6; }
.problem-row:last-child { border-bottom: 0; }
.files { display: flex; gap: 8px; flex-wrap: wrap; }
.files img { max-width: 220px; max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.problem-image { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.problem-stem-image { display: block; width: 760px; max-width: none; background: #fff; }

.archive-shell header { padding: 16px 24px; }
.archive-shell main { max-width: 1120px; margin: 0 auto; padding: 22px 18px; }
.archive-shell .stack { display: grid; gap: 14px; }
.archive-shell .card { padding: 16px; }
.archive-shell h2 { margin: 0; font-size: 17px; }
.archive-shell details { margin-top: 12px; border-top: 1px solid #edf1f6; padding-top: 10px; }
.archive-shell summary { cursor: pointer; font-weight: 700; }
.problem-list { display: grid; gap: 8px; margin-top: 10px; }
.problem { display: grid; grid-template-columns: 88px minmax(0, 1fr) 120px; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid #edf1f6; border-radius: 8px; background: #fbfcfe; }
.title { font-weight: 700; overflow-wrap: anywhere; }
.archive-shell .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; }

.manual-page { margin: 32px; }
.manual-page .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 16px; }
.manual-page input, .manual-page select { padding: 6px; }

@media (max-width: 760px) {
  .portal-hero { grid-template-columns: 1fr; padding: 20px; }
  .daily-shell header, .archive-shell header { align-items: flex-start; flex-direction: column; }
  .daily-shell .grid, .problem { grid-template-columns: 1fr; }
  .daily-hero, .problem-hero { align-items: flex-start; flex-direction: column; }
  .hero-action { justify-items: start; min-width: 0; }
}
