:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #0f766e;
  --danger: #b91c1c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 800;
  color: var(--primary);
}

.nav a {
  font-size: 14px;
  color: var(--muted);
}

.page {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.upload-panel,
.section,
.detail-head,
.content-block,
.empty,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.upload-panel {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

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

.upload-box {
  display: grid;
  place-items: center;
  min-height: 130px;
  padding: 18px;
  border: 2px dashed #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 8px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  background: var(--primary);
  color: #fff;
}

.primary-button:disabled {
  background: #93c5fd;
  cursor: wait;
}

.ghost-button {
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}

.section {
  margin-top: 16px;
  padding: 18px;
}

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

.section-head span,
.time,
.question-meta {
  color: var(--muted);
  font-size: 13px;
}

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

.subject-card,
.question-item {
  display: grid;
  gap: 6px;
  padding: 14px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.subject-name {
  font-size: 18px;
  font-weight: 800;
}

.subject-count {
  color: var(--muted);
  font-size: 14px;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

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

.question-title {
  display: -webkit-box;
  overflow: hidden;
  font-weight: 700;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.detail-head {
  padding: 18px;
}

.question-image {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  margin: 14px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.content-block {
  margin-top: 12px;
  padding: 18px;
}

.content-block p {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.answer {
  border-left: 4px solid var(--accent);
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 18px;
}

.login-card {
  width: min(380px, 100%);
  padding: 24px;
}

.login-card p {
  color: var(--muted);
}

.login-card input {
  width: 100%;
  height: 46px;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 16px;
}

.form-error,
.error-box strong {
  color: var(--danger);
}

.link-button {
  width: auto;
  margin-top: 10px;
}

@media (min-width: 720px) {
  h1 {
    font-size: 34px;
  }

  .upload-panel {
    grid-template-columns: 1fr 320px;
    align-items: center;
  }

  .subject-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
