:root {
  --bg: #f6f3ee;
  --bg-soft: #efe8de;
  --card: rgba(255, 252, 247, 0.88);
  --card-soft: rgba(250, 245, 238, 0.94);
  --line: rgba(74, 62, 51, 0.12);
  --text: #1f1a17;
  --muted: #6d6258;
  --accent: #b5653b;
  --accent-2: #8c6a43;
  --sans: "Space Grotesk", sans-serif;
  --serif: "Newsreader", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at top left, rgba(181, 101, 59, 0.08), transparent 30%),
    radial-gradient(circle at bottom right, rgba(140, 106, 67, 0.08), transparent 32%),
    linear-gradient(180deg, #f8f4ee 0%, #f1ebe3 100%);
}

.app-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 18px auto 32px;
}

.stack {
  display: grid;
  gap: 18px;
}

.hero,
.panel,
.exam-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 10px 30px rgba(72, 53, 34, 0.06);
  backdrop-filter: blur(10px);
}

.hero,
.panel {
  border-radius: 24px;
  padding: 20px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.55fr);
  gap: 14px;
  margin-bottom: 14px;
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.94), rgba(248, 242, 234, 0.92));
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 700;
}

.hero h1,
.section-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  letter-spacing: 0;
}

.hero h1 {
  margin-bottom: 6px;
  font-size: clamp(2.1rem, 3.4vw, 3rem);
  line-height: 0.94;
}

.hero-text,
.section-copy,
.card-code {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-copy {
  display: grid;
  gap: 10px;
  align-content: start;
}

.hero-metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.hero-side {
  display: block;
}

.hero-stat {
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(250, 245, 238, 0.88);
  border: 1px solid var(--line);
  min-width: 150px;
  flex: 1 1 150px;
}

.hero-stat-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
}

.hero-stat strong {
  font-size: 1.8rem;
  font-weight: 700;
}

.hero-account-slot:empty {
  display: none;
}

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

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

.archived-panel[hidden] {
  display: none;
}

.exam-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.exam-card:hover {
  transform: translateY(-1px);
  border-color: rgba(181, 101, 59, 0.28);
  background: rgba(255, 250, 244, 0.96);
}

.card-top,
.card-meta,
.card-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: rgba(181, 101, 59, 0.08);
}

.card-status {
  padding: 6px 10px;
  border-radius: 999px;
  color: #5f4a38;
  background: rgba(181, 101, 59, 0.1);
  font-size: 0.78rem;
  font-weight: 700;
}

.card-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.meta-chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(120, 98, 76, 0.08);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.card-action-btn {
  border: 1px solid var(--line);
  background: rgba(250, 245, 238, 0.92);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 10px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.card-action-btn:hover {
  background: rgba(244, 236, 226, 0.96);
  border-color: rgba(181, 101, 59, 0.22);
  color: var(--text);
}

.exam-card.archived .card-order-up,
.exam-card.archived .card-order-down {
  display: none;
}

.ghost-btn {
  border: 1px solid var(--line);
  background: rgba(250, 245, 238, 0.92);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.ghost-btn:hover {
  background: rgba(244, 236, 226, 0.96);
  border-color: rgba(181, 101, 59, 0.22);
}

.card-progress {
  display: grid;
  gap: 8px;
}

.progress-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(120, 98, 76, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
}

.auth-shell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(242, 236, 228, 0.76);
  backdrop-filter: blur(8px);
}

.auth-dialog,
.auth-user-box {
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.97);
  box-shadow: 0 14px 40px rgba(72, 53, 34, 0.08);
}

.auth-dialog {
  width: min(460px, 100%);
  border-radius: 22px;
  padding: 24px;
}

.auth-title {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 2rem;
}

.auth-copy,
.auth-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-google-slot {
  margin: 18px 0 14px;
}

.auth-message.error {
  color: #a24832;
}

.auth-user-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.92);
  border: 1px solid var(--line);
}

.auth-avatar,
.auth-avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
}

.auth-avatar-fallback {
  display: grid;
  place-items: center;
  background: rgba(181, 101, 59, 0.12);
  color: var(--text);
  font-weight: 700;
}

.auth-user-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.auth-user-copy strong,
.auth-user-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-user-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

.auth-logout-btn {
  margin-left: auto;
}

.primary-btn {
  border: 1px solid transparent;
  background: linear-gradient(135deg, #172121, #294442);
  color: #f8f4ee;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.pwa-install-card {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(460px, calc(100vw - 24px));
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.96);
  box-shadow: 0 20px 48px rgba(31, 26, 23, 0.14);
  backdrop-filter: blur(16px);
}

.pwa-install-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.pwa-install-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
}

.pwa-install-copy strong {
  font-size: 1rem;
}

.pwa-install-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.pwa-install-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

@media (max-width: 860px) {
  .hero,
  .panel-head {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .hero-side {
    display: block;
  }

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

  .auth-user-box {
    min-width: 0;
  }

  .pwa-install-card {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    margin: 10px auto 24px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .hero h1 {
    font-size: clamp(1.9rem, 10vw, 2.5rem);
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .auth-user-box {
    grid-template-columns: auto 1fr;
  }

  .auth-logout-btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .pwa-install-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .pwa-install-actions {
    margin-left: 0;
    width: 100%;
    justify-content: stretch;
  }

  .pwa-install-actions .ghost-btn,
  .pwa-install-actions .primary-btn {
    flex: 1 1 0;
    justify-content: center;
  }
}
