:root {
  color-scheme: light;
  --bg: #fffaf8;
  --bg-soft: #fff3f7;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #23151b;
  --muted: #7f6873;
  --subtle: #b9a4ae;
  --line: #f2dbe2;
  --accent: #ff5a6e;
  --accent-strong: #ee3e5f;
  --accent-soft: #ffe3e8;
  --peach: #ffb687;
  --mint: #2d9b8f;
  --mint-soft: #e9faf5;
  --shadow: 0 18px 48px rgba(223, 85, 119, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(255, 182, 135, 0.28), transparent 24%),
    linear-gradient(180deg, var(--bg) 0%, #ffffff 42%, var(--bg-soft) 100%);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family:
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

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

.quiz-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 18px 18px 96px;
}

.quiz-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.quiz-brand {
  color: inherit;
  text-decoration: none;
}

.quiz-brand-main {
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0;
}

.hero-panel,
.panel,
.history-panel {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(242, 219, 226, 0.9);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-panel {
  display: block;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.92) 0%, rgba(255, 243, 247, 0.92) 100%);
}

.hero-copy {
  display: grid;
  gap: 10px;
  max-width: 700px;
}

.hero-copy h1 {
  font-size: clamp(28px, 4.6vw, 42px);
  line-height: 1.08;
  font-weight: 900;
}

.hero-copy p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.field span,
.template-head h3,
.section-head h2 {
  font-weight: 900;
}

.submission-row span,
.submission-row small,
.result-row small,
.history-row small,
.empty-state,
.custom-empty {
  color: var(--muted);
  line-height: 1.55;
}

.notice {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  width: min(calc(100% - 32px), 420px);
  padding: 11px 14px;
  border: 1px solid rgba(219, 245, 238, 0.92);
  border-radius: 999px;
  background: rgba(233, 250, 245, 0.96);
  box-shadow: 0 14px 34px rgba(45, 155, 143, 0.18);
  color: #1f7e71;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.notice[data-tone="error"] {
  border-color: rgba(241, 195, 207, 0.96);
  background: rgba(255, 240, 245, 0.96);
  box-shadow: 0 14px 34px rgba(197, 54, 89, 0.16);
  color: #c53659;
}

.section-head,
.template-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.align-top {
  align-items: flex-start;
}

.section-head {
  margin-bottom: 10px;
}

.mode-tag,
.section-head span,
.template-head span {
  flex-shrink: 0;
  color: var(--mint);
  font-size: 12px;
  font-weight: 900;
}

.form-grid,
.settings-grid,
.result-columns,
.history-grid {
  display: grid;
  gap: 12px;
}

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

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

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

.field span {
  font-size: 14px;
}

.field input,
.field select,
.share-box input,
.custom-form input {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid #e7d8df;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-size: 14px;
}

.field input:focus,
.field select:focus,
.share-box input:focus,
.custom-form input:focus {
  border-color: #f09bb8;
  box-shadow: 0 0 0 4px rgba(255, 90, 110, 0.08);
}

.template-box,
.custom-builder,
.result-card {
  padding: 12px;
  border: 1px solid #f1dbe2;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.category-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.category-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #f0dde4;
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.category-card strong {
  font-size: 15px;
}

.category-card span,
.category-card small {
  color: var(--muted);
}

.category-card.active {
  border-color: rgba(255, 90, 110, 0.45);
  background: linear-gradient(135deg, #fff3f7 0%, #fffafc 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 90, 110, 0.08);
}

.custom-form,
.share-box {
  display: flex;
  gap: 8px;
}

.custom-form {
  margin-top: 12px;
}

.custom-form button,
.share-box button,
.primary,
.secondary,
.action-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.custom-form button,
.primary,
.action-link.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--peach) 100%);
  color: #fff;
  box-shadow: 0 14px 28px rgba(255, 90, 110, 0.22);
}

.secondary,
.share-box button,
.action-link.secondary {
  border: 1px solid #f1d4de;
  background: #fff;
  color: var(--accent-strong);
}

.custom-form button {
  width: 72px;
  flex: 0 0 auto;
}

.custom-list,
.history-list,
.result-list,
.submission-list,
.question-groups,
.question-list {
  display: grid;
  gap: 8px;
}

.custom-list {
  margin-top: 10px;
}

.custom-row,
.history-row,
.history-empty,
.result-row,
.submission-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid #f0d9e0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.74);
}

.custom-row span,
.history-row strong,
.result-row strong,
.submission-row strong {
  font-weight: 850;
}

.custom-row button,
.history-delete {
  width: 32px;
  height: 32px;
  border: 1px solid #f1d4de;
  border-radius: 50%;
  background: #fff;
  color: var(--accent-strong);
  cursor: pointer;
}

.history-row {
  text-decoration: none;
  color: inherit;
}

.history-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.history-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.history-status.matched {
  background: var(--accent);
  color: #fff;
}

.history-status svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.intro-copy {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.intro-copy h1 {
  font-size: clamp(24px, 3.8vw, 34px);
  line-height: 1.12;
  font-weight: 900;
}

.intro-copy p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.intro-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 320px;
}

.intro-stats div,
.overview-card {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #f0dde4;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
}

.intro-stats strong,
.overview-card strong {
  font-size: 18px;
  font-weight: 900;
}

.intro-stats span,
.overview-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.question-group {
  padding: 12px;
  border: 1px solid #f0dde4;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.score-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #f0dde4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
}

.score-legend strong {
  color: var(--accent-strong);
  font-weight: 900;
}

.question-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid #f3e4ea;
  border-radius: 12px;
  background: #fff;
}

.question-order {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 900;
}

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

.question-main h3 {
  font-size: 15px;
  line-height: 1.55;
}

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

.score-chip {
  display: grid;
  min-height: 42px;
  padding: 8px 6px;
  border: 1px solid #eadce2;
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}

.score-chip strong {
  font-size: 16px;
  font-weight: 900;
}

.score-chip.active {
  border-color: rgba(255, 90, 110, 0.42);
  background: linear-gradient(135deg, #fff1f5 0%, #fff9fb 100%);
  color: var(--accent-strong);
}

.result-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.result-columns,
.history-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-score {
  display: grid;
  justify-items: end;
  gap: 2px;
  flex-shrink: 0;
}

.result-score span {
  color: var(--accent-strong);
  font-weight: 900;
}

.empty-state,
.custom-empty {
  padding: 12px;
  border: 1px dashed #d9dce8;
  border-radius: 12px;
}

.share-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: center;
  gap: 12px;
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 10px max(16px, env(safe-area-inset-left))
    calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(242, 206, 218, 0.76);
  background: rgba(255, 248, 251, 0.92);
  backdrop-filter: blur(18px);
  box-shadow: 0 -18px 34px rgba(219, 73, 116, 0.09);
}

.static-bar {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.action-bar button,
.action-bar .action-link {
  width: min(220px, calc(50vw - 22px));
}

.static-bar .action-link {
  width: min(220px, calc(50vw - 22px));
}

.quiz-footer {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  font-size: 12px;
}

.quiz-footer a {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.primary:disabled,
.secondary:disabled,
.history-delete:disabled,
.custom-form button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .share-panel,
  .form-grid,
  .settings-grid,
  .result-columns,
  .history-grid {
    grid-template-columns: 1fr;
  }

  .intro-copy {
    align-items: stretch;
    flex-direction: column;
  }

  .intro-stats,
  .result-overview {
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .quiz-shell {
    padding: 14px 12px 82px;
  }

  .category-list,
  .score-row {
    grid-template-columns: 1fr;
  }

  .custom-form,
  .share-box {
    flex-direction: column;
  }

  .custom-form button,
  .share-box button,
  .action-bar button,
  .action-bar .action-link {
    width: 100%;
  }

  .result-overview,
  .intro-stats {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
