:root {
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1f2329;
  --muted: #646a73;
  --line: #e5e2dc;
  --red: #d93025;
  --red-soft: #fdecea;
  --red-dark: #b3261e;
  --green: #188038;
  --green-soft: #e6f4ea;
  --amber: #b06000;
  --amber-soft: #fef7e0;
  --radius: 14px;
  --shadow: 0 2px 12px rgba(24, 24, 27, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 16px 14px 48px;
}

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

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #e53935, #c62828);
  color: #fff;
  font-family: "KaiTi", "STKaiti", "SimKai", serif;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(217, 48, 37, 0.28);
}

.brand h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 12px;
  color: var(--muted);
}

.status-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: #eceae4;
  color: var(--muted);
  white-space: nowrap;
}

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

.status-pill.pending {
  background: var(--amber-soft);
  color: var(--amber);
}

.banner {
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
  line-height: 1.55;
}

.banner-warn {
  background: var(--amber-soft);
  color: #7c4a03;
  border: 1px solid #f7dfa0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.field select,
.field input,
.auth-card input {
  width: 100%;
  height: 42px;
  border: 1px solid #d5d2cb;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
}

.field select:focus,
.field input:focus,
.auth-card input:focus {
  border-color: var(--red);
}

.upload-zone {
  border: 2px dashed #d6d0c4;
  border-radius: 12px;
  background: #faf9f6;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--red);
  background: #fff8f7;
}

.upload-icon {
  font-size: 32px;
  margin-bottom: 6px;
}

.upload-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-hint {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}

.thumb-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.thumb-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f0eee9;
  aspect-ratio: 3 / 4;
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}

.thumb-del {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: rgba(217, 48, 37, 0.9);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.action-bar {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s, transform 0.08s;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  flex: 1;
  min-width: 160px;
}

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

.btn-secondary {
  background: var(--red-soft);
  color: var(--red-dark);
  border-color: #f6cbc7;
}

.btn-outline {
  background: #fff;
  color: var(--ink);
  border-color: #d5d2cb;
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 13.5px;
  flex: 0 0 auto;
  min-width: auto;
}

.full-width {
  width: 100%;
}

.progress-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: #fafafa;
  border: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid #e0e0e0;
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 13.5px;
  border: 1px solid #f5c2c0;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.result-toolbar h2 {
  font-size: 18px;
}

.result-tip {
  font-size: 13px;
  color: var(--muted);
}

.toolbar-btns {
  display: flex;
  gap: 8px;
}

.report-pages {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.report-page-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.report-page-card img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  border: 1px solid #efefef;
}

.report-page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.overall-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ai-tag {
  font-size: 11px;
  color: var(--muted);
  background: #f3f2ee;
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 4px;
}

.teacher-summary {
  font-family: "KaiTi", "STKaiti", "SimKai", serif;
  font-size: 17px;
  line-height: 1.7;
  color: #a61c1c;
  background: #fff9f8;
  border-left: 3.5px solid var(--red);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
}

.overall-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.overall-col {
  background: #faf9f6;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
}

.overall-col h4 {
  font-size: 14.5px;
  margin-bottom: 8px;
}

.overall-col ul {
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.65;
  color: #333;
}

.overall-col li {
  margin-bottom: 4px;
}

.app-footer {
  text-align: center;
  font-size: 12.5px;
  color: #8f959e;
  margin-top: 24px;
}

/* Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(246, 244, 239, 0.96);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 999;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
  padding: 28px 24px;
  text-align: center;
}

.auth-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.auth-card h2 {
  font-size: 20px;
  margin-bottom: 6px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 16px;
}

.auth-card input {
  margin-bottom: 12px;
}

.error-tip {
  color: var(--red-dark);
  font-size: 13px;
  margin-bottom: 10px;
}

@media (max-width: 640px) {
  .field-row,
  .overall-grid {
    grid-template-columns: 1fr;
  }
  .action-bar {
    flex-direction: column;
  }
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }
}
