/* ============================================================
   Nota10 NEXO — Calm Study Interface
   Paletas novas em oklch (3 propostas × dark/light)
   ============================================================ */

/* ---- PALETA 1: Indigo Ink (default) ---- */
[data-palette="indigo"][data-theme="dark"] {
  --bg: oklch(0.18 0.015 265);
  --surface-0: oklch(0.18 0.015 265);
  --surface-1: oklch(0.22 0.018 265);
  --surface-2: oklch(0.26 0.022 265);
  --surface-3: oklch(0.32 0.025 265);
  --text-1: oklch(0.96 0.005 265);
  --text-2: oklch(0.72 0.015 265);
  --text-3: oklch(0.52 0.015 265);
  --accent: oklch(0.74 0.14 260);
  --accent-soft: oklch(0.74 0.14 260 / 0.14);
  --accent-fg: oklch(0.18 0.02 265);
  --warm: oklch(0.82 0.12 70);
  --warm-soft: oklch(0.82 0.12 70 / 0.16);
  --success: oklch(0.78 0.14 155);
  --success-soft: oklch(0.78 0.14 155 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.74 0.14 260 / 0.45);
}

[data-palette="indigo"][data-theme="light"] {
  --bg: oklch(0.985 0.005 90);
  --surface-0: oklch(0.985 0.005 90);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.965 0.008 90);
  --surface-3: oklch(0.94 0.012 90);
  --text-1: oklch(0.22 0.02 265);
  --text-2: oklch(0.42 0.022 265);
  --text-3: oklch(0.58 0.018 265);
  --accent: oklch(0.48 0.16 265);
  --accent-soft: oklch(0.48 0.16 265 / 0.09);
  --accent-fg: oklch(0.99 0 0);
  --warm: oklch(0.58 0.14 55);
  --warm-soft: oklch(0.58 0.14 55 / 0.12);
  --success: oklch(0.52 0.13 155);
  --success-soft: oklch(0.52 0.13 155 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.48 0.16 265 / 0.3);
}

/* ---- PALETA 2: Sage Study ---- */
[data-palette="sage"][data-theme="dark"] {
  --bg: oklch(0.19 0.012 155);
  --surface-0: oklch(0.19 0.012 155);
  --surface-1: oklch(0.23 0.015 155);
  --surface-2: oklch(0.27 0.018 155);
  --surface-3: oklch(0.33 0.02 155);
  --text-1: oklch(0.96 0.008 100);
  --text-2: oklch(0.72 0.015 120);
  --text-3: oklch(0.52 0.015 120);
  --accent: oklch(0.78 0.11 150);
  --accent-soft: oklch(0.78 0.11 150 / 0.14);
  --accent-fg: oklch(0.19 0.015 155);
  --warm: oklch(0.76 0.13 40);
  --warm-soft: oklch(0.76 0.13 40 / 0.16);
  --success: oklch(0.78 0.14 150);
  --success-soft: oklch(0.78 0.14 150 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.78 0.11 150 / 0.4);
}

[data-palette="sage"][data-theme="light"] {
  --bg: oklch(0.975 0.008 110);
  --surface-0: oklch(0.975 0.008 110);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.955 0.012 110);
  --surface-3: oklch(0.93 0.015 110);
  --text-1: oklch(0.24 0.02 150);
  --text-2: oklch(0.44 0.022 150);
  --text-3: oklch(0.6 0.018 150);
  --accent: oklch(0.5 0.13 150);
  --accent-soft: oklch(0.5 0.13 150 / 0.1);
  --accent-fg: oklch(0.99 0 0);
  --warm: oklch(0.56 0.14 40);
  --warm-soft: oklch(0.56 0.14 40 / 0.12);
  --success: oklch(0.52 0.13 150);
  --success-soft: oklch(0.52 0.13 150 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.5 0.13 150 / 0.3);
}

/* ---- PALETA 3: Nexo Blue (refinada do original) ---- */
[data-palette="nexo"][data-theme="dark"] {
  --bg: oklch(0.17 0.02 240);
  --surface-0: oklch(0.17 0.02 240);
  --surface-1: oklch(0.21 0.025 240);
  --surface-2: oklch(0.25 0.028 240);
  --surface-3: oklch(0.31 0.03 240);
  --text-1: oklch(0.96 0.01 220);
  --text-2: oklch(0.72 0.018 220);
  --text-3: oklch(0.52 0.018 220);
  --accent: oklch(0.78 0.13 230);
  --accent-soft: oklch(0.78 0.13 230 / 0.14);
  --accent-fg: oklch(0.17 0.02 240);
  --warm: oklch(0.82 0.12 70);
  --warm-soft: oklch(0.82 0.12 70 / 0.16);
  --success: oklch(0.84 0.16 160);
  --success-soft: oklch(0.84 0.16 160 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.78 0.13 230 / 0.4);
}

[data-palette="nexo"][data-theme="light"] {
  --bg: oklch(0.98 0.008 230);
  --surface-0: oklch(0.98 0.008 230);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.96 0.012 230);
  --surface-3: oklch(0.93 0.015 230);
  --text-1: oklch(0.22 0.025 240);
  --text-2: oklch(0.42 0.025 240);
  --text-3: oklch(0.58 0.02 240);
  --accent: oklch(0.5 0.16 235);
  --accent-soft: oklch(0.5 0.16 235 / 0.09);
  --accent-fg: oklch(0.99 0 0);
  --warm: oklch(0.58 0.14 55);
  --warm-soft: oklch(0.58 0.14 55 / 0.12);
  --success: oklch(0.54 0.14 160);
  --success-soft: oklch(0.54 0.14 160 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.5 0.16 235 / 0.3);
}

/* ---- PALETA 4: Rose Garden ---- */
[data-palette="rose"][data-theme="dark"] {
  --bg: oklch(0.19 0.018 5);
  --surface-0: oklch(0.19 0.018 5);
  --surface-1: oklch(0.23 0.02 5);
  --surface-2: oklch(0.27 0.022 5);
  --surface-3: oklch(0.33 0.025 5);
  --text-1: oklch(0.96 0.01 5);
  --text-2: oklch(0.72 0.015 5);
  --text-3: oklch(0.52 0.015 5);
  --accent: oklch(0.76 0.15 355);
  --accent-soft: oklch(0.76 0.15 355 / 0.14);
  --accent-fg: oklch(0.19 0.018 5);
  --warm: oklch(0.82 0.14 45);
  --warm-soft: oklch(0.82 0.14 45 / 0.16);
  --success: oklch(0.84 0.16 160);
  --success-soft: oklch(0.84 0.16 160 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.76 0.15 355 / 0.4);
}

[data-palette="rose"][data-theme="light"] {
  --bg: oklch(0.985 0.006 0);
  --surface-0: oklch(0.985 0.006 0);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.97 0.01 5);
  --surface-3: oklch(0.94 0.014 5);
  --text-1: oklch(0.22 0.02 5);
  --text-2: oklch(0.42 0.02 5);
  --text-3: oklch(0.58 0.018 5);
  --accent: oklch(0.5 0.18 355);
  --accent-soft: oklch(0.5 0.18 355 / 0.09);
  --accent-fg: oklch(0.99 0 0);
  --warm: oklch(0.58 0.15 40);
  --warm-soft: oklch(0.58 0.15 40 / 0.12);
  --success: oklch(0.54 0.14 160);
  --success-soft: oklch(0.54 0.14 160 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.5 0.18 355 / 0.3);
}

/* ---- PALETA 5: Amber Dusk ---- */
[data-palette="amber"][data-theme="dark"] {
  --bg: oklch(0.19 0.02 60);
  --surface-0: oklch(0.19 0.02 60);
  --surface-1: oklch(0.23 0.025 60);
  --surface-2: oklch(0.27 0.028 60);
  --surface-3: oklch(0.33 0.032 60);
  --text-1: oklch(0.96 0.015 80);
  --text-2: oklch(0.72 0.018 80);
  --text-3: oklch(0.52 0.018 80);
  --accent: oklch(0.82 0.16 70);
  --accent-soft: oklch(0.82 0.16 70 / 0.16);
  --accent-fg: oklch(0.19 0.02 60);
  --warm: oklch(0.76 0.14 40);
  --warm-soft: oklch(0.76 0.14 40 / 0.16);
  --success: oklch(0.84 0.16 160);
  --success-soft: oklch(0.84 0.16 160 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.82 0.16 70 / 0.4);
}

[data-palette="amber"][data-theme="light"] {
  --bg: oklch(0.985 0.008 80);
  --surface-0: oklch(0.985 0.008 80);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.97 0.012 75);
  --surface-3: oklch(0.94 0.016 70);
  --text-1: oklch(0.22 0.025 60);
  --text-2: oklch(0.42 0.025 60);
  --text-3: oklch(0.58 0.02 65);
  --accent: oklch(0.56 0.18 65);
  --accent-soft: oklch(0.56 0.18 65 / 0.09);
  --accent-fg: oklch(0.18 0.02 60);
  --warm: oklch(0.56 0.16 45);
  --warm-soft: oklch(0.56 0.16 45 / 0.12);
  --success: oklch(0.54 0.14 160);
  --success-soft: oklch(0.54 0.14 160 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.56 0.18 65 / 0.3);
}

/* ---- PALETA 6: Teal Depths ---- */
[data-palette="teal"][data-theme="dark"] {
  --bg: oklch(0.18 0.018 185);
  --surface-0: oklch(0.18 0.018 185);
  --surface-1: oklch(0.22 0.022 185);
  --surface-2: oklch(0.26 0.025 185);
  --surface-3: oklch(0.32 0.028 185);
  --text-1: oklch(0.96 0.01 185);
  --text-2: oklch(0.72 0.015 185);
  --text-3: oklch(0.52 0.015 185);
  --accent: oklch(0.80 0.13 185);
  --accent-soft: oklch(0.80 0.13 185 / 0.14);
  --accent-fg: oklch(0.18 0.018 185);
  --warm: oklch(0.82 0.12 70);
  --warm-soft: oklch(0.82 0.12 70 / 0.16);
  --success: oklch(0.84 0.16 160);
  --success-soft: oklch(0.84 0.16 160 / 0.16);
  --danger: oklch(0.72 0.16 25);
  --danger-soft: oklch(0.72 0.16 25 / 0.16);
  --hairline: oklch(1 0 0 / 0.06);
  --ring: oklch(0.80 0.13 185 / 0.4);
}

[data-palette="teal"][data-theme="light"] {
  --bg: oklch(0.975 0.008 185);
  --surface-0: oklch(0.975 0.008 185);
  --surface-1: oklch(1 0 0);
  --surface-2: oklch(0.96 0.012 185);
  --surface-3: oklch(0.93 0.016 185);
  --text-1: oklch(0.22 0.022 185);
  --text-2: oklch(0.42 0.022 185);
  --text-3: oklch(0.58 0.018 185);
  --accent: oklch(0.48 0.15 185);
  --accent-soft: oklch(0.48 0.15 185 / 0.09);
  --accent-fg: oklch(0.99 0 0);
  --warm: oklch(0.56 0.14 55);
  --warm-soft: oklch(0.56 0.14 55 / 0.12);
  --success: oklch(0.54 0.14 160);
  --success-soft: oklch(0.54 0.14 160 / 0.12);
  --danger: oklch(0.52 0.18 25);
  --danger-soft: oklch(0.52 0.18 25 / 0.1);
  --hairline: oklch(0 0 0 / 0.07);
  --ring: oklch(0.48 0.15 185 / 0.3);
}

/* ============================================================
   Base reset + tokens shared
   ============================================================ */
* {
  box-sizing: border-box;
}

html,
body,
#root {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  transition: background 0.25s ease, color 0.25s ease;
}

.serif {
  font-family: 'Instrument Serif', Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.display {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

/* Page header: title (+ subtitle) on left, actions on right. Wraps on narrow widths. */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head>.page-head-title {
  flex: 1 1 360px;
  min-width: 0;
}

.page-head>.page-head-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding-top: 6px;
}

.page-head h1.serif {
  font-size: clamp(24px, 3.5vw, 40px);
  margin: 0;
  line-height: 1.05;
  word-break: break-word;
  overflow-wrap: anywhere;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-weight: 300;
  font-style: normal;
  letter-spacing: -0.03em;
  max-width: 100%;
}

.page-head h1.display {
  font-size: clamp(22px, 3.2vw, 38px);
  margin: 0;
  line-height: 1.05;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}


.page-head p.sub {
  font-size: 14px;
  color: var(--text-2);
  margin: 10px 0 0;
  max-width: 580px;
  line-height: 1.5;
}

.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

input,
textarea {
  font: inherit;
  color: inherit;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

/* ============================================================
   Layout primitives
   ============================================================ */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
  transition: grid-template-columns 0.22s ease;
  --sidebar-total-w: 248px;
}

.app-shell.collapsed {
  grid-template-columns: 72px minmax(0, 1fr);
  --sidebar-total-w: 72px;
}

.app-shell.tools-open {
  grid-template-columns: 248px 200px minmax(0, 1fr);
  --sidebar-total-w: 448px;
}

.app-shell.collapsed.tools-open {
  grid-template-columns: 72px 200px minmax(0, 1fr);
  --sidebar-total-w: 272px;
}

/* Barra secundária de ferramentas de estudo */
.tools-bar {
  background: var(--surface-0);
  border-right: 1px solid var(--hairline);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 38;
  transition: transform 0.2s ease;
}

/* Quando o sidebar retraído hover-expande (260px), a barra secundária acompanha */
.app-shell.collapsed.tools-open .sidebar:hover~.tools-bar {
  transform: translateX(188px);
  /* 260px - 72px */
}

.sidebar {
  background: var(--surface-0);
  border-right: 1px solid var(--hairline);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
  transition: width 0.2s ease, padding 0.2s ease;
}

.collapsed .sidebar {
  padding: 20px 10px;
}

/* Hover-expand the collapsed sidebar (desktop + tablet) without shifting main */
@media (min-width: 721px) {
  .sidebar-mobile-close {
    display: none !important;
  }

  .app-shell.collapsed .sidebar {
    width: 72px;
  }

  .app-shell.collapsed .sidebar:hover {
    width: 260px;
    padding: 20px 14px;
    box-shadow: 12px 0 40px -12px rgba(0, 0, 0, 0.25);
    z-index: 55;
  }

  .app-shell.collapsed .sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .app-shell.collapsed .sidebar:hover .nav-item .label,
  .app-shell.collapsed .sidebar:hover .brand-text,
  .app-shell.collapsed .sidebar:hover .nav-section-label,
  .app-shell.collapsed .sidebar:hover .user-info {
    display: initial;
  }

  .app-shell.collapsed .sidebar:hover .nav-item.active::before {
    display: block;
  }

  .app-shell.collapsed .sidebar:hover .nav-item.active {
    box-shadow: none;
  }

  .app-shell.collapsed .sidebar:hover .brand {
    justify-content: flex-start;
    padding: 4px 8px 18px;
  }

  .app-shell.collapsed .sidebar:hover .user-card {
    padding: 10px;
    justify-content: flex-start;
  }
}

/* Sidebar collapse button */
.sidebar-toggle {
  position: absolute;
  top: 20px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-1);
  color: var(--text-2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), 0 0 0 1px var(--hairline);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 10;
  transition: all 0.15s;
}

.sidebar-toggle:hover {
  color: var(--accent);
  transform: scale(1.1);
}

.sidebar-toggle svg {
  width: 14px;
  height: 14px;
}

/* Mobile menu toggle (hamburger in topbar) */
.mobile-menu-btn {
  display: none;
}

/* Sidebar close button — hidden on desktop, shown inside mobile drawer */
.sidebar-mobile-close {
  display: none;
}

/* Mobile overlay when sidebar opens — always fixed/out of flow, toggle visibility only */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  visibility: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--text-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}

.nav-section-label {
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 16px 10px 6px;
  font-family: 'JetBrains Mono', monospace;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 450;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background: var(--surface-1);
  color: var(--text-1);
}

.nav-item.active {
  color: var(--text-1);
  background: var(--surface-2);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.nav-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.85;
}

.collapsed .sidebar .nav-item {
  justify-content: center;
  padding: 10px;
}

.collapsed .sidebar .nav-item .label,
.collapsed .sidebar .brand-text,
.collapsed .sidebar .nav-section-label {
  display: none;
}

.collapsed .sidebar .nav-item.active::before {
  display: none;
}

.collapsed .sidebar .nav-item.active {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.collapsed .brand {
  justify-content: center;
  padding: 4px 0 18px;
}

.user-card {
  margin-top: auto;
  padding: 10px;
  border-radius: 10px;
  background: var(--surface-1);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-3);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.user-xp {
  font-size: 10.5px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.05em;
}

.collapsed .user-info,
.collapsed .user-chevron {
  display: none;
}

.collapsed .user-card {
  padding: 6px;
  justify-content: center;
}

/* ---- Main area ---- */
.main {
  --main-pad-x: 40px;
  --main-pad-t: 28px;
  padding: calc(var(--main-pad-t) + 68px) var(--main-pad-x) 120px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: fixed;
  top: 0;
  left: var(--sidebar-total-w, 248px);
  right: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid color-mix(in oklab, var(--hairline) 60%, transparent);
  padding: 14px var(--main-pad-x, 40px);
  transition: left 0.22s ease;
}

.crumb {
  font-size: 12px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--text-2);
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--surface-1);
  color: var(--text-1);
}

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

/* ---- Cards ---- */
.card {
  background: var(--surface-1);
  border-radius: 14px;
  padding: 20px;
  transition: background 0.15s, transform 0.15s;
}

.card.hover:hover {
  background: var(--surface-2);
}

.card-sm {
  padding: 14px;
  border-radius: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-ghost {
  background: var(--surface-1);
  color: var(--text-1);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-outline {
  background: transparent;
  color: var(--text-1);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.btn-outline:hover {
  background: var(--surface-1);
}

.btn-lg {
  padding: 11px 20px;
  font-size: 14px;
  border-radius: 10px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ---- Inputs ---- */
.input {
  width: 100%;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 9px 12px;
  color: var(--text-1);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.input::placeholder {
  color: var(--text-3);
}

/* ---- Pill / tag ---- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.pill-accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-warm {
  background: var(--warm-soft);
  color: var(--warm);
}

.pill-success {
  background: var(--success-soft);
  color: var(--success);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.pill-muted {
  background: var(--surface-2);
  color: var(--text-2);
}

/* ---- Progress ---- */
.progress {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress>span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.5s ease;
}

/* ---- Divider ---- */
.divider {
  height: 1px;
  background: var(--hairline);
  margin: 16px 0;
}

/* ---- Section headers ---- */
.section-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-h h2 {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(16px, 2.2vw, 22px);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin: 0;
}

.section-h .see-all {
  font-size: 12px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}

.section-h .see-all:hover {
  color: var(--accent);
}

/* ---- Floating mentor button (ALWAYS visible) ---- */
/* Durante o Modo Foco ativo, esconde o FAB do mentor (anti-distração) */
body.focus-running .mentor-fab { display: none !important; }

.mentor-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--surface-1);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--hairline);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  overflow: visible;
}

.mentor-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--accent-soft);
}

.mentor-fab img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.mentor-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--accent-soft);
  animation: mentor-pulse 2.8s ease-out infinite;
  pointer-events: none;
}

@keyframes mentor-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--accent-soft);
  }

  100% {
    box-shadow: 0 0 0 24px transparent;
  }
}

.mentor-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--warm);
  color: var(--accent-fg);
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 3px var(--bg);
  font-family: 'JetBrains Mono', monospace;
}

/* ---- Mentor chat panel ---- */
.mentor-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  width: 380px;
  max-height: calc(100vh - 140px);
  background: var(--surface-1);
  border-radius: 18px;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--hairline);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: panel-in 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(8px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.mentor-panel-head {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--hairline);
}

.mentor-panel-head img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.mentor-panel-title {
  font-size: 14px;
  font-weight: 500;
}

.mentor-panel-status {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  align-items: center;
  gap: 5px;
}

.dot-online {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.mentor-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
}

.msg.bot {
  background: var(--surface-2);
  color: var(--text-1);
  align-self: flex-start;
  border-top-left-radius: 4px;
}

.msg.user {
  background: var(--accent);
  color: var(--accent-fg);
  align-self: flex-end;
  border-top-right-radius: 4px;
}

.suggest-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 10px;
}

.suggest-chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  transition: all 0.15s;
}

.suggest-chip:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.mentor-panel-input {
  border-top: 1px solid var(--hairline);
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.mentor-panel-input input {
  flex: 1;
  background: var(--surface-2);
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  font-size: 13.5px;
}

.mentor-panel-input input:focus {
  background: var(--surface-3);
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  transition: filter 0.15s;
}

.send-btn:hover {
  filter: brightness(1.08);
}

/* ---- Tweaks panel ---- */
.tweaks {
  position: fixed;
  right: 24px;
  top: 24px;
  width: 300px;
  background: var(--surface-1);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--hairline);
  z-index: 60;
  font-size: 13px;
}

.tweaks h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.tweaks-group {
  margin-bottom: 14px;
}

.tweaks-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 6px;
}

.tweaks-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tweak-chip {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  transition: all 0.15s;
}

.tweak-chip:hover {
  background: var(--surface-3);
  color: var(--text-1);
}

.tweak-chip.active {
  background: var(--accent);
  color: var(--accent-fg);
}

.palette-swatch {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s;
}

.palette-swatch.active {
  box-shadow: 0 0 0 2px var(--accent);
  transform: scale(1.05);
}

.palette-swatch::before,
.palette-swatch::after {
  content: '';
  position: absolute;
  inset: 0;
}

/* ---- Stats row ---- */
.stat {
  background: var(--surface-1);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}

.stat-value {
  font-family: 'Instrument Serif', serif;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

.stat-sub.up {
  color: var(--success);
}

/* ---- Animations ---- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.stagger>* {
  opacity: 0;
  animation: fadeUp 0.4s ease forwards;
}

.stagger>*:nth-child(1) {
  animation-delay: 0.02s;
}

.stagger>*:nth-child(2) {
  animation-delay: 0.06s;
}

.stagger>*:nth-child(3) {
  animation-delay: 0.1s;
}

.stagger>*:nth-child(4) {
  animation-delay: 0.14s;
}

.stagger>*:nth-child(5) {
  animation-delay: 0.18s;
}

.stagger>*:nth-child(6) {
  animation-delay: 0.22s;
}

.stagger>*:nth-child(7) {
  animation-delay: 0.26s;
}

/* ---- Focus mode overlay ---- */
.focus-mode {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 70;
  display: grid;
  place-items: center;
}

.focus-timer {
  font-family: 'Instrument Serif', serif;
  font-size: 140px;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text-1);
}

/* ---- Page grid helpers ---- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr));
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 14px;
}

.grid-responsive-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 20px;
}

/* ---- Calendar cells uniform ---- */
.cal-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  padding: 7px;
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.cal-cell-events {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: hidden;
}

.cal-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}

@media (max-width: 1100px) {
  .cal-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .cal-cell {
    aspect-ratio: auto;
    min-height: 64px;
  }
}

.hide-sm {}

@media (max-width: 720px) {
  .hide-sm {
    display: none;
  }
}

/* Library actions row */
.lib-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.lib-actions .icon-btn {
  width: 32px;
  height: 32px;
}

/* Ranking table grid columns */
.rank-table-head,
.rank-table-row {
  grid-template-columns: 56px 2fr 1fr 90px 70px 90px 80px;
}

.rank-table-row:hover {
  background: var(--surface-2);
}

@media (max-width: 900px) {

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

  .rank-table-head,
  .rank-table-row {
    grid-template-columns: 48px 1.5fr 1fr 70px 60px;
  }

  .rank-table-head>*:nth-child(6),
  .rank-table-head>*:nth-child(7),
  .rank-table-row>*:nth-child(6),
  .rank-table-row>*:nth-child(7) {
    display: none;
  }
}

@media (max-width: 600px) {

  .rank-table-head,
  .rank-table-row {
    grid-template-columns: 44px 1fr 80px;
  }

  .rank-table-head>*:nth-child(4),
  .rank-table-head>*:nth-child(5),
  .rank-table-row>*:nth-child(4),
  .rank-table-row>*:nth-child(5) {
    display: none;
  }
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* Tablet — sidebar acts like collapsed, hover expands over content */
@media (max-width: 1100px) and (min-width: 721px) {
  .app-shell {
    grid-template-columns: 72px minmax(0, 1fr);
    --sidebar-total-w: 72px;
  }

  .app-shell.tools-open {
    grid-template-columns: 72px 200px minmax(0, 1fr);
    --sidebar-total-w: 272px;
  }

  .app-shell.tools-open .sidebar:hover~.tools-bar {
    transform: translateX(188px);
  }

  .app-shell .sidebar {
    width: 72px;
    padding: 20px 10px;
    transition: width 0.2s ease, padding 0.2s ease;
  }

  .app-shell .sidebar .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .app-shell .sidebar .nav-item .label,
  .app-shell .sidebar .brand-text,
  .app-shell .sidebar .nav-section-label,
  .app-shell .sidebar .user-info {
    display: none;
  }

  .app-shell .sidebar .nav-item.active::before {
    display: none;
  }

  .app-shell .sidebar .nav-item.active {
    box-shadow: inset 0 0 0 1px var(--accent);
  }

  .app-shell .sidebar .brand {
    justify-content: center;
    padding: 4px 0 18px;
  }

  .app-shell .sidebar .user-card {
    padding: 6px;
    justify-content: center;
  }

  .sidebar-toggle {
    display: none;
  }

  .main {
    padding: calc(24px + 68px) 28px 100px;
    --main-pad-x: 28px;
    --main-pad-t: 24px;
  }

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

  /* Hover-expand over content */
  .app-shell .sidebar:hover {
    width: 260px;
    padding: 20px 14px;
    box-shadow: 12px 0 40px -12px rgba(0, 0, 0, 0.25);
    z-index: 55;
  }

  .app-shell .sidebar:hover .nav-item {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .app-shell .sidebar:hover .nav-item .label,
  .app-shell .sidebar:hover .brand-text,
  .app-shell .sidebar:hover .nav-section-label,
  .app-shell .sidebar:hover .user-info {
    display: initial;
  }

  .app-shell .sidebar:hover .nav-item.active::before {
    display: block;
  }

  .app-shell .sidebar:hover .nav-item.active {
    box-shadow: none;
  }

  .app-shell .sidebar:hover .brand {
    justify-content: flex-start;
    padding: 4px 8px 18px;
  }

  .app-shell .sidebar:hover .user-card {
    padding: 10px;
    justify-content: flex-start;
  }
}

@media (max-width: 900px) {

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

  .page-head h1.serif,
  .page-head h1.display {
    font-size: 28px !important;
  }
}

/* Mobile — sidebar becomes slide-in drawer */
@media (max-width: 720px) {
  /* Coluna única em QUALQUER estado — vence .tools-open/.collapsed (especificidade)
     para o conteúdo nunca ser espremido pelas colunas fixas da sidebar/tools-bar. */
  .app-shell,
  .app-shell.collapsed,
  .app-shell.tools-open,
  .app-shell.collapsed.tools-open {
    grid-template-columns: 1fr;
    --sidebar-total-w: 0px;
  }

  /* Barra de ferramentas (nav secundária) some no mobile — navegação fica no drawer */
  .tools-bar {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    padding: 20px 14px;
    box-shadow: 12px 0 40px -12px rgba(0, 0, 0, 0.3);
  }

  .app-shell.mobile-open .sidebar {
    transform: translateX(0);
  }

  /* Reset collapsed overrides inside mobile drawer */
  .app-shell .sidebar .nav-item {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .app-shell .sidebar .nav-item .label,
  .app-shell .sidebar .brand-text,
  .app-shell .sidebar .nav-section-label,
  .app-shell .sidebar .user-info {
    display: initial;
  }

  .app-shell .sidebar .nav-item.active::before {
    display: block;
  }

  .app-shell .sidebar .brand {
    justify-content: flex-start;
    padding: 4px 8px 18px;
  }

  .app-shell .sidebar .user-card {
    padding: 10px;
    justify-content: flex-start;
  }

  .mobile-overlay {
    visibility: visible;
  }

  .app-shell.mobile-open .mobile-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-menu-btn {
    display: grid;
  }

  .sidebar-mobile-close {
    display: flex;
    align-self: flex-end;
    margin-bottom: 8px;
    color: var(--text-3);
  }

  .main {
    padding: calc(16px + 68px) 18px 100px;
    max-width: 100%;
    --main-pad-x: 18px;
    --main-pad-t: 16px;
  }

  .topbar {
    left: 0;
    padding: 10px 18px;
  }

  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .page-head h1.serif,
  .page-head h1.display {
    font-size: 22px !important;
  }

  .page-head {
    gap: 14px;
    margin-bottom: 18px;
  }

  .page-head>.page-head-actions {
    width: 100%;
  }

  .card {
    padding: 16px;
    border-radius: 12px;
  }

  .stat {
    padding: 12px;
  }

  .stat-value {
    font-size: 26px;
  }

  /* Mentor FAB smaller on mobile */
  .mentor-fab {
    width: 54px;
    height: 54px;
    right: 16px;
    bottom: 16px;
  }

  .mentor-fab img {
    width: 48px;
    height: 48px;
  }

  .mentor-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 82px;
  }

  /* Tweaks panel mobile */
  .tweaks {
    right: 12px;
    left: 12px;
    top: 12px;
    width: auto;
  }

  /* Calendar — flip to week list on mobile */
  .cal-cell {
    aspect-ratio: auto;
    min-height: 56px;
  }
}

/* Hide sidebar nav section labels crumb shortening */
@media (max-width: 500px) {
  .brand-sub {
    display: none;
  }

  .crumb {
    font-size: 11px;
  }
}

/* ======================================================
   PROFILE MODAL
   ====================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.profile-modal {
  position: relative;
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface-0);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: 0 24px 80px -20px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.profile-head {
  padding: 28px 28px 18px;
  display: flex;
  align-items: flex-start;
  gap: 22px;
  border-bottom: 1px solid var(--hairline);
}

.profile-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-2);
  border: 3px solid var(--surface-0);
  box-shadow: 0 0 0 2px var(--accent);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-edit {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: 2px solid var(--surface-0);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.avatar-edit svg {
  width: 14px;
  height: 14px;
}

.profile-tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
  min-height: 48px;
}

.profile-tabs::-webkit-scrollbar {
  display: none;
}

.profile-tab {
  background: transparent;
  border: none;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}

.profile-tab:hover {
  color: var(--text);
}

.profile-tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.profile-body {
  padding: 24px 28px;
  flex: 1;
}

.profile-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

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

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.profile-field-value {
  font-size: 14px;
  color: var(--text);
  padding: 4px 0;
}

.profile-field .input {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

/* Plans */
.profile-plans {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.plan-card-profile {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}

.plan-card-profile.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent);
}

.plan-card-profile.current {
  background: var(--surface-2);
}

.plan-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.plan-card-name {
  font-size: 16px;
  font-weight: 600;
}

.plan-card-price {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-serif);
  margin: 4px 0 14px;
}

.plan-card-features {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.plan-card-features li {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.plan-card-features li svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Payment */
.payment-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cc-brand {
  background: linear-gradient(135deg, #1a1f71, #0063c6);
  color: white;
  font-weight: 800;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.billing-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.billing-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 10px;
}

.chip-success {
  background: color-mix(in oklab, oklch(0.72 0.14 140) 20%, transparent);
  color: oklch(0.82 0.16 140);
}

/* Chip (pill) — generic small label used in profile header & fields */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  white-space: nowrap;
}

.chip-accent {
  background: color-mix(in oklab, var(--accent) 18%, transparent);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
  font-weight: 600;
}

.chip-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Credits */
.credits-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.credit-row {
  display: grid;
  grid-template-columns: 170px 1fr 44px;
  gap: 14px;
  align-items: center;
}

.credit-label {
  font-size: 13px;
  color: var(--text);
}

.credit-bar {
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}

.credit-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.4s ease;
}

.credit-val {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  color: var(--muted);
}

/* Referral */
.referral-code {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  max-width: 420px;
  margin: 20px auto 0;
}

.referral-code-val {
  flex: 1;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: var(--surface-2);
  padding: 12px 18px;
  border-radius: 8px;
  color: var(--accent);
}

.referral-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 20px;
}

.referral-stat {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.referral-stat-val {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-serif);
}

.referral-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .profile-head {
    padding: 20px;
    gap: 14px;
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-avatar {
    width: 72px;
    height: 72px;
  }

  .profile-body {
    padding: 18px;
  }

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

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

  .credit-row {
    grid-template-columns: 120px 1fr 44px;
  }
}

/* ── Markdown content rendering ─────────────────────────────────────────── */
.md-content {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-1);
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
  font-family: var(--font-serif, 'Instrument Serif', serif);
  margin: 1.1em 0 0.4em;
  line-height: 1.2;
  color: var(--text-1);
}

.md-content h1 {
  font-size: 22px;
}

.md-content h2 {
  font-size: 18px;
}

.md-content h3 {
  font-size: 15px;
}

.md-content h4 {
  font-size: 14px;
  font-weight: 600;
}

.md-content p {
  margin: 0 0 0.75em;
}

.md-content p:last-child {
  margin-bottom: 0;
}

.md-content strong {
  font-weight: 600;
}

.md-content em {
  font-style: italic;
}

.md-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}

.md-content pre {
  background: var(--surface-1);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0.75em 0;
}

.md-content pre code {
  background: none;
  padding: 0;
}

.md-content ul,
.md-content ol {
  padding-left: 22px;
  margin: 0.4em 0 0.75em;
}

.md-content li {
  margin-bottom: 0.2em;
}

.md-content blockquote {
  margin: 0.75em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 6px 6px 0;
  color: var(--text-2);
}

.md-content hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 1.1em 0;
}

.md-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75em 0;
  font-size: 13px;
}

.md-content th,
.md-content td {
  border: 1px solid var(--hairline);
  padding: 6px 12px;
  text-align: left;
}

.md-content th {
  background: var(--surface-2);
  font-weight: 600;
}

.md-content a {
  color: var(--accent);
  text-decoration: underline;
}

.md-content .katex-display {
  margin: 1em 0;
  overflow-x: auto;
}