:root {
  color-scheme: light;
  --paper: #f5f7f3;
  --surface: #ffffff;
  --ink: #202923;
  --muted: #69736c;
  --line: #dfe6df;
  --green: #147a59;
  --green-dark: #0f6046;
  --green-soft: #e6f2eb;
  --amber: #b76720;
  --amber-soft: #fff1dc;
  --red: #a4413b;
  --mono: 'Cascadia Code', 'SFMono-Regular', Consolas, monospace;
  --sans: 'Microsoft YaHei UI', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 3px solid #d7943f;
  outline-offset: 3px;
}

.topbar {
  min-height: 72px;
  padding: 0 max(24px, calc((100vw - 1080px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-left { min-width: 0; display: flex; align-items: center; gap: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 22px; height: 20px; display: flex; align-items: end; gap: 3px; }
.brand-mark span { width: 5px; border-radius: 2px 2px 0 0; background: var(--green); }
.brand-mark span:nth-child(1) { height: 11px; }
.brand-mark span:nth-child(2) { height: 17px; background: var(--amber); }
.brand-mark span:nth-child(3) { height: 14px; }
.daily-quote { min-width: 0; max-width: 570px; border-left: 1px solid var(--line); padding-left: 14px; }
.quote-text { display: -webkit-box; overflow: hidden; margin: 0 0 2px; color: var(--ink); font-size: 13px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.quote-source { color: var(--muted); font-size: 11px; text-decoration: underline; text-decoration-color: #c7d1c8; text-underline-offset: 2px; }
.exam-countdown { flex: none; display: flex; align-items: baseline; gap: 5px; white-space: nowrap; color: var(--green-dark); }
.countdown-caption, .countdown-unit { font-size: 12px; }
.countdown-number { color: var(--amber); font-family: var(--mono); font-size: 27px; font-weight: 500; font-variant-numeric: tabular-nums; }
.countdown-status { color: var(--amber); font-size: 14px; }
[hidden] { display: none !important; }

.page-shell { width: min(100% - 48px, 980px); margin: 0 auto; }
.workspace { padding: 40px 0 36px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 13px; font-weight: 600; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 27px; line-height: 1.35; font-weight: 600; }
h2 { margin: 0; font-size: 17px; font-weight: 600; }
.today-date { color: var(--muted); font-size: 13px; padding-bottom: 4px; }

.focus-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(260px, .85fr); gap: 18px; align-items: stretch; }
.timer-tool { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.timer-panel { min-height: 210px; padding: 26px 28px 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-bottom: 1px solid var(--line); text-align: center; }
.timer-hint { margin: 0 0 11px; color: var(--muted); font-size: 14px; }
.elapsed { color: var(--ink); font-family: var(--mono); font-size: 48px; font-weight: 500; line-height: 1.25; font-variant-numeric: tabular-nums; }
.elapsed.idle { color: #aab3ac; }
.running-copy { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--green-dark); font-size: 14px; font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.stop-button { margin-top: 14px; border: 0; border-radius: 4px; padding: 10px 20px; background: var(--amber-soft); color: #77420f; font-weight: 600; cursor: pointer; }
.stop-button:hover { background: #fbe5c2; }
.subject-picker { padding: 20px 22px 22px; }
.subsection-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.subsection-heading > span { color: var(--muted); font-size: 12px; }
.subject-buttons { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.subject-button { min-height: 46px; display: flex; justify-content: space-between; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 4px; padding: 0 11px; background: #fbfcfa; cursor: pointer; text-align: left; }
.subject-button:hover:not(:disabled) { border-color: var(--green); background: var(--green-soft); }
.subject-button:disabled { color: #a4aea6; cursor: not-allowed; }
.button-mark { color: var(--green); font-size: 18px; line-height: 1; }

.today-panel { padding: 21px 22px; background: var(--surface); border-top: 3px solid var(--green); border-bottom: 1px solid var(--line); }
.summary-date { padding: 4px 8px; border-radius: 3px; background: var(--green-soft); color: var(--green-dark) !important; }
.today-summary { min-height: 180px; }
.total-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 13px 0 16px; border-bottom: 1px solid var(--line); }
.total-line span { color: var(--muted); font-size: 13px; }
.total-line strong { font-size: 23px; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary-list { list-style: none; padding: 5px 0 0; margin: 0; }
.summary-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 14px; }
.summary-list strong { font-weight: 500; font-variant-numeric: tabular-nums; }
.empty-copy { color: var(--muted); font-size: 13px; }
.today-summary > .empty-copy { padding-top: 8px; }
.summary-note { display: flex; align-items: center; gap: 7px; border-top: 1px solid var(--line); padding-top: 13px; color: var(--muted); font-size: 12px; }
.note-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }

.history-section { border-top: 1px solid #cdd7ce; padding: 28px 0 26px; }
.compact-heading { margin-bottom: 15px; }
.compact-heading h2 { font-size: 20px; }
.date-control { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.date-control input { min-height: 36px; border: 1px solid var(--line); border-radius: 4px; padding: 0 8px; background: var(--surface); color: var(--ink); }
.history-list, .manage-list { list-style: none; padding: 0; margin: 0; }
.history-list li { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(145px, 1fr) 120px; align-items: center; gap: 14px; min-height: 47px; border-bottom: 1px solid var(--line); }
.history-list li:first-child { border-top: 1px solid var(--line); }
.history-subject { font-weight: 500; }
.history-list time { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.history-list strong { justify-self: end; font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.history-list .empty-copy { display: block; padding: 15px 0; border-top: 1px solid var(--line); }

.subject-management { border-top: 1px solid #cdd7ce; padding: 18px 0; }
.subject-management summary { width: fit-content; cursor: pointer; font-size: 14px; font-weight: 600; }
.subject-management summary::marker { color: var(--green); }
.add-subject-form { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.add-subject-form label { color: var(--muted); font-size: 13px; }
.add-subject-form input { width: min(260px, 45vw); min-height: 36px; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; background: var(--surface); }
.add-button { min-height: 36px; border: 0; border-radius: 4px; padding: 0 15px; background: var(--green); color: #fff; cursor: pointer; }
.add-button:hover { background: var(--green-dark); }
.manage-list li { display: flex; align-items: center; justify-content: space-between; min-height: 42px; max-width: 520px; border-bottom: 1px solid var(--line); }
.subject-actions { display: flex; gap: 5px; }
.subject-actions button { border: 0; border-radius: 3px; padding: 5px 8px; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; }
.subject-actions button:hover:not(:disabled) { background: var(--green-soft); color: var(--green-dark); }
.subject-actions button:last-child:hover:not(:disabled) { background: #f8e9e6; color: var(--red); }
.subject-actions button:disabled { color: #b5bcb7; cursor: not-allowed; }
.page-footer { border-top: 1px solid var(--line); padding: 17px 0 28px; color: var(--muted); font-size: 12px; }

@media (max-width: 720px) {
  .topbar { min-height: 72px; padding: 10px 18px; align-items: flex-start; }
  .header-left { flex: 1; flex-direction: column; align-items: flex-start; gap: 5px; }
  .daily-quote { width: 100%; padding-left: 0; border-left: 0; }
  .quote-text { font-size: 12px; }
  .exam-countdown { gap: 3px; padding-top: 2px; }
  .countdown-caption, .countdown-unit { font-size: 11px; }
  .countdown-number { font-size: 23px; }
  .page-shell { width: min(100% - 36px, 560px); }
  .workspace { padding-top: 28px; }
  .section-heading { align-items: flex-start; }
  h1 { font-size: 24px; }
  .focus-layout { grid-template-columns: 1fr; gap: 14px; }
  .timer-panel { min-height: 190px; }
  .today-panel { min-height: 0; }
  .today-summary { min-height: 0; }
  .subject-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-list li { grid-template-columns: minmax(70px, 1fr) minmax(120px, 1.2fr) auto; gap: 8px; }
  .history-list time { font-size: 11px; }
  .date-control { flex-direction: column; align-items: flex-end; gap: 4px; }
  .subject-management summary { min-height: 44px; display: flex; align-items: center; }
  .date-control input, .add-subject-form input, .add-button, .stop-button { min-height: 44px; }
  .subject-actions button { min-height: 44px; padding-inline: 10px; }
  button, input { touch-action: manipulation; }
}

@media (max-width: 390px) {
  .page-shell { width: min(100% - 28px, 560px); }
  .elapsed { font-size: 40px; }
  .subject-picker { padding: 18px 14px; }
  .subject-button { padding: 0 8px; font-size: 13px; }
  .history-list li { grid-template-columns: 1fr auto; min-height: 54px; }
  .history-list time { grid-column: 1; grid-row: 2; padding-bottom: 7px; }
  .history-list strong { grid-column: 2; grid-row: 1 / span 2; }
  .add-subject-form { flex-wrap: wrap; }
  .add-subject-form label { width: 100%; }
  .add-subject-form input { flex: 1; width: auto; min-width: 0; }
}

@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}
