:root {
  color-scheme: light;
  --ink: #0a2b50;
  --ink-soft: #35506d;
  --muted: #566779;
  --line: #d9dfe5;
  --line-strong: #c7d0d9;
  --paper: #ffffff;
  --canvas: #f7f4ec;
  --verified: #167354;
  --verified-soft: #edf8f3;
  --coral: #c83a27;
  --coral-dark: #a92d1d;
  --focus: #1769aa;
  --body-size: 16px;
  --content-width: 1216px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: var(--body-size);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
}

button,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
select {
  min-height: 44px;
}

button,
a,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 28%, transparent);
  outline-offset: 2px;
}

button {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
  font-weight: 650;
}

button .ph {
  margin-right: 6px;
  font-size: 1.08em;
  vertical-align: -0.08em;
}

button:hover {
  border-color: #96a7b7;
  background: #f7fafc;
}

button:active {
  transform: translateY(1px);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px max(24px, calc((100vw - var(--content-width)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.82);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand img {
  display: block;
  border-radius: 9px;
}

.header-links {
  display: flex;
  gap: 34px;
}

.header-links a {
  color: var(--ink);
  text-decoration: none;
  font-size: 15px;
  font-weight: 650;
}

.header-links a:hover {
  text-decoration: underline;
  text-underline-offset: 5px;
}

.page-shell {
  width: min(calc(100% - 48px), var(--content-width));
  margin: 20px auto 32px;
}

.input-panel,
.result-surface {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.86);
}

.input-panel {
  display: grid;
  gap: 12px;
  padding: 16px 18px 14px;
}

.grade-field {
  display: grid;
  grid-template-columns: 80px 144px;
  align-items: center;
  gap: 16px;
}

.grade-field label,
.question-field > label {
  color: var(--ink);
  font-size: 15px;
  font-weight: 750;
}

select {
  width: 100%;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
}

.question-field {
  display: grid;
  gap: 6px;
}

.textarea-wrap {
  position: relative;
}

textarea {
  display: block;
  width: 100%;
  height: 106px;
  min-height: 106px;
  resize: vertical;
  padding: 11px 14px 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  line-height: 1.7;
}

textarea::placeholder {
  color: #8a96a4;
}

.character-count {
  position: absolute;
  right: 12px;
  bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.input-actions {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.secondary-action {
  min-width: 118px;
  padding: 8px 16px;
}

.inline-status {
  color: var(--muted);
  font-size: 13px;
}

.generate-action {
  width: min(240px, 100%);
  min-height: 48px;
  margin-left: auto;
  padding: 10px 24px;
  border-color: var(--coral);
  background: var(--coral);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.generate-action:hover {
  border-color: var(--coral-dark);
  background: var(--coral-dark);
}

.privacy-line {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.result-surface {
  margin-top: 12px;
  padding: 0 18px 16px;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 62px;
  border-bottom: 1px solid var(--line);
}

.result-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.result-heading h2 {
  margin: 0;
  white-space: nowrap;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.verification-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid #a8d4c4;
  border-radius: 999px;
  background: var(--verified-soft);
  color: var(--verified);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.verification-badge[data-state="needs_review"] {
  border-color: #e3c6a3;
  background: #fff8ef;
  color: #81511c;
}

.toolbar-controls,
.font-controls,
.export-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.font-controls > span,
.export-controls > span {
  margin-right: 3px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.toolbar-controls button {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13px;
}

.font-controls button[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.save-action {
  margin-left: 8px;
}

.app-status {
  min-height: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.app-status:not(:empty) {
  padding: 9px 0 0;
}

.correction-card {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}

.card-section {
  min-width: 0;
  padding: 16px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.card-section h3 {
  display: flex;
  align-items: center;
  min-height: 28px;
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0.01em;
}

.card-section h3 .ph {
  flex: 0 0 auto;
  margin-right: 8px;
  font-size: 20px;
}

.card-section p {
  margin: 0 0 8px;
}

.card-section p:last-child,
.card-section ol:last-child,
.card-section ul:last-child {
  margin-bottom: 0;
}

.card-section ol,
.card-section ul {
  margin: 0;
  padding-left: 1.35em;
}

.card-section li + li {
  margin-top: 5px;
}

.answer-section,
.method-section,
.diagnosis-section {
  grid-column: span 2;
  min-height: 174px;
}

.diagnosis-section {
  border-right: 0;
}

.parent-section,
.retell-section {
  grid-column: span 3;
  min-height: 136px;
}

.retell-section {
  border-right: 0;
}

.practice-section {
  grid-column: 1 / -1;
  border-right: 0;
  border-bottom: 0;
}

.answer-line {
  font-weight: 760;
}

.verification-note {
  padding-top: 8px;
  border-top: 1px dashed var(--line-strong);
  color: var(--verified);
  font-size: 13px;
  font-weight: 700;
}

.diagnosis-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
}

.quote-line {
  padding-left: 12px;
  border-left: 3px solid var(--ink);
  line-height: 1.8;
}

.practice-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 0 !important;
  list-style: none;
}

.practice-item {
  min-height: 106px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.practice-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 13px;
}

.practice-answer-line {
  margin-top: 10px !important;
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(calc(100% - 48px), var(--content-width));
  margin: 0 auto 24px;
  color: var(--muted);
  font-size: 12px;
}

.photo-dialog {
  width: min(920px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(7, 31, 58, 0.24);
}

.photo-dialog::backdrop {
  background: rgba(5, 22, 42, 0.62);
}

.photo-dialog-header,
.photo-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
}

.photo-dialog-header {
  border-bottom: 1px solid var(--line);
}

.photo-dialog-header h2,
.photo-dialog-header p {
  margin: 0;
}

.photo-dialog-header h2 {
  font-size: 18px;
}

.photo-dialog-header p {
  color: var(--muted);
  font-size: 13px;
}

.photo-canvas-wrap {
  display: grid;
  place-items: center;
  max-height: 68dvh;
  padding: 12px;
  overflow: auto;
  background: #122d48;
}

#photoEditorCanvas {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 62dvh;
  touch-action: none;
  cursor: crosshair;
}

.photo-dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.photo-dialog-actions button,
.photo-dialog-header button {
  padding: 8px 14px;
}

.photo-dialog-actions .dialog-primary {
  border-color: var(--coral);
  background: var(--coral);
  color: #fff;
}

.photo-dialog-actions .dialog-primary:hover {
  border-color: var(--coral-dark);
  background: var(--coral-dark);
}

.records-dialog {
  width: min(680px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 22px 70px rgba(7, 31, 58, 0.24);
}

.records-dialog::backdrop {
  background: rgba(5, 22, 42, 0.62);
}

.records-dialog-header,
.records-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.records-dialog-header {
  border-bottom: 1px solid var(--line);
}

.records-dialog-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.records-dialog-header h2,
.records-dialog-header p {
  margin: 0;
}

.records-dialog-header h2 {
  font-size: 18px;
}

.records-dialog-header p {
  color: var(--muted);
  font-size: 13px;
}

.saved-records-list {
  display: grid;
  gap: 10px;
  max-height: 62dvh;
  padding: 14px 16px;
  overflow: auto;
}

.saved-record-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.saved-record-copy strong,
.saved-record-copy span {
  display: block;
}

.saved-record-copy span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.saved-record-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.empty-records {
  margin: 0;
  padding: 24px 0;
  color: var(--muted);
  text-align: center;
}

html[data-font-mode="large"] {
  --body-size: 19px;
}

html[data-font-mode="large"] .card-section h3,
html[data-font-mode="large"] .result-heading h2 {
  font-size: 1.15rem;
}

@media (max-width: 900px) {
  .site-header {
    padding-inline: 18px;
  }

  .page-shell,
  .site-footer {
    width: min(calc(100% - 24px), var(--content-width));
  }

  .result-toolbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 14px 0;
  }

  .toolbar-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .save-action {
    margin-left: auto;
  }

  .answer-section,
  .method-section,
  .diagnosis-section,
  .parent-section,
  .retell-section {
    grid-column: 1 / -1;
    min-height: 0;
    border-right: 0;
  }

  .practice-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .site-header {
    min-height: 58px;
  }

  .brand {
    gap: 9px;
    font-size: 17px;
  }

  .brand img {
    width: 32px;
    height: 32px;
  }

  .header-links {
    gap: 14px;
  }

  .header-links a {
    font-size: 13px;
  }

  .page-shell {
    margin-top: 12px;
  }

  .input-panel,
  .result-surface {
    border-radius: 8px;
  }

  .input-panel,
  .result-surface {
    padding-inline: 12px;
  }

  .grade-field {
    grid-template-columns: 60px minmax(0, 148px);
    gap: 10px;
  }

  .input-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .secondary-action {
    width: 100%;
  }

  .inline-status {
    order: 3;
  }

  .result-heading {
    flex-wrap: wrap;
  }

  .toolbar-controls,
  .font-controls,
  .export-controls {
    align-items: stretch;
  }

  .font-controls,
  .export-controls {
    flex: 1 1 auto;
    flex-wrap: wrap;
  }

  .font-controls > span,
  .export-controls > span {
    flex-basis: 100%;
  }

  .save-action {
    flex: 1 1 100%;
    margin-left: 0;
  }

  .card-section {
    padding: 16px 4px;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}

@media print {
  .site-header,
  .input-panel,
  .result-toolbar,
  .app-status,
  .site-footer {
    display: none !important;
  }

  body,
  .page-shell,
  .result-surface {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: #fff;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

.content-page,
.showcase-page {
  width: min(calc(100% - 32px), 960px);
  margin: 0 auto;
  padding: 52px 0 42px;
}

.content-hero {
  max-width: 780px;
  padding-bottom: 34px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--verified);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.content-hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.16;
  letter-spacing: -0.025em;
}

.content-hero > p:last-child,
.showcase-intro > p:not(.eyebrow) {
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1.8;
}

.policy-list {
  border-top: 1px solid var(--line-strong);
}

.policy-list article {
  display: grid;
  grid-template-columns: minmax(160px, 0.34fr) minmax(0, 1fr);
  gap: 32px;
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.policy-list h2,
.policy-list p {
  margin: 0;
}

.policy-list h2 {
  font-size: 18px;
}

.policy-list p {
  color: var(--ink-soft);
  line-height: 1.85;
}

.content-note {
  margin-top: 28px;
  padding: 20px 22px;
  border-left: 4px solid var(--verified);
  background: var(--verified-soft);
}

.content-note h2,
.content-note p {
  margin: 0;
}

.content-note h2 {
  margin-bottom: 6px;
  font-size: 17px;
}

.content-note p {
  color: var(--ink-soft);
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 6px 0 34px;
  border-block: 1px solid var(--line-strong);
}

.metric-strip div {
  padding: 22px;
  border-right: 1px solid var(--line);
}

.metric-strip div:last-child {
  border-right: 0;
}

.metric-strip strong,
.metric-strip span {
  display: block;
}

.metric-strip strong {
  font-size: 30px;
  line-height: 1.2;
}

.metric-strip span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer a,
.text-action {
  color: var(--ink);
  font-weight: 700;
  text-underline-offset: 4px;
}

.showcase-intro {
  max-width: 820px;
}

.text-action {
  display: inline-block;
  margin-top: 18px;
}

.sample-shell {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.sample-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 76px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.sample-meta h2,
.sample-meta p {
  margin: 0;
}

.sample-meta h2 {
  font-size: 19px;
}

.sample-meta p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.static-sample .answer-section,
.static-sample .method-section,
.static-sample .diagnosis-section {
  min-height: 236px;
}

.sample-disclaimer {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 700px) {
  .content-page,
  .showcase-page {
    padding-top: 30px;
  }

  .content-hero h1 {
    font-size: clamp(30px, 10vw, 42px);
  }

  .content-hero > p:last-child,
  .showcase-intro > p:not(.eyebrow) {
    font-size: 16px;
  }

  .policy-list article {
    grid-template-columns: 1fr;
    gap: 8px;
  }

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

  .metric-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-strip div:last-child {
    border-bottom: 0;
  }

  .sample-meta {
    align-items: flex-start;
    flex-direction: column;
  }
}
