:root {
  --zju: #003F88;
  --zju-ink: #002255;
  --zju-lite: #E8EEF7;
  --zju-line: #D5DCE8;
  --accent: #1565C0;
  --ink: #0B1B33;
  --ink-2: #4A5A73;
  --ink-3: #8C98A8;
  --bg: #FAFBFD;
  --surface: #FFFFFF;
  --line: #ECEEF2;
  --line-2: #F3F5F8;
  --success: #2E7D32;
  --success-bg: #E8F5E9;
  --warning: #E65100;
  --warning-bg: #FFF3E0;
  --error: #C62828;
  --error-bg: #FFEBEE;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(11,27,51,0.04), 0 0 0 1px var(--line);
  --shadow-lg: 0 4px 24px rgba(11,27,51,0.08), 0 0 0 1px var(--line);
  --font: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body.page-app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

body.page-wide {
  max-width: 560px;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); }
button { cursor: pointer; }

.hero {
  margin: 0 -20px 24px;
  padding: 32px 24px 36px;
  background:
    radial-gradient(110% 90% at 20% 0%, rgba(255,255,255,0.06), transparent 60%),
    linear-gradient(155deg, var(--zju-ink) 0%, var(--zju) 48%, var(--accent) 100%);
  color: white;
  border-radius: 0 0 24px 24px;
}

.hero .top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  letter-spacing: 1px;
  margin-bottom: 18px;
}

.hero .right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero .online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.hero .online::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4FC3F7;
  box-shadow: 0 0 6px rgba(79,195,247,0.6);
}

.hero h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 4px;
  margin-bottom: 6px;
}

.hero .sub {
  font-size: 12px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 2px;
}

.session-tag {
  display: inline-flex;
  align-items: center;
  margin-top: 18px;
  padding: 6px 14px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.88);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 20px;
}

.session-tag.editable {
  cursor: pointer;
}

.module-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: -12px 0 14px;
  padding: 4px;
  background: #EDF0F4;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.module-switch a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}

.module-switch a.active {
  color: var(--zju);
  background: white;
  box-shadow: 0 1px 2px rgba(11,27,51,0.08);
}

.card {
  display: block;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title-row h2 {
  margin-bottom: 0;
}

.hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.6;
  margin-top: 8px;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  font-size: 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  transition: border-color .15s, background .15s;
}

.field textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #F8FBFF;
}

.field .mono,
.mono {
  font-family: var(--mono);
  letter-spacing: 0.5px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  transition: background .15s, transform .08s, border-color .15s;
  gap: 6px;
  letter-spacing: 0.5px;
}

.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--zju); color: white; border-color: var(--zju); }
.btn.success { background: var(--success); color: white; border-color: var(--success); }
.btn.danger { background: var(--error); color: white; border-color: var(--error); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.full { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row {
  display: flex;
  gap: 10px;
}

.btn-row .btn { flex: 1; }

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

.entry-card {
  display: block;
  min-height: 92px;
  padding: 14px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  transition: border-color .15s, transform .08s;
}

.entry-card:active { transform: scale(0.98); }

.entry-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.entry-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
  line-height: 1.45;
}

.session-audio-meta {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-2);
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.5;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge.gray { background: #F0F2F5; color: var(--ink-2); }
.badge.blue { background: #E3F2FD; color: var(--accent); }
.badge.green { background: var(--success-bg); color: var(--success); }
.badge.orange { background: var(--warning-bg); color: var(--warning); }
.badge.red { background: var(--error-bg); color: var(--error); }

.tabs {
  display: flex;
  gap: 4px;
  background: #EDF0F4;
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: 8px;
  font-weight: 500;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.tab.active {
  background: white;
  color: var(--zju);
  box-shadow: 0 1px 2px rgba(11,27,51,0.08);
}

.subject-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.subject-row:last-child { border-bottom: none; }

.subject-row .num {
  min-width: 38px;
  font-family: var(--mono);
  color: var(--zju);
  font-size: 20px;
  font-weight: 700;
}

.subject-row .info {
  flex: 1;
  min-width: 0;
}

.subject-row .name {
  font-size: 15px;
  font-weight: 600;
}

.subject-row .meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
  line-height: 1.5;
}

.status-pair {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: wrap;
}

.progress-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: #F7F9FB;
  color: var(--ink-3);
}

.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.pill.done {
  background: var(--success-bg);
  color: var(--success);
  border-color: #A5D6A7;
}

.pill.doing {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: #FFCC80;
}

.question-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}

.question-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.question-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.45;
}

.question-instruction {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.7;
  padding: 10px 12px;
  background: var(--line-2);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  white-space: pre-line;
}

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

.option {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink-2);
  cursor: pointer;
}

.option input {
  width: 16px;
  height: 16px;
}

.option:has(input:checked) {
  border-color: var(--accent);
  background: #F8FBFF;
  color: var(--zju);
}

.other-field,
.matrix-other {
  display: none;
  margin-top: -2px;
}

.other-field.show,
.matrix-other.show {
  display: block;
}

.matrix-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  overflow-y: hidden;
}

.matrix-head,
.matrix-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.6fr) repeat(var(--matrix-cols, 3), minmax(52px, 1fr));
  align-items: stretch;
  min-width: calc(120px + var(--matrix-cols, 3) * 64px);
}

.matrix-head {
  background: #FAFBFD;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
}

.matrix-head > div,
.matrix-label,
.matrix-option {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

.matrix-label {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.4;
  white-space: pre-line;
}

.matrix-option {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink-2);
  border-left: 1px solid var(--line);
  cursor: pointer;
  font-size: 12px;
}

.matrix-option:has(input:checked) {
  background: #F8FBFF;
  color: var(--zju);
}

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

.scale-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.4;
}

.scale-row {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #FAFBFD;
}

.scale-label {
  margin-bottom: 10px;
}

.scale-title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.scale-desc {
  margin-top: 3px;
  color: var(--ink-3);
  font-size: 11px;
  line-height: 1.5;
}

.scale-options {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.scale-option {
  min-width: 0;
}

.scale-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.scale-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.scale-option:has(input:checked) span {
  border-color: var(--zju);
  background: var(--zju);
  color: white;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.score-choice {
  min-height: 42px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}

.score-choice.active {
  background: var(--zju);
  border-color: var(--zju);
  color: white;
}

.media-box {
  border: 1.5px dashed var(--zju-line);
  border-radius: var(--radius-sm);
  background: #F8FAFD;
  color: var(--ink-2);
  padding: 18px;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.6;
}

.upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
}

.upload-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.record-box {
  display: grid;
  gap: 10px;
}

.record-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.record-actions .btn {
  min-height: 38px;
  padding: 8px 14px;
}

.record-duration {
  min-width: 46px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.record-box audio {
  width: 100%;
  min-height: 40px;
}

.audio-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #EDF0F4;
  box-shadow: inset 0 0 0 1px var(--line);
}

.audio-meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width .08s linear;
}

.score-option-list {
  margin-top: 2px;
}

.record-note-field {
  margin-bottom: 0;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 16px -20px -72px;
  padding: 12px 20px 18px;
  background: rgba(250,251,253,0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: white;
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 1.5px;
}

.stat-card .value {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
}

.stat-card.accent .value { color: var(--zju); }
.stat-card.green .value { color: var(--success); }
.stat-card.orange .value { color: var(--warning); }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  font-size: 12px;
}

.question-card-missing {
  box-shadow: 0 0 0 2px var(--warning), var(--shadow-lg);
}

.result-table {
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 10px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  color: var(--ink-3);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 1px;
  background: #FAFBFD;
}

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 1px;
}

.empty.compact {
  padding: 14px 8px;
  letter-spacing: 0.5px;
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  max-width: calc(100vw - 32px);
  background: rgba(11,27,51,0.92);
  color: white;
  padding: 11px 20px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  letter-spacing: 0.5px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { background: var(--error); }
.toast.success { background: var(--success); }

.sync-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 18, 38, 0.52);
}

.sync-dialog {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 18px;
  background: white;
  box-shadow: 0 18px 60px rgba(5, 18, 38, 0.28);
  border-top: 6px solid var(--zju);
  text-align: center;
}

.sync-dialog.success { border-top-color: var(--success); }
.sync-dialog.error { border-top-color: var(--error); }

.sync-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin-bottom: 12px;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 800;
  background: var(--zju-lite);
  color: var(--zju);
}

.sync-dialog.success .sync-icon {
  background: var(--success-bg);
  color: var(--success);
}

.sync-dialog.error .sync-icon {
  background: var(--error-bg);
  color: var(--error);
}

.sync-dialog h2 {
  margin: 0 0 10px;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.sync-dialog p {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.7;
  text-align: left;
}

.sync-detail {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #F7F8FA;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  word-break: break-word;
}

.sync-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 18px;
}

.sync-actions.with-retry {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 860px) {
  body.page-wide {
    max-width: 560px;
  }
}

@media (max-width: 480px) {
  body.page-app {
    padding: 0 12px 72px;
  }
  .hero {
    margin-left: -12px;
    margin-right: -12px;
    padding: 26px 18px 32px;
  }
  .hero h1 {
    font-size: 22px;
    letter-spacing: 3px;
  }
  .card,
  .question-card {
    padding: 14px;
  }
  .btn {
    min-height: 40px;
    padding: 8px 14px;
    font-size: 14px;
  }
  .btn.sm {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 11px;
  }
  .entry-strip {
    grid-template-columns: 1fr;
  }
  .entry-card {
    min-height: 76px;
  }
  .subject-row {
    align-items: flex-start;
  }
  .status-pair {
    max-width: 76px;
  }
  .field input,
  .field select,
  .field textarea {
    padding: 10px 12px;
    font-size: 15px;
  }
  .score-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .matrix-head,
  .matrix-row {
    grid-template-columns: minmax(108px, 1.4fr) repeat(var(--matrix-cols, 3), minmax(42px, 1fr));
  }
  .matrix-head > div,
  .matrix-label,
  .matrix-option {
    padding: 9px 6px;
  }
  .matrix-option {
    font-size: 11px;
    justify-content: center;
  }
  .stat-card .value {
    font-size: 24px;
  }
  .sticky-actions {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }
}
