:root {
  --bg: #f3f3f4;
  --bg-strong: #e5e5e7;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(0, 0, 0, 0.08);
  --ink: #111111;
  --muted: #6e6e73;
  --accent: #111111;
  --accent-strong: #000000;
  --accent-soft: rgba(0, 0, 0, 0.06);
  --good: #111111;
  --good-soft: rgba(0, 0, 0, 0.07);
  --bad: #111111;
  --bad-soft: rgba(0, 0, 0, 0.05);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.07);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "SF Pro Display",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 26%),
    linear-gradient(180deg, #fbfbfc 0%, #f3f3f4 45%, #ececee 100%);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.34), transparent 88%);
  pointer-events: none;
}

button,
input,
select {
  font: inherit;
  color: var(--ink);
}

button {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  -webkit-text-fill-color: currentColor;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.08);
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:active {
  transform: scale(0.98);
}

input,
select {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.09);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: calc(0.85rem + var(--safe-top)) 1rem calc(7rem + var(--safe-bottom));
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0 0.75rem;
}

.brand {
  display: flex;
  gap: 0.82rem;
  align-items: center;
}

.brand h1,
.hero-panel h2,
.panel h3,
.question-card h4 {
  margin: 0;
  letter-spacing: -0.03em;
}

.brand h1 {
  font-size: clamp(2rem, 8vw, 2.55rem);
  line-height: 1;
}

.brand-mark {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #1c1c1e, #000000);
  color: white;
  font-size: 1.45rem;
  font-weight: 800;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.16);
}

.eyebrow {
  margin: 0 0 0.15rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.layout {
  display: grid;
  gap: 0.9rem;
}

.hero-panel,
.panel,
.question-card,
.progress-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero-panel {
  border-radius: var(--radius-xl);
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.hero-copy,
.subtle {
  color: var(--muted);
  line-height: 1.6;
}

.hero-panel h2 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 0.96;
  text-transform: lowercase;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.stat-card {
  padding: 0.9rem;
  border-radius: 18px;
  background: linear-gradient(180deg, #1c1c1e, #000000);
  color: #ffffff;
}

.stat-card span {
  display: block;
  font-size: 0.8rem;
  opacity: 0.72;
}

.stat-card strong {
  display: block;
  margin-top: 0.5rem;
  font-size: clamp(1.35rem, 5vw, 1.65rem);
}

.panel {
  border-radius: var(--radius-xl);
  padding: 1.1rem;
}

.panel-head,
.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.search-inline {
  width: min(280px, 100%);
}

.subject-grid {
  display: grid;
  gap: 0.8rem;
}

.subject-card {
  width: 100%;
  padding: 1rem;
  text-align: left;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 245, 247, 0.94));
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
}

.subject-card:hover {
  transform: translateY(-2px);
}

.subject-card h4,
.subject-card p {
  margin: 0;
}

.subject-card h4 {
  font-size: 1.05rem;
}

.subject-card p {
  color: var(--muted);
  margin-top: 0.45rem;
}

.subject-card footer {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  font-size: 0.76rem;
  -webkit-text-fill-color: currentColor;
}

.pill {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink);
}

.badge {
  background: rgba(0, 0, 0, 0.08);
  color: #111111;
}

.badge-soft {
  background: rgba(0, 0, 0, 0.05);
  color: var(--muted);
}

.controls-stack {
  display: grid;
  gap: 0.85rem;
}

.filter-row,
.launch-row,
.summary-strip,
.tab-row {
  display: grid;
  gap: 0.75rem;
}

.filter-row {
  grid-template-columns: 1fr;
}

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

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

.tab {
  padding: 0.9rem 0.75rem;
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
  border-radius: 14px;
}

.tab.active {
  background: rgba(0, 0, 0, 0.92);
  color: #ffffff;
}

.summary-strip {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.load-notice {
  margin-bottom: 0.95rem;
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--muted);
  line-height: 1.65;
  white-space: pre-wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.warn-button {
  min-height: 48px;
  border-radius: 16px;
  padding: 0.85rem 1rem;
  font-weight: 600;
}

.primary-button {
  background: linear-gradient(180deg, #1c1c1e, #000000);
  color: white;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.16);
}

.secondary-button {
  background: rgba(0, 0, 0, 0.08);
  color: #111111;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
}

.warn-button {
  background: rgba(0, 0, 0, 0.08);
  color: #111111;
}

.progress-card {
  border-radius: var(--radius-lg);
  padding: 0.95rem 1rem;
  margin-bottom: 0.9rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.progress-bar {
  margin-top: 0.75rem;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.progress-bar > div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8e8e93, #111111);
  transition: width 180ms ease;
}

.question-card {
  border-radius: var(--radius-xl);
  padding: 1.15rem;
}

.question-badges {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.question-card h4 {
  font-size: 1.15rem;
  line-height: 1.6;
}

.options-list {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.option-button {
  width: 100%;
  position: relative;
  overflow: hidden;
  padding: 0.95rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  text-align: left;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-text-fill-color: currentColor;
}

.option-button span {
  color: inherit;
  -webkit-text-fill-color: currentColor;
}

.option-letter {
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.08);
  font-weight: 700;
  line-height: 1;
}

.option-button.correct {
  background: linear-gradient(180deg, #1c1c1e, #000000);
  background-color: #000000;
  border-color: #000000;
  color: #ffffff;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
}

.option-button.correct .option-letter {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.option-button.wrong {
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(0, 0, 0, 0.035) 0,
      rgba(0, 0, 0, 0.035) 7px,
      transparent 7px,
      transparent 15px
    ),
    #f5f5f7;
  background-color: #f5f5f7;
  border-color: rgba(0, 0, 0, 0.42);
  color: #111111;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.option-button.wrong::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: #111111;
}

.option-button.wrong .option-letter {
  background: #d1d1d6;
  color: #111111;
}

.text-mode-controls,
.self-mark-row {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
}

.answer-panel {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.05);
  line-height: 1.65;
}

.answer-panel strong {
  display: block;
  margin-bottom: 0.45rem;
}

.detail-panel {
  margin-top: 0.85rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 0.2rem 1rem 0.95rem;
}

.detail-panel summary {
  cursor: pointer;
  padding: 0.9rem 0;
  font-weight: 600;
}

.detail-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.action-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(960px, 100%);
  padding: 0.8rem 1rem calc(0.8rem + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  background: linear-gradient(180deg, rgba(243, 243, 244, 0), rgba(243, 243, 244, 0.96) 28%);
  backdrop-filter: blur(24px);
}

.jump-control {
  min-height: 48px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: center;
  gap: 0;
  padding: 0;
  border-radius: 16px;
  background: transparent;
  border: 0;
  color: var(--ink);
  box-shadow: none;
  font-weight: 800;
  font-size: clamp(1rem, 4.4vw, 1.18rem);
  justify-content: center;
  white-space: nowrap;
  min-width: 0;
}

.jump-control input {
  width: var(--jump-input-width, 1ch);
  min-width: 1ch;
  border: 0;
  border-radius: 10px;
  padding: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  font-weight: 800;
  text-align: right;
  -webkit-text-fill-color: currentColor;
}

.jump-control input:focus {
  background: rgba(0, 0, 0, 0.06);
  outline: 0;
}

@media (min-width: 720px) {
  .subject-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-row {
    grid-template-columns: 1fr 1.2fr;
  }

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

  .option-button {
    font-size: 1.05rem;
  }
}
