:root {
  --bg: #f4f6f0;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --line: rgba(19, 47, 76, 0.12);
  --text: #183247;
  --muted: #688197;
  --primary: #0f7cff;
  --primary-soft: #eaf4ff;
  --accent: #18b47b;
  --accent-soft: #e7faf2;
  --gold: #f2b84b;
  --ink-soft: #23435c;
  --shadow: 0 20px 60px rgba(15, 49, 80, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --sidebar-width: 280px;
  font-family: "Segoe UI Variable", "Aptos", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(24, 180, 123, 0.16), transparent 24%),
    radial-gradient(circle at top right, rgba(15, 124, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #f8faf7 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: rgba(250, 252, 248, 0.88);
  backdrop-filter: blur(14px);
}

.brand,
.topbar,
.split-header,
.modal-header,
.modal-actions,
.hero-stats,
.row-between,
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  align-items: flex-start;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  color: white;
  font-weight: 700;
  background: linear-gradient(135deg, #18b47b 0%, #0f7cff 100%);
  box-shadow: 0 14px 24px rgba(15, 124, 255, 0.24);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.brand h1,
.topbar h2,
.modal-header h3,
.hero-copy h3,
.sidebar-card h3,
.section-card h3 {
  margin: 0;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link,
.ghost-button,
.primary-button,
.chip-button,
.quick-action,
.icon-button {
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.nav-link {
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
  color: var(--ink-soft);
  background: transparent;
}

.nav-link:hover,
.nav-link.is-active {
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.sidebar-card,
.section-card,
.hero-panel,
.stat-card,
.subject-card,
.achievement-card,
.leader-card,
.clan-banner,
.quest-card,
.profile-card,
.list-card {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.sidebar-card {
  margin-top: 24px;
  padding: 18px;
}

.main-content {
  padding: 30px;
}

.topbar-actions {
  display: flex;
  gap: 12px;
}

.feedback-banner:empty {
  display: none;
}

.feedback-banner {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(24, 180, 123, 0.12), rgba(15, 124, 255, 0.1));
  border: 1px solid rgba(24, 180, 123, 0.18);
  color: var(--ink-soft);
}

.ghost-button,
.primary-button,
.chip-button,
.quick-action {
  padding: 12px 16px;
  border-radius: 14px;
}

.ghost-button {
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}

.primary-button {
  color: white;
  background: linear-gradient(135deg, #0f7cff, #18b47b);
  box-shadow: 0 16px 30px rgba(15, 124, 255, 0.24);
}

.chip-button,
.quick-action {
  color: var(--ink-soft);
  background: var(--primary-soft);
}

.ghost-button:hover,
.primary-button:hover,
.chip-button:hover,
.quick-action:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.view-grid,
.stats-grid,
.subject-grid,
.achievement-grid,
.leaderboard-grid,
.quest-grid,
.profile-grid,
.learning-grid,
.detail-grid {
  display: grid;
  gap: 18px;
}

.view-grid {
  margin-top: 24px;
}

.view-grid.dashboard {
  grid-template-columns: 1.45fr 1fr;
}

.view-grid.two-column,
.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.subject-grid,
.achievement-grid,
.quest-grid,
.learning-grid,
.profile-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.leaderboard-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.hero-panel {
  overflow: hidden;
  position: relative;
  padding: 26px;
  background:
    radial-gradient(circle at top right, rgba(242, 184, 75, 0.2), transparent 26%),
    linear-gradient(135deg, rgba(15, 124, 255, 0.12), rgba(24, 180, 123, 0.08)),
    var(--surface);
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -40px -50px auto;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(15, 124, 255, 0.16), transparent 70%);
}

.hero-copy h3 {
  font-size: clamp(1.8rem, 2.8vw, 2.8rem);
  line-height: 1.06;
  max-width: 12ch;
}

.hero-copy p,
.section-copy,
.muted,
.small-note {
  color: var(--muted);
}

.hero-stats {
  align-items: stretch;
  margin-top: 26px;
}

.pill,
.status-pill,
.tag,
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.92rem;
}

.pill,
.tag {
  background: rgba(255, 255, 255, 0.78);
}

.status-pill.is-positive {
  background: var(--accent-soft);
  color: #0d8458;
}

.status-pill.is-neutral {
  background: var(--primary-soft);
  color: #0b60c2;
}

.rank-badge {
  color: #785507;
  background: rgba(242, 184, 75, 0.2);
}

.progress-shell {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(19, 47, 76, 0.08);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #18b47b, #0f7cff);
}

.section-card,
.stat-card,
.subject-card,
.achievement-card,
.leader-card,
.quest-card,
.profile-card,
.list-card,
.clan-banner {
  padding: 22px;
}

.stat-card .value,
.metric-value,
.score {
  margin: 8px 0 4px;
  font-size: 2rem;
  font-weight: 700;
}

.section-card h3 {
  font-size: 1.18rem;
}

.action-row,
.stack,
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stack {
  flex-direction: column;
}

.list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.list-row {
  align-items: flex-start;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.list-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.list-row:first-child {
  padding-top: 0;
}

.subject-card.compact {
  padding-bottom: 18px;
}

.grade-trail {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.grade-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  font-size: 0.88rem;
}

.achievement-card.is-unlocked {
  background:
    radial-gradient(circle at top right, rgba(242, 184, 75, 0.22), transparent 24%),
    var(--surface);
}

.achievement-icon,
.leader-rank,
.avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: var(--primary-soft);
  font-size: 1.4rem;
}

.leader-rank.is-top {
  background: rgba(242, 184, 75, 0.18);
}

.clan-banner {
  background:
    radial-gradient(circle at bottom left, rgba(24, 180, 123, 0.14), transparent 28%),
    linear-gradient(135deg, rgba(15, 124, 255, 0.08), rgba(24, 180, 123, 0.08)),
    var(--surface);
}

.modal {
  width: min(720px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(12, 26, 38, 0.42);
  backdrop-filter: blur(5px);
}

.quiet-card {
  opacity: 0.92;
}

.quest-card.is-muted {
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
}

.rank-roadmap {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.rank-step {
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
}

.rank-step.is-reached {
  background: rgba(24, 180, 123, 0.08);
  border-color: rgba(24, 180, 123, 0.2);
}

.rank-step.is-current {
  background: linear-gradient(135deg, rgba(15, 124, 255, 0.14), rgba(24, 180, 123, 0.12));
  border-color: rgba(15, 124, 255, 0.24);
}

.rank-panel {
  grid-column: 1 / -1;
}

.modal-card {
  padding: 24px;
  background: #fdfefd;
  border-radius: 28px;
  box-shadow: 0 30px 60px rgba(9, 35, 58, 0.18);
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--ink-soft);
  background: rgba(15, 124, 255, 0.08);
}

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

.field-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 12px;
  z-index: 50;
}

.toast {
  min-width: 280px;
  max-width: 360px;
  padding: 16px 18px;
  border-radius: 20px;
  color: white;
  background: linear-gradient(135deg, #0f7cff, #18b47b);
  box-shadow: 0 20px 40px rgba(15, 124, 255, 0.24);
  animation: toast-in 180ms ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .stats-grid,
  .subject-grid,
  .achievement-grid,
  .quest-grid,
  .learning-grid,
  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .view-grid.dashboard,
  .leaderboard-grid,
  .view-grid.two-column,
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    overflow: visible;
    z-index: 10;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .nav-link {
    text-align: center;
    padding: 12px 10px;
    font-size: 0.92rem;
  }

  .sidebar-card {
    display: none;
  }

  .topbar,
  .hero-stats,
  .split-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .field-grid,
  .stats-grid,
  .subject-grid,
  .achievement-grid,
  .quest-grid,
  .learning-grid,
  .profile-grid,
  .compact-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .main-content,
  .sidebar {
    padding: 18px;
  }

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

  .toast-stack {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    min-width: 0;
    max-width: none;
  }
}
