:root {
  --color-bg-1: #0f1c3f;
  --color-bg-2: #1c3a6e;
  --color-surface: #ffffff;
  --color-text: #16213a;
  --color-muted: #6b7690;
  --color-accent: #2f5fe0;
  --color-accent-soft: #eef2ff;
  --color-danger: #d64545;
  --color-danger-soft: #fdeeee;
  --color-scaled: #c2650a;
  --radius-lg: 20px;
  --radius-md: 14px;
  --space-section: clamp(2rem, 1.5rem + 2vw, 3.5rem);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--color-text);
  background: radial-gradient(circle at 20% -10%, var(--color-bg-2), var(--color-bg-1) 60%);
  background-attachment: fixed;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: var(--space-section) 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero {
  color: #fff;
  text-align: center;
  padding: 0 8px 0;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.35;
  font-weight: 700;
}

.hero-tip {
  margin: 48px 0 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.68);
}

.query-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 20px 50px rgba(10, 20, 50, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

#q {
  font-size: 17px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid #dfe4f0;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#q:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 4px var(--color-accent-soft);
}

#submit-btn {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--color-accent), #4a3fd6);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

#submit-btn:active {
  transform: scale(0.98);
}

#submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.state-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 24px 22px;
  box-shadow: 0 20px 50px rgba(10, 20, 50, 0.3);
}

.state-card.error {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  font-size: 15px;
  text-align: center;
}

.state-card.loading {
  color: var(--color-muted);
  text-align: center;
  font-size: 15px;
}

.result-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
}

.result-name {
  font-size: 20px;
  font-weight: 700;
}

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

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.totals .item {
  background: var(--color-accent-soft);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
}

.totals .item .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--color-accent);
  line-height: 1.2;
}

.totals .item .label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-muted);
}

.subjects-box {
  border: 1.5px solid #e3e7f2;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.subjects-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f0f2f8;
  font-size: 15px;
  font-weight: 700;
  color: var(--color-muted);
  letter-spacing: 0.03em;
}

.subjects {
  display: flex;
  flex-direction: column;
}

.subject-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid #eef1f8;
}

.subject-row .name {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
}

.subject-row .raw {
  font-size: 19px;
  font-weight: 700;
}

.subject-row .score-lines {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.subject-row .score-line {
  font-size: 17px;
  font-weight: 700;
  color: var(--color-text);
}

.subject-row .score-line.scaled-line {
  color: var(--color-scaled);
}

.subject-row .score-line .tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  margin-right: 5px;
}

.subject-row .score-line.scaled-line .tag {
  color: var(--color-scaled);
  opacity: 0.75;
}

.empty-note {
  text-align: center;
  color: var(--color-muted);
  font-size: 14px;
  line-height: 1.7;
  padding: 8px 4px 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-surface: #16213a;
    --color-text: #eef1fb;
    --color-muted: #93a0c2;
    --color-accent-soft: #1f2c52;
    --color-danger-soft: #3a1f24;
    --color-scaled: #f0a63d;
  }
  #q { border-color: #2c3a63; background: #101a33; color: var(--color-text); }
  .subjects-box { border-color: #2c3a63; }
  .subjects-head { background: #101a33; }
  .subject-row { border-top-color: #223058; }
}
