:root {
  color-scheme: light;
  --ink: #1b1b1f;
  --muted: #5f6368;
  --line: #e1e4e8;
  --paper: #f7f9fc;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-low: #f3f6fb;
  --surface-high: #edf4ff;
  --accent: #0b57d0;
  --accent-ink: #ffffff;
  --accent-soft: #d3e3fd;
  --secondary: #006c52;
  --secondary-soft: #d8f1e6;
  --good: #137333;
  --warn: #b06000;
  --danger: #b3261e;
  --shadow-1: 0 1px 2px rgba(60, 64, 67, 0.08), 0 1px 3px rgba(60, 64, 67, 0.06);
  --shadow-2: 0 2px 8px rgba(60, 64, 67, 0.12), 0 1px 3px rgba(60, 64, 67, 0.08);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  font-family: Roboto, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(211, 227, 253, 0.42), transparent 34rem),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 28rem);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(225, 228, 232, 0.82);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0;
}

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

h1, h2, h3 {
  letter-spacing: 0;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

h3 {
  font-size: 17px;
  line-height: 1.25;
  font-weight: 700;
}

.topbar p, .muted {
  color: var(--muted);
  margin-bottom: 0;
}

.compact {
  font-size: 13px;
  line-height: 1.45;
  margin: -2px 0 10px;
}

.nav,
.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-left {
  justify-content: flex-start;
}

.topbar-right {
  justify-content: flex-end;
}

a {
  color: var(--accent);
  font-weight: 600;
}

.nav > a:not(.button-link) {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border-radius: 999px;
  padding: 9px 12px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.nav > a:not(.button-link):hover,
.nav-link:hover,
button.secondary:hover {
  background: rgba(11, 87, 208, 0.08);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 20px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.secondary-link {
  background: transparent;
  border: 1px solid #74777f;
  color: var(--accent);
  box-shadow: none;
}

.button-link:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.nav-link {
  color: var(--accent);
  text-decoration: none;
  border: 1px solid #74777f;
  border-radius: 999px;
  padding: 9px 16px;
  background: transparent;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.layout {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 72px;
  display: grid;
  gap: 20px;
}

.narrow { width: min(860px, calc(100% - 32px)); }

.grid {
  display: grid;
  gap: 20px;
}

.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel {
  background: var(--panel);
  border: 1px solid rgba(225, 228, 232, 0.9);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 360px);
  gap: 24px;
  align-items: end;
  border: 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(244, 248, 255, 0.96) 58%, rgba(237, 244, 255, 0.96) 100%);
  box-shadow: var(--shadow-1);
}

.landing-hero {
  min-height: 420px;
}

.hero h1 {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1;
  letter-spacing: 0;
  max-width: 760px;
  margin-bottom: 18px;
  font-weight: 700;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.metric-card {
  border: 0;
  border-radius: var(--radius-md);
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: none;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin: 8px 0;
}

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

input, textarea, select {
  width: 100%;
  border: 1px solid #74777f;
  border-radius: 4px;
  padding: 13px 14px;
  font: inherit;
  background: var(--surface);
  margin-bottom: 12px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:hover, textarea:hover, select:hover {
  border-color: var(--ink);
  background: #fcfcff;
}

input:focus, textarea:focus, select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

input[type="file"] {
  border-style: dashed;
  background: var(--surface-low);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

textarea.large { min-height: 220px; }

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  min-height: 40px;
  padding: 10px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

button:hover {
  box-shadow: var(--shadow-1);
  transform: translateY(-1px);
}

button.secondary {
  background: transparent;
  border: 1px solid #74777f;
  color: var(--accent);
  box-shadow: none;
}

button.danger-button {
  border-color: rgba(179, 38, 30, 0.45);
  color: var(--danger);
}

button.danger-button:hover {
  background: rgba(179, 38, 30, 0.08);
}

.icon-button {
  width: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 8px;
  font-size: 18px;
  line-height: 1;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
  transform: none;
  box-shadow: none;
}

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

.list {
  display: grid;
  gap: 12px;
}

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: none;
}

.compact-item {
  padding: 12px 14px;
}

.item-title {
  display: inline-block;
  color: var(--ink);
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.item-title:hover, .nav-link:hover, .link-button:hover {
  color: var(--accent);
}

.topic-card {
  display: block;
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.topic-card:hover {
  border-color: rgba(11, 87, 208, 0.42);
  background: rgba(237, 244, 255, 0.72);
  box-shadow: none;
  transform: translateY(-1px);
}

.topic-card:hover .item-title {
  color: var(--accent);
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.link-row a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.attempt-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
}

.activity-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
}

.teacher-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
}

.metric-tile span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.metric-tile strong {
  font-size: 30px;
  font-weight: 700;
}

.attempt-row .attempt-detail,
.attempt-row .compact {
  grid-column: 1 / -1;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  min-height: auto;
  text-align: left;
  font-weight: 700;
  box-shadow: none;
}

.item h3 {
  margin-bottom: 8px;
}

.item p:last-child {
  margin-bottom: 0;
}

.clean-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.clean-list li + li {
  margin-top: 6px;
}

.analysis-blocks {
  margin-top: 18px;
}

pre {
  white-space: pre-wrap;
  font: inherit;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  color: #174ea6;
  background: var(--accent-soft);
  font-weight: 600;
}

.status-mastered { color: var(--good); }
.status-gaps_found, .status-practicing { color: var(--warn); }

.answer-correct {
  border-color: rgba(24, 121, 78, 0.35);
  background: #ecf8f0;
}

.answer-wrong {
  border-color: rgba(180, 83, 9, 0.35);
  background: #fff4e5;
}

.attempt-detail {
  margin-top: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.tab {
  background: var(--surface-high);
  color: var(--accent);
  box-shadow: none;
}

.tab.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.publish-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px minmax(180px, 240px) auto;
  gap: 10px;
  align-items: start;
}

.question-editor {
  display: grid;
  gap: 8px;
}

.question-editor textarea {
  min-height: 74px;
}

.question-editor-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.topic-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.wizard-progress {
  display: flex;
  gap: 8px;
  margin: 18px 0;
}

.wizard-dot {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #dfe3eb;
}

.wizard-dot.active {
  background: var(--accent);
}

.wizard-dot.done {
  background: var(--accent-soft);
}

.wizard-step {
  display: grid;
  gap: 14px;
}

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

.choice-card {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.choice-card input {
  width: auto;
  min-height: auto;
}

.choice-card:hover {
  border-color: rgba(11, 87, 208, 0.42);
  background: rgba(237, 244, 255, 0.72);
}

.choice-card:has(input:checked) {
  border-color: var(--accent);
  background: #edf4ff;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice-card:has(input:checked) strong {
  color: var(--accent);
}

.choice-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.wizard-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.processing-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
}

.processing-row.active {
  border-color: rgba(11, 87, 208, 0.42);
  background: rgba(237, 244, 255, 0.72);
}

.processing-row.done {
  border-color: rgba(24, 121, 78, 0.35);
  background: #ecf8f0;
}

.spinner {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2px solid rgba(11, 87, 208, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.hidden { display: none; }

.auth-card {
  max-width: 560px;
  margin: 0 auto;
}

.auth-link {
  display: inline-block;
  margin-top: 6px;
}

.question {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .topbar, .hero, .two, .three, .four, .inline-form, .publish-form, .activity-row, .teacher-row, .choice-grid, .link-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-left,
  .topbar-right {
    justify-content: flex-start;
  }

  .hero h1 {
    font-size: 40px;
  }
}
