:root {
  color-scheme: light;
  --paper: #fffdf8;
  --surface: #ffffff;
  --ink: #22201c;
  --muted: #716b60;
  --line: #ded7c9;
  --soft: #f4efe5;
  --green: #245c4f;
  --green-soft: #e8f2ec;
  --blue: #345781;
  --blue-soft: #e9eef7;
  --orange: #b85c38;
  --orange-soft: #f7e6dc;
  --red: #a43d32;
  --red-soft: #f7dfdc;
  --shadow: 0 16px 42px rgba(38, 31, 21, 0.08);
  font-family: "Songti SC", "Noto Serif CJK SC", "PingFang SC", "Microsoft YaHei", serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #e9e3d7;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(246, 241, 230, 0.96)),
    repeating-linear-gradient(0deg, rgba(36, 92, 79, 0.035) 0 1px, transparent 1px 12px);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

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

code,
pre {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(88px + env(safe-area-inset-bottom));
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(36, 92, 79, 0.08), 0 26px 80px rgba(0, 0, 0, 0.13);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 -14px 14px;
  padding: 16px 18px 13px;
  border-bottom: 1px solid rgba(222, 215, 201, 0.86);
  background: rgba(255, 253, 248, 0.92);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 10px;
  font-size: 19px;
  line-height: 1.26;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
  line-height: 1.35;
}

p {
  line-height: 1.66;
}

.app-main {
  display: grid;
  gap: 14px;
}

.hero,
.panel,
.task-card,
.metric-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero {
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(36, 92, 79, 0.12), transparent 48%),
    linear-gradient(315deg, rgba(184, 92, 56, 0.11), transparent 56%),
    #fffaf1;
}

.hero.compact {
  padding: 16px;
}

.student-hero {
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(36, 92, 79, 0.11), transparent 54%),
    #fffaf1;
}

.student-hero h2 {
  max-width: 12em;
  font-size: 22px;
}

.student-hero p {
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
}

.hero h2 {
  margin-bottom: 7px;
  font-size: 24px;
}

.hero p:last-child,
.panel p:last-child {
  margin-bottom: 0;
}

.panel {
  padding: 16px;
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
}

.quick-action {
  display: grid;
  gap: 2px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 253, 248, 0.82);
}

.quick-action.primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #fffdf8;
}

.quick-action strong {
  font-size: 16px;
  line-height: 1.2;
}

.quick-action span {
  color: currentColor;
  opacity: 0.74;
  font-size: 12px;
  font-weight: 800;
}

.today-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  box-shadow: none;
}

.today-summary div {
  padding: 10px;
  border-radius: 8px;
  background: var(--soft);
}

.today-summary strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.today-summary span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.quiet-panel {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffaf1;
}

.quiet-panel strong {
  display: block;
  margin-bottom: 5px;
}

.quiet-panel p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.done-panel {
  background: var(--green-soft);
}

.mode-banner {
  padding: 13px 14px;
  border: 1px solid #c8b99f;
  border-left: 6px solid var(--orange);
  border-radius: 9px;
  background: #fff5e8;
  box-shadow: var(--shadow);
}

.load-advice {
  padding: 14px 15px;
  border: 1px solid #c8b99f;
  border-left: 6px solid var(--blue);
  border-radius: 9px;
  background: #f3f7fc;
  box-shadow: var(--shadow);
}

.load-advice strong {
  display: block;
  margin-bottom: 5px;
  color: var(--blue);
}

.load-advice p {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 13px;
}

.mode-banner strong {
  display: block;
  margin-bottom: 4px;
}

.mode-banner p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.metric-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.metric-card {
  padding: 12px 9px;
  box-shadow: none;
}

.metric-card strong {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.metric-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.task-list,
.error-list {
  display: grid;
  gap: 12px;
}

.task-section {
  display: grid;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 3px 0;
}

.section-heading h2 {
  margin-bottom: 0;
}

.section-heading span {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.task-list.dense {
  gap: 10px;
}

.task-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-left-width: 6px;
}

.task-card.subject-math {
  border-left-color: var(--green);
}

.task-card.subject-physics {
  border-left-color: var(--blue);
}

.task-card.subject-english {
  border-left-color: var(--orange);
}

.task-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.subject-task-card {
  gap: 13px;
}

.subject-task-card h3 {
  margin-bottom: 0;
}

.subject-plan {
  display: grid;
  gap: 5px;
  padding: 12px;
  border-radius: 8px;
  background: #fffaf1;
}

.subject-plan span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.subject-plan strong {
  font-size: 17px;
  line-height: 1.35;
}

.subject-plan p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.subject-side-note {
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.subject-side-note strong {
  color: var(--ink);
}

.task-note {
  margin-bottom: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.subject-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 7px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.status-pill {
  flex: none;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.done {
  background: var(--green-soft);
  color: var(--green);
}

.status-pill.repair,
.status-pill.waiting {
  background: var(--orange-soft);
  color: var(--orange);
}

.status-pill.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.meta-row,
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.meta-row span,
.tag-list span {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.tag-list.vertical {
  display: grid;
}

.tag-list.vertical span {
  justify-content: flex-start;
  border-radius: 7px;
  min-height: 36px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.button,
.ghost-button,
.role-switch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: var(--ink);
  color: #fffdf8;
  font-weight: 900;
  cursor: pointer;
}

.button.secondary {
  border-color: var(--green);
  background: var(--green);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.button:disabled {
  border-color: #c9c0ae;
  background: #c9c0ae;
  cursor: not-allowed;
}

.role-switch {
  min-height: 36px;
  border-color: var(--green);
  background: var(--green);
  font-size: 13px;
  white-space: nowrap;
}

.step-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-list li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.step-list li.current {
  border-color: rgba(36, 92, 79, 0.45);
  background: var(--green-soft);
}

.step-list li span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.step-list p {
  margin-bottom: 0;
}

.form-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.check-list {
  display: grid;
  gap: 9px;
}

.check-list label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  line-height: 1.55;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-grid .checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.form-grid .checkbox-line input {
  width: auto;
  min-height: auto;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffdf8;
  color: var(--ink);
}

.form-grid textarea {
  min-height: 92px;
  padding: 10px;
  resize: vertical;
  line-height: 1.6;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.adjustment-list,
.material-list,
.attempt-list,
.print-list {
  display: grid;
  gap: 10px;
}

.adjustment-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #fffdf8;
}

.adjustment-card strong {
  display: block;
  margin-bottom: 5px;
}

.adjustment-card p {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.adjustment-card small {
  color: var(--muted);
}

.material-row {
  position: relative;
}

.print-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.print-card h3 {
  margin-bottom: 6px;
}

.print-card p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.print-card code {
  display: block;
  padding: 8px;
  border-radius: 7px;
  background: var(--soft);
  font-size: 12px;
  word-break: break-all;
}

.material-row code {
  word-break: break-all;
  font-size: 12px;
}

.empty-state {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--soft);
  color: var(--muted);
  line-height: 1.7;
}

.path-list {
  display: grid;
  gap: 8px;
}

.path-list p {
  margin-bottom: 0;
  word-break: break-all;
}

.pdf-frame {
  overflow: hidden;
  height: min(72vh, 640px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f1e7;
}

.pdf-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.upload-drop {
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 24px 14px;
  border: 1px dashed #9d927f;
  border-radius: 9px;
  background: #fffaf1;
  cursor: pointer;
}

.upload-drop input {
  max-width: 100%;
}

.upload-drop span {
  font-size: 17px;
  font-weight: 900;
}

.upload-drop small {
  color: var(--muted);
}

.preview {
  display: grid;
  gap: 8px;
  justify-items: center;
  min-height: 92px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fffdf8;
}

.preview.empty {
  place-items: center;
  color: var(--muted);
}

.preview img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.upload-gallery {
  display: grid;
  gap: 10px;
  width: 100%;
}

.upload-gallery figure {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.upload-gallery img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: 6px;
  background: #f8f3e8;
}

.upload-gallery figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  word-break: break-all;
}

.file-preview-card {
  display: grid;
  gap: 8px;
  align-content: center;
  justify-items: center;
  min-height: 156px;
}

.file-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 92px;
  height: 112px;
  border: 2px solid var(--red);
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.compact-gallery {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-gallery img,
.compact-gallery .file-preview-card {
  height: 160px;
}

.attempt-card {
  display: grid;
  gap: 12px;
}

.sync-list {
  display: grid;
  gap: 10px;
}

.sync-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.sync-row p {
  margin: 5px 0 0;
  color: var(--muted);
}

.insight-list,
.analysis-list {
  display: grid;
  gap: 10px;
}

.teacher-summary {
  margin-bottom: 12px;
  padding: 14px 16px;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: #f6fbf7;
  color: var(--ink);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.65;
}

.compact-list {
  margin-top: 10px;
}

.insight-list p,
.analysis-card {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid rgba(222, 215, 201, 0.88);
  border-radius: 8px;
  background: #fffaf0;
}

.analysis-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--green);
}

.analysis-card p {
  margin: 0;
  color: var(--muted);
}

.teacher-card {
  background: #fffdf8;
}

.teacher-card p {
  line-height: 1.75;
}

.explanation-steps {
  margin: 10px 0 0;
  padding-left: 22px;
  color: var(--ink);
  line-height: 1.85;
}

.explanation-steps li + li {
  margin-top: 6px;
}

.method-tip {
  margin-top: 10px !important;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f0e8;
  color: var(--ink) !important;
  font-weight: 800;
}

.result-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
}

.result-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 14px;
}

.result-table th,
.result-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.result-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  background: #f6f0e8;
}

.result-table tr:last-child td {
  border-bottom: 0;
}

.grading-table td:last-child {
  min-width: 220px;
  line-height: 1.6;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.recorded-errors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 13px 14px;
  border: 1px solid rgba(32, 96, 80, 0.22);
  border-radius: 8px;
  background: #f6fbf7;
}

.recorded-errors strong {
  color: var(--green);
}

.recorded-error-tags {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.recorded-error-tags p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.hint-list {
  margin: 0;
  padding-left: 20px;
  color: var(--ink);
}

.hint-list li + li {
  margin-top: 8px;
}

.check-list.static label {
  cursor: default;
}

.attempt-card header,
.correction-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.grading-form {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.code-block {
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  background: #26221d;
  color: #fff6e6;
  font-size: 12px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(222, 215, 201, 0.92);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: grid;
  gap: 3px;
  justify-items: center;
  padding: 5px 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bottom-nav a.active {
  background: var(--green-soft);
  color: var(--green);
}

.app-toast {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 40;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid rgba(36, 92, 79, 0.22);
  border-radius: 9px;
  background: rgba(34, 32, 28, 0.94);
  color: #fffdf8;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  border: 1px solid currentColor;
  border-radius: 5px;
  font-size: 11px;
}

@media (max-width: 390px) {
  .metric-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stack-on-small {
    display: grid;
  }
}

@media (min-width: 840px) {
  .app-shell,
  .bottom-nav {
    width: min(100%, 860px);
  }

  .task-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
