:root {
  color-scheme: light;
  --ink: #211b36;
  --muted: #5e5872;
  --violet: #5b39c7;
  --violet-dark: #4824b0;
  --soft: #eee9fe;
  --line: #e5dff0;
  --paper: #fff;
  --page: #f8f7ff;
  --radius: 20px;
  font: 16px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); }
button, textarea, input, select { font: inherit; color: inherit; }
button, .button, summary { -webkit-tap-highlight-color: transparent; }
button, .button {
  display: inline-flex; min-height: 44px; align-items: center; justify-content: center; gap: 9px;
  padding: 9px 16px; border: 1px solid transparent; border-radius: 12px;
  background: var(--soft); color: var(--violet-dark); font-weight: 650; cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: .48; cursor: default; }
button:not(:disabled):active, .file-button:active { transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid #9579f4; outline-offset: 3px;
}
.primary { background: var(--violet); color: white; border-color: var(--violet); }
.primary:hover:not(:disabled) { background: var(--violet-dark); }
.secondary { background: #f4f0ff; border-color: #e7dfff; color: var(--violet-dark); }
.text-button { background: transparent; padding-inline: 9px; }
.full { width: 100%; }
a { color: var(--violet-dark); }
p, h1, h2, h3, h4 { margin: 0; overflow-wrap: anywhere; }
h1, h2, h3, h4 { line-height: 1.35; }
h1 { font-size: clamp(1.72rem, 4vw, 2.48rem); letter-spacing: -.045em; }
h2 { font-size: 1.16rem; letter-spacing: -.025em; }
h3 { font-size: 1.02rem; }
p { white-space: pre-wrap; }
.muted, small { color: var(--muted); }
small { display: block; font-size: .82rem; line-height: 1.5; overflow-wrap: anywhere; }
.top { background: #fcfbff; border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1120px; margin: 0 auto; min-height: 68px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 1.08rem; font-weight: 760; white-space: nowrap; text-decoration: none; color: var(--ink); }
.brand-symbol { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--violet); border-radius: 11px; font: 700 1.55rem Georgia, serif; }
.desktop-nav { display: flex; gap: 6px; }
.desktop-nav button { background: transparent; color: var(--muted); }
.desktop-nav button[aria-pressed="true"] { color: var(--violet-dark); background: var(--soft); }
.connection { min-width: 100px; color: var(--muted); font-size: .84rem; text-align: right; }
.connection[data-state="ready"]::before { content: ""; display: inline-block; border-radius: 50%; width: 7px; height: 7px; margin-right: 6px; background: #309467; vertical-align: 2px; }
main { max-width: 920px; margin: auto; padding: 35px 20px 48px; }
.intro { margin-bottom: 19px; }
.intro p { font-size: 1rem; margin-top: 8px; color: var(--muted); }
.intro .notice { margin: 14px 0 0; }
.card { width: 100%; min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 23px; margin-bottom: 14px; box-shadow: 0 3px 16px #23124b06; scroll-margin-top: 20px; }
.card p + p { margin-top: 8px; }
.account-card { max-width: 440px; margin: 24px auto; }
.invite-result { margin-top: 12px; display: grid; gap: 8px; }
#invite-code { width: min(100%, 220px); font: 600 1.1rem ui-monospace, Consolas, monospace; }
.account-card h1 { margin: 0 0 8px; }
.account-card form { display: grid; gap: 9px; margin-top: 18px; }
.account-card label { display: block; }
#account-code-field input { margin-top: 6px; }
#account-switch { justify-self: center; }
#trial-state, #redeem-state { margin-top: 8px; }
.student-account { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; padding-block: 12px; align-items: start; }
.student-account details { grid-column: 1/-1; }
.redeem-form { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.redeem-form input { min-width: 0; }
.redeem-form button { flex-shrink: 0; }
body[data-login] .mobile-nav, body[data-login] .desktop-nav { display: none; }
.upload { padding: 14px; }
.upload-top { padding: 4px 4px 13px; display: flex; justify-content: center; }
.segmented { display: flex; gap: 4px; padding: 4px; background: #f2effa; border: 1px solid #eae3f6; border-radius: 14px; }
.segmented button { min-width: 124px; min-height: 42px; background: transparent; color: var(--muted); padding-block: 5px; border-radius: 10px; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--violet-dark); box-shadow: 0 1px 5px #26175120; }
.drop-zone {
  min-height: 260px; padding: 23px; border-radius: 16px; border: 1px solid #e5dafd; display: grid;
  align-content: center; justify-items: center; gap: 14px;
  background: radial-gradient(120% 120% at 50% 20%, #fbfaff 15%, #f1ebff 100%);
}
.drop-zone.dragging { outline: 2px solid var(--violet); outline-offset: -2px; }
.upload-copy { text-align: center; }
.upload-copy p { margin-top: 5px; color: var(--muted); }
.scan-icon {
  width: 78px; height: 78px; display: grid; place-items: center; position: relative; border-radius: 21px;
  background: #e8dcff; border: 1px solid #ddcdfc; color: var(--violet-dark);
}
.scan-icon span { width: 33px; height: 40px; border: 2px solid currentColor; border-radius: 6px; transform: rotate(-10deg); background: #faf7ff; }
.scan-icon span::after { content: ""; display: block; width: 15px; height: 9px; margin: 15px 6px; border-top: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.scan-icon i { position: absolute; width: 18px; height: 18px; right: 15px; bottom: 15px; border: 2px solid #704ddb; border-radius: 50%; background: #f8ecff; }
.scan-icon i::after { content: ""; position: absolute; width: 10px; height: 2px; background: #704ddb; top: 12px; left: 11px; transform: rotate(46deg); transform-origin: left; border-radius: 2px; }
.capture-actions, .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-width: 0; }
.capture-actions { justify-content: center; gap: 10px; }
.capture-actions .button { min-width: 138px; min-height: 50px; }
.file-control, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); clip-path: inset(50%); white-space: nowrap; }
.file-button:has(+ input:focus-visible) { outline: 3px solid #9579f4; outline-offset: 3px; }
.camera-icon, .image-icon, .history-icon { display: inline-block; flex: none; position: relative; width: 19px; height: 15px; border: 1.8px solid currentColor; border-radius: 4px; }
.camera-icon::before { content: ""; position: absolute; border: 1.5px solid currentColor; width: 5px; height: 5px; top: 3px; left: 5px; border-radius: 50%; }
.camera-icon::after { content: ""; position: absolute; height: 2px; width: 6px; border-radius: 2px 2px 0 0; background: currentColor; top: -3px; left: 4px; }
.image-icon::after { content: ""; position: absolute; border-left: 1.6px solid currentColor; border-top: 1.6px solid currentColor; width: 7px; height: 7px; bottom: -1px; left: 3px; transform: rotate(45deg); }
.history-icon { width: 16px; height: 19px; }
.history-icon::after { content: ""; position: absolute; width: 6px; height: 5px; border-block: 1.5px solid currentColor; left: 3px; top: 4px; }
.upload-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; column-gap: 8px; padding-top: 6px; }
.upload-footer p { flex: 1 1 100%; text-align: center; padding: 6px 8px; color: var(--muted); }
.upload-footer p[data-state="error"] { background: #fff1ee; color: #8b3226; border-radius: 9px; margin: 4px 0; }
.upload-footer p[data-state="working"]::before { content: ""; display: inline-block; width: .65em; height: .65em; border: 2px solid #d9cffa; border-top-color: var(--violet); border-radius: 50%; margin-right: 7px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.photo { padding: 2px 4px 6px; }
#image-stage { position: relative; width: fit-content; max-width: 100%; margin: 8px auto 14px; line-height: 0; }
#image { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; object-fit: contain; border-radius: 12px; background: #f2eff9; }
#image-stage.cropping { touch-action: none; user-select: none; cursor: crosshair; }
#crop-box { position: absolute; border: 2px solid #a895f1; box-shadow: 0 0 0 100vmax #25213a55; pointer-events: none; }
#image-stage.cropping { overflow: hidden; border-radius: 12px; }
#crop-actions { margin-bottom: 10px; }
#crop-actions p { flex: 1 1 100%; }
.diagnosis-button { display: flex; width: min(100%, 460px); min-height: 52px; margin: 0 auto; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 9px; }
.section-bar > .muted { font-size: .87rem; }
.verdict { display: inline-block; padding: 5px 10px; border-radius: 9px; color: var(--violet-dark); background: #f0eaff; margin-bottom: 10px; font-weight: 650; }
.verdict[data-kind="pending"] { background: #fff2d6; color: #71410d; }
.verdict[data-kind="correct"] { background: #e5f6ec; color: #196142; }
.feedback { line-height: 1.72; }
.issue, .notice { background: #f4f0ff; border: 1px solid #e9e0ff; padding: 13px; border-radius: 11px; margin-top: 12px; overflow-wrap: anywhere; }
.issue h3 { margin-bottom: 6px; }
.quoted { padding: 7px 9px; border-left: 3px solid #a68be9; color: var(--muted); }
.notice:empty, output:empty, #learning-status:empty, #ask-state:empty { display: none; }
.readback { background: #faf8ff; border: 1px solid var(--line); padding: 10px 13px; border-radius: 12px; margin-top: 14px; }
summary { cursor: pointer; min-height: 36px; line-height: 1.5; padding-block: 6px; font-weight: 650; color: var(--violet-dark); }
.readback h3 { margin: 9px 0 3px; }
.readback button { margin-top: 8px; }
.result-next { margin-top: 14px; }
.clarification { border-color: #ecd49e; background: #fffdfa; }
.clarification p { margin: 7px 0 10px; }
input:not([type="file"]):not([type="checkbox"]), textarea, select {
  display: block; width: 100%; min-width: 0; padding: 10px 12px;
  border: 1px solid #d9d0ed; border-radius: 10px; background: #fff; font-size: 1rem; min-height: 44px;
}
textarea { resize: vertical; }
label:not(.button) { display: block; color: var(--muted); margin-bottom: 4px; }
#edit-area button, #make-summary, #save-record { margin-top: 10px; }
#scope { max-width: 420px; appearance: none; }
#scope { background-image: linear-gradient(45deg,transparent 50%,#655a7e 50%),linear-gradient(135deg,#655a7e 50%,transparent 50%); background-position: calc(100% - 16px) 55%,calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat:no-repeat; padding-right: 36px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding-bottom: 4px; }
.question-actions { justify-content: flex-end; margin-top: 8px; }
#talk:not(:empty) { display: grid; gap: 9px; margin-bottom: 12px; }
#talk p { background: #f3effb; padding: 10px 12px; border-radius: 11px; margin: 0; }
#talk .student-turn { background: #e9e0ff; justify-self: end; }
.student-turn { border-radius: 12px; padding: 7px; max-width: 100%; min-width: 0; }
.student-turn img, .attachment img { display: block; width: auto; max-width: min(100%, 240px); max-height: 180px; object-fit: contain; border-radius: 8px; }
.attachment, .voice-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.attachment small, .voice-controls small { flex-basis: 100%; }
.attachment small:empty, .voice-controls small:empty { display: none; }
.voice-controls select { width: auto; max-width: 100%; }
.voice-controls audio { width: 100%; max-width: 350px; }
.report-detail { margin-block: 14px; }
#report-parts { display: grid; gap: 8px; margin-top: 8px; }
#report-parts article { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
#report-parts p { margin-top: 6px; }
#text-entry + .diagnosis-button { margin-top: 12px; }
@media print { .voice-controls { display: none !important; } }
#exercises { display: grid; gap: 12px; margin-top: 13px; }
#exercises article, .record-row, .skill-card { border: 1px solid var(--line); border-radius: 11px; padding: 12px; background: #fbfaff; min-width: 0; }
#exercises article > * + *, .skill-card > * + * { margin-top: 8px; }
#exercises textarea { margin-top: 10px; }
output { display: block; background: #ede8ff; padding: 9px 11px; border-radius: 9px; white-space: pre-wrap; overflow-wrap: anywhere; }
#record-list, #summary-result { display: grid; gap: 8px; margin-top: 10px; }
.record-row .check-row { margin-bottom: 6px; }
.check-row { min-height: 44px; display: flex !important; align-items: center; gap: 6px; }
input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--violet); }
#learning-status { margin-top: 8px; }
.mobile-nav { display: none; }
dialog { max-width: min(calc(100vw - 24px), 490px); width: 100%; border: 1px solid var(--line); border-radius: 18px; padding: 17px; color: var(--ink); }
dialog::backdrop { background: #1f153a80; }
dialog .full { margin-top: 9px; }
@media (max-width: 680px) {
  body { padding-bottom: calc(67px + env(safe-area-inset-bottom)); }
  .top-inner { min-height: 60px; padding-inline: 15px; gap: 10px; }
  .desktop-nav { display: none; }
  .brand { font-size: 1rem; }
  .brand-symbol { width: 33px; height: 33px; }
  main { padding: 24px 12px 20px; }
  .intro { padding: 0 4px; margin-bottom: 15px; }
  .intro p { margin-top: 6px; }
  .card { padding: 15px; border-radius: 16px; scroll-margin-top: 12px; }
  .upload { padding: 10px; }
  .upload-top { padding: 2px 1px 9px; }
  .segmented { width: 100%; }
  .segmented button { min-width: 0; flex: 1; }
  .drop-zone { min-height: 244px; padding: 16px 11px; gap: 11px; }
  .scan-icon { width: 64px; height: 64px; }
  .scan-icon i { right: 10px; bottom: 9px; }
  .capture-actions { width: 100%; }
  .capture-actions .button { min-width: 0; flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .result-next > button, .question-actions > button { flex: 1; }
  .mobile-nav {
    display: grid; grid-template-columns: 1fr 1fr; position: fixed; inset: auto 0 0; z-index: 5;
    padding: 5px max(8px,env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
    border-top: 1px solid var(--line); background: #fcfbff; box-shadow: 0 -4px 14px #31265309;
  }
  .mobile-nav button { gap: 5px; flex-direction: column; background: transparent; color: var(--muted); font-size: .87rem; min-height: 50px; padding: 5px; }
  .mobile-nav button[aria-pressed="true"] { background: #eee9fe; color: var(--violet-dark); }
}
@media (max-width: 352px) {
  .section-bar h2 { min-width: 0; }
  .share-actions { gap: 2px; }
  .share-actions button { padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .upload-footer p[data-state="working"]::before { animation: none; }
}
@media print {
  body { background: white; padding: 0; }
  .top, .mobile-nav, button, dialog { display: none !important; }
  main { padding: 0; max-width: none; }
  body.print-result #diagnosis-view > :not(#result) { display: none !important; }
  #result { box-shadow: none; border: 0; }
}
