/* Document defaults and reusable content components. */
:root {
  font-family: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

.records-practice {
  margin: 18px 0;
}

.diagnostic-records {
  margin: 18px 0;
}

.update-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3) 20px;
  padding: 14px 18px;
  border: 1px solid #89bcb7;
  border-radius: var(--radius);
  background: var(--soft);
}

.update-notice > div {
  flex: 1 1 280px;
  min-width: 0;
}

.update-notice p {
  margin: 2px 0 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

#update-backup-status {
  flex-basis: 100%;
}

a {
  color: var(--accent-strong);
  text-underline-offset: 4px;
}

h1,
h2,
h3,
p {
  margin: 0 0 var(--space-3);
}

h1, h2, h3 { color: var(--ink); }

h1 {
  font-size: clamp(26px, 2.3vw, 32px);
  line-height: 1.4;
  letter-spacing: -0.025em;
  font-weight: 750;
}

h2 {
  font-size: 21px;
  line-height: 1.4;
}

h3 {
  font-size: 18px;
  line-height: 1.5;
}

p:last-child {
  margin-bottom: 0;
}

small {
  font-size: 13px;
}

b,
strong {
  font-weight: 700;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  font-weight: 650;
  margin-bottom: var(--space-2);
}

.skip {
  position: fixed;
  left: 20px;
  top: -100px;
  z-index: 50;
  padding: var(--space-3);
  background: white;
}

.skip:focus {
  top: 10px;
}

:focus-visible:not([tabindex="-1"]) {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

:where(main,article,section,h1,h2,h3,p,[role="status"])[tabindex="-1"]:focus {
  outline: none;
}

main {
  min-width: 0;
}

main > section,
main > .panel {
  margin-bottom: 20px;
}

:is(#quiz-app, #diagnostic-app, #report-app) > .panel {
  margin-block: var(--section-gap);
}

.sidebar .button {
  width: 100%;
  font-size: 14px;
}

.eyebrow,
.step-label {
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 750;
  margin-bottom: 9px;
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  font-size: 17px;
  max-width: var(--measure);
  margin-bottom: var(--space-6);
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-6);
  min-width: 0;
  box-shadow: 0 3px 15px #302a4003;
  border-color: var(--line);
}

.vehicle-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  padding: 0;
  margin-bottom: var(--space-4);
  font-size: 14px;
  color: var(--muted);
}

.vehicle-context a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-left: 0;
}

.compact {
  padding-top: var(--space-6);
}

.next-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-6);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: var(--space-6) 0;
}

.next-strip h2 {
  margin-bottom: 5px;
}

.next-strip p {
  font-size: 14px;
  color: var(--muted);
}

.two-col,
.chapter-grid {
  display: grid;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.chapter-link {
  text-decoration: none;
  color: var(--text);
  display: block;
}

.chapter-link:hover {
  border-color: var(--accent);
  background: var(--surface-subtle);
}

.chapter-link p {
  color: var(--muted);
  font-size: 15px;
}

.notice {
  padding: var(--space-4) 20px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 9px;
  margin: 20px 0;
}

.notice a {
  font-weight: 600;
}

.local-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 var(--space-6);
}

.local-nav a {
  font-size: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: 13px;
  color: var(--muted);
}

.tag {
  color: #85600a;
  background: #fff5d7;
  padding: 2px 6px;
  border-radius: 4px;
}

.review-mark {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  cursor: pointer;
}

.picture {
  display: flex;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 14px;
  border-radius: 8px;
  overflow: hidden;
  min-height: 180px;
  min-width: 0;
  max-width: none;
  cursor: zoom-in;
}

.picture img {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 280px;
  object-fit: contain;
  margin: auto;
}

summary {
  cursor: pointer;
  font-weight: 600;
  min-height: 44px;
  padding: 10px 0;
}

details .refs {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-3);
  font-size: 13px;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.progress-track {
  height: 5px;
  background: var(--line);
  border-radius: 5px;
  overflow: hidden;
  margin: 10px 0 var(--space-4);
}

.progress-track > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: var(--progress);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--action-gap);
  align-items: stretch;
}

.actions > :is(button, .button) { flex: 0 1 var(--button-width); }

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: var(--space-6);
}

.metric-grid {
  display: grid;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 22px 0;
}

.metric {
  background: white;
  border: 1px solid var(--line);
  padding: 18px;
  border-radius: 10px;
}

.metric strong {
  display: block;
  font-size: 32px;
  color: var(--accent);
  line-height: 1.3;
}

.metric p {
  font-size: 13px;
  color: var(--muted);
  margin: 5px 0 0;
}

.report-grid {
  display: grid;
  grid-auto-rows: 1fr;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 20px 0;
}

.report-grid h2 {
  font-size: 19px;
}

.report-grid p {
  font-size: 14px;
}

.report-grid .actions a {
  font-size: 13px;
}

#import-preview {
  padding: 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: var(--space-4) 0;
}

.prose {
  max-width: 880px;
  margin: 0;
}

.prose > .panel {
  margin: 22px 0;
}

.prose p,
.prose ol,
.prose ul {
  max-width: var(--measure);
}

.prose h2:not(:first-child) {
  margin-top: 28px;
}

.prose li {
  padding: 5px 0;
}

.loading {
  padding: 28px;
  border: 1px dashed var(--control-border);
  border-radius: 10px;
  color: var(--muted);
  background: #fff;
}

.error {
  padding: var(--space-6);
  background: #fff4ed;
  border: 1px solid #dabca4;
  border-radius: 10px;
}

.error p {
  margin-bottom: 14px;
}

.negative {
  color: #9e3c26;
  font-size: 13px;
  font-weight: 650;
}

.ad-reading {
  margin-top: 60px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
}

.ad-reading > span {
  font-size: 13px;
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  .sidebar .eyebrow,
.sidebar .side-note,
.sidebar > .button {
    display: none;
  }

  .compact {
    padding: 20px;
  }

  .report-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid {
    gap: 10px;
  }

  .metric {
    padding: 14px;
  }

  .metric strong {
    font-size: 27px;
  }

  .next-strip {
    padding: 20px;
  }

  .prose {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .two-col,
.chapter-grid,
.report-grid {
    grid-template-columns: 1fr;
  }

  .lede {
    font-size: 16px;
    line-height: 1.7;
  }

  .next-strip {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .panel {
    padding: 20px;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .metric-grid .metric:last-child {
    grid-column: 1/-1;
  }

  .metric strong {
    font-size: 30px;
  }

  .page-heading {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 14px;
  }

  .page-heading > .actions {
    width: 100%;
  }

  .page-heading h1 {
    font-size: 26px;
  }

  .local-nav a {
    min-height: 44px;
  }

  .notice {
    padding: 15px;
    font-size: 15px;
  }

  .prose ol {
    padding-left: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

@media print {
  .lesson,
.panel {
    break-inside: avoid;
    margin-bottom: 14px;
  }

  .picture {
    display: block !important;
    border: 0;
    padding: 0;
    min-height: 0;
  }

  body {
    background: white;
  }

  .prose {
    max-width: none;
  }
}

.spaced {
  margin-top: 20px;
}

.paste-backup {
  margin: 20px 0;
}

.paste-backup summary {
  min-height: 44px;
  padding: 10px 0;
  cursor: pointer;
}

.eyebrow {
  letter-spacing: .08em;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.figure-title {
  display: block;
  font-size: 17px;
  color: var(--ink);
}

.editorial-note {
  margin-top: var(--space-3);
  border-left: 3px solid #b47616;
  padding: var(--space-3) var(--space-4);
  background: #fff9eb;
}

.next-strip .button {
  flex-shrink: 0;
}

@media (max-width: 800px) {
  .page-heading .button {
    font-size: 13px;
  }
}

@media (max-width: 600px) {
  .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 1fr;
    max-width: calc(2 * var(--button-width) + var(--action-gap));
  }

  .actions > :is(button, .button) { width: 100%; min-width: 0; }

  .actions .button,
.actions button {
    font-size: 14px;
  }

  .page-heading > .actions .button {
    min-width: 0;
    text-align: center;
  }

  .page-heading > .button {
    align-self: flex-start;
  }

  .page-heading .button { padding-inline: 12px; }
}
