:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: rgba(34, 48, 74, 0.1);
  --primary: #315efb;
  --primary-2: #18b6a8;
  --danger: #f04438;
  --shadow: 0 18px 50px rgba(24, 35, 61, 0.12);
  --radius: 24px;
  --accent-glow: rgba(49, 94, 251, 0.18);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10131a;
  --surface: rgba(27, 32, 43, 0.82);
  --surface-strong: #1a2030;
  --text: #f4f7fb;
  --muted: #aab4c4;
  --line: rgba(255, 255, 255, 0.1);
  --primary: #7c9cff;
  --primary-2: #39d3be;
  --danger: #ff6b6b;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
  --accent-glow: rgba(124, 156, 255, 0.2);
}

* {
  box-sizing: border-box;
}

.app-hidden {
  display: none !important;
}

.landing-page {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 28px;
  background:
    radial-gradient(circle at 20% 10%, rgba(49, 94, 251, 0.16), transparent 34%),
    radial-gradient(circle at 86% 14%, rgba(24, 182, 168, 0.16), transparent 30%),
    var(--bg);
}

.landing-page.hidden {
  display: none;
}

.landing-nav,
.landing-actions,
.preview-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.7fr);
  gap: 28px;
  align-items: center;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.landing-copy h1 {
  max-width: 720px;
  margin: 8px 0 14px;
  font-size: clamp(48px, 7vw, 86px);
  line-height: 0.95;
}

.landing-copy p {
  max-width: 620px;
  color: var(--muted);
  font-size: 18px;
}

.landing-preview {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.preview-card {
  padding: 18px;
  border-radius: 20px;
  background: var(--surface-strong);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.preview-card.hot {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.landing-features article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  display: grid;
  gap: 8px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 10%, rgba(49, 94, 251, 0.16), transparent 30%),
    radial-gradient(circle at 90% 12%, rgba(24, 182, 168, 0.14), transparent 26%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

[data-theme="dark"] .sidebar {
  background: rgba(16, 19, 26, 0.72);
}

.brand,
.mini-profile,
.level-row,
.panel-head,
.topbar,
.top-actions,
.form-row,
.color-row {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 14px 30px rgba(49, 94, 251, 0.28);
}

.brand strong {
  display: block;
  font-size: 20px;
}

.brand span,
.level-card span,
small,
.eyebrow,
.empty-state span {
  color: var(--muted);
}

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

.nav-item {
  min-height: 48px;
  border: 0;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease;
}

.nav-item span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--surface);
}

.nav-item:hover,
.nav-item.active {
  color: var(--text);
  background: var(--surface);
  transform: translateX(3px);
}

.level-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
}

.level-row {
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-track {
  height: 9px;
  border-radius: 99px;
  background: rgba(120, 134, 160, 0.22);
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 400ms ease;
}

.main {
  padding: 28px;
  overflow: hidden;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.02;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.top-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-box {
  min-height: 46px;
  min-width: 220px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box span {
  color: var(--muted);
  font-weight: 800;
}

.search-box input {
  min-height: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.search-box input:focus {
  box-shadow: none;
}

.search-box.wide {
  width: min(420px, 100%);
}

.mini-profile {
  min-height: 46px;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.mini-profile img,
.profile-panel img {
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.mini-profile img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.icon-btn,
.pill-btn,
.primary-btn,
.ghost-btn {
  border: 0;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
}

.pill-btn,
.primary-btn {
  min-height: 46px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 26px rgba(49, 94, 251, 0.22);
}

.pill-btn {
  padding: 0 18px;
}

.primary-btn {
  padding: 0 20px;
  font-weight: 800;
}

.ghost-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(120, 134, 160, 0.14);
}

.icon-btn:hover,
.pill-btn:hover,
.primary-btn:hover,
.ghost-btn:hover,
.task-card:hover,
.subject-card:hover,
.friend-card:hover {
  transform: translateY(-2px);
}

.view {
  display: none;
  animation: viewIn 240ms ease;
}

.view.active {
  display: block;
}

.dashboard-tabs {
  width: fit-content;
  margin: 0 0 16px;
}

.insight-list {
  display: grid;
  gap: 10px;
}

.insight-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  display: grid;
  gap: 6px;
}

.insight-card strong {
  display: block;
}

.momentum-ring {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
  align-items: center;
}

.ring {
  width: 170px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, var(--surface-strong) 58%, transparent 60%),
    conic-gradient(var(--primary-2) var(--ring, 0%), rgba(120, 134, 160, 0.18) 0);
  box-shadow: inset 0 0 0 1px var(--line), 0 18px 45px var(--accent-glow);
}

.ring span {
  font-size: 30px;
  font-weight: 900;
}

.dashboard-section {
  display: none;
}

.dashboard-section.active {
  display: grid;
}

section.dashboard-section.active {
  display: block;
}

.quick-add-panel {
  display: none;
  margin-bottom: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: viewIn 220ms ease;
}

.quick-add-panel.open {
  display: block;
}

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

.quick-add-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
}

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

.mini-form {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  display: grid;
  gap: 10px;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.7fr repeat(3, minmax(150px, 0.6fr));
  gap: 16px;
  margin-bottom: 16px;
}

.hero-panel,
.metric-card,
.panel,
.subject-card,
.task-card,
.friend-card,
.day-column {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel {
  min-height: 210px;
  padding: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  background:
    linear-gradient(135deg, rgba(49, 94, 251, 0.16), rgba(24, 182, 168, 0.1)),
    var(--surface);
}

.hero-panel h2 {
  max-width: 680px;
  margin: 6px 0 10px;
  font-size: clamp(28px, 4vw, 54px);
  line-height: 1;
}

.hero-panel p:last-child {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.metric-card {
  padding: 20px;
  min-height: 150px;
  display: grid;
  align-content: space-between;
}

.metric-card strong {
  font-size: 48px;
  line-height: 1;
}

.content-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.content-grid.two,
.split-layout,
.profile-layout {
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.4fr);
}

.command-grid {
  grid-template-columns: 1.2fr 0.85fr 0.85fr;
}

.panel {
  padding: 20px;
  margin-bottom: 16px;
}

.panel h3 {
  margin: 0 0 16px;
  font-size: 20px;
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
}

.task-list,
.subject-progress-list,
.planner-list,
.challenge-list,
.activity-list,
.focus-timeline,
.risk-list,
.load-bars {
  display: grid;
  gap: 10px;
}

.focus-item,
.risk-item,
.load-item {
  padding: 13px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.focus-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.focus-step {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: white;
  font-weight: 900;
  background: var(--subject-color, var(--primary));
}

.risk-item {
  display: grid;
  gap: 8px;
}

.risk-top,
.load-top,
.toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.risk-score {
  padding: 5px 10px;
  border-radius: 999px;
  color: white;
  background: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.load-bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(120, 134, 160, 0.18);
  overflow: hidden;
}

.load-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.task-list.spacious {
  gap: 12px;
}

.task-card {
  position: relative;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  box-shadow: none;
}

.task-dot {
  width: 12px;
  height: 44px;
  border-radius: 99px;
  background: var(--subject-color, var(--primary));
}

.task-main strong,
.subject-card strong {
  display: block;
}

.task-meta,
.grade-row,
.friend-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.task-actions {
  display: flex;
  gap: 8px;
}

.round-action {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  color: var(--text);
  background: rgba(120, 134, 160, 0.14);
}

.round-action.done {
  color: white;
  background: var(--primary-2);
}

.subject-row {
  display: grid;
  gap: 8px;
}

.subject-row-top,
.subject-row-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.badges,
.subject-grid,
.friends-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.badge {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  opacity: 0.48;
}

.badge.unlocked {
  opacity: 1;
  box-shadow: 0 12px 28px rgba(24, 182, 168, 0.14);
}

.badge-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  margin-bottom: 10px;
}

.reward-head-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.reward-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.reward-summary > div:not(.reward-summary-progress) {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.reward-summary span,
.reward-level span {
  color: var(--muted);
  font-size: .75rem;
}

.reward-summary-progress {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(120, 134, 160, .18);
}

.reward-summary-progress span,
.badge-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width .7s cubic-bezier(.2,.8,.2,1);
}

.reward-level-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(150px, 180px);
  gap: 12px;
  overflow-x: auto;
  padding: 18px 8px 24px;
  scroll-snap-type: x mandatory;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
}

.reward-level {
  position: relative;
  display: grid;
  min-height: 178px;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  text-align: center;
  scroll-snap-align: center;
  background: var(--surface-strong);
  transition: transform .25s ease, opacity .25s ease, border-color .25s ease;
}

.reward-level::after {
  content: "";
  position: absolute;
  inset: auto -35% -65% -35%;
  height: 120px;
  background: radial-gradient(circle, var(--accent-glow), transparent 66%);
}

.reward-level:hover {
  transform: translateY(-6px) scale(1.015);
}

.reward-level.locked {
  opacity: .48;
  filter: grayscale(.7);
}

.reward-level.current {
  border-color: var(--primary);
  box-shadow: 0 14px 38px var(--accent-glow);
  animation: rewardCurrentPulse 2.4s ease-in-out infinite;
}

.reward-level-orb {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border-radius: 19px;
  color: white;
  font-size: 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px var(--accent-glow);
}

.reward-level.locked .reward-level-orb {
  color: var(--muted);
  background: rgba(120, 134, 160, .17);
  box-shadow: none;
}

.reward-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin: 8px 0 10px;
}

.reward-section-title h4 {
  margin: 0;
}

.badges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.badge {
  position: relative;
  overflow: hidden;
  transition: transform .25s ease, box-shadow .25s ease;
}

.badge.unlocked:hover {
  transform: translateY(-5px);
}

.badge.unlocked .badge-icon {
  animation: rewardBadgeFloat 2.8s ease-in-out infinite;
}

.badge-progress {
  height: 5px;
  margin-top: 11px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(120, 134, 160, .18);
}

@keyframes rewardCurrentPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 12px 30px var(--accent-glow); }
  50% { transform: translateY(-5px); box-shadow: 0 20px 46px var(--accent-glow); }
}

@keyframes rewardBadgeFloat {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-4px) rotate(3deg); }
}

@media (max-width: 620px) {
  .reward-summary {
    grid-template-columns: 1fr;
  }

  .reward-summary-progress {
    grid-column: auto;
  }

  .reward-level-track {
    grid-auto-columns: minmax(145px, 72vw);
  }
}

/* Subject-style XP layout: overview left, work area right */
.reward-workspace {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  grid-template-areas: "side main";
  gap: 14px;
  align-items: start;
}

.reward-main,
.reward-side {
  min-width: 0;
}

.reward-main {
  grid-area: main;
}

.reward-level-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reward-level-head h4,
.reward-side h4 {
  margin: 0;
}

.reward-level-head small {
  color: var(--muted);
}

.reward-side {
  grid-area: side;
  position: sticky;
  top: 0;
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(120, 134, 160, .06);
}

.reward-side .reward-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin: 0;
}

.reward-side .reward-summary > div:not(.reward-summary-progress) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  padding: 7px 9px;
}

.reward-side .reward-summary-progress {
  grid-column: auto;
  margin: 2px 0 4px;
}

.reward-tip {
  display: grid;
  gap: 3px;
  padding: 10px;
  border-radius: 12px;
  color: var(--text);
  background: var(--accent-glow);
}

.reward-tip small {
  color: var(--muted);
  line-height: 1.4;
}

.reward-mission-list {
  display: grid;
  gap: 7px;
}

.reward-mission {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  min-height: 62px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  transition: border-color .2s ease, transform .2s ease;
}

.reward-mission:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  transform: translateX(3px);
}

.reward-mission-xp {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 11px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.reward-mission-xp small {
  color: inherit;
  font-size: .58rem;
}

.reward-mission-body {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.reward-mission-body small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reward-mission-action {
  padding: 8px 11px;
}

.reward-main .reward-level-track {
  grid-auto-columns: 100px;
  padding: 7px 3px 10px;
}

.reward-main .reward-level {
  min-height: 96px;
  padding: 7px;
  border-radius: 13px;
}

.reward-main .reward-level-orb {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 15px;
}

.reward-main .reward-level span {
  display: none;
}

@media (max-width: 820px) {
  .reward-workspace {
    grid-template-columns: 1fr;
    grid-template-areas: "side" "main";
  }

  .reward-side {
    position: static;
  }

  .reward-side .reward-summary {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .reward-side .reward-summary > div:not(.reward-summary-progress) {
    display: grid;
    justify-content: start;
  }

  .reward-side .reward-summary-progress {
    grid-column: 1 / -1;
  }

  .reward-tip {
    display: none;
  }
}

@media (max-width: 560px) {
  .reward-side .reward-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .reward-mission {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .reward-mission-action {
    grid-column: 1 / -1;
  }
}

/* Reward section frame */
#dashboardView [data-dashboard-section="rewards"] {
  padding: 14px;
  overflow: hidden;
}

#dashboardView [data-dashboard-section="rewards"] .panel-head {
  margin-bottom: 4px;
}

.badge-progress {
  margin-top: 7px;
  height: 4px;
}

@media (max-width: 620px) {
  #dashboardView [data-dashboard-section="rewards"] {
    padding: 10px;
  }

}

.split-layout,
.profile-layout {
  display: grid;
  gap: 16px;
  align-items: start;
}

.form-stack {
  display: grid;
  gap: 12px;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 94, 251, 0.12);
}

.form-row {
  gap: 10px;
}

.color-row {
  gap: 10px;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
}

.swatch.selected {
  border-color: var(--text);
}

.subject-card {
  padding: 18px;
  box-shadow: none;
  display: grid;
  gap: 14px;
}

.subject-card.selected {
  outline: 3px solid color-mix(in srgb, var(--subject-color) 45%, transparent);
}

.subject-detail {
  margin-top: 16px;
}

.subject-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.subject-detail-grid div {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-strong);
}

.subject-detail-grid strong {
  display: block;
  font-size: 26px;
}

.subject-card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.subject-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 900;
  border-radius: 17px;
  background: var(--subject-color);
}

.task-form {
  display: grid;
  grid-template-columns: minmax(210px, 2fr) repeat(5, minmax(120px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 16px;
}

.toolbar-row {
  margin-bottom: 12px;
}

.task-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.board-column {
  min-height: 220px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(120, 134, 160, 0.1);
}

.board-column h4 {
  margin: 0 0 12px;
}

.board-stack {
  display: grid;
  gap: 8px;
}

.board-task {
  padding: 11px;
  border-radius: 16px;
  border-left: 5px solid var(--subject-color, var(--primary));
  background: var(--surface-strong);
}

.board-task strong {
  display: block;
  margin-bottom: 4px;
}

.segmented {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(120, 134, 160, 0.14);
}

.segmented button {
  min-height: 32px;
  border: 0;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: var(--text);
  background: var(--surface-strong);
}

.soft-badge {
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--muted);
  background: rgba(120, 134, 160, 0.14);
  white-space: nowrap;
}

.grades-table {
  display: grid;
  gap: 10px;
}

.grade-card,
.planner-card,
.challenge-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 12px;
}

.calendar-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.calendar-pill {
  min-height: 58px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  display: grid;
  align-content: center;
  gap: 4px;
}

.calendar-pill.hot {
  color: white;
  background: linear-gradient(135deg, var(--danger), #f7b731);
}

.day-column {
  min-height: 380px;
  padding: 14px;
  box-shadow: none;
}

.day-column h4 {
  margin: 0 0 10px;
}

.grades-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.grades-list-panel {
  position: sticky;
  top: 0;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

.grades-side-stack {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.grades-side-stack .panel {
  margin: 0;
}

.calendar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-controls select {
  width: auto;
  min-width: 140px;
}

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

.day-column.day-empty {
  min-height: 170px;
  opacity: .76;
}

.empty-state.compact {
  min-height: 64px;
  padding: 12px;
}

.day-tasks {
  display: grid;
  gap: 8px;
}

.tiny-task {
  padding: 10px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(120, 134, 160, 0.14);
  border-left: 4px solid var(--subject-color, var(--primary));
}

.privacy-box {
  margin-top: 18px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(120, 134, 160, 0.12);
  display: grid;
  gap: 10px;
}

.privacy-box h4 {
  margin: 0;
}

.privacy-box label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.privacy-box input {
  width: 18px;
  min-height: 18px;
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  color: var(--text);
  background: var(--surface-strong);
  outline: none;
  font: inherit;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(49, 94, 251, 0.12);
}

.friend-card {
  padding: 18px;
  box-shadow: none;
  display: grid;
  gap: 12px;
}

.friend-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.friend-head img {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.profile-panel {
  display: grid;
  gap: 18px;
}

.profile-panel img {
  width: 118px;
  height: 118px;
  border-radius: 34px;
}

.stats-grid div {
  min-height: 130px;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface-strong);
  display: grid;
  align-content: center;
  gap: 6px;
}

.stats-grid strong {
  font-size: 42px;
}

.stats-grid span {
  color: var(--muted);
}

.stats-grid.compact div {
  min-height: 104px;
}

.stats-grid.compact strong {
  font-size: 26px;
}

.activity-item {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.data-tools {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.import-label {
  display: inline-flex;
  align-items: center;
}

.import-label input {
  display: none;
}

.ghost-btn.danger {
  color: var(--danger);
}

.cloud-status {
  font-weight: 800;
}

.cloud-status.online {
  color: #087f5b;
  background: rgba(32, 201, 151, 0.18);
}

.cloud-status.syncing {
  color: var(--primary);
  background: rgba(49, 94, 251, 0.14);
}

.cloud-status.offline {
  color: var(--muted);
}

.empty-state {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 22px;
  display: grid;
  gap: 6px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 120px);
  padding: 14px 18px;
  border-radius: 999px;
  color: white;
  background: #151927;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
  z-index: 20;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 4px;
  background: var(--confetti-color);
  animation: confettiFall 900ms ease-in forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(105vh) rotate(420deg);
    opacity: 0;
  }
}

.focus-overlay {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(8, 11, 18, 0.62);
  backdrop-filter: blur(18px);
}

.focus-overlay.open {
  display: grid;
}

.auth-overlay,
.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(8, 11, 18, 0.58);
  backdrop-filter: blur(18px);
}

.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 27;
  display: none;
  pointer-events: none;
  padding: 22px;
  background: rgba(8, 11, 18, 0.12);
  backdrop-filter: none;
}

.tour-overlay.open {
  display: block;
}

.tour-card {
  position: absolute;
  right: 24px;
  bottom: 24px;
  z-index: 34;
  pointer-events: auto;
  width: min(520px, 100%);
  padding: 26px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.26);
}

.tour-overlay[data-placement="top"] .tour-card {
  top: 24px;
  bottom: auto;
}

.tour-example {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 14px;
  color: var(--text);
  background: rgba(49, 94, 251, 0.1);
  border-left: 4px solid var(--primary);
}

.tour-target {
  position: relative;
  z-index: auto !important;
  outline: 4px solid var(--primary);
  outline-offset: 6px;
  border-radius: 18px;
  animation: tourPulse 1.4s ease-in-out infinite;
}

@keyframes tourPulse {
  50% { outline-color: var(--primary-2); outline-offset: 10px; }
}

.tour-card h2 {
  margin: 8px 0;
  font-size: 32px;
}

.tour-card p {
  color: var(--muted);
}

.tour-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.search-results,
.admin-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 18px;
}

.user-result,
.admin-user,
.chat-message {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
}

.user-result {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.user-result img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.chat-box {
  min-height: 340px;
  max-height: 48vh;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(120, 134, 160, 0.08);
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-message.mine {
  margin-left: 18%;
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.chat-message.failed {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 18%, var(--surface-strong));
}

.chat-delivery {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  opacity: 0.78;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 10px;
}

.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-bottom: 8px;
}

.chat-image-preview {
  position: relative;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

.chat-image-preview img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 9px;
  vertical-align: middle;
  margin-right: 8px;
}

.chat-message {
  position: relative;
  max-width: 84%;
  justify-self: start;
  overflow-wrap: anywhere;
}

.chat-message.mine {
  justify-self: end;
  margin-left: 0;
}

.chat-image {
  display: block;
  width: min(100%, 360px);
  max-height: 360px;
  margin-top: 7px;
  object-fit: contain;
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.12);
}

.chat-message-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 5px;
  font-size: 0.69rem;
  opacity: 0.75;
}

.chat-delete-btn {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.friend-card {
  position: relative;
}

.friend-head {
  cursor: pointer;
}

.unread-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  min-width: 23px;
  height: 23px;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: white;
  background: var(--danger);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--danger) 45%, transparent);
}

.friend-card.has-unread {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
}

.friend-chat-preview {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}

.friend-chat-preview span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(8, 11, 18, 0.68);
}

.profile-preview-overlay.open {
  display: grid;
}

.profile-preview-card {
  position: relative;
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  text-align: center;
  background: var(--surface-strong);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.32);
}

.profile-preview-card > img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 50%;
}

.profile-preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.profile-center {
  display: grid;
  grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 1320px;
  margin: 0 auto;
}

.profile-hero {
  position: sticky;
  top: 0;
  overflow: hidden;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.profile-cover {
  height: 96px;
  background:
    radial-gradient(circle at 78% 30%, rgba(255,255,255,.3), transparent 24%),
    linear-gradient(125deg, var(--primary), var(--primary-2));
}

.profile-identity {
  display: grid;
  justify-items: center;
  gap: 9px;
  padding: 0 18px;
  text-align: center;
  transform: translateY(-38px);
}

.profile-identity img {
  width: 104px;
  height: 104px;
  border: 5px solid var(--surface-strong);
  border-radius: 28px;
  object-fit: cover;
  background: var(--surface-strong);
}

.profile-identity h2,
.settings-head h3 {
  margin: 0;
}

.profile-identity span {
  color: var(--muted);
}

.profile-quick-stats {
  position: static;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: -20px 14px 14px;
}

.profile-quick-stats div {
  display: grid;
  gap: 1px;
  padding: 9px 12px;
  border-radius: 12px;
  text-align: center;
  background: rgba(120, 134, 160, 0.11);
}

.profile-quick-stats span {
  color: var(--muted);
  font-size: .72rem;
}

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

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.profile-public-card,
.settings-data-card {
  grid-column: 1 / -1;
}

.settings-head,
.settings-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.settings-form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

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

.toggle-setting {
  display: flex !important;
  align-items: center;
  grid-column: 1 / -1;
}

.toggle-setting input,
.settings-toggles input {
  width: 19px;
  min-height: 19px;
}

.settings-toggles {
  display: grid;
  gap: 7px;
}

.settings-toggles label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(120, 134, 160, .07);
}

.settings-toggles span {
  display: grid;
  gap: 2px;
}

.settings-toggles small,
.settings-save-row small {
  color: var(--muted);
}

[data-density="compact"] .panel,
[data-density="compact"] .settings-card {
  padding: 12px;
}

[data-density="compact"] .main {
  padding: 12px;
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: .001ms !important;
  transition-duration: .001ms !important;
}

@media (max-width: 850px) {
  .profile-center {
    grid-template-columns: 1fr;
  }

  .profile-settings-grid,
  .settings-form-grid {
    grid-template-columns: 1fr;
  }

  .profile-public-card,
  .settings-data-card,
  .settings-span {
    grid-column: auto;
  }

  .profile-hero {
    position: static;
    min-height: 0;
    padding-bottom: 14px;
  }

  .profile-quick-stats {
    grid-template-columns: repeat(4, 1fr);
    margin: -20px 14px 0;
  }
}

@media (max-width: 520px) {
  .profile-identity {
    align-items: center;
    padding: 0 14px;
  }

  .profile-identity img {
    width: 82px;
    height: 82px;
  }

  .profile-quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-head,
  .settings-save-row {
    align-items: stretch;
    flex-direction: column;
  }
}

.profile-card-main {
  display: grid;
  gap: 4px;
}

.profile-card-main strong {
  font-size: 24px;
}

.profile-card-main span {
  color: var(--muted);
}

.nav-item.admin-only,
.admin-only {
  display: none !important;
}

.admin-enabled .nav-item.admin-only,
.admin-enabled .admin-only {
  display: flex !important;
}

.relationship-list,
.relationship-actions,
.friend-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.relationship-list {
  display: grid;
  margin: 10px 0 18px;
}

.relationship-actions {
  justify-content: flex-end;
}

.friend-actions {
  margin-top: 14px;
}

.social-subhead {
  margin-top: 18px;
}

.social-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 0.9fr) minmax(360px, 1.2fr);
  gap: 14px;
  height: calc(100vh - 112px);
  min-height: 520px;
}

.social-column {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.social-friends-list {
  grid-template-columns: 1fr;
}

.social-chat-panel {
  display: flex;
  flex-direction: column;
}

.social-chat-panel .chat-box {
  flex: 1;
  min-height: 260px;
  max-height: none;
}

.auth-overlay.open {
  display: grid;
}

.setup-overlay.open {
  display: grid;
}

.setup-card {
  width: min(620px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.3);
}

.setup-progress {
  height: 7px;
  margin-bottom: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(120, 134, 160, 0.18);
}

.setup-progress div {
  height: 100%;
  width: 33.333%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 180ms ease;
}

.setup-step {
  display: none;
  gap: 14px;
}

.setup-step.active {
  display: grid;
}

.setup-step h2 {
  margin: 4px 0 0;
  font-size: 30px;
}

.setup-step p {
  margin: 0 0 8px;
  color: var(--muted);
}

.setup-step label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

.setup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

#setupError {
  display: block;
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger, #d63c4a);
}

.setup-summary {
  padding: 18px;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 800;
  background: rgba(24, 182, 168, 0.12);
}

.guest-session [data-view="social"],
.guest-session #socialView {
  display: none !important;
}

.auth-card {
  position: relative;
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface-strong);
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.26);
  display: grid;
  gap: 18px;
}

.auth-close {
  position: absolute;
  right: 16px;
  top: 16px;
}

.auth-brand {
  padding-right: 42px;
}

.auth-copy h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.auth-copy p {
  margin: 0;
  color: var(--muted);
}

.auth-actions,
.auth-session {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-tabs {
  width: fit-content;
}

.auth-card[data-mode="login"] .register-only {
  display: none;
}

.auth-card[data-mode="register"] .login-only {
  display: none;
}

.auth-session {
  justify-content: space-between;
  padding: 12px;
  border-radius: 18px;
  background: rgba(120, 134, 160, 0.12);
}

.focus-card {
  position: relative;
  width: min(620px, 100%);
  padding: 30px;
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: white;
  background:
    linear-gradient(135deg, rgba(49, 94, 251, 0.88), rgba(24, 182, 168, 0.86)),
    #121826;
  box-shadow: 0 34px 90px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.focus-card .eyebrow,
.focus-mini-meta {
  color: rgba(255, 255, 255, 0.76);
}

.focus-card h2 {
  margin: 8px 0 18px;
  font-size: 32px;
}

.focus-timer {
  font-size: clamp(64px, 12vw, 116px);
  line-height: 1;
  font-weight: 900;
  margin: 18px 0;
}

.focus-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.focus-close {
  position: absolute;
  right: 18px;
  top: 18px;
  color: white;
  background: rgba(255, 255, 255, 0.18);
}

.celebrate {
  animation: celebrate 520ms ease;
}

@keyframes celebrate {
  45% {
    transform: scale(1.04) rotate(-1deg);
  }
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .task-form,
  .week-grid,
  .command-grid,
  .quick-add-grid,
  .task-board,
  .share-grid,
  .momentum-ring,
  .calendar-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

#dashboardView .dashboard-section:not(.active) {
  display: none !important;
}

#dashboardView .content-grid.dashboard-section.active {
  display: grid !important;
}

#dashboardView section.dashboard-section.active {
  display: flex !important;
}

@media (max-width: 850px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .nav-item {
    justify-content: center;
    padding: 0 8px;
  }

  .nav-item span {
    display: none;
  }

  .main {
    padding: 18px;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .topbar,
  .hero-panel,
  .content-grid.two,
  .split-layout,
  .profile-layout,
  .dashboard-grid,
  .task-form,
  .week-grid,
  .command-grid,
  .quick-add-grid,
  .task-board,
  .share-grid,
  .momentum-ring,
  .calendar-strip,
  .subject-detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .hero-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .top-actions > * {
    flex: 0 0 auto;
  }

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

  .relationship-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .relationship-actions button {
    flex: 1 1 auto;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  button,
  .ghost-btn,
  .primary-btn {
    min-height: 44px;
  }

  .tour-card {
    right: 12px;
    bottom: 12px;
    width: calc(100% - 24px);
    padding: 20px;
  }
}

/* Product UI refresh: workspace layout, less page-scroll, stronger hierarchy. */
body {
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  padding: 20px 14px;
  gap: 18px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}

.brand strong {
  font-size: 18px;
}

.nav {
  gap: 5px;
}

.nav-item {
  min-height: 42px;
  border-radius: 14px;
  font-weight: 700;
}

.nav-item span {
  width: 26px;
  height: 26px;
  border-radius: 10px;
}

.main {
  height: 100vh;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  min-height: 64px;
  margin-bottom: 14px;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 30px;
}

.top-actions {
  gap: 8px;
}

.search-box {
  min-height: 40px;
}

.pill-btn,
.primary-btn,
.icon-btn,
.ghost-btn {
  min-height: 40px;
}

.icon-btn {
  width: 40px;
  height: 40px;
}

.view.active {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 2px 4px 28px 0;
}

#dashboardView.view.active {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) repeat(3, minmax(118px, 150px));
  gap: 10px;
  margin-bottom: 10px;
}

.hero-panel {
  min-height: 136px;
  padding: 18px;
  align-items: center;
  border-radius: 20px;
}

.hero-panel h2 {
  font-size: clamp(24px, 2.4vw, 34px);
  line-height: 1.06;
  margin: 4px 0 6px;
}

.hero-panel p:last-child {
  font-size: 14px;
}

.metric-card {
  min-height: 136px;
  padding: 16px;
  border-radius: 20px;
  box-shadow: none;
}

.metric-card strong {
  font-size: 34px;
}

.dashboard-tabs {
  margin: 0 0 10px;
  padding: 5px;
  border: 1px solid var(--line);
  background: var(--surface);
  flex-wrap: wrap;
}

.dashboard-section.active {
  min-height: 0;
  height: 100%;
}

.content-grid.two.dashboard-section.active {
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
}

.command-grid.dashboard-section.active {
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr) minmax(260px, 0.8fr);
}

.panel {
  min-height: 0;
  margin-bottom: 0;
  padding: 16px;
  border-radius: 20px;
  box-shadow: none;
}

.panel h3 {
  font-size: 17px;
}

.panel-head {
  margin-bottom: 12px;
}

.dashboard-section.active .panel {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dashboard-section.active .task-list,
.dashboard-section.active .subject-progress-list,
.dashboard-section.active .focus-timeline,
.dashboard-section.active .risk-list,
.dashboard-section.active .load-bars,
.dashboard-section.active .activity-list,
.dashboard-section.active .insight-list,
.dashboard-section.active .badges {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

.task-card,
.focus-item,
.risk-item,
.load-item,
.insight-card,
.grade-card,
.planner-card,
.challenge-card,
.activity-item {
  border-radius: 14px;
  box-shadow: none;
}

.task-card {
  grid-template-columns: 8px 1fr auto;
  padding: 12px;
}

.task-dot {
  width: 8px;
  height: 38px;
}

.task-actions {
  gap: 5px;
}

.round-action {
  width: 34px;
  height: 34px;
}

.quick-add-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 24;
  width: min(460px, 100vw);
  height: 100vh;
  margin: 0;
  border-radius: 28px 0 0 28px;
  border-width: 0 0 0 1px;
  transform: translateX(104%);
  transition: transform 220ms ease;
  overflow: auto;
}

.quick-add-panel.open {
  display: block;
  transform: translateX(0);
}

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

.quick-add-head h2 {
  font-size: 22px;
}

.split-layout,
.profile-layout,
.content-grid.two {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  align-items: stretch;
}

#subjectsView .split-layout,
#gradesView .content-grid.two,
#socialView .content-grid.two,
#profileView .profile-layout {
  min-height: 100%;
}

.form-panel,
#gradesView .content-grid.two > .panel:first-child,
#socialView .content-grid.two > .panel:first-child,
#profileView .profile-panel {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

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

.subject-card {
  padding: 14px;
  border-radius: 18px;
}

.subject-detail {
  margin-top: 12px;
}

#tasksView > .panel,
#calendarView > .panel,
#socialView > .panel {
  min-height: 100%;
}

.task-form {
  grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(120px, 1fr)) auto;
}

.task-form input[name="effort"],
.task-form select[name="priority"] {
  min-width: 0;
}

.task-board {
  min-height: 280px;
}

.board-column {
  min-height: 260px;
  border-radius: 18px;
}

.task-list.spacious {
  max-height: 36vh;
  overflow: auto;
  padding-right: 4px;
}

.week-grid {
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  overflow: auto;
}

.day-column {
  min-height: calc(100vh - 260px);
}

.calendar-strip {
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  overflow: auto;
}

.level-card {
  padding: 14px;
  border-radius: 18px;
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell,
  .main {
    height: auto;
    overflow: visible;
  }

  .view.active,
  #dashboardView.view.active {
    overflow: visible;
    display: block;
  }

  .dashboard-grid,
  .content-grid.two.dashboard-section.active,
  .command-grid.dashboard-section.active,
  .split-layout,
  .profile-layout,
  .content-grid.two {
    grid-template-columns: 1fr;
  }

  .dashboard-section.active .panel {
    height: auto;
  }

  .form-panel,
  #gradesView .content-grid.two > .panel:first-child,
  #socialView .content-grid.two > .panel:first-child,
  #profileView .profile-panel {
    position: static;
    max-height: none;
  }

  .social-workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }

  .social-chat-panel {
    grid-column: 1 / -1;
  }

  .social-column {
    overflow: visible;
  }
}

@media (max-width: 760px) {
  .social-workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .social-chat-panel {
    grid-column: auto;
  }
}

/* Compact workspace density */
.app-shell {
  grid-template-columns: 220px minmax(0, 1fr);
}

.sidebar {
  padding: 12px 10px;
  gap: 10px;
}

.sidebar .brand {
  padding: 2px 6px 8px;
}

.nav-item {
  min-height: 36px;
  padding: 6px 9px;
  border-radius: 10px;
  font-size: 14px;
}

.nav-item span {
  width: 23px;
  height: 23px;
}

.level-card {
  padding: 10px;
}

.main {
  padding: 10px 14px;
}

.topbar {
  min-height: 58px;
  margin-bottom: 10px;
}

.topbar h1 {
  font-size: 24px;
}

.top-actions {
  gap: 6px;
}

.top-actions .ghost-btn,
.top-actions .pill-btn {
  padding: 8px 10px;
}

.panel {
  padding: 13px;
  border-radius: 16px;
}

.panel h3 {
  margin: 0;
  font-size: 16px;
}

.content-grid,
.dashboard-grid,
.command-grid {
  gap: 10px;
}

input,
select,
textarea {
  padding: 9px 10px;
}

.form-stack,
.mini-form {
  gap: 9px;
}

.metric-card,
.planner-card,
.friend-card,
.task-card {
  padding: 11px;
  border-radius: 14px;
}

.social-workspace {
  grid-template-columns: minmax(245px, 0.8fr) minmax(245px, 0.8fr) minmax(320px, 1.25fr);
  gap: 10px;
  height: calc(100vh - 82px);
  min-height: 480px;
}

.social-column {
  padding: 12px;
}

.search-results,
.admin-list,
.relationship-list {
  gap: 7px;
  margin: 8px 0 12px;
}

.user-result {
  padding: 9px;
  border-radius: 12px;
}

.social-notifications {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.social-notification {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--text);
  background: rgba(24, 182, 168, 0.12);
}

.chat-box {
  padding: 9px;
  border-radius: 12px;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 190px minmax(0, 1fr);
  }

  .social-workspace {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
  }
}

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

  .main {
    padding: 10px;
  }
}

/* Grades and long-range plan layout fixes. */
#gradesView .grades-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 100%;
}

#gradesView .grades-list-panel {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: calc(100vh - 112px);
  overflow: auto;
}

#gradesView .grades-side-stack {
  min-width: 0;
  display: grid;
  gap: 12px;
}

#gradesView .grades-side-stack .panel {
  margin: 0;
}

#calendarView .panel-head {
  align-items: flex-start;
}

#calendarView .calendar-controls {
  margin-left: auto;
}

#calendarView .week-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  overflow: visible;
}

#calendarView .day-column {
  min-height: 170px;
}

@media (max-width: 1180px) {
  #gradesView .grades-workspace {
    grid-template-columns: 1fr;
  }

  #gradesView .grades-list-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  #calendarView .calendar-controls {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }
}

/* Final workspace sizing: keep page scroll locked on desktop and scroll only dense lists. */
@media (min-width: 821px) {
  html,
  body,
  .app-shell {
    height: 100vh;
    overflow: hidden;
  }

  .main {
    height: 100vh;
    min-height: 0;
    overflow: hidden;
  }

  .view.active {
    min-height: 0;
    overflow: hidden;
  }

  #subjectsView.view.active,
  #tasksView.view.active,
  #gradesView.view.active,
  #calendarView.view.active,
  #profileView.view.active {
    overflow: auto;
  }

  #dashboardView.view.active,
  #socialView.view.active,
  #adminView.view.active,
  #genaiView.view.active {
    overflow: hidden;
  }
}

/* Rewards */
#dashboardView.view.active {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

#dashboardView .dashboard-section.active {
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#dashboardView .content-grid.dashboard-section.active,
#dashboardView .content-grid.two.dashboard-section.active,
#dashboardView .command-grid.dashboard-section.active {
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

#dashboardView .dashboard-section.active > .panel,
#dashboardView .dashboard-section.active .panel {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#dashboardView .dashboard-section.active .panel-head {
  flex: 0 0 auto;
}

#dashboardView .dashboard-section.active .task-list,
#dashboardView .dashboard-section.active .subject-progress-list,
#dashboardView .dashboard-section.active .focus-timeline,
#dashboardView .dashboard-section.active .risk-list,
#dashboardView .dashboard-section.active .load-bars,
#dashboardView .dashboard-section.active .activity-list,
#dashboardView .dashboard-section.active .insight-list,
#dashboardView .dashboard-section.active .planner-list,
#dashboardView .dashboard-section.active .stats-grid,
#dashboardView .dashboard-section.active .momentum-ring {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

#dashboardView .dashboard-section.active .stats-grid {
  align-content: start;
}

#dashboardView .momentum-ring {
  grid-template-columns: minmax(116px, 140px) minmax(0, 1fr);
}

#dashboardView .ring {
  background: conic-gradient(var(--primary) var(--progress, var(--ring, 0%)), var(--line) 0);
}

#dashboardView [data-dashboard-section="rewards"].active {
  height: 100%;
  min-height: 0;
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#dashboardView [data-dashboard-section="rewards"] > .panel-head {
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 12px;
}

#dashboardView [data-dashboard-section="rewards"] > .panel-head > div {
  min-width: 0;
}

#dashboardView [data-dashboard-section="rewards"] > .panel-head h3 {
  margin: 0;
  font-size: 22px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  grid-template-areas: "side main";
  gap: 16px;
  align-items: stretch;
}

#dashboardView [data-dashboard-section="rewards"] .reward-main,
#dashboardView [data-dashboard-section="rewards"] .reward-side {
  min-height: 0;
  overflow: hidden;
  border-radius: 16px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-level-head,
#dashboardView [data-dashboard-section="rewards"] .reward-section-title {
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}

#dashboardView [data-dashboard-section="rewards"] .reward-level-track {
  flex: 0 0 auto;
  grid-auto-columns: minmax(170px, 220px);
  padding-bottom: 8px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-main .reward-level {
  min-height: 118px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-mission-list {
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-side h4 {
  margin: 0;
  font-size: 18px;
}

#dashboardView [data-dashboard-section="rewards"] .reward-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Admin */
#adminView.view.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#adminView .admin-metrics,
#adminView .admin-operations-grid {
  flex: 0 0 auto;
}

#adminView .admin-operations-grid {
  margin: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#adminView .admin-workspace {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
  gap: 12px;
  align-items: stretch;
}

#adminView .admin-users-panel,
#adminView .admin-side-stack > .panel {
  min-height: 0;
  overflow: hidden;
}

#adminView .admin-users-panel {
  display: flex;
  flex-direction: column;
}

#adminView .admin-search {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

#adminView .admin-list {
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
}

#adminView .admin-side-stack {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(120px, .75fr) minmax(160px, 1fr);
  gap: 12px;
}

#adminView .admin-announcement-list,
#adminView .admin-audit-list {
  min-height: 0;
  max-height: min(32vh, 320px);
  overflow: auto;
  padding-right: 4px;
}

#adminView .admin-audit-list {
  max-height: min(38vh, 390px);
}

#adminView .admin-user-row {
  grid-template-columns: minmax(180px, 1fr) minmax(170px, auto) auto;
}

@media (max-width: 1180px) and (min-width: 821px) {
  #dashboardView [data-dashboard-section="rewards"] .reward-workspace {
    grid-template-columns: 1fr;
    grid-template-areas: "side" "main";
    overflow: auto;
  }

  #adminView.view.active {
    overflow: auto;
  }

  #adminView .admin-workspace {
    grid-template-columns: 1fr;
  }
}

/* Messenger-style social view */
#socialView.view.active {
  height: calc(100dvh - 126px);
  overflow: hidden;
}

#socialView .social-workspace {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
}

#socialView .messenger-sidebar,
#socialView .messenger-chat-panel {
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

#socialView .messenger-sidebar {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 14px;
}

.messenger-head,
.messenger-chat-head,
.messenger-chat-identity,
.messenger-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.messenger-head,
.messenger-chat-head {
  justify-content: space-between;
}

.messenger-head h2,
.messenger-chat-head h3 {
  margin: 2px 0 0;
}

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

.messenger-stats button,
.messenger-settings-list button {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface-soft);
}

.messenger-stats button {
  min-height: 58px;
  display: grid;
  place-items: center;
  gap: 2px;
}

.messenger-stats strong {
  font-size: 18px;
}

.messenger-stats span,
.messenger-chat-copy span,
.group-chat-copy small,
.messenger-chat-side,
#chatPresenceLabel {
  color: var(--muted);
  font-size: 11px;
}

.messenger-search {
  min-height: 42px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.messenger-search input {
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

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

.messenger-tabs button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted-strong);
  background: transparent;
}

.messenger-tabs button.active {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  color: var(--primary);
  background: var(--primary-soft);
}

.messenger-list-stack,
#socialView .social-friends-list,
#socialView .group-chat-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  overflow: auto;
}

.messenger-list-stack {
  padding-right: 3px;
}

#socialView .messenger-chat-row {
  position: relative;
  width: 100%;
  min-height: 68px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  text-align: left;
  background: transparent;
  box-shadow: none;
}

#socialView .messenger-chat-row:hover,
#socialView .messenger-chat-row.active,
#socialView .messenger-chat-row:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
  background: var(--surface-soft);
  transform: none;
  outline: none;
}

#socialView .messenger-chat-row.has-unread {
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
}

.messenger-chat-row > img,
.group-chat-avatar,
.messenger-chat-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  object-fit: cover;
  color: var(--primary);
  background-color: var(--primary-soft);
  background-size: cover;
  background-position: center;
  font-weight: 900;
}

.messenger-chat-copy,
.group-chat-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.messenger-chat-copy strong,
.messenger-chat-copy span,
.group-chat-copy strong,
.group-chat-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messenger-chat-side {
  display: grid;
  justify-items: end;
  gap: 5px;
}

.unread-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-size: 11px;
}

.messenger-row-actions {
  grid-column: 1 / -1;
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.messenger-chat-row:hover .messenger-row-actions,
.messenger-chat-row:focus-within .messenger-row-actions {
  display: grid;
}

.messenger-drawer {
  position: absolute;
  inset: 10px;
  z-index: 20;
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.messenger-drawer[hidden] {
  display: none;
}

.messenger-drawer .relationship-list,
.messenger-drawer .search-results {
  min-height: 0;
  overflow: auto;
}

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

.messenger-settings-list button {
  min-height: 46px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

#socialView .messenger-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: 0;
}

#messengerListToggle {
  display: none;
}

.messenger-chat-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.messenger-chat-identity > div:last-child {
  min-width: 0;
}

.messenger-chat-identity h3,
.messenger-chat-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#socialView .chat-toolbar {
  margin: 0;
  flex-wrap: nowrap;
}

#socialView .chat-box {
  min-height: 0;
  max-height: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 72%, transparent), transparent 36%),
    var(--surface);
}

#socialView .chat-image-preview {
  margin: 8px 14px 0;
}

#socialView .messenger-compose {
  margin: 0;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
}

.profile-reward-showcase,
.profile-preview-rewards {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.profile-preview-card.reward-rare {
  border-color: color-mix(in srgb, #0ea5e9 42%, var(--line));
}

.profile-preview-card.reward-epic {
  border-color: color-mix(in srgb, #a855f7 52%, var(--line));
  box-shadow: 0 24px 80px color-mix(in srgb, #a855f7 18%, transparent);
}

.profile-preview-card.reward-legendary {
  border-color: color-mix(in srgb, #f59e0b 62%, var(--line));
  box-shadow: 0 26px 90px color-mix(in srgb, #f59e0b 20%, transparent);
}

.profile-preview-card.reward-mythic {
  border-color: color-mix(in srgb, #f43f5e 66%, var(--line));
  box-shadow: 0 30px 110px color-mix(in srgb, #f43f5e 20%, transparent), 0 0 0 1px color-mix(in srgb, var(--primary) 30%, transparent) inset;
}

.profile-preview-card.reward-rare #friendProfileAvatar,
.profile-preview-card.reward-epic #friendProfileAvatar,
.profile-preview-card.reward-legendary #friendProfileAvatar,
.profile-preview-card.reward-mythic #friendProfileAvatar {
  padding: 3px;
  border: 2px solid currentColor;
  color: var(--primary);
  background: var(--surface);
}

.profile-reward-showcase > span,
.profile-preview-rewards > strong {
  color: var(--primary);
  font-weight: 900;
}

.profile-reward-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-achievement-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 7px;
}

.reward-item-chip {
  min-height: 28px;
  padding: 5px 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 800;
}

.reward-item-chip.reward-rare,
.reward-level.reward-rare {
  border-color: color-mix(in srgb, #0ea5e9 48%, var(--line));
}

.reward-item-chip.reward-epic,
.reward-level.reward-epic {
  border-color: color-mix(in srgb, #a855f7 50%, var(--line));
}

.reward-item-chip.reward-legendary,
.reward-level.reward-legendary {
  border-color: color-mix(in srgb, #f59e0b 58%, var(--line));
  background: color-mix(in srgb, #f59e0b 10%, var(--surface));
}

.reward-item-chip.reward-mythic,
.reward-level.reward-mythic {
  border-color: color-mix(in srgb, #f43f5e 60%, var(--line));
  background: linear-gradient(135deg, color-mix(in srgb, #f43f5e 12%, var(--surface)), color-mix(in srgb, var(--primary) 12%, var(--surface)));
}

.reward-level em {
  margin-top: 4px;
  color: var(--primary);
  font-size: 11px;
  font-style: normal;
  font-weight: 850;
}

.achievement-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.achievement-card {
  padding: 10px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.achievement-card.unlocked {
  border-color: color-mix(in srgb, var(--success) 38%, var(--line));
  background: color-mix(in srgb, var(--success-soft) 55%, var(--surface));
}

.achievement-card.locked {
  opacity: .62;
}

.tiny-task-actions {
  margin-top: 7px;
  display: flex;
  gap: 5px;
}

.tiny-task-actions .round-action {
  width: 28px;
  height: 28px;
  min-height: 28px;
}

#tasksView .task-board {
  grid-template-columns: repeat(3, minmax(230px, 1fr)) !important;
  align-items: start;
  overflow-x: auto;
}

#tasksView .board-column {
  min-width: 230px;
  border-radius: 14px;
}

@media (max-width: 900px) {
  #socialView.view.active {
    height: auto;
    overflow: visible;
  }

  #socialView .social-workspace {
    height: auto;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  #socialView .messenger-sidebar {
    min-height: 520px;
  }

  #socialView .messenger-chat-panel {
    min-height: 70dvh;
  }

  .messenger-drawer {
    position: fixed;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px;
    max-height: min(76dvh, 620px);
  }
}
