/* ===========================================================================================
   webCalendar — Style System v2
   Font: Plus Jakarta Sans (UI) + DM Mono (numbers/code)
   =========================================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&family=DM+Mono:wght@400;500&display=swap');

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ===== DESIGN TOKENS ===== */
:root {
  /* Surfaces */
  --bg:           #eef0f6;
  --surface:      #ffffff;
  --surface2:     #f5f6fa;
  --surface-hover:#f8f9ff;

  /* Borders */
  --border:        #e0e3ee;
  --border-subtle: #cdd1e3;

  /* Text */
  --text:      #0e1320;
  --text-dim:  #5b6478;
  --text-muted: var(--text-dim);

  /* Brand */
  --primary:       #2563eb;
  --primary-hover: #1d4fd8;
  --primary-light: #eff6ff;

  /* States */
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;

  /* Calendar tags */
  --tag-tareas:    #ef4444;
  --tag-estudio:   #7c3aed;
  --tag-proyectos: #059669;

  /* Tints */
  --tint-primary: #eff6ff;
  --tint-danger:  #fef2f2;
  --tint-warning: #fffbeb;
  --tint-success: #f0fdf4;

  /* Calendar */
  --cell-hover:  #eff6ff;
  --today-col:   #fafcff;

  /* Badges */
  --badge-neutral: #374151;

  /* Elevation */
  --shadow:    0 1px 3px rgba(14,19,32,.07), 0 1px 2px rgba(14,19,32,.04);
  --shadow-lg: 0 8px 24px rgba(14,19,32,.09), 0 2px 8px rgba(14,19,32,.05);
  --shadow-xl: 0 24px 48px rgba(14,19,32,.12), 0 8px 16px rgba(14,19,32,.06);

  /* Shape */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Header */
  --header-h: 60px;

  /* Scrollbars */
  --scrollbar-track: #e0e3ee;
  --scrollbar-thumb: #b0b6cc;
  --scrollbar-thumb-hover: #8890aa;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
  --bg:        #0c0d14;
  --surface:   #161820;
  --surface2:  #1e2030;
  --surface-hover: rgba(255,255,255,.04);
  --border:    #252738;
  --border-subtle: #363852;
  --text:      #d8daf0;
  --text-dim:  #6b7194;
  --primary:   #818cf8;
  --primary-hover: #a5b4fc;
  --primary-light: rgba(129,140,248,.12);
  --danger:    #f87171;
  --success:   #4ade80;
  --warning:   #fbbf24;
  --tag-tareas: #f87171;
  --tag-estudio: #a78bfa;
  --tag-proyectos: #34d399;
  --shadow:    0 1px 3px rgba(0,0,0,.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
  --shadow-xl: 0 24px 48px rgba(0,0,0,.6);
  --cell-hover:  rgba(129,140,248,.08);
  --today-col:   rgba(129,140,248,.04);
  --tint-primary: rgba(129,140,248,.14);
  --tint-danger:  rgba(248,113,113,.14);
  --tint-warning: rgba(251,191,36,.14);
  --tint-success: rgba(52,211,153,.14);
  --badge-neutral: #6b7394;
  --scrollbar-track: #1a1c2a;
  --scrollbar-thumb: #3a3d55;
  --scrollbar-thumb-hover: #555778;
}

/* ===== MIDNIGHT ===== */
[data-theme="midnight"] {
  --bg:        #080c18;
  --surface:   #111827;
  --surface2:  #0f172a;
  --surface-hover: rgba(255,255,255,.03);
  --border:    #1e2d47;
  --border-subtle: #2a3f5f;
  --text:      #e2e8f0;
  --text-dim:  #64748b;
  --primary:   #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-light: rgba(56,189,248,.12);
  --danger:    #f87171;
  --success:   #4ade80;
  --warning:   #facc15;
  --tag-tareas:    #fb923c;
  --tag-estudio:   #818cf8;
  --tag-proyectos: #4ade80;
  --shadow:    0 1px 3px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
  --shadow-xl: 0 24px 48px rgba(0,0,0,.7);
  --cell-hover:  rgba(56,189,248,.06);
  --today-col:   rgba(56,189,248,.03);
  --surface2: #0d1624;
  --tint-primary: rgba(56,189,248,.14);
  --tint-danger:  rgba(248,113,113,.14);
  --tint-warning: rgba(250,204,21,.14);
  --tint-success: rgba(74,222,128,.14);
  --badge-neutral: #5a7494;
  --scrollbar-track: #0d1624;
  --scrollbar-thumb: #1e2d47;
  --scrollbar-thumb-hover: #2a3f5f;
}

/* ===== EMERALD ===== */
[data-theme="emerald"] {
  --bg:        #ecfdf5;
  --surface:   #ffffff;
  --surface2:  #f0fdf4;
  --border:    #bbf7d0;
  --border-subtle: #86efac;
  --text:      #14532d;
  --text-dim:  #4d7c5f;
  --primary:   #16a34a;
  --primary-hover: #15803d;
  --primary-light: #dcfce7;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --tag-tareas: #dc2626;
  --tag-estudio: #7c3aed;
  --tag-proyectos: #0891b2;
  --shadow:    0 1px 3px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.08);
  --cell-hover: #dcfce7;
  --today-col:  #f0fdf4;
  --tint-primary: #dcfce7;
}

/* ===== ROSE ===== */
[data-theme="rose"] {
  --bg:        #fff1f2;
  --surface:   #ffffff;
  --surface2:  #fff5f6;
  --border:    #fecdd3;
  --border-subtle: #fda4af;
  --text:      #1c1917;
  --text-dim:  #78716c;
  --primary:   #e11d48;
  --primary-hover: #be123c;
  --primary-light: #ffe4e6;
  --danger:    #e11d48;
  --success:   #16a34a;
  --warning:   #d97706;
  --tag-tareas: #f97316;
  --tag-estudio: #9333ea;
  --tag-proyectos: #0891b2;
  --cell-hover: #ffe4e6;
  --today-col:  #fff8f9;
  --tint-primary: #ffe4e6;
}

/* ===== OCEAN ===== */
[data-theme="ocean"] {
  --bg:        #e0f2fe;
  --surface:   #ffffff;
  --surface2:  #f0f9ff;
  --border:    #bae6fd;
  --border-subtle: #7dd3fc;
  --text:      #0c2a3e;
  --text-dim:  #4e7a97;
  --primary:   #0369a1;
  --primary-hover: #075985;
  --primary-light: #e0f2fe;
  --danger:    #dc2626;
  --success:   #16a34a;
  --warning:   #d97706;
  --tag-tareas: #dc2626;
  --tag-estudio: #7c3aed;
  --tag-proyectos: #059669;
  --cell-hover: #bae6fd;
  --today-col:  #f0f9ff;
  --tint-primary: #e0f2fe;
}

/* ===== SCROLLBARS ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); border-radius: 4px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ===== BASE ===== */
body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--surface);
}

/* Numeric displays */
.mono, .checklist-deadline, .checklist-eta, .upcoming-time,
.task-prog-input, .cu-num-val, .cu-count-val, .lb-hours,
.stats-total-card .value, .grid-time {
  font-family: 'DM Mono', 'JetBrains Mono', monospace;
}

/* ===== HEADER ===== */
.app-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 300;
}

.app-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  margin-right: 24px;
  letter-spacing: -0.4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: linear-gradient(135deg, var(--primary) 0%, color-mix(in srgb, var(--primary) 60%, #7c3aed) 100%);
  border-radius: 5px;
  flex-shrink: 0;
}

.app-nav {
  display: flex;
  gap: 2px;
  height: 100%;
  align-items: center;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-width: 0;
}
.app-nav::-webkit-scrollbar { display: none; }

.nav-tab {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: background .12s ease, color .12s ease;
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}
.nav-tab:hover {
  background: var(--bg);
  color: var(--text);
}
.nav-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

/* ===== HEADER USER ===== */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 16px;
  flex-shrink: 0;
}
.header-email {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== HAMBURGER / MOBILE NAV ===== */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  border-radius: 8px;
  transition: background 0.12s;
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}
.nav-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 199;
}
.nav-backdrop.visible { display: block; }

/* ===== MAIN ===== */
.app-main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}
.app-main.dashboard-mode { padding: 0; max-width: none; overflow: hidden; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== DASHBOARD ===== */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 30vw;
  grid-template-rows: 1fr;
  height: calc(100vh - var(--header-h));
  overflow: hidden;
  background: var(--bg);
}

.dashboard-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
  align-self: stretch;
}
.dashboard-panel:last-child { border-right: none; }

#panel-tasks .panel-header,
#panel-events .panel-header {
  height: 70px;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 10px;
}
.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text);
}
.panel-date {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  font-family: 'DM Mono', monospace;
}
.panel-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
#panel-events .panel-actions { flex-wrap: nowrap; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  background: var(--bg);
  transition: opacity 0.15s ease;
}

/* ===== CHECKLIST ===== */
.checklist-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-dim);
  padding: 10px 4px 5px;
}
.checklist-section-label:first-child { padding-top: 2px; }

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: border-color .15s, box-shadow .15s;
  cursor: default;
}
.checklist-item:hover {
  border-color: var(--border-subtle);
  border-left-color: var(--primary);
  box-shadow: var(--shadow);
}
.checklist-item.done {
  opacity: 0.38;
  border-left-color: var(--border) !important;
}

.check-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  background: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--success);
  font-weight: 700;
  transition: all .15s;
  padding: 0;
}
.check-btn:hover {
  border-color: var(--success);
  background: var(--tint-success);
}
.check-btn.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.checklist-info { flex: 1; min-width: 0; }
.checklist-concepto {
  font-size: 13px;
  font-weight: 600;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.checklist-deadline {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  display: inline-block;
}
.checklist-deadline.urgent { color: var(--danger); font-weight: 600; }
.checklist-deadline.soon   { color: var(--warning); font-weight: 600; }
.checklist-meta {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.evt-edit-btn, .evt-del-btn {
  display: none;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.6;
  border-radius: 4px;
  cursor: pointer;
}
.evt-del-btn { color: var(--danger); border-color: var(--danger); }
.checklist-item:hover .evt-edit-btn,
.checklist-item:hover .evt-del-btn { display: inline-flex; }

.evt-inline-edit {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  flex-wrap: wrap;
}

.prio-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-dim);
  font-family: 'DM Mono', monospace;
}
.prio-badge[data-prio="5"] { background: var(--tint-danger);   color: var(--danger); }
.prio-badge[data-prio="4"] { background: var(--tint-warning);  color: var(--warning); }
.prio-badge[data-prio="3"] { background: var(--tint-primary);  color: var(--primary); }
.checklist-eta { font-size: 11px; color: var(--text-dim); }

/* ===== UPCOMING EVENTS ===== */
.upcoming-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 6px;
  transition: box-shadow .15s, border-color .15s;
}
.upcoming-item:hover { box-shadow: var(--shadow); }

.upcoming-date {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-dim);
}
.upcoming-date.today    { color: var(--primary); }
.upcoming-date.tomorrow { color: var(--warning); }
.upcoming-title { font-size: 13px; font-weight: 600; margin-top: 2px; color: var(--text); }
.upcoming-time  { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-family: 'DM Mono', monospace; }

.upcoming-countdown {
  display: inline-block;
  margin-top: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-dim);
  font-family: 'DM Mono', monospace;
}
.upcoming-countdown.urgent {
  background: var(--tint-danger);
  color: var(--danger);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
  white-space: nowrap;
  font-family: inherit;
  text-decoration: none;
  line-height: 1;
}
.btn:hover {
  background: var(--surface2);
  border-color: var(--border-subtle);
}
.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(37,99,235,.28);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-dim);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border-subtle);
}

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

.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--tint-danger); border-color: var(--danger); }

/* ===== TOOLBARS ===== */
.calendar-toolbar, .tasks-toolbar, .stats-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar-group { display: flex; align-items: center; gap: 8px; }
.week-label {
  font-weight: 700;
  font-size: 14px;
  min-width: 180px;
  text-align: center;
  font-family: 'DM Mono', monospace;
  letter-spacing: -0.3px;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
}
.toggle-label input { accent-color: var(--primary); }

/* ===== CALENDAR GRID ===== */
.calendar-grid-wrapper { overflow-x: auto; }
.calendar-grid {
  display: grid;
  min-width: 700px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.grid-header { display: contents; }
.grid-header-cell {
  padding: 8px 4px;
  text-align: center;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text-dim);
}
.grid-header-cell:first-child {
  width: 60px;
  background: var(--surface);
}
.grid-row { display: contents; }
.grid-time {
  padding: 0 6px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 30px;
  font-family: 'DM Mono', monospace;
  letter-spacing: -0.2px;
}
.grid-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  min-height: 30px;
  background: var(--surface);
  cursor: pointer;
  transition: background .08s;
  padding: 2px;
  position: relative;
}
.grid-cell:hover { background: var(--cell-hover); }
.grid-cell.today-col { background: var(--today-col); }

/* Event blocks */
.cell-event {
  padding: 2px 5px;
  margin: 1px 0;
  border-radius: 4px;
  font-size: 10px;
  color: #fff;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  user-select: none;
  font-weight: 500;
}
.cell-event[data-type="Fixed"]     { border-left: 3px solid rgba(255,255,255,.45); }
.cell-event[data-type="Tareas"]    { background: var(--tag-tareas); }
.cell-event[data-type="Estudio"]   { background: var(--tag-estudio); }
.cell-event[data-type="Proyectos"] { background: var(--tag-proyectos); }
.cell-event[data-type="Fixed"]     { background: #64748b; }
.cell-event.span-2 { min-height: 62px; }
.cell-event.span-3 { min-height: 94px; }
.cell-event.span-4 { min-height: 126px; }

/* Legend */
.calendar-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-dim);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* ===== TASKS ===== */
.task-form-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.task-form h3 { margin-bottom: 16px; font-size: 15px; font-weight: 700; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-group input, .form-group select, .form-group textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: var(--surface);
}
.form-actions { display: flex; gap: 8px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .form-group { min-width: 150px; }

/* Task list */
.task-list { display: flex; flex-direction: column; gap: 4px; }
.task-row {
  display: grid;
  grid-template-columns: 32px 1fr 120px 50px 50px 50px 80px 80px 100px;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  align-items: center;
  transition: box-shadow .12s, border-color .12s;
}
.task-row:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-subtle);
}
.task-row.completed { opacity: .4; }
.task-prio {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  font-family: 'DM Mono', monospace;
}
.task-prio[data-prio="1"] { background: var(--danger); }
.task-prio[data-prio="2"] { background: var(--warning); }
.task-prio[data-prio="3"] { background: var(--success); }
.task-prio[data-prio="4"] { background: var(--primary); }
.task-prio[data-prio="5"] { background: var(--badge-neutral); }
.task-actions { display: flex; gap: 3px; }
.task-actions .btn { padding: 3px 8px; font-size: 11px; }
.progress-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--bg);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width .3s ease;
}

/* Task progress widget (dashboard) */
.task-prog-wrap {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}
.task-prog-input {
  width: 42px;
  padding: 4px 2px 4px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  -moz-appearance: textfield;
  outline: none;
  transition: border-color .12s;
  font-family: 'DM Mono', monospace;
}
.task-prog-input::-webkit-inner-spin-button,
.task-prog-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.task-prog-input:focus {
  border-color: var(--primary);
  background: var(--surface);
}
.task-prog-unit {
  padding: 4px 6px 4px 3px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--bg);
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.6;
}
.task-prog-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin: 3px 0 1px;
  overflow: hidden;
}
.task-prog-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .3s ease;
}

/* ===== SUBJECTS ===== */
#tab-subjects { padding: 20px; }
.subjects-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.subjects-form-card,
.subjects-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.subjects-form-card h3,
.subjects-table-card h3 { margin-bottom: 16px; font-size: 15px; font-weight: 700; }
.subjects-table-card { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  padding: 6px 10px;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }

/* Exam inline form */
.exam-inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0;
}
.eif-input {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}
.eif-dur-wrap { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-dim); }
.eif-err { font-size: 12px; color: var(--danger); margin-top: 4px; min-height: 16px; }
.exam-form-row td { padding: 0 8px 10px; }

/* ===== STATS ===== */
.stats-content { margin-top: 16px; }

/* --- Overview container --- */
.stats-overview-container { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stats-divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* --- Summary cards row --- */
.stats-summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stats-card-sm {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stats-card-sm-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.stats-card-sm-value {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.stats-card-sm-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .4px;
}

/* --- Horizontal breakdown bar --- */
.stats-hbar {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  display: flex;
  overflow: hidden;
}
.stats-hbar-seg { height: 100%; }
.stats-breakdown-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 2px;
}
.stats-breakdown-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--text-dim);
}
.sbi-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.sbi-empty { font-size: 11px; color: var(--text-dim); font-style: italic; }

/* --- 7-day stacked bar chart card --- */
.stats-7d {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stats-daily-chart { width: 100%; overflow: hidden; }
.stats-chart-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: -0.2px;
}

/* --- Custom charts section --- */
.stats-custom-section { display: flex; flex-direction: column; gap: 14px; }
.stats-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stats-section-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.stats-charts-list { display: flex; flex-direction: column; gap: 12px; }
.stats-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}
.stats-chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.stats-chart-card-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}
.stats-chart-card-actions { display: flex; gap: 6px; }
.stats-chart-card-body { width: 100%; min-width: 0; overflow: hidden; }
.chart-empty {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
  padding: 20px 0;
  text-align: center;
}

/* --- Pie chart legend --- */
.pie-wrap { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.pie-legend-row { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text); }
.pie-legend-dot { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.pie-legend-val { margin-left: auto; font-weight: 700; font-size: 11px; color: var(--text-dim); }

/* --- Chart builder overlay --- */
.chart-builder-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  width: min(540px, 92vw);
  min-width: 0;
  box-shadow: var(--shadow-lg, 0 8px 32px rgba(0,0,0,.18));
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.chart-builder-box .modal-body { min-width: 0; overflow: hidden; }
.chart-builder-box h3 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.4px;
  margin: 0;
}
.cb-form { display: flex; flex-direction: column; gap: 14px; }
.cb-row { display: flex; flex-direction: column; gap: 4px; }
.cb-row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cb-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
}
.cb-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}
.cb-input-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
  width: 68px;
}
.cb-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}
.cb-checkbox-row { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }

/* --- Series list --- */
.cb-series-section { display: flex; flex-direction: column; gap: 8px; }
.cb-series-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cb-series-list { display: flex; flex-direction: column; gap: 6px; }
.cb-series-header-row {
  display: grid;
  grid-template-columns: minmax(0,1.4fr) minmax(0,1.5fr) minmax(0,1.5fr) auto;
  gap: 6px;
  padding: 0 8px;
}
.cb-s-col-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
}
.cb-series-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1.2fr) auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}
/* shared input/select appearance for series row children */
.cb-s-tipo,
.cb-s-concept,
.cb-s-label {
  min-width: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  font-family: inherit;
}
.cb-s-remove { flex-shrink: 0; }

/* --- Chart builder wizard --- */
.cb-step { display: none; }
.cb-step.active { display: block; }

.cb-step-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.cb-step-pill {
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.cb-step-pill.active {
  background: color-mix(in srgb, var(--primary,#89b4fa) 15%, transparent);
  color: var(--primary, #89b4fa);
  border-color: color-mix(in srgb, var(--primary,#89b4fa) 40%, transparent);
}
.cb-step-pill.done {
  background: color-mix(in srgb, var(--success,#a6e3a1) 12%, transparent);
  color: var(--success, #a6e3a1);
  border-color: color-mix(in srgb, var(--success,#a6e3a1) 35%, transparent);
}
.cb-step-arrow { color: var(--border); font-size: 12px; }

/* --- Type selection cards --- */
.cb-type-cards { display: flex; flex-direction: column; gap: 8px; }
.cb-type-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.cb-type-card:hover { border-color: var(--primary, #89b4fa); }
.cb-type-card.selected {
  border-color: var(--primary, #89b4fa);
  background: color-mix(in srgb, var(--primary,#89b4fa) 8%, transparent);
}
.cb-type-card-icon { font-size: 22px; flex-shrink: 0; }
.cb-type-card-name { font-size: 13px; font-weight: 700; color: var(--text); }
.cb-type-card-desc { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.cb-type-card-check { margin-left: auto; color: var(--primary, #89b4fa); font-size: 14px; opacity: 0; transition: opacity .1s; }
.cb-type-card.selected .cb-type-card-check { opacity: 1; }

/* --- Step 2 layout helpers --- */
.cb-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.cb-series-entry { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.cb-series-autolabel {
  font-size: 11px;
  color: var(--success, #a6e3a1);
  padding-left: 8px;
}

/* --- Auto-filled title --- */
.cb-title-auto {
  border-color: color-mix(in srgb, var(--primary,#89b4fa) 40%, transparent) !important;
  color: var(--primary, #89b4fa) !important;
  font-style: italic;
}

/* --- Legacy stats kept for any remaining references --- */
.stats-total {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stats-total-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stats-total-card .value { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stats-total-card .label { font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .5px; margin-top: 6px; }
.stats-total-card .value.tareas    { color: var(--tag-tareas); }
.stats-total-card .value.estudio   { color: var(--tag-estudio); }
.stats-total-card .value.proyectos { color: var(--tag-proyectos); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.stats-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow); }
.stats-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 14px; letter-spacing: -0.2px; }
.stats-card table { width: 100%; border-collapse: collapse; }
.stats-card th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); padding: 4px 8px; }
.stats-card td { padding: 6px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 9999;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
  transform: translateY(6px);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14,19,32,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: 92vw;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close {
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .12s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

/* ===== SPLASH (boot screen — prevents black flash) ===== */
#splash {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity .5s ease;
}
#splash.fade-out { opacity: 0; pointer-events: none; }

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay .spinner { width: 32px; height: 32px; border-width: 3px; }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: var(--radius);
}

/* ===== AUTH SCREEN ===== */
#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37,99,235,.12) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 90% 90%, rgba(124,58,237,.08) 0%, transparent 60%);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
}

.auth-title {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.auth-title::before {
  content: '';
  display: inline-block;
  width: 22px;
  height: 22px;
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 6px;
  flex-shrink: 0;
}

.auth-tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 22px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
}
.auth-tab {
  flex: 1;
  padding: 7px;
  border: none;
  background: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  transition: background .12s, color .12s, box-shadow .12s;
  font-family: inherit;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow);
}
.auth-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 8px;
  min-height: 16px;
  font-weight: 500;
}

.auth-form .form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: none;
  letter-spacing: 0;
}
.auth-form .form-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 10px 12px;
}
.auth-form .form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: var(--surface);
}

/* ===== SETTINGS ===== */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
}
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.settings-card h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}
.settings-card h4 {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.settings-card-wide { grid-column: 1 / 3; }
.settings-status { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.settings-status:empty { display: none; }
.settings-hint { font-size: 12px; color: var(--text-dim); line-height: 1.55; }
.settings-hint a { color: var(--primary); }
.settings-hint code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'DM Mono', monospace;
}

/* ===== TIMEZONE PICKER ===== */
.tz-zone-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s;
}
.tz-zone-btn:hover { border-color: var(--primary); color: var(--text); }
.tz-zone-btn.tz-zone-selected { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.08); }
.tz-zone-full { display: none; }

/* ===== INLINE INPUT ===== */
.inline-input {
  padding: 4px 8px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: box-shadow .12s;
}
.inline-input:focus { box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.row-actions { white-space: nowrap; }

/* ===== SCHEDULE MODAL ===== */
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  min-width: 300px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-xl);
}
.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.modal-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  flex-wrap: wrap;
  padding: 4px 0;
}
.modal-option:hover { color: var(--primary); }
.modal-option input[type="radio"] { accent-color: var(--primary); cursor: pointer; }
.modal-hint { color: var(--text-dim); font-size: 11px; }
.modal-date-input {
  margin-left: 2px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: 'DM Mono', monospace;
}
.modal-date-input:disabled { opacity: 0.38; cursor: not-allowed; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* ===== INFO BUTTON ===== */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 5px;
  line-height: 1;
  padding: 0;
  transition: background .12s, color .12s;
}
.info-btn:hover { background: var(--primary); color: #fff; }

/* ===== GUIDE MODAL ===== */
.guide-box {
  max-width: 520px;
  width: 94vw;
  max-height: 85vh;
  overflow-y: auto;
  gap: 0;
  padding: 22px 26px;
}
.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.guide-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  border-radius: 6px;
  transition: background .12s;
}
.guide-close:hover { background: var(--bg); color: var(--text); }
.guide-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
}
.guide-steps li strong { color: var(--text); }
.guide-steps a { color: var(--primary); text-decoration: none; }
.guide-steps a:hover { text-decoration: underline; }
.guide-steps code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}
.guide-sub {
  margin: 6px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  list-style: disc;
}
.guide-warn { color: var(--warning); font-weight: 600; }
.guide-footer { display: flex; justify-content: flex-end; margin-top: 20px; }

/* ===== SCHEDULING SETTINGS ===== */
.sched-days { display: flex; flex-direction: column; gap: 6px; }
.sched-day-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sched-day-row:last-child { border-bottom: none; }
.sched-day-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  min-width: 110px;
  font-size: 13px;
  font-weight: 600;
  padding-top: 3px;
}
.sched-day-toggle input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.sched-intervals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.sched-interval {
  display: flex;
  align-items: center;
  opacity: 0;
  gap: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  transition: border-color .12s;
}
.sched-interval:hover { border-color: var(--border-subtle); }
.sched-interval.iv-in  { opacity: 1; transition: opacity .13s ease; }
.sched-interval.iv-out { opacity: 0; transition: opacity .13s ease; }
.sched-interval input[type="time"],
.sched-interval input.tp-input {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  padding: 0;
  width: 80px;
  font-family: 'DM Mono', monospace;
}
.sched-sep { color: var(--text-dim); font-size: 12px; }
.btn-add-interval {
  align-self: flex-start;
  margin-top: 2px;
  white-space: nowrap;
}

/* Calendar chips */
.cal-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.cal-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.cal-chip-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
}
.cal-chip-del:hover { color: var(--danger); }
.cal-add-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.study-intensity-grid { display: flex; flex-direction: column; gap: 8px; }
.study-intensity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.study-intensity-label { min-width: 100px; color: var(--text-dim); font-weight: 500; }
.study-intensity-unit  { color: var(--text-dim); font-size: 12px; }

/* Clear schedule modal */
.modal-label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.clear-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.clear-toggle input[type="checkbox"] { accent-color: var(--primary); cursor: pointer; }

/* Password visibility toggle */
.pw-input-wrap { position: relative; display: flex; align-items: center; }
.pw-input-wrap input { width: 100%; padding-right: 38px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1;
  display: flex;
  align-items: center;
}
.pw-toggle:hover { color: var(--text); }

/* Toggle for calendar sync / auto-sched */
.sched-day-toggle.is-row-toggle { font-weight: 500; }

/* ===== CHECKUP ===== */
.checkup-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
  align-items: start;
}
@media (max-width: 860px) { .checkup-layout { grid-template-columns: 1fr; } }

.checkup-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}
.checkup-panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.checkup-heading { font-size: 14px; font-weight: 700; margin: 0 0 2px; }
.checkup-date-label { font-size: 12px; color: var(--text-dim); font-family: 'DM Mono', monospace; }

.checkup-add-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.checkup-add-form input[type="text"],
.checkup-add-form select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.checkup-add-form input[type="text"]:focus,
.checkup-add-form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.checkup-add-form input[type="text"] { flex: 1; min-width: 120px; }

/* Item cards */
.checkup-grid { display: flex; flex-direction: column; gap: 8px; }
.cu-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color .12s;
}
.cu-card:hover { border-color: var(--border-subtle); }
.cu-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.cu-card-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cu-type-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 20px;
  margin-left: 6px;
}
.cu-badge-num     { background: var(--tint-primary); color: var(--primary); }
.cu-badge-bool    { background: var(--tint-success);  color: var(--success); }
.cu-badge-hour    { background: var(--tint-warning);  color: var(--warning); }
.cu-badge-count   { background: var(--tint-danger);   color: var(--danger); }
.cu-badge-event   { background: var(--tint-primary);  color: var(--primary); }
.cu-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  transition: color .12s, background .12s;
}
.cu-delete:hover { color: var(--danger); background: var(--tint-danger); }

/* Num input */
.cu-num-row { display: flex; align-items: center; gap: 10px; }
.cu-slider { flex: 1; accent-color: var(--primary); cursor: pointer; height: 4px; }
.cu-num-val { font-size: 20px; font-weight: 700; color: var(--primary); min-width: 26px; text-align: center; }
.cu-num-ends { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* Bool toggle */
.cu-bool-row { display: flex; align-items: center; gap: 10px; }
.cu-toggle-wrap { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.cu-toggle-wrap input { opacity: 0; width: 0; height: 0; position: absolute; }
.cu-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background .2s;
}
.cu-toggle-wrap input:checked ~ .cu-toggle-track { background: var(--primary); }
.cu-toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.cu-toggle-wrap input:checked ~ .cu-toggle-track::after { left: 23px; }
.cu-bool-label { font-size: 13px; color: var(--text-dim); }

/* Hour input */
.cu-hour-row { display: flex; flex-direction: column; gap: 8px; }
.cu-hour-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cu-hour-custom { display: flex; align-items: center; gap: 5px; }
.cu-custom-time {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  width: 110px;
  font-family: 'DM Mono', monospace;
}
.cu-hour-chips { display: flex; flex-wrap: wrap; gap: 5px; min-height: 24px; }
.cu-hour-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px 2px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}
.cu-hour-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  padding: 0 1px;
  display: flex;
  align-items: center;
}
.cu-hour-remove:hover { color: var(--danger); }

/* Count input */
.cu-count-row { display: flex; align-items: center; gap: 16px; }
.cu-count-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
  line-height: 1;
}
.cu-count-btn:hover { background: var(--primary); color: #fff; }
.cu-count-sub { border-color: var(--danger); color: var(--danger); }
.cu-count-sub:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.cu-count-val { font-size: 28px; font-weight: 800; color: var(--primary); min-width: 36px; text-align: center; }
.cu-count-unit { font-size: 12px; color: var(--text-dim); }

/* History */
.checkup-history-wrap { overflow-y: auto; max-height: 600px; }
.cu-history-day { margin-bottom: 16px; }
.cu-history-day-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .07em;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  font-family: 'DM Mono', monospace;
}
.cu-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.cu-history-table td { padding: 5px 8px; vertical-align: top; border-bottom: 1px solid var(--border); }
.cu-history-table tr:last-child td { border-bottom: none; }
.cu-history-table td:first-child { font-weight: 600; color: var(--text); width: 40%; }
.cu-hist-done    { color: var(--success); font-weight: 600; font-size: 12px; }
.cu-hist-notdone { color: var(--danger);  font-weight: 600; font-size: 12px; }
.cu-hist-ts {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: 6px;
  font-weight: 400;
  font-family: 'DM Mono', monospace;
}
.cu-hist-time { font-size: 10px; color: var(--text-dim); margin-left: 4px; font-family: 'DM Mono', monospace; }
.cu-hist-name { width: 50%; }
.hist-add-btns { display: flex; gap: 4px; }
.cu-committed-at { font-size: 10px; color: var(--text-dim); margin-top: 4px; text-align: right; font-family: 'DM Mono', monospace; }
.hist-val-cell { color: var(--text-dim); }
.hist-act-cell { width: 64px; white-space: nowrap; text-align: right; vertical-align: middle; padding-right: 0 !important; }
.hist-act-cell .btn { padding: 1px 5px; font-size: 11px; opacity: 0.45; min-width: 0; }
.hist-act-cell .btn:hover { opacity: 1; }
.hist-add-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 2px 10px;
  flex-wrap: wrap;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 6px;
}
.hist-fl {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
}
.hist-fl input, .hist-fl select { font-size: 12px; }
.hist-edit-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px 4px;
  background: var(--bg);
  border-radius: var(--radius);
}
.hist-val-wrap { display: contents; }

/* ===== LEADERBOARD ===== */
.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 0;
  gap: 12px;
}
.lb-page-title { font-size: 15px; font-weight: 700; }
.lb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 16px 20px 20px;
}
@media (max-width: 860px) { .lb-grid { grid-template-columns: 1fr; } }

.lb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}
.lb-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tag-estudio);
  margin-bottom: 2px;
}
.lb-card-subtitle { font-size: 11px; color: var(--text-dim); margin-bottom: 10px; }
.lb-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.lb-entry { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: flex; align-items: baseline; gap: 8px; }
.lb-rank { font-size: 14px; min-width: 22px; text-align: center; flex-shrink: 0; }
.lb-email {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.lb-email.lb-me { color: var(--primary); font-weight: 700; }
.lb-hours {
  font-size: 13px;
  font-weight: 700;
  color: var(--tag-estudio);
  white-space: nowrap;
  flex-shrink: 0;
}
.lb-days { font-size: 10px; color: var(--text-dim); margin-left: 4px; font-weight: 400; }
.lb-bar-track {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  overflow: hidden;
}
.lb-bar-fill {
  height: 100%;
  background: var(--tag-estudio);
  border-radius: 2px;
  opacity: .45;
  transition: width .4s ease;
}
.lb-bar-fill.lb-me { opacity: 0.9; }
.lb-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 20px 0; }

/* ===== THEME SWATCHES ===== */
.theme-swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  cursor: pointer;
  transition: border-color .12s, transform .1s, box-shadow .12s;
  min-width: 70px;
}
.theme-swatch:hover { transform: translateY(-2px); border-color: var(--border-subtle); }
.theme-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.swatch-preview {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,.22);
}
.swatch-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.theme-swatch.active .swatch-label { color: var(--primary); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root { --header-h: 52px; }

  .hamburger-btn { display: flex; }
  .app-header { padding: 0 12px; gap: 6px; }
  .app-title { flex: 1; margin-right: 0; }

  .app-nav {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 220px;
    height: calc(100dvh - var(--header-h));
    flex-direction: column;
    align-items: stretch;
    flex: unset;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 20px rgba(0,0,0,0.12);
    z-index: 200;
    padding: 10px 8px;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
  }
  .app-nav.mobile-open { display: flex; }
  .app-nav::-webkit-scrollbar { display: none; }
  .nav-backdrop { top: var(--header-h); }

  .nav-tab {
    width: 100%;
    text-align: left;
    height: auto;
    padding: 11px 14px;
    font-size: 14px;
    border-radius: 8px;
    flex-shrink: 0;
  }
  .app-main { padding: 14px; }
  .subjects-layout { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: 28px 1fr 72px auto; gap: 4px; }
  .task-row > :nth-child(4),
  .task-row > :nth-child(5),
  .task-row > :nth-child(6) { display: none; }
  .task-concepto { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .task-actions { gap: 2px; }
  .task-actions .btn { padding: 3px 6px; font-size: 11px; }
  .stats-total { grid-template-columns: 1fr; }
  .stats-summary-cards { grid-template-columns: 1fr; }
  .pie-wrap { flex-direction: column; }
  .chart-builder-box { padding: 18px 16px; }
  .cb-series-row { flex-wrap: wrap; }
  .cb-s-tipo, .cb-s-concept, .cb-s-label { width: 100%; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .form-group { min-width: unset; }
  .inline-form button[type="submit"] { width: 100%; }
  .settings-layout { grid-template-columns: 1fr; padding: 14px; gap: 12px; }
  .settings-card-wide { grid-column: auto; }
}

@media (max-width: 700px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-rows: 1.86fr 1fr;
    height: calc(100dvh - var(--header-h));
  }
  .dashboard-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .dashboard-panel:last-child { border-bottom: none; }
  #panel-tasks .panel-header {
    flex-wrap: nowrap;
    padding: 8px 12px;
    gap: 6px;
  }
  #panel-tasks .panel-header > div:first-child {
    min-width: 0;
    flex-shrink: 1;
  }
  #panel-tasks .panel-header h2 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #panel-tasks .panel-date { display: none; }
  #panel-tasks .panel-actions { flex-wrap: nowrap; flex-shrink: 0; }
  #panel-tasks .panel-actions .btn { padding: 8px 10px; font-size: 12px; }
  #panel-events { align-self: stretch; height: auto; border-top: none; }
}

@media (max-width: 480px) {
  #tab-subjects { padding: 12px; }
  .subjects-form-card, .subjects-table-card { padding: 14px 16px; }
  .sched-day-row { flex-direction: column; gap: 4px; }
  .sched-intervals { width: 100%; }
  .sched-interval input[type="time"],
  .sched-interval input.tp-input { width: 68px; font-size: 12px; }
  .study-intensity-label { min-width: 0; width: 90px; }
  .cal-add-row { flex-wrap: wrap; }
  .cal-add-row input { min-width: 0; }
  .auth-card { padding: 26px 22px; }
}

/* ===================================================================
   ONBOARDING WIZARD
   =================================================================== */
#ob-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(14,19,32,.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#ob-overlay.ob-visible { display: flex; }

#ob-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

.ob-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.ob-app-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.3px;
}
.ob-progress {
  flex: 1;
  margin: 0 24px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.ob-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .35s ease;
}
.ob-step-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
}

#ob-steps {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 20px;
}
.ob-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.4px;
}
.ob-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
  line-height: 1.6;
}
.ob-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  gap: 10px;
}
.ob-actions-right { display: flex; gap: 10px; align-items: center; }
.ob-btn {
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-family: inherit;
  transition: background .12s, border-color .12s;
}
.ob-btn:hover { background: var(--bg); }
.ob-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.ob-btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.ob-btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.ob-btn-ghost:hover { background: var(--bg); }
.ob-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-dim);
  margin: 16px 0 10px;
}
.ob-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.ob-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-dim);
  transition: border-color .12s, color .12s, background .12s;
}
.ob-chip:hover { border-color: var(--primary); color: var(--primary); }
.ob-chip.selected {
  border-color: var(--primary);
  background: var(--tint-primary);
  color: var(--primary);
  font-weight: 600;
}
.ob-chip-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 15px;
  padding: 0;
  display: flex;
  align-items: center;
}
.ob-chip-del:hover { color: var(--danger); }
.ob-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}
.ob-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: var(--surface);
}
.ob-input-sm { width: auto; padding: 6px 10px; font-size: 13px; }
.ob-optional { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.ob-muted { color: var(--text-dim); font-size: 13px; }
.ob-err { color: var(--danger); font-size: 12px; min-height: 18px; margin: 6px 0 0; font-weight: 500; }
.ob-no-items { margin: 8px 0; color: var(--text-dim); font-size: 13px; }

/* ── Input row (subjects / projects add form) ── */
.ob-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.ob-input-row .ob-input { flex: 1; min-width: 120px; }
.ob-input-row .ob-input-sm { flex: 0 0 auto; }

/* ── Chip list ── */
.ob-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 28px;
  margin-bottom: 12px;
}

/* ── Exam form (step 4) ── */
.ob-exam-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.ob-exam-form-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.ob-exam-select { flex: 1; min-width: 140px; }
.ob-exam-info-input { flex: 2; min-width: 160px; }
.ob-exam-dt-group { display: flex; gap: 8px; align-items: center; flex: 1; min-width: 220px; flex-wrap: wrap; }
.ob-input-date { min-width: 130px; width: auto; }
.ob-input-time { width: 84px; cursor: pointer; text-align: center; }
.ob-dur-wrap { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ob-dur-wrap .ob-input-sm { width: 68px; text-align: center; }

/* ── Exam list ── */
.ob-exam-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.ob-exam-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.ob-exam-table tr:last-child td { border-bottom: none; }
.ob-dt { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.ob-exam-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.ob-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 9px;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.ob-exam-edit {
  color: var(--primary);
  background: rgba(79,70,229,.08);
  border: 1.5px solid rgba(79,70,229,.4);
}
.ob-exam-edit:hover {
  background: rgba(79,70,229,.18);
  border-color: var(--primary);
}
.ob-exam-del.ob-icon-btn {
  color: var(--danger);
  background: rgba(229,62,62,.07);
  border: 1.5px solid rgba(229,62,62,.4);
}
.ob-exam-del.ob-icon-btn:hover {
  background: rgba(229,62,62,.16);
  border-color: var(--danger);
}

/* ── Google Calendar connection (step 2) ── */
.ob-gcal-status {
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px 0 4px;
  min-height: 22px;
}
.ob-connected-badge {
  color: var(--success);
  font-weight: 600;
  font-size: 14px;
}
.ob-btn-google {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  font-weight: 500;
}

/* ── Loading state ── */
.ob-loading { color: var(--text-dim); font-size: 13px; padding: 8px 0; }

/* ── Calendar list (step 3) ── */
.ob-cal-item { padding: 4px 0; }
.ob-cal-item input { accent-color: var(--primary); cursor: pointer; }

/* ── Theme picker (step 8) ── */
.ob-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.ob-theme-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 12px 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--swatch-bg, var(--surface));
  cursor: pointer;
  transition: border-color .15s, transform .12s;
  font-family: inherit;
}
.ob-theme-swatch:hover { border-color: var(--swatch-primary, var(--primary)); transform: translateY(-2px); }
.ob-theme-swatch.ob-theme-active { border-color: var(--swatch-primary, var(--primary)); }
.ob-swatch-bar { width: 100%; height: 5px; border-radius: 3px; }
.ob-swatch-label { font-size: 12px; font-weight: 600; color: var(--swatch-text, var(--text)); }

/* ── Summary (step 10) ── */
.ob-summary-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}
.ob-summary-section h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.ob-summary-section ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ob-summary-section li { font-size: 13px; color: var(--text); }

/* ── Large button (step 10) ── */
.ob-btn-lg { padding: 11px 28px; font-size: 15px; }

/* ── Add interval button (step 7) ── */
.ob-add-iv {
  font-size: 12px;
  color: var(--primary);
  background: none;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
  font-family: inherit;
  margin-top: 2px;
}
.ob-add-iv:hover { background: var(--tint-primary, rgba(99,102,241,.08)); border-color: var(--primary); }

.ob-info-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.ob-info-card--success {
  border-left-color: var(--success);
  background: var(--tint-success);
}
.ob-info-heading { font-size: 14px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.ob-info-card p { font-size: 13px; color: var(--text-dim); margin: 0; line-height: 1.55; }

.ob-sched-grid { display: flex; flex-direction: column; gap: 8px; }
.ob-sched-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.ob-sched-row:last-child { border-bottom: none; }
.ob-sched-day {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  min-width: 110px;
  padding-top: 4px;
}
.ob-sched-day input { accent-color: var(--primary); cursor: pointer; }
.ob-sched-ivs-col { display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ob-sched-ivs-col.ob-disabled { opacity: .4; pointer-events: none; }
.ob-sched-iv-list { display: flex; flex-direction: column; gap: 5px; }
.ob-sched-iv-row { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); }
.ob-add-iv { white-space: nowrap; }

.ob-intensity-grid { display: flex; flex-direction: column; gap: 8px; }
.ob-intensity-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.ob-intensity-label { min-width: 130px; font-size: 13px; font-weight: 500; }
.ob-intensity-input { width: 80px; }

.ob-cal-type-header { font-size: 12px; font-weight: 700; color: var(--text-dim); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.ob-cal-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.ob-cal-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.ob-cal-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ob-cal-edit { display: flex; align-items: center; gap: 5px; margin-left: auto; }

.ob-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ob-summary-item { font-size: 13px; line-height: 1.5; }
.ob-summary-label { font-weight: 700; color: var(--text-dim); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }

@media (max-width: 520px) {
  #ob-steps { padding: 18px 16px 14px; }
  .ob-title { font-size: 17px; }
  .ob-intensity-label { min-width: 110px; font-size: 13px; }
  .ob-sched-day { min-width: 100px; }
  .ob-summary { grid-template-columns: 1fr; }
  .ob-actions { flex-direction: column; align-items: stretch; }
  .ob-actions .ob-btn { width: 100%; text-align: center; }
  .ob-actions-right { flex-direction: column; }
  .ob-exam-form-row { flex-direction: column; align-items: stretch; }
  .ob-exam-dt-group { flex-wrap: nowrap; }
  .ob-exam-select, .ob-exam-info-input { min-width: 0; flex: none; width: 100%; }
  .ob-exam-form-row .ob-btn { width: 100%; }
  .ob-theme-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===================================================================
   CUSTOM TIME PICKER
   =================================================================== */

input.tp-input {
  cursor: pointer !important;
  user-select: none;
  min-width: 64px;
  text-align: center;
  -webkit-user-select: none;
  font-family: 'DM Mono', monospace;
}

.sched-interval input.tp-input {
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  padding: 0;
  width: 80px;
}

.tp-drop {
  position: fixed;
  z-index: 10000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  overscroll-behavior: contain;
  min-width: 90px;
}
.tp-item {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  white-space: nowrap;
  font-family: 'DM Mono', monospace;
  transition: background .08s;
}
.tp-item:hover { background: var(--bg); }
.tp-item.tp-sel {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.tp-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(14,19,32,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.tp-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-xl);
  padding: 22px 22px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 284px;
  max-width: 100%;
  border: 1px solid var(--border);
}
.tp-clock-hdr {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  width: 100%;
  justify-content: center;
}
.tp-clock-seg {
  font-size: 2rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  transition: background .12s, color .12s;
  min-width: 72px;
  text-align: center;
  font-family: 'DM Mono', monospace;
}
.tp-clock-seg:hover { background: var(--surface-hover); color: var(--text); }
.tp-clock-seg.active { background: var(--primary); color: #fff; }
.tp-clock-colon {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  font-family: 'DM Mono', monospace;
}
.tp-clock-face { width: 220px; height: 220px; }
.tp-clock-face svg { display: block; }
.tp-clock-actions { display: flex; gap: 8px; align-self: stretch; justify-content: flex-end; }

.dt-split { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 480px) {
  .sched-interval input[type="time"],
  .sched-interval input.tp-input { width: 68px; font-size: 12px; }
}

/* ===================================================================
   UI TOUR — spotlight system
   =================================================================== */

/* ── Overlay ── */
#ut-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9900;
  pointer-events: auto;
  touch-action: none;
}
#ut-overlay.ut-visible { display: block; }

/* When a spotlight is active the overlay blocks stray clicks;
   when noSpotlight the overlay itself provides the dim */
#ut-overlay.ut-dimmed {
  background: transparent; /* dim comes from spotlight box-shadow */
}
#ut-overlay:not(.ut-dimmed) {
  background: rgba(14,19,32,.72);
}
/* Keeps the dim alive while spotlight is fading out (tab changes, noSpotlight transitions) */
#ut-overlay.ut-keep-dim {
  background: rgba(14,19,32,.72) !important;
}

/* ── Spotlight ── */
#ut-spotlight {
  position: fixed;
  z-index: 9901;
  pointer-events: none;
  opacity: 0;
  border-radius: 10px;
  /* The giant box-shadow IS the dim — it covers everything outside this element */
  box-shadow: 0 0 0 9999px rgba(14,19,32,.72);
  transition: left .38s cubic-bezier(.16,1,.3,1),
              top  .38s cubic-bezier(.16,1,.3,1),
              width  .38s cubic-bezier(.16,1,.3,1),
              height .38s cubic-bezier(.16,1,.3,1),
              border-radius .38s ease;
  /* Highlight ring around the spotlit element */
  outline: 2.5px solid rgba(255,255,255,.18);
  outline-offset: 0;
}

/* ── Tooltip card ── */
#ut-tooltip {
  position: fixed;
  z-index: 9902;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 300px;
  max-width: calc(100vw - 16px);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(37,99,235,.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  transition: left .38s cubic-bezier(.16,1,.3,1),
              top  .38s cubic-bezier(.16,1,.3,1),
              transform .38s cubic-bezier(.16,1,.3,1),
              translate .16s ease,
              opacity .2s ease;
  animation: ut-tip-in .3s cubic-bezier(.16,1,.3,1);
}
#ut-tooltip.ut-tooltip-wide {
  width: 400px;
  max-width: min(400px, calc(100vw - 16px));
}
@keyframes ut-tip-in {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1)   translateY(0);   }
}

/* Tooltip inner sections */
.ut-tip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 0;
}
.ut-step-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ut-skip-btn {
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 5px;
  transition: color .15s, background .15s;
}
.ut-skip-btn:hover { background: var(--bg); color: var(--text); }

.ut-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  padding: 8px 14px 4px;
  line-height: 1.3;
  letter-spacing: -.2px;
}
.ut-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
  padding: 0 14px 12px;
}
.ut-text strong { color: var(--text); }
.ut-text em     { color: var(--text-dim); font-style: normal; font-weight: 600; }

/* Checklist (used in wide steps) */
.ut-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 0;
}
.ut-checklist li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
}
.ut-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}
.ut-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Footer */
.ut-tip-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.ut-dots { display: flex; gap: 5px; align-items: center; }
.ut-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background .18s, transform .18s, width .18s;
}
.ut-dot.active { background: var(--primary); transform: scale(1.2); width: 16px; border-radius: 3px; }

.ut-tip-nav { display: flex; gap: 6px; }
.ut-nav-btn {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background .15s, opacity .15s;
}
.ut-nav-btn:disabled { opacity: .3; cursor: default; pointer-events: none; }
.ut-nav-btn:not(:disabled):hover { background: var(--bg); }
.ut-nav-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.ut-nav-primary:hover { background: var(--primary-hover) !important; border-color: var(--primary-hover) !important; }

/* Arrow caret from tooltip toward spotlit element */
#ut-tooltip[data-place="top"]::after,
#ut-tooltip[data-place="bottom"]::before,
#ut-tooltip[data-place="left"]::after,
#ut-tooltip[data-place="right"]::before {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  transform: rotate(45deg);
  z-index: -1;
}
#ut-tooltip[data-place="top"]::after {
  bottom: -6px;
  left: 22px;
  border-top: none;
  border-left: none;
}
#ut-tooltip[data-place="bottom"]::before {
  top: -6px;
  left: 22px;
  border-bottom: none;
  border-right: none;
}
#ut-tooltip[data-place="right"]::before {
  top: 16px;
  left: -6px;
  border-right: none;
  border-top: none;
}
#ut-tooltip[data-place="left"]::after {
  top: 16px;
  right: -6px;
  border-left: none;
  border-bottom: none;
}

/* ── Spotlight pulse animation ── */
@keyframes ut-spot-pulse {
  0%   { outline-color: rgba(255,255,255,.18); }
  50%  { outline-color: rgba(255,255,255,.45); }
  100% { outline-color: rgba(255,255,255,.18); }
}
#ut-spotlight { animation: ut-spot-pulse 2.4s ease-in-out infinite; }

/* ── Mobile ── */
@media (max-width: 640px) {
  #ut-tooltip, #ut-tooltip.ut-tooltip-wide {
    width: calc(100vw - 16px);
    left: 8px !important;
    bottom: 8px;
    top: auto !important;
    transform: none !important;
    border-radius: 12px;
  }
  /* Force tooltip to top of screen for steps where spotlight is near the bottom */
  #ut-tooltip.ut-at-top {
    top: 12px !important;
    bottom: auto !important;
  }
  #ut-tooltip[data-place]::after,
  #ut-tooltip[data-place]::before { display: none; }
}

/* ── Auto-scheduling mini visualisation (used in pre-tour) ── */
.ut-algo-viz {
  display: flex;
  gap: 6px;
  margin: 4px 0 2px;
}
.ut-algo-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.ut-algo-label {
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: .04em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.ut-algo-slot {
  border-radius: 5px;
  padding: 4px 5px;
  font-size: 10px;
  line-height: 1.3;
  text-align: center;
}
.ut-algo-slot small {
  display: block;
  font-size: 9px;
  opacity: .75;
}
.ut-algo-busy {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.ut-algo-free {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  opacity: .5;
}
.ut-algo-study {
  background: rgba(99,102,241,.22);
  border: 1px solid rgba(99,102,241,.5);
  color: #a5b4fc;
  font-weight: 600;
  animation: ut-study-pop .6s ease both;
}
@keyframes ut-study-pop {
  from { opacity: 0; transform: scaleY(.6); }
  to   { opacity: 1; transform: scaleY(1); }
}
