/* ==========================================================================
   Revisa — design system
   Tokens primeiro, componentes depois. Nada de valores mágicos soltos.
   ========================================================================== */

/* --- Fonte local (Manrope), com fallback de sistema --------------------- */
@font-face {
  font-family: 'Manrope';
  src: local('Manrope'), local('Manrope-Regular');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: local('Manrope Medium'), local('Manrope-Medium');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: local('Manrope SemiBold'), local('Manrope-SemiBold');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Manrope';
  src: local('Manrope Bold'), local('Manrope-Bold');
  font-weight: 700;
  font-display: swap;
}

/* ==========================================================================
   1. Tokens
   ========================================================================== */

:root {
  /* Amarra os controles nativos (checkbox, radio, range, seletor de data e
     barras de rolagem) ao tema do app. Sem isto, um usuário com o sistema em
     modo escuro veria controles escuros dentro do tema claro. */
  color-scheme: light;

  /* Identidade — roxo mais claro e vivo */
  --color-primary: #7c5cff;
  --color-primary-light: #9b82ff;
  --color-primary-hover: #6b48f5;
  --color-primary-active: #5b39e0;
  --color-primary-soft: #f1edff;
  --color-primary-softer: #f8f6ff;
  --color-primary-border: #ded4ff;
  --color-secondary: #9b82ff;
  --color-on-primary: #ffffff;

  /* Gradiente da marca: usado no item ativo, no botão principal e no logo */
  --gradient-primary: linear-gradient(135deg, #9b82ff 0%, #6d3ff5 100%);
  --glow-primary: 0 8px 20px -6px rgba(109, 63, 245, 0.45);

  /* Superfícies */
  --color-bg: #f7f7fc;
  --color-surface: #ffffff;
  --color-surface-2: #fbfaff;
  --color-surface-hover: #f4f2fb;
  --color-overlay: rgba(23, 24, 34, 0.42);

  /* Acentos dos cards (ícone + brilho de fundo) */
  --accent-green: #10b981;
  --accent-green-2: #059669;
  --accent-purple: #8b5cf6;
  --accent-purple-2: #7c3aed;
  --accent-blue: #3b82f6;
  --accent-blue-2: #2563eb;
  --accent-orange: #f59e0b;
  --accent-orange-2: #d97706;
  --accent-rose: #f43f5e;
  --accent-rose-2: #e11d48;
  --accent-teal: #14b8a6;
  --accent-teal-2: #0d9488;

  /* Texto */
  --color-text: #20212b;
  --color-text-soft: #4a4b5c;
  --color-muted: #6b6c7e;
  --color-faint: #9294a6;

  /* Traços */
  --color-border: #e6e6ee;
  --color-border-strong: #d5d5e0;

  /* Semânticas */
  --color-success: #128a5b;
  --color-success-soft: #e5f5ee;
  --color-success-border: #b7e3d0;
  --color-warning: #a8630a;
  --color-warning-soft: #fdf1e0;
  --color-warning-border: #f2d9b0;
  --color-danger: #c02b3d;
  --color-danger-soft: #fdecee;
  --color-danger-border: #f5c9cf;
  --color-info: #1f6aa8;
  --color-info-soft: #e8f2fa;
  --color-info-border: #bfdcf0;

  /* Prioridade */
  --color-priority-high: #c02b3d;
  --color-priority-normal: var(--color-muted);
  --color-priority-low: #9294a6;

  /* Raio */
  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Espaço (escala de 4px) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 2.5rem;
  --space-9: 3rem;
  --space-10: 4rem;

  /* Sombras — muito leves, de propósito */
  --shadow-xs: 0 1px 2px rgba(24, 25, 36, 0.05);
  --shadow-sm: 0 1px 3px rgba(24, 25, 36, 0.07), 0 1px 2px rgba(24, 25, 36, 0.04);
  --shadow-md: 0 4px 12px rgba(24, 25, 36, 0.08);
  --shadow-lg: 0 12px 32px rgba(24, 25, 36, 0.12);

  /* Tipografia */
  --font-sans: 'Manrope', 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Layout — o conteúdo ocupa praticamente toda a largura disponível */
  --sidebar-width: 244px;
  --topbar-height: 60px;
  --bottomnav-height: 60px;
  --content-max: 1680px;
  --page-gutter: var(--space-7);

  /* Movimento */
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --duration-fast: 120ms;
  --duration: 180ms;
  --duration-slow: 260ms;

  --z-drawer: 60;
  --z-modal: 70;
  --z-toast: 90;
  --z-palette: 95;
}

[data-theme='dark'] {
  color-scheme: dark;

  --color-primary: #9b82ff;
  --color-primary-light: #b3a0ff;
  --color-primary-hover: #a892ff;
  --color-primary-active: #b8a6ff;
  --color-primary-soft: #272441;
  --color-primary-softer: #1f1d33;
  --color-primary-border: #3d3766;
  --color-secondary: #b3a0ff;
  --color-on-primary: #14121f;

  --gradient-primary: linear-gradient(135deg, #a892ff 0%, #7c5cff 100%);
  --glow-primary: 0 8px 22px -6px rgba(124, 92, 255, 0.55);

  --color-bg: #101017;
  --color-surface: #191922;
  --color-surface-2: #1e1e2a;
  --color-surface-hover: #23232f;
  --color-overlay: rgba(6, 6, 10, 0.62);

  --accent-green: #34d399;
  --accent-green-2: #10b981;
  --accent-purple: #a78bfa;
  --accent-purple-2: #8b5cf6;
  --accent-blue: #60a5fa;
  --accent-blue-2: #3b82f6;
  --accent-orange: #fbbf24;
  --accent-orange-2: #f59e0b;
  --accent-rose: #fb7185;
  --accent-rose-2: #f43f5e;
  --accent-teal: #2dd4bf;
  --accent-teal-2: #14b8a6;

  --color-text: #f2f2f6;
  --color-text-soft: #d3d4de;
  --color-muted: #9294a6;
  --color-faint: #6b6c7e;

  --color-border: #282936;
  --color-border-strong: #363746;

  --color-success: #4ecb96;
  --color-success-soft: #172b23;
  --color-success-border: #23503f;
  --color-warning: #e2a34e;
  --color-warning-soft: #2c2318;
  --color-warning-border: #55401f;
  --color-danger: #f0808f;
  --color-danger-soft: #2d1a1e;
  --color-danger-border: #55292f;
  --color-info: #6cb2e8;
  --color-info-soft: #17242f;
  --color-info-border: #274257;

  --color-priority-high: #f0808f;
  --color-priority-normal: var(--color-muted);
  --color-priority-low: #6b6c7e;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* ==========================================================================
   2. Base
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

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

ul, ol { margin: 0; padding-left: 1.25rem; }

img, svg { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-5) 0;
}

code, pre { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

::selection {
  background: var(--color-primary-soft);
  color: var(--color-text);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Utilidades ------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: var(--space-3); text-decoration: none; }

.icon { flex-shrink: 0; }
.text-muted { color: var(--color-muted); }
.text-faint { color: var(--color-faint); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* O atributo `hidden` precisa vencer as utilidades de display (.flex, .grid).
   Sem isto, `<div class="flex" hidden>` continua visível. */
[hidden] { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.w-full { width: 100%; }

/* ==========================================================================
   3. Layout do app
   ========================================================================== */

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-6) var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-2) var(--space-5);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--gradient-primary);
  box-shadow: var(--glow-primary);
  color: #fff;
  font-size: var(--text-base);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

/* Serve tanto para <a> quanto para <button>: os botões precisam do reset
   explícito, senão herdam a moldura padrão do navegador. */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 11px var(--space-3);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--color-text-soft);
  font-family: inherit;
  font-weight: 450;
  font-size: var(--text-md);
  line-height: 1.4;
  letter-spacing: -0.005em;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.nav-link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

/* Item ativo: pílula com gradiente da marca e um brilho suave embaixo. */
.nav-link.is-active {
  background: var(--gradient-primary);
  box-shadow: var(--glow-primary);
  color: #fff;
  font-weight: 600;
}
.nav-link.is-active:hover { background: var(--gradient-primary); color: #fff; }
.nav-link .icon { color: currentColor; opacity: 0.9; }
.nav-link.is-active .icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--color-danger);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* O contador continua vermelho mesmo no item selecionado — é um alerta, e
   trocá-lo por um tom translúcido fazia ele perder o sentido. */

.sidebar-section {
  margin: var(--space-5) 0 var(--space-2);
  padding: 0 var(--space-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-faint);
}
.sidebar-section:first-of-type { margin-top: 0; }

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Cartão do usuário no rodapé da barra lateral -------------------------- */

.user-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.user-card:hover { background: var(--color-surface-hover); }
.user-card[aria-expanded='true'] { background: var(--color-surface-hover); }

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

/*
 * `overflow`/`text-overflow` só valem em elementos de bloco — como estes são
 * <span>, sem o `display: block` o e-mail longo vazava para fora da barra
 * lateral em vez de virar reticências.
 */
.user-card-name,
.user-card-mail {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
}
.user-card-mail {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* O menu abre para CIMA, então a seta aponta para cima; ao abrir, ela vira
   para baixo indicando "fechar". */
.user-card .icon {
  color: var(--color-faint);
  flex-shrink: 0;
  transform: rotate(180deg);
  transition: transform var(--duration) var(--ease);
}
.user-card[aria-expanded='true'] .icon { transform: rotate(0deg); }

/*
 * O menu sobe a partir do rodapé. Precisa de `.dropdown-menu.user-menu`
 * (e não só `.user-menu`): a regra genérica .dropdown-menu vem depois no
 * arquivo e, com a mesma especificidade, venceria o posicionamento — o menu
 * abriria para baixo e ficaria cortado pelo overflow da barra lateral.
 */
.dropdown-menu.user-menu {
  bottom: calc(100% + 6px);
  top: auto;
  left: 0;
  right: 0;
  min-width: 0;
}

/* Interruptor de tema dentro do menu ------------------------------------ */

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.theme-row:hover { background: var(--color-surface-hover); }
.theme-row-label { display: flex; align-items: center; gap: var(--space-3); font-size: var(--text-base); }
.theme-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-row .switch-track { width: 38px; height: 21px; }
.theme-row .switch-track::after { width: 17px; height: 17px; }
.theme-row input:checked + .switch-track { background: var(--color-primary); }
.theme-row input:checked + .switch-track::after { transform: translateX(17px); }
.theme-row input:focus-visible + .switch-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/*
 * No desktop não existe barra superior: o título já está no <h1> da página.
 * As ações globais viram uma barrinha flutuante no canto direito.
 */
.topbar { display: none; }

.topbar-title {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

/* Barrinha de ações no canto direito ------------------------------------ */

.action-rail {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 35;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

.action-rail .btn-icon { width: 34px; height: 34px; border-radius: 50%; }

/* O painel de notificações abre para a esquerda, sob a barrinha. */
.action-rail .dropdown-menu { top: calc(100% + 10px); right: 0; }

.page {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-7) var(--page-gutter) var(--space-10);
}

/* Com o cronômetro visível, reserva espaço para ele não cobrir o último item. */
body:has(.timer-bar.is-visible) .page {
  padding-bottom: calc(var(--space-10) + 72px);
}

/* Cabeçalho: título à esquerda, informação secundária à direita.
   O padding à direita abre espaço para a barrinha flutuante de ações. */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding-right: 56px;
  margin-bottom: var(--space-7);
}
.page-title {
  font-size: var(--text-3xl);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}
.page-subtitle { color: var(--color-muted); font-size: var(--text-md); }

.page-header-aside {
  text-align: right;
  font-size: var(--text-sm);
  color: var(--color-muted);
  line-height: 1.4;
}
.page-header-aside strong {
  display: block;
  color: var(--color-text);
  font-size: var(--text-md);
}
.page-header-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-faint);
}

/* Saudação da Home */
.greeting-title {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-1);
}
.greeting-name {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* Se o navegador não fizer clip no texto, o nome ainda aparece legível. */
@supports not (background-clip: text) {
  .greeting-name { color: var(--color-primary); }
}

.section { margin-bottom: var(--space-8); }
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.section-title {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.005em;
}
.section-hint { font-size: var(--text-sm); color: var(--color-muted); }

/* ==========================================================================
   4. Componentes
   ========================================================================== */

/* Card ------------------------------------------------------------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-body { padding: var(--space-5); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.card-title { font-size: var(--text-md); font-weight: 700; }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/*
 * Formulários dentro de cards: `.field:last-child` zera a margem inferior,
 * o que deixava o botão de envio colado no último campo. Este respiro vale
 * para todas as abas das configurações de uma vez.
 */
form.card-body > .btn,
form.card-body > .btn-group,
form.card-body > .flex:last-child {
  margin-top: var(--space-5);
}

/* Botões ----------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 36px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled,
.btn[aria-disabled='true'] { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gradient-primary);
  box-shadow: var(--glow-primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); }
.btn-primary:active:not(:disabled) { filter: brightness(0.96); }

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-hover); }

.btn-ghost { color: var(--color-text-soft); }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-hover); color: var(--color-text); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.94); }

.btn-danger-soft {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}
.btn-danger-soft:hover:not(:disabled) { filter: brightness(0.97); }

.btn-sm { height: 30px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn-lg { height: 42px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px;
  padding: 0;
  color: var(--color-text-soft);
  border-radius: var(--radius-md);
}
.btn-icon:hover:not(:disabled) { background: var(--color-surface-hover); color: var(--color-text); }
.btn-icon.btn-sm { width: 30px; }

.btn-icon-badge { position: relative; }
.btn-icon-badge .badge-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }

/* Formulários ------------------------------------------------------------ */

.field { margin-bottom: var(--space-4); }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-soft);
}
.label .required { color: var(--color-danger); margin-left: 2px; }

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  padding: 0 var(--space-3);
  height: 38px;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
  appearance: none;
}
.textarea {
  height: auto;
  min-height: 84px;
  padding: var(--space-3);
  line-height: 1.6;
  resize: vertical;
}
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.input::placeholder,
.textarea::placeholder { color: var(--color-faint); }
.input:disabled,
.select:disabled,
.textarea:disabled { background: var(--color-surface-hover); color: var(--color-muted); cursor: not-allowed; }
.input.has-error,
.select.has-error,
.textarea.has-error { border-color: var(--color-danger); }

.select {
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6c7e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  cursor: pointer;
}

/*
 * Entrada de duração: horas e minutos lado a lado dentro de um único
 * controle. Ninguém precisa converter "2 horas e 13 minutos" para 133.
 */
/* Presets e o campo personalizado dividem a linha em células iguais, todas
   na altura do campo — antes eram botões pequenos ao lado de um input alto. */
.timer-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: var(--space-2);
  margin-top: var(--space-3);
}
.timer-presets .btn { height: 38px; }
.timer-presets .input { text-align: center; }

/* Horas e minutos são dois campos irmãos, não um controle largo com os
   números jogados nas pontas: cada metade se parece com um input normal. */
.duration-input {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  width: 100%;
}
.duration-part {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 38px;
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}
.duration-part:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.duration-input.has-error .duration-part { border-color: var(--color-danger); }

.duration-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-base);
  text-align: right;
  /* Some com as setinhas: elas apertam o campo e não ajudam aqui. */
  appearance: textfield;
  -moz-appearance: textfield;
}
.duration-input input::-webkit-outer-spin-button,
.duration-input input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.duration-input input:focus { outline: none; }
.duration-input input::placeholder { color: var(--color-faint); }

.duration-unit {
  flex-shrink: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  user-select: none;
}

/* Bloco, como o .field-error: num <span> inline o margin-top não vale e a
   dica encostava no controle quando ele não ocupa a linha toda. */
.field-hint {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.field-error {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-danger);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
}
.field-row .field { margin-bottom: 0; }
/* A linha zera a margem dos filhos, então precisa ter a sua. */
.field-row { margin-bottom: var(--space-4); }
.field-row:last-child { margin-bottom: 0; }

.checkbox,
.radio {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-base);
  padding: var(--space-1) 0;
}
.checkbox input,
.radio input {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Controles nativos restantes seguem a identidade roxa. */
input[type='range'] {
  accent-color: var(--color-primary);
  cursor: pointer;
}
input[type='range']:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
}
.checkbox-text { line-height: 1.45; }
.checkbox-title { font-weight: 600; }
.checkbox-hint { display: block; font-size: var(--text-xs); color: var(--color-muted); }

/* Switch ----------------------------------------------------------------- */

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  cursor: pointer;
}
.switch + .switch { border-top: 1px solid var(--color-border); }
.switch-label { font-weight: 600; }
.switch-hint { display: block; font-size: var(--text-xs); color: var(--color-muted); font-weight: 400; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--color-border-strong);
  transition: background var(--duration) var(--ease);
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--duration) var(--ease);
}
.switch input:checked + .switch-track { background: var(--color-primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* Segmented -------------------------------------------------------------- */

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--color-surface-hover);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
/* Dentro de modal o segmentado ocupa a linha inteira; nas barras de
   ferramentas (calendário, estatísticas) ele continua abraçando o conteúdo. */
.segmented--block { display: flex; width: 100%; }
.segmented--block button { flex: 1; justify-content: center; }

.segmented button,
.segmented a {
  padding: var(--space-1) var(--space-3);
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.segmented button:hover,
.segmented a:hover { color: var(--color-text); text-decoration: none; }
.segmented button.is-active,
.segmented a.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
}

/* Badges ----------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  color: var(--color-text-soft);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-primary { background: var(--color-primary-soft); border-color: var(--color-primary-border); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); border-color: var(--color-success-border); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); border-color: var(--color-warning-border); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); border-color: var(--color-danger-border); color: var(--color-danger); }
.badge-info { background: var(--color-info-soft); border-color: var(--color-info-border); color: var(--color-info); }
.badge-plain { background: transparent; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 1px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: 500;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-border-strong);
  flex-shrink: 0;
}
.dot-high { background: var(--color-priority-high); }
.dot-normal { background: var(--color-priority-normal); }
.dot-low { background: var(--color-priority-low); }

/* Stat cards ------------------------------------------------------------- */

.stat-grid {
  display: grid;
  /* 165px permite encaixar os 6 cards da Home numa linha só em 1440px. */
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: var(--space-4);
}

/*
 * Colunas fixas por grupo.
 *
 * Com `auto-fit` o número de colunas segue a largura disponível, e a conta
 * raramente fecha: oito indicadores caíam em 6+2, seis caíam em 5+1. O
 * modificador diz quantas colunas o grupo quer, e a ordem aqui importa —
 * a faixa larga vem depois para vencer quando as duas se aplicam.
 */
@media (min-width: 1024px) {
  .stat-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* A Home tem exatamente 6 indicadores: em telas largas eles ficam em uma
   única faixa, sem um card órfão na segunda linha. */
@media (min-width: 1280px) {
  .stat-grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/*
 * Card de indicador: ícone colorido no topo, rótulo pequeno em caixa alta,
 * número grande e uma "luzinha" — um brilho radial suave no canto, na cor do
 * acento do card. O brilho fica no ::after para não interferir no conteúdo.
 */
.stat {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  text-align: left;
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.stat::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    120% 90% at 100% 0%,
    var(--stat-glow, rgba(124, 92, 255, 0.10)),
    transparent 62%
  );
}

.stat > * { position: relative; z-index: 1; }

button.stat, a.stat { cursor: pointer; }
button.stat:hover, a.stat:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}
.stat.is-active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.stat.is-alert .stat-value { color: var(--color-danger); }

/* Selo do ícone */
.stat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: var(--space-4);
  border-radius: 11px;
  background: var(--stat-accent, var(--gradient-primary));
  color: #fff;
  box-shadow: 0 6px 14px -6px var(--stat-shadow, rgba(124, 92, 255, 0.6));
}

.stat-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}
/* Rótulo, valor e detalhe são <span> nas views — precisam ser block para
   empilharem em vez de escorrerem na mesma linha. */
.stat-value {
  display: block;
  font-size: var(--text-3xl);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.stat-meta {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
  line-height: 1.4;
}

/* Paleta de acentos dos cards */
.stat--purple { --stat-accent: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-2));
                --stat-glow: rgba(139, 92, 246, 0.12); --stat-shadow: rgba(124, 58, 237, 0.6); }
.stat--green  { --stat-accent: linear-gradient(135deg, var(--accent-green), var(--accent-green-2));
                --stat-glow: rgba(16, 185, 129, 0.12); --stat-shadow: rgba(5, 150, 105, 0.55); }
.stat--blue   { --stat-accent: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-2));
                --stat-glow: rgba(59, 130, 246, 0.12); --stat-shadow: rgba(37, 99, 235, 0.55); }
.stat--orange { --stat-accent: linear-gradient(135deg, var(--accent-orange), var(--accent-orange-2));
                --stat-glow: rgba(245, 158, 11, 0.14); --stat-shadow: rgba(217, 119, 6, 0.55); }
.stat--rose   { --stat-accent: linear-gradient(135deg, var(--accent-rose), var(--accent-rose-2));
                --stat-glow: rgba(244, 63, 94, 0.12); --stat-shadow: rgba(225, 29, 72, 0.55); }
.stat--teal   { --stat-accent: linear-gradient(135deg, var(--accent-teal), var(--accent-teal-2));
                --stat-glow: rgba(20, 184, 166, 0.12); --stat-shadow: rgba(13, 148, 136, 0.55); }

[data-theme='dark'] .stat::after { opacity: 0.55; }

/* Lista de revisões ------------------------------------------------------ */

.review-list { display: flex; flex-direction: column; gap: var(--space-2); }

.review-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}
.review-item:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-xs); }
.review-item.is-overdue { border-left: 3px solid var(--color-danger); }
.review-item.is-high { border-left: 3px solid var(--color-priority-high); }
.review-item.is-overdue.is-high { border-left-color: var(--color-danger); }
.review-item.is-done { opacity: 0.5; }

.review-main {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}
.review-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-path {
  font-size: var(--text-xs);
  color: var(--color-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.review-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-2);
}
.review-actions { display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; }

/* Biblioteca ------------------------------------------------------------- */

.library-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-6);
  align-items: start;
}

.filter-panel {
  position: sticky;
  top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.filter-group + .filter-group { margin-top: var(--space-5); }
.filter-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-faint);
  margin-bottom: var(--space-2);
}
.filter-list { display: flex; flex-direction: column; gap: 1px; }
.filter-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  transition: background var(--duration-fast) var(--ease);
}
.filter-option:hover { background: var(--color-surface-hover); text-decoration: none; color: var(--color-text); }
.filter-option.is-active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 600; }
.filter-count { margin-left: auto; font-size: var(--text-xs); color: var(--color-faint); font-variant-numeric: tabular-nums; }
.filter-option.is-active .filter-count { color: var(--color-primary); }

.discipline-group { margin-bottom: var(--space-6); }
.discipline-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}
.discipline-name { font-size: var(--text-md); font-weight: 700; }
.discipline-swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--color-primary); flex-shrink: 0; }

.subject-group { margin-bottom: var(--space-4); }
.subject-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
  padding-left: var(--space-1);
}

.content-list { display: flex; flex-direction: column; gap: var(--space-1); }

.content-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease),
              background var(--duration-fast) var(--ease);
}
.content-item:hover { border-color: var(--color-border-strong); background: var(--color-surface-2); }
.content-item.is-paused,
.content-item.is-archived { opacity: 0.62; }

.content-item-title { font-weight: 600; font-size: var(--text-md); }
.content-item-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: 3px;
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Empty state ------------------------------------------------------------ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-9) var(--space-5);
  background: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
}
.empty-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.empty-title { font-size: var(--text-lg); font-weight: 700; margin-bottom: var(--space-2); }
.empty-text { color: var(--color-muted); max-width: 34rem; margin-bottom: var(--space-5); }
.empty-text:last-child { margin-bottom: 0; }

.empty-inline {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================
   5. Sobreposições: modal, drawer, toast, palette
   ========================================================================== */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

/* Modal ------------------------------------------------------------------ */

.modal-root { z-index: var(--z-modal); display: grid; place-items: center; padding: var(--space-4); }

.modal {
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--space-8));
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
}
.overlay.is-open .modal { transform: none; opacity: 1; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 680px; }

.modal-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.modal-title { font-size: var(--text-lg); font-weight: 700; }
.modal-subtitle { margin-top: 2px; font-size: var(--text-sm); color: var(--color-muted); }
.modal-close { margin-left: auto; }

.modal-body { padding: var(--space-5); overflow-y: auto; overscroll-behavior: contain; }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.modal-footer-start { margin-right: auto; }

/* Drawer ----------------------------------------------------------------- */

.drawer-root { z-index: var(--z-drawer); }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease);
}
.overlay.is-open .drawer { transform: none; }

.drawer-header {
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.drawer-body { flex: 1; padding: var(--space-5); overflow-y: auto; overscroll-behavior: contain; }
.drawer-footer {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
}

/* As ações do conteúdo cabem em uma linha só: folgas apertadas, rótulos
   curtos e o botão destrutivo reduzido a ícone, empurrado para a direita. */
.drawer-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  min-width: 0;
}
.drawer-actions .btn { padding: 0 10px; flex-shrink: 0; }
.drawer-actions .btn-icon { padding: 0; }

.drawer-section { margin-bottom: var(--space-6); }
.drawer-section:last-child { margin-bottom: 0; }
.drawer-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-faint);
  margin-bottom: var(--space-3);
}

/* Colunas fixas por grupo: com `auto-fit` os cinco números se acomodavam em
   quatro mais um, deixando uma caixa órfã na última linha do drawer. */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}
.summary-grid--pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.summary-grid + .summary-grid { margin-top: var(--space-3); }
.summary-note {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.summary-item {
  padding: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.summary-value {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.summary-value.is-good { color: var(--color-success); }
.summary-value.is-warn { color: var(--color-warning); }
.summary-value.is-bad { color: var(--color-danger); }
.summary-label { font-size: var(--text-xs); color: var(--color-muted); margin-top: 2px; }

/* Timeline --------------------------------------------------------------- */

.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}
.timeline-item:last-child { border-bottom: 0; }
.timeline-date {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}
.timeline-title { font-weight: 600; font-size: var(--text-base); }
.timeline-meta { font-size: var(--text-xs); color: var(--color-muted); margin-top: 2px; }
.timeline-note {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border-left: 2px solid var(--color-border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--text-sm);
  color: var(--color-text-soft);
}

/* Links de material ------------------------------------------------------ */

.link-list { display: flex; flex-direction: column; gap: var(--space-2); }
.link-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease);
}
.link-item:hover { border-color: var(--color-primary-border); text-decoration: none; }
.link-title { font-weight: 600; font-size: var(--text-base); }
.link-host { font-size: var(--text-xs); color: var(--color-muted); }

/* Toast ------------------------------------------------------------------ */

.toast-region {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(360px, calc(100vw - var(--space-8)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-muted);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: var(--text-base);
  pointer-events: auto;
  animation: toast-in var(--duration) var(--ease);
}
.toast.is-leaving { animation: toast-out var(--duration) var(--ease) forwards; }
.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-info); }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-info .toast-icon { color: var(--color-info); }
.toast-message { flex: 1; min-width: 0; }
.toast-close { margin: -2px -6px 0 0; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(16px); }
}

/* Command palette -------------------------------------------------------- */

.palette-root { z-index: var(--z-palette); align-items: flex-start; padding-top: 12vh; display: grid; place-items: start center; }

.palette {
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: translateY(-8px);
  opacity: 0;
  transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
}
.overlay.is-open .palette { transform: none; opacity: 1; }

.palette-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.palette-input {
  flex: 1;
  height: 50px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-lg);
  color: var(--color-text);
}
.palette-input:focus { outline: none; }
.palette-input::placeholder { color: var(--color-faint); }

.palette-results { max-height: min(420px, 50vh); overflow-y: auto; padding: var(--space-2); }
.palette-group-title {
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-faint);
}
.palette-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}
.palette-item:hover,
.palette-item.is-active { background: var(--color-primary-soft); }
.palette-item-title { font-weight: 600; }
.palette-item-sub { font-size: var(--text-xs); color: var(--color-muted); }
.palette-footer {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

kbd {
  display: inline-flex;
  align-items: center;
  /* gap em vez de espaço em branco: o glifo ⌘ tem folga lateral própria e
     o " " extra abria um vão feio entre as teclas. */
  gap: 3px;
  padding: 2px 6px;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--color-surface);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--color-muted);
}

/* Dropdown --------------------------------------------------------------- */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 50;
  min-width: 190px;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.dropdown-menu.is-open { opacity: 1; transform: none; pointer-events: auto; }
.dropdown-menu.to-left { right: auto; left: 0; }
.dropdown-menu.to-top { top: auto; bottom: calc(100% + 4px); }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}
.dropdown-item:hover { background: var(--color-surface-hover); text-decoration: none; }
.dropdown-item.is-danger { color: var(--color-danger); }
.dropdown-item.is-active { color: var(--color-primary); font-weight: 600; }
.dropdown-divider { height: 1px; margin: var(--space-1) 0; background: var(--color-border); }
.dropdown-header {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* Notificações ----------------------------------------------------------- */

.notification-panel { width: min(340px, calc(100vw - var(--space-6))); padding: 0; }
.notification-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.notification-list { max-height: 360px; overflow-y: auto; }
.notification-item {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  font-family: inherit;
  font-size: var(--text-base);
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.notification-item:last-child { border-bottom: 0; }
.notification-item:hover { background: var(--color-surface-hover); text-decoration: none; }
.notification-item.is-unread { background: var(--color-primary-softer); }
.notification-item.is-unread:hover { background: var(--color-primary-soft); }
.notification-title { font-weight: 600; display: flex; align-items: center; gap: var(--space-2); }
.notification-body { font-size: var(--text-sm); color: var(--color-muted); margin-top: 2px; }
.notification-time { font-size: var(--text-xs); color: var(--color-faint); margin-top: var(--space-1); }
.unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary); flex-shrink: 0; }

/* ==========================================================================
   6. Cronômetro global
   ========================================================================== */

.timer-bar {
  position: fixed;
  bottom: var(--space-4);
  left: calc(var(--sidebar-width) + var(--space-4));
  z-index: 55;
  display: none;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: min(440px, calc(100vw - var(--sidebar-width) - var(--space-8)));
  /* Recorta a barra de progresso nos cantos arredondados: sem isto ela é um
     retângulo reto e "escapa" pelas quinas do cartão. */
  overflow: hidden;
}
.timer-bar.is-visible { display: flex; }
.timer-bar.is-finished { border-color: var(--color-success); }

.timer-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
  animation: pulse 2s var(--ease) infinite;
}
.timer-bar.is-paused .timer-pulse { background: var(--color-warning); animation: none; }
.timer-bar.is-finished .timer-pulse { background: var(--color-primary); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.timer-clock {
  font-size: var(--text-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  min-width: 4.2rem;
}
.timer-info { min-width: 0; flex: 1; }
.timer-label { font-weight: 600; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-sub { font-size: var(--text-xs); color: var(--color-muted); }
.timer-actions { display: flex; gap: var(--space-1); flex-shrink: 0; }

/* Sem raio próprio — quem arredonda é o cartão, via overflow: hidden. */
.timer-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  border-radius: 0;
  background: var(--gradient-primary);
  transition: width 1s linear;
}

/* Cronômetro grande no modo foco ---------------------------------------- */

.timer-display {
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ==========================================================================
   7. Modo foco
   ========================================================================== */

.focus-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.focus-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.focus-progress-track {
  flex: 1;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-hover);
  overflow: hidden;
}
.focus-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-pill);
  transition: width var(--duration-slow) var(--ease);
}

.focus-body {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: var(--space-6) var(--space-5) var(--space-9);
}

.focus-card {
  width: 100%;
  max-width: 620px;
  padding: var(--space-7);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.focus-breadcrumb {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}
.focus-title {
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
}
.focus-meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-5); }
.focus-notes {
  padding: var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: var(--space-5);
}
.focus-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Os três botões com a mesma geometria: o primário era `btn-lg` e os outros
   não, e a diferença de altura aparecia lado a lado. A ênfase fica na cor.
   O slot precisa aparecer no seletor: `display: contents` muda o layout, não
   a árvore do DOM, então o botão de dentro não é filho de .focus-actions. */
.focus-actions > .btn,
.focus-timer-slot > .btn {
  height: 42px;
  padding: 0 var(--space-5);
  font-size: var(--text-md);
}

/* O slot some da caixa: quem entra na linha é o próprio botão. */
.focus-timer-slot { display: contents; }

/* Com sessão ativa o cronômetro ocupa a linha inteira, acima dos botões. */
.focus-timer-live {
  order: -1;
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.focus-timer-note {
  order: -1;
  flex: 1 0 100%;
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.focus-secondary {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  margin-top: var(--space-5);
  font-size: var(--text-sm);
}

.focus-done {
  text-align: center;
  max-width: 420px;
}
.focus-done-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background: var(--color-success-soft);
  color: var(--color-success);
}

/* ==========================================================================
   8. Markdown renderizado
   ========================================================================== */

.markdown { font-size: var(--text-base); line-height: 1.65; color: var(--color-text-soft); }
.markdown > *:first-child { margin-top: 0; }
.markdown > *:last-child { margin-bottom: 0; }
.markdown h2, .markdown h3, .markdown h4, .markdown h5, .markdown h6 {
  margin: var(--space-5) 0 var(--space-2);
  color: var(--color-text);
}
.markdown h2 { font-size: var(--text-lg); }
.markdown h3 { font-size: var(--text-md); }
.markdown h4, .markdown h5, .markdown h6 { font-size: var(--text-base); }
.markdown p { margin: 0 0 var(--space-3); }
.markdown ul, .markdown ol { margin: 0 0 var(--space-3); padding-left: 1.35rem; }
.markdown li { margin-bottom: var(--space-1); }
.markdown li::marker { color: var(--color-faint); }
.markdown strong { color: var(--color-text); font-weight: 700; }
.markdown mark {
  background: var(--color-warning-soft);
  color: var(--color-text);
  padding: 0 3px;
  border-radius: var(--radius-xs);
}
.markdown code {
  padding: 1px 5px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xs);
  font-size: 0.875em;
}
.markdown pre {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
}
.markdown pre code { padding: 0; background: none; border: 0; }
.markdown blockquote {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-left: 3px solid var(--color-primary-border);
  background: var(--color-primary-softer);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--color-text-soft);
}
.markdown hr { margin: var(--space-4) 0; }
.markdown a { text-decoration: underline; text-underline-offset: 2px; }

.markdown .md-task { list-style: none; display: flex; align-items: flex-start; gap: var(--space-2); margin-left: -1.35rem; }
.markdown .md-check {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 3px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-xs);
  font-size: 11px;
  line-height: 1;
  color: transparent;
}
.markdown .md-task.is-done .md-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-on-primary);
}
.markdown .md-task.is-done .md-task-text { color: var(--color-faint); text-decoration: line-through; }

/* Editor de markdown ----------------------------------------------------- */

.editor { border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); overflow: hidden; }
.editor:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  padding: var(--space-1);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}
.editor-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
}
.editor-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.editor-sep { width: 1px; height: 18px; margin: 0 var(--space-1); background: var(--color-border); }
.editor-textarea {
  display: block;
  width: 100%;
  min-height: 180px;
  padding: var(--space-3);
  border: 0;
  background: var(--color-surface);
  color: var(--color-text);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.65;
  resize: vertical;
}
.editor-textarea:focus { outline: none; }
.editor-preview { padding: var(--space-3); min-height: 180px; background: var(--color-surface); }
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* ==========================================================================
   9. Calendário
   ========================================================================== */

.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.calendar-period {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  min-width: 11rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  gap: 1px;
}
.calendar-weekday {
  padding: var(--space-2);
  background: var(--color-surface-2);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
}
.calendar-day {
  min-height: 116px;
  padding: var(--space-2) 5px;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.calendar-day.is-outside { background: var(--color-surface-2); }
.calendar-day.is-outside .calendar-daynum { color: var(--color-faint); }
.calendar-day.is-today { background: var(--color-primary-softer); }

.calendar-daynum {
  align-self: flex-start;
  padding: 0 5px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}
/* A bolinha do dia atual precisa zerar o padding lateral do número, senão
   o círculo fica descentralizado em relação ao dígito. */
.calendar-day.is-today .calendar-daynum {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 650;
  line-height: 1;
}

/*
 * Evento do dia: um traço colorido à esquerda e texto neutro. Bem mais calmo
 * que um retângulo preenchido por evento — a cor identifica o tipo sem
 * transformar o mês num mosaico.
 */
.calendar-event {
  position: relative;
  display: block;
  width: 100%;
  padding: 3px var(--space-2) 3px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-text-soft);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease);
}
.calendar-event::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 2px;
  background: var(--ev-color, var(--color-primary));
}
.calendar-event:hover { background: var(--color-surface-hover); }

/* O rótulo (R1, 45 min) fica discreto; o nome do conteúdo é o que se lê. */
.calendar-event-badge {
  color: var(--ev-color, var(--color-primary));
  font-weight: 600;
  margin-right: 4px;
}
.calendar-event-title { color: inherit; }

.calendar-more {
  align-self: flex-start;
  padding: 2px var(--space-2);
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--color-faint);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.calendar-more:hover { color: var(--color-primary); background: var(--color-primary-soft); }

/*
 * Cor por tipo de evento. `--ev-color` pinta o traço lateral no calendário;
 * as demais propriedades servem à legenda e aos badges da visão em lista.
 */
.ev-review_scheduled { --ev-color: var(--color-primary);
  background: var(--color-primary-soft); border-color: var(--color-primary-border); color: var(--color-primary); }
.ev-review_overdue { --ev-color: var(--color-danger);
  background: var(--color-danger-soft); border-color: var(--color-danger-border); color: var(--color-danger); }
.ev-review_completed { --ev-color: var(--color-success);
  background: var(--color-success-soft); border-color: var(--color-success-border); color: var(--color-success); }
.ev-maintenance { --ev-color: var(--color-info);
  background: var(--color-info-soft); border-color: var(--color-info-border); color: var(--color-info); }
.ev-study { --ev-color: var(--color-muted);
  background: var(--color-surface-hover); border-color: var(--color-border); color: var(--color-text-soft); }
.ev-free { --ev-color: var(--color-warning);
  background: var(--color-warning-soft); border-color: var(--color-warning-border); color: var(--color-warning); }

/* Dentro do calendário o chip é só traço + texto: nada de fundo preenchido. */
.calendar-day .calendar-event,
.calendar-week-day .calendar-event {
  background: transparent;
  border-color: transparent;
  color: var(--color-text-soft);
}
.calendar-day .calendar-event:hover,
.calendar-week-day .calendar-event:hover { background: var(--color-surface-hover); }

/* A revisão atrasada é a única que ganha destaque de cor no texto. */
.calendar-day .calendar-event.ev-review_overdue,
.calendar-week-day .calendar-event.ev-review_overdue { color: var(--color-danger); }

/* Barra de filtros em uma linha ----------------------------------------- */

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.filter-bar-field { flex: 1 1 160px; min-width: 150px; }

.filter-bar-label {
  display: block;
  margin-bottom: 6px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-muted);
}

/* "Limpar filtros" fica por último e alinhado com os campos. */
.filter-bar-action { flex: 0 0 auto; margin-left: auto; }

/* Multisseleção ---------------------------------------------------------- */

.multiselect { position: relative; }

.multiselect-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.multiselect-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multiselect.has-selection .multiselect-value { color: var(--color-text); font-weight: 500; }

.multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 45;
  min-width: 220px;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease);
}
.multiselect.is-open .multiselect-menu { opacity: 1; transform: none; pointer-events: auto; }

.multiselect-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}
.multiselect-option:hover { background: var(--color-surface-hover); }
.multiselect-option input { position: absolute; opacity: 0; width: 0; height: 0; }

.multiselect-box {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--color-border-strong);
  border-radius: 4px;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
}
.multiselect-box::after {
  content: '';
  width: 8px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
}
.multiselect-option input:checked + .multiselect-box {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.multiselect-option input:checked + .multiselect-box::after { opacity: 1; }
.multiselect-option input:focus-visible + .multiselect-box { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.multiselect-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ev-color, var(--color-primary));
}
.multiselect-text { flex: 1; min-width: 0; }

.multiselect-footer {
  margin-top: var(--space-1);
  padding-top: var(--space-1);
  border-top: 1px solid var(--color-border);
}

/* Pílulas de filtro por tipo de evento */
.chip-filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.chip-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 5px var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              color var(--duration-fast) var(--ease);
}
.chip-filter:hover { border-color: var(--color-border-strong); background: var(--color-surface-hover); }

/* O checkbox continua no DOM (o formulário depende dele), só invisível. */
.chip-filter input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.chip-filter:focus-within { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.chip-filter-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
  flex-shrink: 0;
}

/* Selecionado: a pílula assume a cor do próprio tipo de evento. */
.chip-filter:has(input:checked) {
  background: var(--ev-soft, var(--color-primary-soft));
  border-color: var(--ev-border, var(--color-primary-border));
  color: var(--ev-text, var(--color-primary));
  font-weight: 600;
}
.chip-filter:has(input:checked) .chip-filter-dot { opacity: 1; }

.chip-filter.ev-review_scheduled { --ev-soft: var(--color-primary-soft); --ev-border: var(--color-primary-border); --ev-text: var(--color-primary); }
.chip-filter.ev-review_overdue   { --ev-soft: var(--color-danger-soft);  --ev-border: var(--color-danger-border);  --ev-text: var(--color-danger); }
.chip-filter.ev-review_completed { --ev-soft: var(--color-success-soft); --ev-border: var(--color-success-border); --ev-text: var(--color-success); }
.chip-filter.ev-maintenance      { --ev-soft: var(--color-info-soft);    --ev-border: var(--color-info-border);    --ev-text: var(--color-info); }
.chip-filter.ev-study            { --ev-soft: var(--color-surface-hover); --ev-border: var(--color-border-strong); --ev-text: var(--color-text-soft); }
.chip-filter.ev-free             { --ev-soft: var(--color-warning-soft); --ev-border: var(--color-warning-border); --ev-text: var(--color-warning); }

.chip-filter.ev-review_scheduled .chip-filter-dot { color: var(--color-primary); }
.chip-filter.ev-review_overdue .chip-filter-dot { color: var(--color-danger); }
.chip-filter.ev-review_completed .chip-filter-dot { color: var(--color-success); }
.chip-filter.ev-maintenance .chip-filter-dot { color: var(--color-info); }
.chip-filter.ev-study .chip-filter-dot { color: var(--color-muted); }
.chip-filter.ev-free .chip-filter-dot { color: var(--color-warning); }

.calendar-legend {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-muted);
}
.legend-item { display: flex; align-items: center; gap: var(--space-2); }
/* Ponto sólido na cor do tipo — o fundo suave ficava quase invisível. */
.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 0;
  background: var(--ev-color, var(--color-primary));
}

/* Agenda de 7 dias na Home — mesma linguagem do calendário --------------- */

.agenda-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.agenda-day {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 128px;
  padding: var(--space-3) 6px;
  background: var(--color-surface);
}
.agenda-day.is-today { background: var(--color-primary-softer); }
.agenda-day.is-weekend { background: var(--color-surface-2); }
.agenda-day.is-weekend.is-today { background: var(--color-primary-softer); }

.agenda-day-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 0 4px;
  margin-bottom: var(--space-2);
}
.agenda-weekday {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-faint);
}
.agenda-daynum {
  font-size: var(--text-md);
  font-weight: 650;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.agenda-day.is-today .agenda-daynum { color: var(--color-primary); }

.agenda-empty {
  margin: auto 0;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-faint);
}

.agenda-more {
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-faint);
}

/* Lista e semana --------------------------------------------------------- */

.calendar-list { display: flex; flex-direction: column; gap: var(--space-4); }
.calendar-list-day {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.calendar-list-day:last-child { border-bottom: 0; }
.calendar-list-date { font-weight: 700; font-size: var(--text-base); }
.calendar-list-weekday { font-size: var(--text-xs); color: var(--color-muted); text-transform: capitalize; }
.calendar-list-events { display: flex; flex-direction: column; gap: var(--space-2); }

.calendar-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-2);
}
.calendar-week-day {
  min-height: 220px;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.calendar-week-day.is-today { border-color: var(--color-primary); }
.calendar-week-head { text-align: center; margin-bottom: var(--space-2); }

/* ==========================================================================
   10. Gráficos (SVG próprio)
   ========================================================================== */

.chart { width: 100%; overflow: visible; }
.chart-wrap { position: relative; width: 100%; }
.chart-line { fill: none; stroke: var(--color-primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: var(--color-primary); opacity: 0.09; }
.chart-grid { stroke: var(--color-border); stroke-width: 1; }
.chart-axis-label { fill: var(--color-faint); font-size: 10px; font-family: var(--font-sans); }
.chart-point { fill: var(--color-surface); stroke: var(--color-primary); stroke-width: 2; }
.chart-point-hit { fill: transparent; cursor: pointer; }
.chart-bar { fill: var(--color-primary); rx: 3; transition: opacity var(--duration-fast) var(--ease); }
.chart-bar:hover { opacity: 0.8; }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  padding: var(--space-2) var(--space-3);
  background: var(--color-text);
  color: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity var(--duration-fast) var(--ease);
}
.chart-tooltip.is-visible { opacity: 1; }

.chart-empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  color: var(--color-faint);
  font-size: var(--text-sm);
}

/* Barras horizontais ----------------------------------------------------- */

.bar-list { display: flex; flex-direction: column; gap: var(--space-3); }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2) var(--space-3); align-items: center; }
.bar-label { font-size: var(--text-base); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-value { font-size: var(--text-sm); font-weight: 600; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.bar-track {
  grid-column: 1 / -1;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-hover);
  overflow: hidden;
}
/* Mesma regra do .goal-fill: o raio fica só no trilho. */
.bar-fill {
  display: block;
  height: 100%;
  background: var(--gradient-primary);
  transition: width var(--duration-slow) var(--ease);
}

/* Progresso de metas ----------------------------------------------------- */

.goal-row { display: flex; align-items: center; gap: var(--space-3); }
.goal-track {
  flex: 1;
  min-width: 0;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-hover);
  overflow: hidden;
}
/*
 * O preenchimento NÃO tem raio próprio: quem arredonda é o trilho, via
 * overflow:hidden. Com raio nos dois, a ponta esquerda do preenchimento
 * "descolava" da borda do trilho e a barra parecia começar fora do lugar.
 */
.goal-fill {
  display: block;
  height: 100%;
  background: var(--gradient-primary);
}
.goal-fill.is-done { background: linear-gradient(135deg, #34d399, var(--color-success)); }
.goal-label { font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ==========================================================================
   11. Tabelas (viram cards no mobile)
   ========================================================================== */

.table-wrap {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.table { width: 100%; border-collapse: collapse; background: var(--color-surface); font-size: var(--text-base); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; }
.table th {
  background: var(--color-surface-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--color-border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-2); }

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 700;
  flex-shrink: 0;
}

/* Paginação -------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
}
.pagination-info { font-size: var(--text-sm); color: var(--color-muted); }

/* Abas ------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: var(--space-3) var(--space-4);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--color-muted);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Alertas ---------------------------------------------------------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  font-size: var(--text-base);
}
.alert-icon { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--color-success-soft); border-color: var(--color-success-border); color: var(--color-success); }
.alert-warning { background: var(--color-warning-soft); border-color: var(--color-warning-border); color: var(--color-warning); }
.alert-danger { background: var(--color-danger-soft); border-color: var(--color-danger-border); color: var(--color-danger); }
.alert-info { background: var(--color-info-soft); border-color: var(--color-info-border); color: var(--color-info); }

/* ==========================================================================
   12. Auth
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: var(--color-bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
.auth-brand:hover { text-decoration: none; }
.auth-box {
  padding: var(--space-7);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.auth-title { font-size: var(--text-xl); margin-bottom: var(--space-1); }
.auth-subtitle { color: var(--color-muted); font-size: var(--text-base); margin-bottom: var(--space-6); }
.auth-footer { margin-top: var(--space-5); text-align: center; font-size: var(--text-sm); color: var(--color-muted); }

/* Criação rápida de disciplina/assunto: os botões acompanham a altura do
   campo (38px), e não a altura padrão do .btn, para a linha ficar alinhada. */
.inline-create {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.inline-create .input { flex: 1; min-width: 0; }
.inline-create .btn {
  flex-shrink: 0;
  height: 38px;
}
.inline-create .btn-icon { width: 38px; }

/* Ajuda contextual: aparece no hover e também no foco, para o balão não ser
   privilégio de quem usa mouse. */
.tip {
  display: inline-grid;
  position: relative;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: var(--space-2);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--color-faint);
  cursor: help;
  vertical-align: -3px;
}
.tip:hover, .tip:focus-visible { color: var(--color-primary); }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  /* Ancorado à esquerda do ícone: os rótulos ficam na borda do formulário, e
     um balão centralizado de até 260px sairia da caixa. */
  left: -8px;
  z-index: 60;
  width: max-content;
  max-width: 260px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease);
}
.tip:hover::after,
.tip:focus-visible::after { opacity: 1; }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 40px; }

/* Centralizar por margem, e não por transform: `.btn:active` tem mais
   especificidade e derrubava o botão para fora do campo a cada clique. */
.password-toggle {
  position: absolute;
  top: 0;
  right: var(--space-1);
  bottom: 0;
  margin: auto 0;
}

/* O Edge desenha o próprio olho quando o campo tem texto; sobrariam dois. */
.password-wrap .input::-ms-reveal,
.password-wrap .input::-ms-clear { display: none; }

/* ==========================================================================
   13. Onboarding
   ========================================================================== */

.onboarding {
  padding: var(--space-6);
  background: linear-gradient(180deg, var(--color-primary-softer), var(--color-surface));
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-6);
}
.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
  margin: var(--space-5) 0;
}
.onboarding-step { display: flex; gap: var(--space-3); align-items: flex-start; }
.onboarding-num {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-size: var(--text-xs);
  font-weight: 700;
}
.onboarding-step-title { font-weight: 600; font-size: var(--text-base); }
.onboarding-step-text { font-size: var(--text-xs); color: var(--color-muted); }

/* ==========================================================================
   14. Chips de tag (input)
   ========================================================================== */

.chip-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
}
.chip-input:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.chip-input input {
  flex: 1;
  min-width: 110px;
  height: 28px;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--color-text);
}
.chip-input input:focus { outline: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-1) 2px var(--space-2);
  background: var(--color-primary-soft);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-sm);
  color: var(--color-primary);
  font-size: var(--text-xs);
  font-weight: 600;
}
.chip button {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.chip button:hover { background: var(--color-primary-border); }

.suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.suggestion {
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-muted);
  font-family: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}
.suggestion:hover { border-color: var(--color-primary-border); color: var(--color-primary); }

/* Linha de link editável ------------------------------------------------- */

.link-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr auto;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* Seção recolhível ------------------------------------------------------- */

.collapsible { border-top: 1px solid var(--color-border); margin-top: var(--space-4); padding-top: var(--space-3); }
.collapsible-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-text-soft);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.collapsible-toggle:hover { color: var(--color-text); }
.collapsible-toggle .icon { transition: transform var(--duration) var(--ease); }
.collapsible-toggle[aria-expanded='true'] .icon { transform: rotate(90deg); }
.collapsible-content { padding-top: var(--space-4); }

/* ==========================================================================
   15. Navegação mobile
   ========================================================================== */

.bottom-nav { display: none; }
.mobile-only { display: none; }

/* Ações secundárias da barra lateral: mesma dupla que o FAB oferece no
   celular, sem competir com o botão principal. */
.sidebar-actions {
  display: grid;
  gap: 2px;
  margin-top: var(--space-2);
}
.sidebar-actions .btn {
  justify-content: flex-start;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  color: var(--color-text-soft);
  font-weight: 500;
}
.sidebar-actions .btn:hover { color: var(--color-text); }

.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--bottomnav-height) + var(--space-4));
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--shadow-md);
  cursor: pointer;
}

/* ==========================================================================
   16. Responsivo
   ========================================================================== */

@media (max-width: 1200px) {
  :root { --page-gutter: var(--space-6); }
}

@media (max-width: 1080px) {
  :root { --sidebar-width: 212px; --page-gutter: var(--space-5); }
  .library-layout { grid-template-columns: 190px 1fr; }
  .stat-grid { gap: var(--space-3); }
  .stat { padding: var(--space-4); }
}

@media (max-width: 900px) {
  .library-layout { grid-template-columns: 1fr; }
  .filter-panel { position: static; }
  .calendar-list-day { grid-template-columns: 84px 1fr; }
}

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

  .sidebar { display: none; }

  .desktop-only { display: none !important; }
  .mobile-only { display: block; }

  :root { --page-gutter: var(--space-4); }

  /* No celular a barra superior volta — não há barra lateral para segurar
     a marca e as ações. */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    height: var(--topbar-height);
    padding: 0 var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
  }

  .action-rail { display: none; }

  /* Ao quebrar linha, a informação lateral vira mais uma linha do cabeçalho.
     No celular não há barrinha flutuante, então o padding extra sai. */
  .page-header { gap: var(--space-3); padding-right: 0; }
  .page-header-aside { text-align: left; }

  .page {
    padding: var(--space-5) var(--space-4);
    /* Espaço para a navegação inferior E para a barra do cronômetro, que
       fica acima dela — sem isso o último item da lista fica encoberto. */
    padding-bottom: calc(var(--bottomnav-height) + var(--space-10));
  }

  body:has(.timer-bar.is-visible) .page {
    padding-bottom: calc(var(--bottomnav-height) + 108px);
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    height: var(--bottomnav-height);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
  }

  .bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--color-muted);
    font-size: 10px;
    font-weight: 600;
    position: relative;
  }
  .bottom-nav-link:hover { text-decoration: none; }
  .bottom-nav-link.is-active { color: var(--color-primary); }
  .bottom-nav-badge {
    position: absolute;
    top: 6px;
    right: 50%;
    transform: translateX(16px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--radius-pill);
    background: var(--color-danger);
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
  }

  .fab { display: flex; }

  /* Modal vira folha inferior no celular */
  .modal-root { place-items: end center; padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: 0;
    transform: translateY(100%);
  }
  .overlay.is-open .modal { transform: none; }
  .modal-footer { border-radius: 0; padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom)); }

  .drawer { width: 100%; border-left: 0; }

  .timer-bar {
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--bottomnav-height) + var(--space-2));
    max-width: none;
  }

  .toast-region {
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--bottomnav-height) + var(--space-3));
    max-width: none;
  }

  .palette-root { padding-top: 0; place-items: start stretch; }
  .palette { max-width: none; border-radius: 0; min-height: 100dvh; }
  .palette-results { max-height: none; }

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

  .calendar-grid { font-size: var(--text-xs); }
  .calendar-day { min-height: 76px; padding: 3px; }
  .calendar-event { padding: 1px 4px; font-size: 10px; }
  .calendar-day .calendar-event { min-height: 0; }
  .calendar-week { grid-template-columns: 1fr; }
  .calendar-week-day { min-height: auto; }
  .calendar-list-day { grid-template-columns: 1fr; gap: var(--space-2); }

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

  .focus-card { padding: var(--space-5); }
  .focus-actions > .btn,
  .focus-timer-slot > .btn { padding: 0 var(--space-3); }
  .focus-body { padding: var(--space-4) var(--space-3) var(--space-8); }

  /* Tabelas viram cards */
  .table-wrap.responsive { border: 0; overflow: visible; }
  .table-wrap.responsive .table { background: transparent; }
  .table-wrap.responsive thead { display: none; }
  .table-wrap.responsive tbody tr {
    display: block;
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }
  .table-wrap.responsive tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-1) 0;
  }
  .table-wrap.responsive tbody td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
  }
  .table-wrap.responsive tbody td[data-label='']::before { display: none; }
}

@media (max-width: 420px) {
  /* Duas colunas continuam legíveis e poupam muita rolagem na tela Hoje. */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .stat { padding: var(--space-3); }
  .stat-value { font-size: var(--text-xl); }
  .field-row { grid-template-columns: 1fr; }
  .auth-box { padding: var(--space-5); }

  /* O seletor de período somava mais largura que a tela e fazia a página
     rolar de lado. Aqui ele ocupa a linha e divide o espaço entre as opções. */
  .segmented {
    display: flex;
    width: 100%;
  }
  .segmented button,
  .segmented a {
    flex: 1;
    min-width: 0;
    height: 34px;
    padding: 0 var(--space-2);
    justify-content: center;
  }

  /* Alvos de toque: 17px de altura é pouco para o dedo nos chips de evento. */
  .calendar-event {
    min-height: 30px;
    display: flex;
    align-items: center;
    padding: var(--space-1) var(--space-2) var(--space-1) 10px;
  }
}

@media (max-width: 330px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* Impressão -------------------------------------------------------------- */

@media print {
  .sidebar, .topbar, .bottom-nav, .timer-bar, .fab, .toast-region { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
  .page { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
}
