:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-2: #eef4f3;
  --ink: #18212f;
  --muted: #667085;
  --line: #dce5e8;
  --primary: #1f5f8b;
  --primary-dark: #163a5f;
  --accent: #159a86;
  --warm: #f5c56b;
  --warning: #a96516;
  --danger: #b84326;
  --success: #147a4f;
  --shadow: 0 14px 34px rgba(20, 34, 50, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(21, 154, 134, .08), transparent 30vw),
    linear-gradient(180deg, #f6f9fa 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    radial-gradient(circle at 22% 18%, rgba(245, 197, 107, .34), transparent 28%),
    linear-gradient(140deg, #edf5f4, #f8faf8 58%, #fff5e5);
}

.login-card {
  width: min(460px, calc(100vw - 40px));
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-line {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-line > div {
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

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

.brand-line h1,
.brand-line h2 {
  font-size: 22px;
}

.brand-line p,
.hint,
.muted,
.panel-head span,
.side-note span {
  color: var(--muted);
}

.hint-line {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.login-tabs button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.login-tabs button.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(17, 24, 39, .08);
}

.login-fields {
  display: grid;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.check-label {
  grid-auto-flow: column;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-content: start;
  min-height: 40px;
}

.check-label input {
  width: 18px;
  min-height: 18px;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.mini-btn {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.ghost-btn,
.mini-btn {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-btn,
.mini-btn.danger {
  border-color: #fed7aa;
  background: #fff7ed;
  color: var(--danger);
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #fff;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  height: 42px;
  padding: 0 13px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}

.nav button.active,
.nav button:hover {
  background: #eaf1ff;
  color: var(--primary-dark);
}

.side-note {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  line-height: 1.55;
}

.main {
  min-width: 0;
  padding: 24px 28px;
}

.topbar,
.filters-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 18px;
}

.topbar h2 {
  margin-top: 5px;
  font-size: 28px;
}

.top-actions,
.filters,
.form-actions,
.report-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  margin-bottom: 14px;
}

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

.metric {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric span {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: var(--primary-dark);
  font-size: 32px;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.split {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: #f8fafc;
  color: #475569;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eaf1ff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.warn {
  background: #fff7ed;
  color: var(--warning);
}

.tag.danger {
  background: #fff1f2;
  color: #be123c;
}

.tag.done {
  background: #ecfdf5;
  color: var(--success);
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.bar-list,
.mistake-cards {
  display: grid;
  gap: 10px;
}

.bar-item,
.mistake-card {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.bar-item strong,
.mistake-card strong {
  color: var(--ink);
}

.bar-item span,
.mistake-card span,
.mistake-card p {
  color: var(--muted);
  line-height: 1.55;
}

.parent-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-box {
  padding: 13px;
  border-radius: 8px;
  background: #f8fafc;
}

.summary-box strong {
  display: block;
  font-size: 24px;
  color: var(--accent);
}

.summary-box small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.mobile-tabbar {
  display: none;
}

.wrong-card-top {
  display: grid;
  gap: 8px;
}

.wrong-tags {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.soft-pill,
.subject-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.soft-pill {
  background: #f3e8ff;
  color: #7e22ce;
}

.subject-pill {
  background: #eef2ff;
  color: #27364f;
}

.question-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.question-chip-row span {
  min-width: 38px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff4cf;
  color: #a46c13;
  font-weight: 800;
}

.question-no-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -4px;
}

.question-no-btn {
  min-width: 48px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #f4dfab;
  border-radius: 999px;
  background: #fff6d9;
  color: #9a6411;
  font-weight: 900;
}

.question-no-btn.active,
.question-no-btn:hover {
  border-color: #f4b740;
  background: #ffe7a3;
  color: #704300;
}

.wrong-card-bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: #d96843;
}

.wrong-card-bottom time {
  color: #b8bdc6;
}

.wrong-card-detail {
  display: grid;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.report-controls label {
  min-width: 210px;
  flex: 1 1 210px;
}

.report-text {
  min-height: 300px;
}

.share-screen {
  min-height: 100vh;
  padding: 18px;
  background: #eef3f0;
}

.share-phone-shell,
.share-preview {
  width: min(430px, 100%);
  margin: 0 auto;
}

.share-preview {
  padding: 12px;
  border-radius: 8px;
  background: #eef3f0;
}

.share-result {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.share-result textarea {
  min-height: 132px;
  line-height: 1.55;
}

.share-history {
  display: grid;
  gap: 10px;
}

.share-history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.share-history-item > div:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.share-history-item strong {
  color: var(--ink);
  line-height: 1.35;
}

.share-history-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.public-share-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 0 12px;
  background: #eef3f0;
}

.share-card {
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(24, 37, 52, .1);
}

.share-card.public-mode {
  min-height: calc(100vh - 36px);
}

.share-hero {
  display: grid;
  gap: 10px;
  padding: 24px 22px 28px;
  background: linear-gradient(135deg, #163a5f, #159a86);
  color: #fff;
}

.share-hero span {
  width: max-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  font-size: 12px;
  font-weight: 900;
}

.share-hero h1 {
  font-size: 27px;
  line-height: 1.22;
}

.share-hero p {
  color: rgba(255, 255, 255, .88);
  line-height: 1.55;
}

.share-student {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #eef2f7;
}

.share-student div:first-child {
  display: grid;
  gap: 5px;
}

.share-student strong {
  font-size: 20px;
}

.share-student span {
  color: var(--muted);
  font-size: 13px;
}

.score-chip {
  min-width: 86px;
  padding: 8px 10px;
  border-radius: 999px;
  background: #fff3cf;
  color: #7a4d0c;
  text-align: center;
  font-weight: 900;
}

.share-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 20px;
}

.share-stats div {
  min-width: 0;
  min-height: 76px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #f8fafc;
}

.share-stats strong {
  color: var(--primary-dark);
  font-size: 25px;
}

.share-stats span {
  color: var(--muted);
  font-size: 12px;
}

.share-block {
  display: grid;
  gap: 10px;
  padding: 16px 20px;
}

.share-block h2 {
  font-size: 17px;
}

.share-block p,
.share-mistake {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: #fbfdff;
}

.share-block p b,
.share-mistake strong {
  color: var(--ink);
  line-height: 1.35;
}

.share-block p span,
.share-mistake span,
.share-mistake p,
.share-mistake small {
  color: var(--muted);
  line-height: 1.45;
}

.share-mistake small {
  padding-top: 6px;
  border-top: 1px dashed #dbe3ef;
}

.share-cta {
  display: grid;
  gap: 6px;
  margin: 4px 20px 0;
  padding: 14px;
  border-radius: 8px;
  background: #eaf8f5;
  color: #0f766e;
}

.share-cta strong {
  color: #0f4f49;
}

.share-cta span {
  line-height: 1.5;
}

.share-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 22px;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app,
  .split,
  .metric-grid,
  .form-grid,
  .parent-summary {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .filters-head,
  .panel-head {
    display: grid;
  }
}

@media (max-width: 680px) {
  body {
    background:
      linear-gradient(180deg, #eef5f3 0%, #f5f1eb 46%, #f4f7f7 100%);
  }

  .login-screen {
    padding: 20px;
    overflow: hidden;
  }

  .login-card {
    width: 350px;
    max-width: calc(100vw - 40px);
    padding: 24px;
  }

  .brand-line h1 {
    font-size: 21px;
  }

  .brand-line p,
  .hint {
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .app {
    display: block;
    padding-bottom: 78px;
  }

  .sidebar {
    display: none;
  }

  .main {
    width: 100%;
    max-width: 430px;
    min-width: 0;
    margin: 0 auto;
    padding: 12px 12px 92px;
    overflow-x: hidden;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    min-height: 54px;
    align-items: center;
    justify-content: center;
    margin: 0 -12px 12px;
    padding: 10px 14px 8px;
    background: rgba(238, 245, 243, .94);
    backdrop-filter: blur(12px);
  }

  .topbar .muted,
  .top-actions {
    display: none;
  }

  .topbar h2 {
    margin: 0;
    color: #152238;
    font-size: 20px;
    text-align: center;
  }

  .panel {
    width: 100%;
    min-width: 0;
    padding: 14px;
    border: 1px solid rgba(216, 226, 229, .8);
    border-radius: 16px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 10px 26px rgba(36, 45, 65, .06);
  }

  .view.active {
    gap: 12px;
  }

  .panel-head {
    gap: 6px;
    margin-bottom: 12px;
  }

  .panel-head h3,
  .filters-head h3 {
    font-size: 17px;
  }

  .panel-head span,
  .filters-head .muted {
    font-size: 12px;
    line-height: 1.45;
  }

  .view.active,
  .table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .parent-card .panel-head {
    position: sticky;
    top: 54px;
    z-index: 3;
    display: grid;
    gap: 10px;
    margin: -14px -14px 12px;
    padding: 12px 14px;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid #eef2f0;
  }

  .parent-card .panel-head h3 {
    display: none;
  }

  .parent-card .panel-head span {
    display: none;
  }

  #parentViewStudent {
    border-radius: 999px;
    background: #fff;
    min-height: 42px;
  }

  .parent-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }

  .summary-box {
    min-height: 82px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 10px 8px;
    border: 1px solid #eef1ee;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 18px rgba(36, 45, 65, .05);
  }

  .summary-box strong {
    color: #173e60;
    font-size: 25px;
    line-height: 1;
  }

  .summary-box span {
    color: #7a8090;
    font-size: 13px;
  }

  .summary-box small {
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 11px;
  }

  .mistake-cards {
    gap: 12px;
  }

  .mobile-wrong-card {
    gap: 13px;
    padding: 16px 15px;
    border: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 28px rgba(35, 45, 62, .08);
  }

  .mobile-wrong-card strong {
    color: #152238;
    font-size: 17px;
    line-height: 1.35;
  }

  .wrong-tags {
    gap: 6px;
  }

  .soft-pill,
  .subject-pill {
    min-height: 26px;
    padding: 0 10px;
    font-size: 12px;
  }

  .soft-pill {
    background: #f1e8ff;
    color: #6f35aa;
  }

  .subject-pill {
    background: #eef4f5;
    color: #173e60;
  }

  .question-chip-row {
    gap: 8px;
  }

  .question-chip-row span {
    min-width: 34px;
    height: 32px;
    padding: 0 9px;
    background: #fff1c7;
    color: #8a5a10;
    font-size: 13px;
  }

  .wrong-card-bottom {
    display: grid;
    gap: 8px;
    align-items: start;
  }

  .wrong-card-bottom b {
    color: #d56540;
    font-size: 16px;
  }

  .wrong-card-detail p {
    color: #667085;
    font-size: 12px;
    line-height: 1.5;
  }

  .question-no-picker {
    gap: 9px;
  }

  .question-no-btn {
    min-width: 42px;
    min-height: 38px;
  }

  .mobile-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(var(--mobile-tab-count, 3), minmax(0, 1fr));
    height: 70px;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid rgba(222, 226, 222, .85);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
  }

  .mobile-tabbar button {
    display: grid;
    place-items: center;
    gap: 2px;
    min-width: 0;
    border: 0;
    background: transparent;
    color: #8a9099;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
  }

  .mobile-tabbar span {
    font-size: 19px;
    line-height: 1;
  }

  .mobile-tabbar button.active {
    color: #173e60;
  }

  .mobile-tabbar button.active span {
    transform: translateY(-2px);
  }

  .share-screen {
    padding: 0;
    background: #eef5f3;
  }

  .share-phone-shell,
  .share-preview {
    width: 100%;
  }

  .share-preview {
    padding: 0;
    border-radius: 0;
    background: transparent;
  }

  .public-share-actions {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e8e4;
  }

  .share-card,
  .share-card.public-mode {
    width: 100%;
    max-width: 100vw;
    min-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }

  .share-hero {
    padding: 28px 20px 30px;
  }

  .share-hero h1 {
    font-size: 24px;
  }

  .share-hero p {
    font-size: 14px;
  }

  .share-student {
    align-items: flex-start;
  }

  .share-student > div:first-child {
    min-width: 0;
  }

  .share-student strong,
  .share-student span,
  .share-mistake strong,
  .share-mistake span,
  .share-mistake p,
  .share-mistake small {
    overflow-wrap: anywhere;
  }

  .score-chip {
    min-width: 78px;
    flex: 0 0 auto;
    font-size: 13px;
  }

  .share-stats,
  .share-student,
  .share-block,
  .share-footer {
    padding-left: 16px;
    padding-right: 16px;
  }

  .share-cta {
    margin-left: 16px;
    margin-right: 16px;
  }

  .share-block {
    gap: 9px;
  }

  .share-mistake {
    border: 1px solid #eef2f7;
  }

  .share-history-item {
    display: grid;
  }

  .share-history-item .row-actions {
    justify-content: stretch;
  }

  .share-history-item .mini-btn {
    flex: 1 1 96px;
  }
}
