:root {
  --ink: #1b2533;
  --muted: #6c7788;
  --line: #e8edf5;
  --surface: #ffffff;
  --bg: #f5f7fb;
  --green: #15d0a6;
  --blue: #2598ff;
  --pink: #ff75b2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body:has(dialog[open]) {
  overflow: hidden;
  touch-action: none;
}

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

.app-shell {
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  padding: 18px 14px 88px;
  background: linear-gradient(180deg, #eaf8ff 0, #f7f8fc 32%, #f7f8fc 100%);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.brand-header,
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px 18px;
}

.section-header {
  display: block;
}

.logo-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  background: #ff3b30;
}

.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

.smart-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 18px 24px 18px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dceaff 0%, #ffd1e6 100%);
}

.smart-card p {
  margin: 6px 0 0;
  color: var(--muted);
}

.pill-button,
.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  cursor: pointer;
}

.pill-button,
.primary-button {
  color: #fff;
  background: #13263a;
}

.ghost-button {
  color: var(--ink);
  background: #eef2f7;
}

.danger-button {
  color: #fff;
  background: #ff5c6c;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.feature-card {
  min-height: 138px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  text-align: left;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 14px 24px rgba(35, 50, 68, 0.12);
}

.feature-card.pink {
  grid-column: span 2;
}

.feature-card.green {
  background: var(--green);
}

.feature-card.blue {
  background: var(--blue);
}

.feature-card.pink {
  background: var(--pink);
}

.feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 800;
}

.feature-card strong {
  font-size: 21px;
}

.feature-card small {
  font-size: 13px;
  opacity: 0.86;
}

.robot-panel {
  margin: 26px auto 0;
  text-align: center;
  color: var(--muted);
}

.icp-record {
  font-size: 14px;
  margin: 0;
  text-align: center;
}

.icp-record a {
  color: #a8b4c8;
  text-decoration: none;
}

.robot-head {
  width: 150px;
  height: 118px;
  margin: 0 auto 12px;
  padding: 28px 18px;
  border-radius: 50% 50% 38% 38%;
  background: #ffffff;
  box-shadow: inset 0 -8px 0 #dff9f2, 0 18px 28px rgba(15, 179, 164, 0.12);
}

.robot-face {
  height: 54px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  color: #9ff7e4;
  letter-spacing: 3px;
  background: #126173;
}

.auth-header {
  padding: 52px 6px 20px;
}

.auth-header h1 {
  margin-top: 6px;
  font-size: 25px;
  text-align: center;
}

.auth-brand-title {
  display: block;
  position: relative;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.auth-ai-badge {
  position: absolute;
  top: -5px;
  left: calc(100% + 4px);
  padding: 2px 5px;
  border-radius: 999px;
  color: #fff;
  background: #ff3b30;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.auth-card {
  display: grid;
  gap: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 14px;
  background: #eaf0f7;
}

.auth-tabs button {
  border: 0;
  border-radius: 10px;
  padding: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.auth-tabs button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 8px 18px rgba(36, 54, 78, 0.08);
}

.auth-form {
  padding: 16px;
}

.auth-register-fields {
  display: grid;
  gap: 14px;
}

.auth-register-fields[hidden] {
  display: none;
}

.sms-code-row {
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 8px;
}

.sms-code-row button {
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: #13263a;
  font-size: 14px;
  font-weight: 700;
}

.sms-code-row button:disabled,
.auth-form button:disabled {
  opacity: 0.58;
}

.auth-tip {
  margin: -4px 0 0;
  color: #f06b21;
  font-size: 13px;
}

.profile-form,
.dialog-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.wrong-list {
  margin-top: 18px;
  display: grid;
  gap: 16px;
  min-height: 80px;
  padding-bottom: 84px;
}

.wrong-filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: center;
  margin-top: 4px;
  padding: 0 14px 8px;
  position: relative;
}

.wrong-filter-trigger {
  width: auto;
  min-height: 30px;
  border: 0;
  border-radius: 0;
  padding: 0 20px 0 0;
  color: var(--ink);
  background: transparent;
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.wrong-master-trigger {
  grid-column: 1;
  justify-self: start;
}

.wrong-time-trigger {
  grid-column: 2;
  justify-self: end;
}

.wrong-filter-trigger.active {
  color: #39bd83;
}

.wrong-filter-trigger::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  border-right-color: currentColor;
  border-bottom-color: currentColor;
  transform: translateY(-65%) rotate(45deg);
}

.wrong-filter-trigger.open::after {
  transform: translateY(-35%) rotate(225deg);
}

.wrong-filter-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: -14px;
  right: -14px;
  z-index: 5;
  display: grid;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 18px 30px rgba(27, 37, 51, 0.14);
}

.wrong-filter-option {
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 15px 24px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  text-align: left;
  position: relative;
}

.wrong-filter-option:last-child {
  border-bottom: 0;
}

.wrong-filter-option.active::after {
  content: "✓";
  position: absolute;
  right: 24px;
  color: #126dff;
  font-weight: 900;
}

.wrong-card {
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(27, 37, 51, 0.08);
  position: relative;
}

.wrong-card-body {
  position: relative;
}

.wrong-card.selected,
.similar-question.selected {
  outline: 2px solid #0b8cff;
  outline-offset: 2px;
}

.wrong-card img {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin-top: 12px;
}

.wrong-card-meta {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr 1fr auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.wrong-card-meta b {
  color: #18b985;
}

.wrong-stars {
  color: var(--green);
  letter-spacing: 1px;
}

.wrong-stars i {
  color: #dfe3ea;
  font-style: normal;
}

.wrong-status {
  padding: 6px 10px;
  border-radius: 10px;
  color: #fff;
  background: #ff4f64;
  font-size: 13px;
}

.wrong-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.wrong-card-actions button {
  border: 0;
  border-radius: 10px;
  padding: 9px 12px;
  color: #25b878;
  background: #edfff7;
  font-weight: 800;
}

.wrong-card-actions button:disabled {
  opacity: 0.62;
}

.wrong-similar-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.similar-question {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #dcefe7;
  border-radius: 10px;
  background: #f8fffb;
  position: relative;
}

.similar-question header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.similar-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.similar-content {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
}

.similar-content span {
  display: block;
}

.similar-diagram {
  margin: 0;
  padding: 8px;
  background: #fff;
}

.similar-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}

.similar-diagram rect {
  fill: #f8faf7;
  stroke: #8e9c95;
}

.similar-diagram path {
  fill: none;
  stroke: #35423d;
  stroke-width: 1.6;
}

.similar-diagram line {
  stroke: #26352f;
  stroke-width: 1.4;
}

.similar-diagram .trail {
  stroke: #6a756f;
  stroke-width: 3;
}

.similar-diagram text {
  fill: #26352f;
  font-size: 11px;
  font-weight: 700;
}

.similar-diagram .camp rect {
  fill: #25332e;
  stroke: none;
}

.similar-diagram .camp path {
  fill: #25332e;
  stroke: none;
}

.similar-diagram .camp text {
  font-size: 12px;
}

.similar-diagram .diagram-title,
.similar-diagram .diagram-legend,
.similar-diagram .diagram-scale text {
  fill: #69766f;
  font-size: 10px;
}

.similar-diagram-generic .object {
  fill: #f8faf7;
  stroke: #8e9c95;
}

.similar-diagram-generic .ground,
.similar-diagram-generic .arrow,
.similar-diagram-generic .arrow-head,
.similar-diagram-generic .motion {
  fill: none;
  stroke: #26352f;
  stroke-width: 2;
  stroke-linecap: round;
}

.similar-diagram-generic .motion {
  stroke-dasharray: 4 5;
}

.similar-diagram-map .china-outline {
  fill: #f8faf7;
  stroke: none;
}

.similar-diagram-map .china-boundary {
  fill: none;
  stroke: #41544d;
  stroke-width: 1.8;
  stroke-linejoin: round;
}

.similar-diagram-map .region {
  stroke: none;
}

.similar-diagram-map .north {
  fill: #dceee5;
}

.similar-diagram-map .south {
  fill: #d7eadf;
}

.similar-diagram-map .northwest {
  fill: #f2e6ca;
}

.similar-diagram-map .qinghai {
  fill: #e7d9ef;
}

.similar-diagram-map .region-line {
  fill: none;
  stroke: #5f726b;
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
}

.similar-diagram-map .map-label circle {
  fill: #25332e;
  stroke: #fff;
  stroke-width: 1.5;
}

.similar-diagram-map .map-label text {
  fill: #25332e;
  font-size: 10.5px;
  font-weight: 700;
}

.similar-diagram-taiwan .taiwan-sea {
  fill: #f7fbfd;
  stroke: none;
}

.similar-diagram-taiwan .taiwan-island {
  fill: #dceee5;
  stroke: #41544d;
  stroke-width: 1.8;
}

.similar-diagram-taiwan .taiwan-plain {
  fill: #f2e6ca;
  stroke: none;
}

.similar-diagram-taiwan .taiwan-mountain {
  fill: none;
  stroke: #5f726b;
  stroke-width: 2;
  stroke-dasharray: 5 4;
}

.similar-diagram-taiwan .taiwan-river {
  fill: none;
  stroke: #6aa0bd;
  stroke-width: 1.4;
}

.similar-diagram-taiwan .map-water {
  fill: #6c7788;
  font-size: 10px;
  font-weight: 600;
}

.similar-question p {
  margin: 0;
  color: var(--ink);
  line-height: 1.6;
}

.similar-reveal {
  justify-self: center;
  border: 0;
  padding: 4px 8px;
  color: #25b878;
  background: transparent;
  font-size: 14px;
  font-weight: 800;
}

.similar-solution {
  display: grid;
  gap: 6px;
}

.similar-solution[hidden] {
  display: none;
}

.similar-answer,
.similar-analysis {
  color: var(--muted) !important;
  font-size: 13px;
}

.wrong-list-footer,
.learning-record-footer {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
  padding: 10px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 -10px 28px rgba(27, 37, 51, 0.08);
}

.app-shell:has(#page-subject-wrong.active) .wrong-list-footer {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(430px, 100vw);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  transform: translateX(-50%);
}

.wrong-list-footer button,
.learning-record-footer button {
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.wrong-manage-button {
  color: var(--ink);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.wrong-compose-button {
  color: #fff;
  background: #19c17d;
  box-shadow: 0 10px 20px rgba(25, 193, 125, 0.2);
}

.selection-footer {
  grid-template-columns: 96px 1fr 96px;
}

.selection-footer button {
  background: transparent;
}

.selection-footer button:first-child {
  color: #20b782;
}

.selection-footer button:nth-child(2) {
  color: #fff;
  background: #19c17d;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(25, 193, 125, 0.22);
}

.selection-footer .wrong-delete-selected {
  background: #ff4f64;
  box-shadow: 0 10px 20px rgba(255, 79, 100, 0.2);
}

.selection-footer button:last-child {
  color: var(--ink);
}

.select-toggle {
  position: absolute;
  z-index: 2;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 2px solid #d7dee8;
  border-radius: 999px;
  background: #fff;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.select-toggle span {
  position: relative;
  z-index: 1;
}

.wrong-select-toggle {
  top: 50%;
  transform: translateY(-50%);
}

.select-toggle.selected {
  border-color: #18be7c;
  background: #18be7c;
}

.select-toggle.selected::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 7px;
  height: 13px;
  border: solid #fff;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.select-toggle.selected:has(span)::after {
  content: none;
}

.similar-select-toggle {
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
}

.practice-header {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  padding: 12px 2px 20px;
}

.practice-header h1 {
  grid-column: 2;
  grid-row: 1;
  text-align: center;
  font-size: 26px;
}

.ai-paper-header {
  padding-bottom: 14px;
}

.ai-paper-tip {
  margin-bottom: 16px;
  border: 1px solid #d9f0bb;
  border-radius: 12px;
  padding: 12px 14px;
  color: #1f2733;
  background: #fbfff3;
  font-size: 15px;
  line-height: 1.5;
}

.ai-paper-grade {
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 14px;
  border: 0;
  border-radius: 14px;
  padding: 0 18px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.ai-paper-grade span {
  font-size: 17px;
}

.ai-paper-grade b {
  position: relative;
  padding-right: 18px;
  font-size: 17px;
}

.ai-paper-grade b::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  width: 10px;
  height: 10px;
  border-right: 3px solid currentColor;
  border-bottom: 3px solid currentColor;
  transform: translateY(-55%) rotate(-45deg);
}

.ai-paper-section {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  border-radius: 14px;
  padding: 16px 14px;
  background: #fff;
}

.ai-paper-section header {
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.ai-paper-section h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
}

.ai-paper-section p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.ai-paper-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ai-paper-options button {
  min-height: 42px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: #f4f5f7;
  font-size: 15px;
}

.ai-paper-options button.active {
  color: #19a872;
  background: #eafff4;
  box-shadow: inset 0 0 0 1px #20b782;
}

.ai-paper-options button:disabled,
.ai-paper-grade:disabled,
.ai-paper-difficulty-grid input:disabled,
.ai-paper-custom-prompt:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.ai-paper-difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.ai-paper-difficulty-grid label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f4f5f7;
  font-size: 14px;
}

.ai-paper-difficulty-grid input {
  min-width: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
  text-align: right;
}

.ai-paper-difficulty-grid p {
  grid-column: 1 / -1;
  justify-self: start;
  color: #20b782;
}

.ai-paper-section .ai-paper-error {
  color: #ff4f64;
}

.ai-paper-custom-prompt {
  width: 100%;
  min-height: 78px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f4f5f7;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: none;
}

.ai-paper-custom-prompt::placeholder {
  color: var(--muted);
}

.ai-paper-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(430px, 100vw);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  transform: translateX(-50%);
}

.ai-paper-actions button {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #20b782;
  font-size: 17px;
  font-weight: 800;
}

.ai-paper-actions button:disabled {
  color: rgba(255, 255, 255, 0.72);
  background: #a9e5c2;
}

.compose-preview-card {
  display: grid;
  gap: 14px;
  padding: 14px 18px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(27, 37, 51, 0.08);
}

.compose-paper-head {
  position: relative;
  min-height: 66px;
  display: grid;
  align-items: center;
  justify-items: stretch;
  padding: 0 54px 6px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.compose-paper-head h2 {
  margin: 0 0 20px;
  font-size: 17px;
  line-height: 1.25;
}

.compose-paper-head p {
  position: absolute;
  left: 0;
  right: 54px;
  bottom: 6px;
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 10px;
  text-align: left;
}

.compose-paper-title-block {
  min-width: 0;
  width: 100%;
  justify-self: stretch;
}

.compose-analysis-code {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 6px;
  display: grid;
  grid-template-columns: 38px;
  grid-template-rows: 38px 1fr;
  align-items: start;
  justify-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.compose-analysis-code img {
  grid-column: 1;
  grid-row: 1;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: #fff;
}

.compose-analysis-code span {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  margin-top: 0;
  font-size: 10px;
  line-height: 1;
}

.wrong-status.mastered {
  background: #20b782;
}

.compose-paper-list {
  display: grid;
  gap: 18px;
}

.compose-paper-item {
  break-inside: avoid;
  display: grid;
  gap: 10px;
}

.compose-paper-item h3 {
  margin: 0 0 -4px;
  font-size: 16px;
}

.compose-paper-item img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compose-similar-content {
  display: grid;
  gap: 8px;
  line-height: 1.7;
}

.compose-similar-content b {
  font-size: 16px;
}

.compose-preview-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(430px, 100vw);
  display: grid;
  gap: 10px;
  padding: 12px 28px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: 0 -10px 28px rgba(27, 37, 51, 0.08);
  transform: translateX(-50%);
}

.compose-name-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 16px;
}

.compose-name-row span {
  color: var(--ink);
  min-width: 0;
}

.compose-name-row b {
  font-weight: 500;
}

.compose-name-row input {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.compose-name-row button {
  border: 0;
  color: #20b782;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
}

.compose-preview-actions .primary-button {
  min-height: 46px;
  border-radius: 999px;
  background: #19c17d;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(25, 193, 125, 0.22);
}

.grade-chip {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  align-self: center;
  min-height: 32px;
  border: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
}

.practice-semester-select {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  align-self: center;
  width: 82px;
  min-height: 32px;
  border: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.2;
  font-weight: 800;
  text-align: right;
  appearance: auto;
}

.subject-panel {
  padding: 12px;
  border: 8px solid #12d5ab;
  border-radius: 28px;
  background: #fff;
}

.subject-panel-title {
  padding: 10px 12px 14px;
  color: #fff;
  background: #12d5ab;
  border-radius: 20px 20px 8px 8px;
  font-size: 24px;
  font-weight: 800;
}

.subject-panel-title span {
  margin-left: 6px;
  font-size: 18px;
  font-weight: 500;
  opacity: 0.8;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px 4px 4px;
}

.secondary-subject-grid {
  padding: 18px 24px 0;
}

.subject-card {
  min-height: 112px;
  border: 0;
  border-radius: 14px;
  padding: 12px 8px;
  color: var(--subject-color);
  background: linear-gradient(180deg, rgba(var(--subject-rgb), 0.24), rgba(var(--subject-rgb), 0.12));
  box-shadow: inset 0 -14px 22px rgba(255, 255, 255, 0.38);
}

.subject-icon {
  display: grid;
  width: 42px;
  height: 34px;
  margin: 0 auto 6px;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: rgba(var(--subject-rgb), 0.86);
  font-weight: 900;
}

.subject-card strong {
  display: block;
  font-size: 17px;
}

.subject-count {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-width: 66px;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--subject-color);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.subject-count b {
  margin-right: 2px;
  font-size: 26px;
}

.wrong-list-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.wrong-list-header span {
  color: var(--muted);
  font-size: 13px;
}

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

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

.profile-form input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}

.native-select-hidden {
  display: none;
}

.subject-select-field[hidden],
.upload-term-row[hidden] {
  display: none;
}

.subject-select-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.mobile-select-trigger {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 38px 12px 12px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  text-align: left;
  position: relative;
}

.mobile-select-trigger::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  transform: translateY(-65%) rotate(45deg);
}

.practice-semester-trigger {
  grid-column: 3;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  align-self: center;
  width: 82px;
  min-height: 32px;
  border: 0;
  padding: 0 16px 0 0;
  background: transparent;
  font-weight: 800;
  line-height: 1.2;
  text-align: right;
}

.practice-semester-trigger::after {
  right: 2px;
}

.mobile-select-dialog {
  width: min(92vw, 420px);
  max-width: 420px;
  margin: auto auto 0;
  border: 0;
  border-radius: 18px 18px 0 0;
}

.mobile-select-sheet {
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #f7f8fc;
}

.mobile-select-sheet h2 {
  padding: 8px 6px 2px;
  text-align: center;
  font-size: 17px;
}

.mobile-select-options {
  display: grid;
  gap: 1px;
  max-height: min(52vh, 430px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
  background: var(--line);
  -webkit-overflow-scrolling: touch;
}

.mobile-select-option {
  border: 0;
  padding: 15px 18px;
  color: var(--ink);
  background: #fff;
  font-size: 17px;
  text-align: center;
}

.mobile-select-option:focus {
  outline: none;
}

.mobile-select-option:focus-visible {
  outline: none;
  background: #f4fbf8;
}

.mobile-select-option.active {
  color: #14a77c;
  font-weight: 800;
}

.upload-term-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#upload-grade {
  color: #6c7788;
  background: #f7f9fc;
  opacity: 1;
  pointer-events: none;
}

.grade-box {
  padding: 12px;
  border-radius: 10px;
  background: #f2fbf8;
}

.profile-title {
  padding: 14px 0 18px;
  text-align: center;
}

.learning-record-header {
  position: relative;
  padding-bottom: 8px;
}

#page-learning-records {
  position: relative;
}

.learning-record-header #record-manage-button {
  position: absolute;
  top: 50%;
  right: 0;
  border: 0;
  padding: 0;
  color: #1f2733;
  background: transparent;
  font-size: 17px;
  transform: translateY(-50%);
}

.learning-record-header #record-manage-button.active {
  color: #22b980;
}

.profile-card {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 18px 20px;
}

.profile-entry {
  width: 100%;
  margin-top: -20px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.profile-entry > div:nth-child(2) {
  flex: 1;
}

.profile-arrow {
  margin-left: auto;
  width: 18px;
  color: var(--muted);
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
  text-align: right;
}

.profile-avatar {
  position: relative;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  overflow: hidden;
  border-radius: 50%;
}

.profile-avatar img[hidden],
.profile-avatar span[hidden] {
  display: none;
}

.profile-name-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 22px;
}

.vip-badge {
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: #e5a01f;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.profile-avatar .vip-badge {
  position: absolute;
  top: 1px;
  right: -18px;
  z-index: 1;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.vip-badge.inactive {
  color: var(--muted);
  background: #edf1f5;
}

.profile-subtitle {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.baby-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.baby-panel[hidden] {
  display: none;
}

.baby-meta {
  color: var(--muted);
  font-size: 13px;
}

.baby-limit-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.baby-list,
.baby-form {
  display: grid;
  gap: 10px;
}

.baby-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border-radius: 12px;
  background: #f8fbff;
}

.baby-item.active {
  background: #ecfff7;
  outline: 2px solid #2fc985;
}

.baby-info {
  display: grid;
  align-content: center;
  gap: 9px;
}

.baby-item-actions {
  display: grid;
  gap: 8px;
  justify-items: end;
  align-content: center;
}

.baby-switch,
.baby-delete {
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  color: #fff;
}

.baby-switch {
  background: #2fc985;
}

.baby-delete {
  background: #ff6b6b;
}

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

.baby-fields {
  display: grid;
  gap: 10px;
}

.baby-fields[hidden] {
  display: none;
}

.baby-form input,
.baby-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}

.school-search-field {
  position: relative;
}

.school-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(27, 37, 51, 0.12);
}

.school-suggestions[hidden] {
  display: none;
}

.school-suggestions button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.school-suggestions button:last-child {
  border-bottom: 0;
}

.baby-form-actions {
  display: grid;
  gap: 10px;
}

.baby-form-actions:has(#baby-save-button:not([hidden])) {
  grid-template-columns: 1fr 1fr;
}

.baby-form-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.baby-form-actions button[hidden] {
  display: none;
}

.profile-menu {
  display: grid;
  margin-top: 4px;
  border-radius: 14px;
  background: #fff;
}

.profile-menu button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 18px;
  color: var(--ink);
  background: transparent;
  font-size: 18px;
}

.profile-menu button:last-child {
  border-bottom: 0;
}

.profile-menu button[hidden] {
  display: none;
}

.settings-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.vip-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.vip-summary-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.vip-summary-card.active {
  border-color: #f1d68d;
}

.vip-status-card {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border: 1px solid #dce7f0;
  border-radius: 14px;
  background: #f3f8fb;
  text-align: center;
}

.vip-status-card.active {
  justify-content: center;
  min-height: 88px;
  padding: 18px 20px;
  border-color: transparent;
  background:
    radial-gradient(circle at 74% 24%, rgba(255, 255, 255, 0.34), transparent 22%),
    linear-gradient(110deg, #fff0bd 0%, #ffe39a 48%, #ffc96a 100%);
  text-align: center;
}

.vip-status-card.active strong {
  color: #4e3205;
  font-size: 20px;
  letter-spacing: 0;
}

.vip-status-card.active p {
  margin-top: 8px;
  color: #7a6439;
  font-size: 14px;
}

.vip-status-card strong {
  font-size: 20px;
}

.vip-benefits {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.vip-benefits span {
  padding: 12px;
  border-radius: 12px;
  color: #40505f;
  background: #f5f8fa;
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.vip-summary-card.active .vip-benefits span {
  color: #6f330f;
  background: #fff4d6;
}

.vip-buy-link {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none;
}

.vip-buy-link[hidden] {
  display: none;
}

.vip-redeem-form {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.logout-button {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px;
  color: #fff;
  background: #ff5c6c;
  font-weight: 800;
}

.learning-record-menu {
  display: flex;
  gap: 30px;
  overflow-x: auto;
  padding: 4px 0 8px;
  margin: 0 -14px;
  padding-left: 14px;
  white-space: nowrap;
  scrollbar-width: none;
}

.learning-record-menu::-webkit-scrollbar {
  display: none;
}

.learning-record-menu button {
  position: relative;
  flex: 0 0 auto;
  border: 0;
  padding: 0 0 10px;
  color: #1f2733;
  background: transparent;
  font-size: 18px;
}

.learning-record-menu button.active {
  color: #22b980;
  font-weight: 800;
}

.learning-record-menu button.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: #22b980;
  transform: translateX(-50%);
}

.learning-record-toolbar {
  display: flex;
  gap: 56px;
  align-items: center;
  padding: 8px 0 22px;
  font-size: 16px;
}

.learning-record-filter-trigger {
  justify-self: start;
  border: 0;
  border-radius: 0;
  padding: 0 12px 0 0;
  color: #1f2733;
  background: transparent;
  font-size: 17px;
  text-align: left;
  position: relative;
}

.learning-record-filter-trigger::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 0;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-65%) rotate(45deg);
}

.learning-record-filter-trigger.open,
.learning-record-filter-trigger.selected {
  color: #39bd83;
}

.learning-record-filter-trigger.open::after {
  transform: translateY(-35%) rotate(225deg);
}

.learning-record-filter-panel {
  position: absolute;
  top: var(--record-filter-panel-top, 168px);
  left: -14px;
  right: -14px;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 0;
  padding: 18px 26px 28px;
  border-radius: 0 0 14px 14px;
  background: #fff;
  box-shadow: 0 18px 32px rgba(27, 37, 51, 0.13);
}

.learning-record-filter-panel[hidden],
.learning-record-filter-scrim[hidden] {
  display: none;
}

.learning-record-filter-option {
  min-height: 48px;
  border: 0;
  border-radius: 4px;
  padding: 0 8px;
  color: #4d5562;
  background: #f6f7f9;
  font-size: 17px;
}

.learning-record-filter-option.active {
  color: #39bd83;
  background: #eefeef;
}

.learning-record-filter-scrim {
  position: fixed;
  top: var(--record-filter-scrim-top, 220px);
  left: 50%;
  bottom: 0;
  z-index: 10;
  width: min(100vw, 430px);
  background: rgba(0, 0, 0, 0.66);
  transform: translateX(-50%);
}

.learning-record-list {
  display: grid;
  gap: 14px;
}

.learning-record-card {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px 14px;
  align-items: center;
  padding: 20px 18px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(27, 37, 51, 0.05);
}

.learning-record-card.manage-mode {
  cursor: pointer;
}

.learning-record-card.selected {
  box-shadow: inset 0 0 0 2px #20b782, 0 10px 26px rgba(27, 37, 51, 0.05);
}

.learning-record-icon {
  position: relative;
  width: 58px;
  height: 70px;
  display: grid;
  align-items: end;
  justify-items: center;
  padding-bottom: 7px;
  border-radius: 8px 12px 8px 8px;
  background: linear-gradient(180deg, #eaf5ff 0, #ffffff 64%, #fff3d9 100%);
  color: #d48a1d;
  font-size: 12px;
  font-weight: 800;
}

.learning-record-icon::before {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  border-top: 18px solid #78a9ff;
  border-left: 18px solid transparent;
}

.learning-record-icon::after {
  content: "";
  position: absolute;
  left: 12px;
  top: 22px;
  width: 24px;
  height: 4px;
  border-radius: 999px;
  background: #78a9ff;
  box-shadow: 0 12px 0 #78a9ff;
}

.learning-record-icon.reviewed {
  background: linear-gradient(180deg, #eaf5ff 0, #ffffff 64%, #ddffe9 100%);
  color: #1aa96e;
}

.learning-record-select-toggle {
  top: 12px;
  right: 12px;
}

.learning-record-main h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.learning-record-main p {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.learning-record-date {
  min-width: 0;
}

.learning-record-count {
  justify-self: end;
  white-space: nowrap;
}

.learning-record-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
}

.learning-record-actions a,
.learning-record-actions span {
  min-width: 86px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  color: var(--ink);
  background: #fff;
  text-align: center;
  text-decoration: none;
  line-height: 1;
}

.learning-record-actions .learning-record-accuracy {
  min-width: 0;
  justify-self: start;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  font-size: 16px;
  white-space: nowrap;
}

.learning-record-share {
  grid-column: 3;
}

.learning-record-actions .learning-record-accuracy.low {
  color: #ff3b30;
}

.learning-record-actions .learning-record-accuracy.high {
  color: #20b782;
}

.learning-record-actions .learning-record-review {
  border-color: #22b980;
  color: #22b980;
}

.learning-record-actions .disabled {
  color: var(--muted);
}

.learning-record-footer {
  grid-template-columns: 88px 1fr 88px;
}

.app-shell:has(#page-learning-records.active) .learning-record-footer {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  width: min(430px, 100vw);
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  box-shadow: none;
  transform: translateX(-50%);
}

#page-learning-records:has(.learning-record-footer) {
  padding-bottom: 78px;
}

.learning-record-footer .learning-record-delete-selected {
  background: #ff4f64;
  box-shadow: 0 10px 20px rgba(255, 79, 100, 0.2);
}

.subpage-header {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: 12px 0 18px;
}

.subpage-header h1 {
  text-align: center;
}

.subpage-header button {
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 38px;
  line-height: 1;
}

.app-shell:has(#page-compose-preview.active) .bottom-nav,
.app-shell:has(#page-profile-edit.active) .bottom-nav,
.app-shell:has(#page-contact-service.active) .bottom-nav,
.app-shell:has(#page-settings.active) .bottom-nav,
.app-shell:has(#page-baby-grade.active) .bottom-nav,
.app-shell:has(#page-ai-paper.active) .bottom-nav,
.app-shell:has(#page-auth.active) .bottom-nav,
.app-shell:has(#page-subject-wrong.active) .bottom-nav,
.app-shell:has(#page-learning-records.active .learning-record-footer) .bottom-nav {
  display: none;
}

.app-shell:has(#page-auth.active) {
  padding-bottom: 28px;
}

.app-shell:has(#page-ai-paper.active) {
  padding-bottom: 102px;
}

.app-shell:has(#page-compose-preview.active) {
  padding-bottom: 168px;
}

.app-shell:has(#page-baby-grade.active) {
  padding-bottom: 108px;
}

.app-shell:has(#page-learning-records.active) {
  padding-bottom: 88px;
}

.app-shell:has(#page-baby-grade.active) .baby-form-actions {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 20;
  width: min(362px, calc(100vw - 60px));
  transform: translateX(-50%);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(430px, 100vw);
  height: 70px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -10px 28px rgba(27, 37, 51, 0.08);
}

.bottom-nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
}

.bottom-nav button.active {
  color: #0cb98f;
  font-weight: 700;
}

dialog {
  width: min(92vw, 420px);
  border: 0;
  padding: 0;
  border-radius: 18px;
}

dialog::backdrop {
  background: rgba(9, 17, 28, 0.45);
}

.ai-sheet-dialog {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 20px;
  background: rgba(0, 0, 0, 0.66);
}

.ai-sheet-dialog[hidden] {
  display: none;
}

.ai-sheet-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  width: min(100%, 390px);
  max-height: 75dvh;
  margin: 0;
  padding: 22px 20px 24px;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: #fff;
  overflow-x: hidden;
  overflow-y: hidden;
}

/* 旧版原生 dialog 样式保留无效选择器，防止历史缓存 HTML 下视觉突变。 */
.ai-sheet-dialog.legacy-dialog {
  top: auto;
  right: auto;
  bottom: 0;
  left: 50%;
  width: min(calc(100vw - 40px), 390px);
  height: auto;
  max-height: 75dvh;
  margin: 0;
  border-radius: 18px 18px 0 0;
  transform: translateX(-50%);
  overflow-x: hidden;
  overflow-y: hidden;
}

.ai-sheet-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.ai-sheet-header > div {
  min-width: 0;
  display: flex;
  gap: 7px;
  align-items: baseline;
  white-space: nowrap;
}

.ai-sheet-header strong {
  flex: 0 0 auto;
  font-size: 19px;
  font-weight: 900;
}

.ai-sheet-header span {
  min-width: 0;
  overflow: hidden;
  color: #8d96a3;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-sheet-header button {
  border: 0;
  color: #4a5361;
  background: transparent;
  font-size: 32px;
  font-weight: 700;
  line-height: 0.8;
}

.ai-answer-body {
  display: grid;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  border-radius: 8px;
  background: #f6f8fb;
  overflow: visible;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.62;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ai-sheet-dialog::-webkit-scrollbar {
  width: 0;
}

.ai-answer-body h3 {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 900;
}

.ai-answer-body section {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.ai-answer-body p {
  margin: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.dialog-card {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.confirm-card {
  gap: 16px;
}

.message-card {
  gap: 16px;
}

.message-card h2 {
  margin: 0;
  text-align: center;
  font-size: 18px;
}

.message-card p {
  margin: 0;
  text-align: center;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-card .primary-button {
  justify-self: center;
  width: auto;
  min-width: 150px;
  padding-inline: 28px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.upload-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.image-picker-control {
  position: relative;
  width: 100%;
  border: 1px dashed #d8dde5;
  border-radius: 4px;
  height: 150px;
  padding: 18px;
  color: #8b929c;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  overflow: hidden;
}

.image-picker-control img {
  position: absolute;
  inset: 18px;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  border-radius: 10px;
  object-fit: contain;
  object-position: center;
}

.image-picker-plus {
  width: 86px;
  height: 62px;
  display: grid;
  place-items: center;
  color: #c7cbd1;
}

.image-picker-plus svg {
  width: 86px;
  height: 62px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#upload-picker-text {
  color: #8b929c;
  font-size: 14px;
}

.native-file-input {
  display: none;
}

.upload-result {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.upload-result.pending {
  color: #0f5c75;
  background: #e8f8ff;
}

.upload-result.success {
  color: #0f684f;
  background: #e9fbf5;
}

.upload-result.error {
  color: #9f2547;
  background: #fff0f5;
}

.upload-result a {
  color: inherit;
  font-weight: 700;
}

.paper-result-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.paper-result-stage img {
  display: block;
  width: 100%;
}

#paper-question-layer {
  position: absolute;
  inset: 0;
}

.question-box {
  position: absolute;
  border: 2px solid #12c99a;
  border-radius: 6px;
  color: #0b6c54;
  background: rgba(18, 201, 154, 0.12);
  font-weight: 800;
}

.primary-link {
  display: block;
  text-align: center;
  border-radius: 12px;
  padding: 12px 14px;
  color: #fff;
  background: #13263a;
  text-decoration: none;
  font-weight: 700;
}

.wide-dialog {
  width: min(94vw, 430px);
}

#paper-result-dialog {
  width: min(94vw, 430px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

#paper-result-dialog .wide-dialog {
  width: 100%;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#paper-result-dialog .paper-result-stage {
  max-height: calc(100dvh - 238px);
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#paper-result-dialog .paper-result-stage img {
  width: 100%;
  min-width: 0;
}

.crop-stage {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  touch-action: none;
}

.crop-stage img {
  display: block;
  width: 100%;
}

#crop-layer {
  position: absolute;
  inset: 0;
}

.crop-box {
  position: absolute;
  border: 2px solid #14c79c;
  border-radius: 4px;
  background: rgba(20, 199, 156, 0.12);
  cursor: move;
  min-width: 44px;
  min-height: 44px;
  touch-action: none;
}

.crop-box.saved {
  border-color: #5cce7b;
  background: rgba(92, 206, 123, 0.18);
}

.crop-save {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: #13263a;
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  transform: translate(-50%, -50%);
  box-shadow: 0 10px 20px rgba(19, 38, 58, 0.24);
  cursor: pointer;
}

.crop-save:disabled {
  width: auto;
  min-width: 58px;
  padding: 0 10px;
  font-size: 13px;
  background: #25a26f;
}

.crop-label {
  position: absolute;
  left: 6px;
  top: 5px;
  padding: 2px 6px;
  border-radius: 999px;
  color: #0b6c54;
  background: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
}

.crop-resize {
  position: absolute;
  right: -8px;
  bottom: -8px;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #14c79c;
  box-shadow: 0 4px 10px rgba(20, 199, 156, 0.35);
  cursor: nwse-resize;
}

#ai-result {
  margin-left: -10px;
  white-space: normal;
  max-height: none;
  overflow: visible;
  color: var(--ink);
  background: #f7f9fc;
  border-radius: 10px;
  padding: 12px;
}

.ai-sheet-dialog.can-scroll #ai-result {
  overflow-y: auto;
}

.admin-shell {
  max-width: 620px;
  margin: 0 auto;
  padding: 24px 14px;
}

.admin-card {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.admin-card h2 {
  margin: 0;
  font-size: 18px;
}

.admin-card[hidden],
#admin-content[hidden],
#admin-login-form[hidden] {
  display: none;
}

.compact-form {
  padding: 0;
  border: 0;
  background: transparent;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-table {
  display: grid;
  gap: 8px;
}

.admin-row {
  display: grid;
  gap: 5px;
  padding: 10px;
  border-radius: 10px;
  background: #f7f9fc;
}

.admin-row strong {
  font-size: 14px;
}

.admin-row span,
.admin-row small {
  color: var(--muted);
  font-size: 12px;
}

.ghost-link {
  display: inline-flex;
  justify-content: center;
  color: var(--ink);
  text-decoration: none;
  padding: 10px;
}

.review-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  padding: 8px 14px 0;
  overflow: hidden;
  color: var(--ink);
  background: #f7f8fc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.review-header {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding: 4px 0 12px;
}

.review-header button {
  border: 0;
  color: var(--ink);
  background: transparent;
  font-size: 34px;
  line-height: 1;
}

.review-header h1 {
  text-align: center;
  font-size: 21px;
}

.review-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 12px;
}

.review-summary h2 {
  min-width: 0;
  margin: 0;
  font-size: 20px;
}

.review-summary p {
  flex: 0 0 auto;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  text-align: right;
}

.review-question-tabs {
  display: flex;
  gap: 14px;
  align-items: center;
  overflow-x: auto;
  margin: 0 -14px 8px;
  padding: 10px 14px;
  background: #fff;
}

.review-question-total {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 16px;
  white-space: nowrap;
}

.review-question-tabs button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: #f4f5f7;
  font-size: 16px;
}

.review-question-tabs button.correct:not(.active) {
  color: #20b782;
  background: #eafff4;
}

.review-question-tabs button.wrong:not(.active) {
  color: #ff4f64;
  background: #fff0f1;
}

.review-question-tabs button.active {
  color: #20b782;
  background: #f1fff8;
  box-shadow: inset 0 0 0 2px #20b782;
}

.review-card {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

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

.review-question header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.review-question header h2 {
  margin: 0;
  font-size: 16px;
}

.review-question header span {
  color: var(--muted);
}

.review-question header span.correct {
  color: #20b782;
}

.review-question header span.wrong {
  color: #ff4f64;
}

.review-question-image {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.review-question-text {
  display: grid;
  gap: 8px;
  line-height: 1.7;
}

.review-question-text p,
.review-answer p {
  margin: 0;
}

.review-answer {
  display: grid;
  gap: 10px;
}

.review-answer h3 {
  margin: 0;
  font-size: 16px;
}

.review-answer p {
  color: var(--muted);
  line-height: 1.65;
}

.review-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.review-actions button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
}

.review-actions .correct {
  color: #0c9f68;
  background: #f2fbf8;
}

.review-actions .wrong {
  color: #ff4f64;
  background: #fff5f6;
}

.review-footer {
  flex: 0 0 auto;
  z-index: 20;
  width: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 0 -14px;
  padding: 14px 22px calc(14px + env(safe-area-inset-bottom));
  background: #fff;
  box-shadow: 0 -10px 28px rgba(27, 37, 51, 0.08);
}

.review-footer button {
  min-height: 46px;
  border: 0;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
}

.review-footer button:first-child {
  color: #20b782;
  background: #f4f5f7;
}

.review-footer button:last-child {
  color: #fff;
  background: #20b782;
}

.review-footer button:disabled {
  opacity: 0.62;
}

.review-complete-dialog {
  width: min(360px, calc(100vw - 48px));
  border: 0;
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  background: #fff;
}

.review-complete-card {
  gap: 16px;
}

.review-complete-card h2 {
  margin: 0;
  font-size: 20px;
  text-align: center;
}

.review-complete-stats {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f7f8fc;
}

.review-complete-stats p {
  display: flex;
  justify-content: space-between;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
}

.review-complete-stats b {
  color: var(--ink);
}

.review-complete-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.review-complete-actions button {
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
}

.review-complete-actions .secondary {
  color: #20b782;
  background: #f4f5f7;
}

.review-complete-actions .primary {
  color: #fff;
  background: #20b782;
}
