:root {
  --primary: #0057ff;
  --primary-dark: #0039a8;
  --accent: #ffb703;
  --ink: #1f2532;
  --muted: #5b6476;
  --surface: #ffffff;
  --surface-alt: #f2f4ff;
  --border: rgba(15, 63, 167, 0.12);
  --radius: 24px;
  --shadow: 0 20px 60px rgba(15, 87, 255, 0.15);
  --shadow-soft: 0 10px 35px rgba(38, 44, 82, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at top, rgba(169, 200, 255, 0.4), transparent 55%), #eef2ff;
  color: var(--ink);
  line-height: 1.6;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.user-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.logout-btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.hero {
  background: linear-gradient(120deg, var(--primary), #7357ff);
  border-radius: var(--radius);
  padding: 3rem clamp(2rem, 4vw, 4.5rem);
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35), transparent 45%);
  pointer-events: none;
}

.hero-logo {
  position: absolute;
  top: 1.6rem;
  right: 1.8rem;
  width: 86px;
  height: 86px;
  object-fit: contain;
  opacity: 0.9;
  z-index: 1;
  filter: drop-shadow(0 12px 22px rgba(0, 0, 0, 0.18));
}

.hero-content {
  position: relative;
  z-index: 1;
}

.hero h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 4vw, 3.1rem);
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 640px;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.85);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 2rem;
}

.hero-stats {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.hero-note {
  margin: 1.5rem 0 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: right;
}

.stat {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 1rem 1.25rem;
  color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

.stat strong {
  font-size: 1.3rem;
  display: block;
}

section {
  margin-top: 2.5rem;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.25rem clamp(1.5rem, 4vw, 3rem);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}

.section-heading {
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.hero-heading {
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.35em;
}

h2 {
  margin: 0 0 1.2rem;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  align-items: stretch;
}

.chapter-divider {
  grid-column: 1 / -1;
  padding: 1rem 1.3rem;
  border-radius: 18px;
  background: var(--surface-alt);
  border: 1px dashed rgba(0, 87, 255, 0.3);
  font-weight: 600;
  color: var(--primary-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-tile {
  background: var(--surface-alt);
  border-radius: 20px;
  padding: 1.5rem;
  border: 1px solid rgba(15, 63, 167, 0.12);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 180px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(0, 87, 255, 0.12);
}

.card-tile h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary-dark);
}

.card-tile p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: auto;
}

.cta {
  margin-top: 2rem;
  background: linear-gradient(135deg, rgba(0, 87, 255, 0.08), rgba(255, 183, 3, 0.12));
  border-radius: 20px;
  padding: 1.5rem;
  border: 1px dashed rgba(0, 87, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.cta h3 {
  margin: 0;
}

.section-top {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.study-panel {
  display: grid;
  gap: 1.5rem;
  justify-items: center;
  text-align: center;
}

.study-meta {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat-label {
  text-transform: uppercase;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  color: var(--primary-dark);
}

.stat-value {
  display: block;
  font-size: 1.1rem;
  font-weight: 600;
}

.card {
  background: #fff;
  border-radius: var(--radius);
  width: min(70vw, 360px);
  aspect-ratio: 1 / 1;
  padding: 32px;
  min-height: unset;
  box-shadow: 0 25px 60px rgba(15, 87, 255, 0.15);
  border: 1px solid rgba(15, 63, 167, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  display: grid;
  place-items: center;
  perspective: 1000px;
}

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

.card:focus {
  outline: 3px solid rgba(0, 87, 255, 0.35);
  outline-offset: 3px;
}

.card::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  border: 1px dashed rgba(0, 87, 255, 0.3);
  pointer-events: none;
}

.card-face {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  font-weight: 600;
}

.card.is-flipping {
  animation: card-flip 0.45s ease;
}

.card.is-sliding-next {
  animation: card-slide-next 0.35s ease;
}

.card.is-sliding-prev {
  animation: card-slide-prev 0.35s ease;
}

@keyframes card-flip {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

@keyframes card-slide-next {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  50% {
    transform: translateX(-25px);
    opacity: 0.4;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes card-slide-prev {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  50% {
    transform: translateX(25px);
    opacity: 0.4;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

.card-face .back {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--muted);
}

.placeholder {
  color: var(--muted);
  font-weight: 400;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  justify-content: center;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.6rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 87, 255, 0.2);
}

.btn.ghost {
  background: rgba(15, 63, 167, 0.08);
  color: var(--ink);
}

.btn.light {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.18);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.editor {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.editor label {
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.editor .full {
  grid-column: 1 / -1;
}

.editor input,
.editor textarea {
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(15, 63, 167, 0.2);
  font-size: 0.95rem;
  font-family: inherit;
}

.editor textarea {
  resize: vertical;
}

.editor-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.editor-note {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.9rem;
}

.saved {
  margin-top: 2rem;
}

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

.auth-center {
  display: flex;
  justify-content: center;
}

.auth-card {
  background: var(--surface-alt);
  border-radius: 18px;
  padding: 1.5rem;
  border: 1px solid rgba(15, 63, 167, 0.12);
  display: grid;
  gap: 0.75rem;
  max-width: 420px;
  width: 100%;
}

.auth-card h3 {
  margin: 0;
}

.auth-card label {
  display: grid;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.auth-card input {
  padding: 0.7rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 63, 167, 0.2);
  font-size: 0.95rem;
  font-family: inherit;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.auth-error {
  margin: 0;
  color: #c62828;
  font-size: 0.9rem;
}

.auth-success {
  margin: 0;
  color: #1b5e20;
  font-size: 0.9rem;
}

.detail-panel {
  display: grid;
  gap: 1.25rem;
}

.detail-subtitle {
  margin: 0;
  color: var(--muted);
}

.detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.8rem;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  background: var(--surface-alt);
  border-radius: 16px;
  padding: 0.85rem;
  border: 1px solid rgba(15, 63, 167, 0.12);
}

.detail-row input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(15, 63, 167, 0.2);
  font-size: 0.95rem;
  font-family: inherit;
}

.detail-row .btn {
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.file-btn input {
  display: none;
}

code {
  background: rgba(15, 63, 167, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 640px) {
  .hero {
    padding: 2.25rem 1.65rem;
  }

  section {
    padding: 1.75rem 1.35rem;
  }

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

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