:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background:
    radial-gradient(circle at top left, rgba(99, 102, 241, 0.16), transparent 28%),
    linear-gradient(180deg, #eef2ff 0%, #f8faff 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 16px 124px;
}

.profile-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid #e5e7eb;
  padding: 18px 12px 20px;
  margin-bottom: 16px;
}

.profile-user {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.avatar-wrap {
  position: relative;
  width: 56px;
  height: 56px;
  flex: 0 0 56px;
}

.avatar,
.avatar-image {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: block;
}

.avatar-fallback {
  background: linear-gradient(135deg, #c7d2fe, #818cf8);
  color: white;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.profile-online {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  border: 3px solid white;
}

.profile-meta {
  min-width: 0;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.profile-username {
  margin-top: 4px;
  color: #6b7280;
  font-size: 14px;
}

.quota-pill {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 12px 16px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
}

.quota-pill-button {
  appearance: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.quota-icon {
  font-size: 20px;
  line-height: 1;
}

.quota-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.panel {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #dbe4ff;
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 18px 40px rgba(40, 62, 120, 0.08);
}

.home-hero {
  background:
    linear-gradient(135deg, rgba(79, 70, 229, 0.1), rgba(56, 189, 248, 0.06)),
    rgba(255, 255, 255, 0.96);
}

.home-hero.compact {
  padding-bottom: 18px;
}

.screen-topbar {
  display: grid;
  gap: 14px;
}

.screen-topbar-balance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.screen-topbar-title {
  margin-bottom: 0;
}

.screen-topbar-copy {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 400;
  letter-spacing: normal;
  white-space: normal;
  max-width: 620px;
}

.eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #4f46e5;
  letter-spacing: 0.08em;
}

h1,
h2 {
  margin: 0 0 12px;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.muted {
  color: #6b7280;
}

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

.hero-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 600;
}

.info-chip-button {
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.98);
  color: rgba(17, 24, 39, 0.78);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 14px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: none;
  box-shadow: none;
}

.info-chip-button[aria-expanded="true"] {
  background: #f8fafc;
  color: rgba(17, 24, 39, 0.92);
  border-color: rgba(17, 24, 39, 0.82);
}

.card {
  background: #f8faff;
  border: 1px solid #dbe4ff;
  border-radius: 16px;
  padding: 14px;
}

.form-card {
  display: grid;
  gap: 10px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: #4338ca;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.subject-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

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

.hub-card,
.subject,
.primary {
  border: 0;
  border-radius: 24px;
  padding: 18px 18px 20px;
  cursor: pointer;
}

.hub-card {
  min-height: 188px;
  background: linear-gradient(180deg, #ffffff, #fbfcff);
  border: 1px solid #dfe7ff;
  box-shadow: 0 16px 36px rgba(40, 62, 120, 0.08);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
  text-align: left;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.hub-card.active {
  border-color: #c7d2fe;
  box-shadow: 0 22px 42px rgba(79, 70, 229, 0.14);
  transform: translateY(-1px);
}

.hub-card.passive {
  cursor: default;
}

.hub-icon {
  font-size: 38px;
  line-height: 1;
}

.hub-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
  color: #111827;
}

.hub-copy {
  font-size: 15px;
  line-height: 1.45;
  color: #6b7280;
}

.coming-soon {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: #4f46e5;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.subject {
  background: #eef2ff;
  color: #3730a3;
  text-align: left;
  display: grid;
  gap: 4px;
  border: 1px solid transparent;
}

.subject small {
  color: #6b7280;
}

.subject.active,
.primary {
  background: linear-gradient(135deg, #4f46e5, #5b4ef6);
  color: white;
}

.primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary.ghost {
  width: auto;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
}

.secondary {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.secondary.danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff7f7;
}

.workspace-panel {
  margin-top: 6px;
}

.balance-grid {
  display: grid;
  gap: 14px;
}

.balance-card {
  background: #f8faff;
  border: 1px solid #dbe4ff;
  border-radius: 20px;
  padding: 20px 18px;
  display: grid;
  gap: 12px;
}

.balance-main-card {
  gap: 10px;
}

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

.balance-main-copy p,
.balance-copy {
  margin: 0;
  color: #6b7280;
  font-size: 15px;
  line-height: 1.5;
}

.balance-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.balance-card-head h2 {
  margin: 0;
}

.balance-emoji {
  font-size: 24px;
  line-height: 1;
}

.balance-action {
  width: 100%;
  margin-top: 4px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

.groups-summary-card {
  background: #f8faff;
  border: 1px solid #dbe4ff;
  border-radius: 20px;
  padding: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.groups-summary-card h2 {
  margin: 6px 0 8px;
}

.groups-summary-actions {
  display: grid;
  gap: 10px;
  min-width: 190px;
}

.invite-code-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 10px 14px;
  font-weight: 700;
  width: fit-content;
}

.members-list,
.ranking-list {
  display: grid;
  gap: 10px;
}

.member-row,
.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 12px 14px;
}

.member-role {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.ranking-place {
  flex: 0 0 28px;
  font-weight: 800;
  color: #4f46e5;
}

.ranking-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
}

.ranking-value {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1;
}

.stage-card {
  background: #f8faff;
  border: 1px solid #dbe4ff;
  border-radius: 20px;
  padding: 18px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.stage-head h3 {
  margin: 6px 0 0;
  font-size: 18px;
}

.stage-kicker {
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stage-copy {
  margin: 0;
  color: #6b7280;
  line-height: 1.45;
  font-size: 14px;
}

.mode-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-chip {
  border: 1px solid #c7d2fe;
  background: #fff;
  color: #3730a3;
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mode-chip.active {
  background: linear-gradient(135deg, #4f46e5, #5b4ef6);
  border-color: transparent;
  color: white;
}

.stage-action {
  width: 100%;
}

.variant-select,
.text-answer {
  width: 100%;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 12px 14px;
  background: white;
  font: inherit;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat-card {
  background: #f8faff;
  border: 1px solid #dbe4ff;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.stat-label {
  color: #6b7280;
  font-size: 13px;
}

.stat-value {
  font-size: 22px;
  line-height: 1.15;
}

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

.variant-runner {
  display: grid;
  gap: 14px;
}

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

.question-nav {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 8px;
}

.question-dot {
  border: 1px solid #dbe4ff;
  background: #fff;
  color: #6b7280;
  border-radius: 12px;
  padding: 10px 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.question-dot.active {
  background: linear-gradient(135deg, #4f46e5, #5b4ef6);
  color: white;
  border-color: transparent;
}

.question-dot.answered:not(.active) {
  background: #eefcf3;
  color: #166534;
  border-color: #bbf7d0;
}

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

.question-card.focus {
  padding: 18px;
}

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

.question-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #4338ca;
}

.question-meta {
  font-size: 13px;
  color: #6b7280;
}

.question-count {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 8px 10px;
}

.question-prompt {
  line-height: 1.55;
  white-space: pre-wrap;
}

.option-list {
  display: grid;
  gap: 8px;
}

.option-list-compact {
  gap: 10px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.option-tile {
  border: 1px solid #dbe4ff;
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
}

.option-tile.selected {
  border-color: #818cf8;
  background: #eef2ff;
}

.answer-box {
  display: grid;
  gap: 8px;
}

.answer-input {
  font-size: 16px;
}

.feedback-card {
  border-radius: 16px;
  padding: 14px;
  border: 1px solid #dbe4ff;
  background: #f8faff;
  display: grid;
  gap: 8px;
}

.feedback-card.ok {
  background: #eefcf3;
  border-color: #bbf7d0;
}

.feedback-card.bad {
  background: #fff7ed;
  border-color: #fed7aa;
}

.feedback-title {
  font-size: 16px;
  font-weight: 800;
}

.feedback-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: #374151;
}

.feedback-solution {
  line-height: 1.5;
  white-space: pre-wrap;
}

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

.prep-grid .hub-card {
  min-height: 168px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 720px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.94);
  border: 1px solid rgba(99, 102, 241, 0.18);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(16px);
  z-index: 30;
}

.bottom-nav-item {
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  padding: 10px 6px;
  display: grid;
  justify-items: center;
  gap: 4px;
  font: inherit;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.bottom-nav-item.active {
  background: #ffffff;
  color: #111827;
}

.bottom-nav-item:active {
  transform: translateY(1px);
}

.bottom-nav-icon {
  font-size: 18px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 14px 12px 118px;
  }

  .profile-hero {
    padding: 14px 8px 18px;
  }

  .section-head {
    flex-direction: column;
  }

  .hub-grid,
  .workspace-grid,
  .groups-state-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stage-card {
    grid-column: span 2;
  }

  .primary {
    width: 100%;
  }

  .secondary {
    width: 100%;
  }

  .groups-summary-card {
    flex-direction: column;
    align-items: stretch;
  }

  .groups-summary-actions {
    min-width: 0;
  }

  .quota-pill {
    padding: 10px 14px;
  }

  .quota-value {
    font-size: 20px;
  }

  .bottom-nav {
    width: calc(100vw - 16px);
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 4px;
    padding: 8px;
  }

  .bottom-nav-item {
    padding: 10px 4px;
  }

  .bottom-nav-label {
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .hub-grid,
  .workspace-grid,
  .groups-state-grid {
    grid-template-columns: 1fr;
  }

  .stage-card {
    grid-column: auto;
  }

  .hub-card {
    min-height: 164px;
  }

  .question-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .screen-topbar-copy {
    max-width: none;
  }

  .bottom-nav-label {
    font-size: 10px;
  }
}
