:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e7eef8;
  --muted: #8b9bb4;
  --accent: #3d8bfd;
  --accent-hover: #5ca0ff;
  --good: #3fb950;
  --hard: #d29922;
  --again: #f85149;
  --easy: #a371f7;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1b2a44 0%, transparent 50%),
              radial-gradient(900px 500px at 100% 0%, #1a2f28 0%, transparent 45%),
              var(--bg);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid #243044;
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  background: rgba(15, 20, 25, 0.85);
  z-index: 10;
}

.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--text); }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: var(--muted); font-size: 0.95rem; }
.topbar nav a:hover { color: var(--text); }

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--surface2);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface2); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn.danger { color: var(--again); }
.btn.rating { min-width: 4.5rem; }
.btn.rating.again { border-color: var(--again); color: var(--again); }
.btn.rating.hard { border-color: var(--hard); color: var(--hard); }
.btn.rating.good { border-color: var(--good); color: var(--good); }
.btn.rating.easy { border-color: var(--easy); color: var(--easy); }

.dashboard-main { display: flex; flex-direction: column; gap: 1.25rem; }
.progress-card, .grid-card, .form-card, .stat, .done-card {
  background: linear-gradient(180deg, #1c2638 0%, var(--surface) 100%);
  border: 1px solid #2a3a52;
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}
.progress-card h1 { margin: 0 0 0.35rem; font-size: 1.5rem; }
.ok { color: var(--good); }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
}
.stat-label { display: block; color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 1.6rem; font-weight: 700; }

.bar {
  height: 10px;
  background: #0d121a;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.75rem 0 1rem;
}
.bar.thin { height: 6px; margin: 0.45rem 0; }
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2f81f7, #3fb950);
  border-radius: inherit;
}

.contrib-grid {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.contrib-week { display: flex; flex-direction: column; gap: 3px; }
.contrib-day {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: #161b22;
}
.contrib-day.level-0 { background: #161b22; }
.contrib-day.level-1 { background: #0e4429; }
.contrib-day.level-2 { background: #006d32; }
.contrib-day.level-3 { background: #26a641; }
.contrib-day.level-4 { background: #39d353; }
.legend { display: flex; align-items: center; gap: 4px; margin-top: 0.5rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.fab {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(61, 139, 253, 0.35);
  border: none;
}
.fab:hover { background: var(--accent-hover); color: #fff; }

.review-page { max-width: 560px; margin: 0 auto; }
.review-meta { text-align: center; color: var(--muted); margin-bottom: 1rem; }

.flashcard {
  position: relative;
  height: 280px;
  perspective: 1000px;
  cursor: pointer;
  margin-bottom: 1.25rem;
}
.flashcard .face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1px solid #2a3a52;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  transition: transform 0.45s ease;
}
.flashcard .front { transform: rotateY(0deg); }
.flashcard .back { transform: rotateY(180deg); }
.flashcard.flipped .front { transform: rotateY(180deg); }
.flashcard.flipped .back { transform: rotateY(360deg); }
.flashcard .label { text-transform: uppercase; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.08em; }
.flashcard .term, .flashcard .definition {
  font-size: 1.45rem;
  text-align: center;
  margin: 0.75rem 0;
  line-height: 1.35;
}
.hint { font-size: 0.85rem; }

.rating-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.xp-toast {
  text-align: center;
  color: var(--good);
  font-weight: 600;
  margin-bottom: 0.5rem;
  animation: fadeup 1.2s ease forwards;
}
@keyframes fadeup {
  from { opacity: 0; transform: translateY(6px); }
  30% { opacity: 1; }
  to { opacity: 0; transform: translateY(-8px); }
}

.form-card h1 { margin-top: 0; }
.form-card h2 { margin-top: 1.75rem; font-size: 1.1rem; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }
input, textarea {
  font: inherit;
  color: var(--text);
  background: #0d121a;
  border: 1px solid #2a3a52;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}
input:focus, textarea:focus { outline: 2px solid rgba(61, 139, 253, 0.35); border-color: var(--accent); }
.row { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }

.notice {
  background: #12261a;
  border: 1px solid #238636;
  border-radius: 8px;
  padding: 0.85rem;
  margin: 0.75rem 0;
}
.token { display: block; word-break: break-all; margin-top: 0.35rem; color: var(--good); }
.token-list { list-style: none; padding: 0; }
.token-list li {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid #243044;
}

.done-card { text-align: center; margin-top: 3rem; }

@media (max-width: 600px) {
  .container { padding: 1rem; }
  .flashcard { height: 240px; }
}
