/* Gleb Planner — Design Tokens & Components */

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --warning: #fbbf24;
  --danger: #ef4444;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --text: #333;
  --text-muted: #888;
  --radius: 14px;
  --radius-lg: 16px;
  --tap-zone: 56px;
  --font-body: 16px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  touch-action: pan-y;
}

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-body);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* --- Header --- */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header .logout-btn {
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  cursor: pointer;
  padding: 8px;
  min-height: var(--tap-zone);
  display: flex;
  align-items: center;
}

.app-header .logout-btn:active {
  opacity: 0.6;
}

/* --- Main content area --- */
.app-content {
  flex: 1;
  padding: 20px 16px 88px;
}

/* --- Tab Bar (bottom nav) --- */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--card-bg);
  border-top: 1px solid #eee;
  display: flex;
  z-index: 20;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tab-bar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  min-height: var(--tap-zone);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar .tab .tab-icon {
  font-size: 22px;
}

.tab-bar .tab.active {
  color: var(--primary);
  font-weight: 600;
}

/* --- Login Screen --- */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 24px;
}

.login-screen h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-screen .subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
}

.pin-display {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.pin-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  transition: background 0.15s;
}

.pin-dot.filled {
  background: var(--primary);
}

.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  width: 100%;
}

.pin-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid #e0e0e0;
  background: var(--card-bg);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  justify-self: center;
  -webkit-tap-highlight-color: transparent;
}

.pin-btn:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: scale(0.95);
}

.pin-btn.empty {
  visibility: hidden;
}

.pin-btn.backspace {
  font-size: 20px;
  border-color: transparent;
}

.login-error {
  color: var(--danger);
  margin-top: 16px;
  font-size: 14px;
  min-height: 20px;
}

/* --- Empty States --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state .empty-text {
  color: var(--text-muted);
  font-size: 16px;
}

/* --- Schedule: Date Header --- */
.schedule-date-header {
  text-align: center;
  margin-bottom: 16px;
}

.schedule-day {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.schedule-date {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Schedule: "Прямо сейчас" Card --- */
.now-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--radius-lg);
  padding: 16px;
  color: #fff;
  margin-bottom: 16px;
  min-height: 80px;
}

.now-card-label {
  font-size: 12px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.now-card-subject {
  font-size: 22px;
  font-weight: 700;
  margin-top: 4px;
}

.now-card-time {
  font-size: 14px;
  opacity: 0.9;
  margin-top: 2px;
}

/* --- Schedule: Lesson List --- */
.lesson-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  min-height: var(--tap-zone);
  box-shadow: var(--shadow);
  transition: opacity 0.2s;
}

.lesson-item.past {
  opacity: 0.5;
}

.lesson-item.current {
  border: 2px solid #667eea;
}

.lesson-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.lesson-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.lesson-time {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- Tomorrow Block (collapsible on #day) --- */
.tomorrow-block {
  margin-top: 16px;
  margin-bottom: 16px;
}

.tomorrow-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  min-height: var(--tap-zone);
  box-shadow: var(--shadow);
}

.tomorrow-chevron {
  font-size: 20px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.tomorrow-toggle[aria-expanded="true"] .tomorrow-chevron {
  transform: rotate(90deg);
}

.tomorrow-lessons {
  margin-top: 8px;
}

.tomorrow-lessons .lesson-item {
  opacity: 0.85;
}

/* --- Schedule Week View --- */
.schedule-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.schedule-back-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--primary);
  cursor: pointer;
  padding: 8px;
  min-height: var(--tap-zone);
  min-width: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
}

.schedule-page-title {
  font-size: 22px;
  font-weight: 700;
}

.week-tabs-row {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.week-day-tab {
  flex: 1;
  min-width: 48px;
  padding: 10px 4px;
  border: none;
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  min-height: var(--tap-zone);
  box-shadow: var(--shadow);
  transition: all 0.15s;
}

.week-day-tab.active {
  background: var(--primary);
  color: #fff;
}

.week-day-panel {
  display: none;
}

.week-day-panel.active {
  display: block;
}

.week-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px;
  font-size: 15px;
}

/* Section title as link */
.section-title-link {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.section-title-link:active {
  opacity: 0.6;
}

/* --- XP Compact Bar (on #day) --- */
.xp-bar-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #FFF8E1;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}

.xp-bar-compact .level-badge {
  background: #FFD54F;
  color: #5D4037;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.xp-bar-compact .xp-streak {
  font-size: 14px;
  white-space: nowrap;
}

/* --- XP Progress Bar (shared) --- */
.xp-progress {
  flex: 1;
  height: 8px;
  background: #FFE082;
  border-radius: 4px;
  overflow: hidden;
}

.xp-progress-lg {
  height: 12px;
  border-radius: 6px;
}

.xp-progress-fill {
  height: 100%;
  background: #FF9800;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* --- XP Full Tab (#xp) --- */
.xp-full {
  padding: 8px 0;
}

.xp-full-header {
  text-align: center;
  margin-bottom: 24px;
}

.xp-level-big {
  font-size: 64px;
  margin-bottom: 8px;
}

.xp-level-title {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.xp-level-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}

.xp-full-progress {
  background: #FFF8E1;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.xp-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  color: #5D4037;
  margin-bottom: 8px;
}

.xp-to-next {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.xp-full-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.xp-stat-card {
  flex: 1;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.xp-stat-icon {
  font-size: 28px;
  margin-bottom: 4px;
}

.xp-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.xp-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* --- XP Levels List --- */
.xp-levels-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

/* --- Habits Section --- */
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.habit-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  min-height: var(--tap-zone);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.habit-card:active {
  transform: scale(0.97);
}

.habit-card.done {
  background: #dcfce7;
  border-color: #86efac;
}

.habit-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.habit-icon {
  font-size: 22px;
}

.habit-info {
  display: flex;
  flex-direction: column;
}

.habit-name {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.habit-streak-mini {
  font-size: 12px;
  color: var(--text-muted);
}

.habit-check {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #86efac;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--success);
  flex-shrink: 0;
  transition: all 0.2s;
}

.habit-card.done .habit-check {
  background: var(--success);
  color: #fff;
}

#habits-section {
  margin-bottom: 16px;
}

.habit-group {
  margin-bottom: 12px;
}

.habit-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #e8f5e9;
  border-radius: var(--radius);
  margin-bottom: 6px;
  min-height: var(--tap-zone);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.habit-group-header:active {
  background: #c8e6c9;
}

.habit-group-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.habit-group-icon {
  font-size: 20px;
}

.habit-group-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.habit-group-counter {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 8px;
  border-radius: 10px;
}

.habit-group-chevron {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.3s;
}

.hw-day-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.habit-group-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.habit-group.collapsed .habit-group-body {
  max-height: 0 !important;
}

.xp-level-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card-bg);
  border-radius: 10px;
  margin-bottom: 6px;
  opacity: 0.5;
}

.xp-level-row.unlocked {
  opacity: 1;
  background: #FFF8E1;
}

.xp-level-row-emoji {
  font-size: 22px;
}

.xp-level-row-name {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}

.xp-level-row-xp {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* --- Level Hidden (???) --- */
.level-hidden {
  color: #9C27B0;
  font-style: italic;
  text-shadow: 0 0 8px rgba(156, 39, 176, 0.3);
}

/* --- Finnets Teaser --- */
.xp-finnets-teaser {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  padding: 8px 0 4px;
}

/* --- Rank Section on XP tab --- */
.xp-level-title-section {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 0;
  color: var(--text-primary);
}

/* --- Star Burst Animation --- */
.xp-star-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 32px;
  pointer-events: none;
  animation: starBurst 500ms ease forwards;
  z-index: 5;
}

@keyframes starBurst {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}

/* --- Level-Up Fullscreen Overlay --- */
.xp-levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 300ms ease;
}

.xp-levelup-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  max-width: 300px;
  width: 90%;
  animation: levelUpPop 400ms ease;
}

.xp-levelup-emoji {
  font-size: 72px;
  margin-bottom: 12px;
}

.xp-levelup-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.xp-levelup-name {
  font-size: 18px;
  color: #FF9800;
  font-weight: 600;
  margin-bottom: 24px;
}

.xp-levelup-btn {
  background: #FF9800;
  color: #fff;
  border: none;
  border-radius: 28px;
  padding: 14px 48px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  min-height: var(--tap-zone);
  -webkit-tap-highlight-color: transparent;
}

.xp-levelup-btn:active {
  transform: scale(0.95);
  background: #F57C00;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes levelUpPop {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Page views (hidden by default) --- */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* --- HW List & Cards (GP-009) --- */
.hw-page-header {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.hw-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.hw-filter-btn {
  padding: 8px 18px;
  border-radius: 20px;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 56px;
  color: #666;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.hw-filter-btn:active {
  transform: scale(0.95);
}

.hw-filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.hw-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  min-height: var(--tap-zone);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

/* :active scale removed — GP-033 uses gesture-based feedback */

.hw-card .subject-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hw-card .hw-text {
  flex: 1;
  min-width: 0;
}

.hw-card .hw-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-card .hw-due {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* .hw-status removed — GP-033: status icon now inside .hw-card-body as .hw-status-icon */

.hw-card.pending {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.hw-card.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
  opacity: 0.7;
}

.hw-card.done .hw-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.hw-date-divider {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 8px;
}

.hw-date-divider:first-child {
  margin-top: 0;
}

.hw-section-header {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 16px 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
}

.hw-section-header:first-child {
  margin-top: 0;
}

.hw-more-link {
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.hw-more-link:active {
  opacity: 0.7;
}

#homework-section {
  margin-bottom: 16px;
}

.hw-add-inline {
  display: block;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--card-bg);
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
  -webkit-tap-highlight-color: transparent;
}

.hw-add-inline:active {
  background: rgba(59, 130, 246, 0.08);
}

.hw-empty-cta {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  min-height: var(--tap-zone);
  -webkit-tap-highlight-color: transparent;
}

.hw-empty-cta:active {
  background: var(--primary-dark);
  transform: scale(0.95);
}

/* --- HW Wizard (GP-008) --- */
.hw-add-fab {
  margin-top: 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 32px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
  -webkit-tap-highlight-color: transparent;
}

.hw-add-fab:active {
  transform: scale(0.95);
  background: var(--primary-dark);
}

#hw-wizard {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  overflow-y: auto;
  padding: 20px;
}

.hw-wiz-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.hw-wiz-back {
  font-size: 24px;
  color: var(--primary);
  cursor: pointer;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.hw-wiz-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.hw-wiz-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  min-width: var(--tap-zone);
  min-height: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.hw-wiz-step {
  font-size: 14px;
  color: var(--text-muted);
  min-width: 44px;
  text-align: right;
}

.hw-wiz-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.hw-wiz-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5e7eb;
  transition: background 0.2s;
}

.hw-wiz-dot.active {
  background: var(--primary);
}

.hw-wiz-dot.done {
  background: var(--success);
}

.hw-wiz-prompt {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.3;
}

.hw-wiz-badge {
  display: inline-block;
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* Step 1: Subject grid */
.hw-wiz-subject-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hw-wiz-subject {
  min-height: 80px;
  border-radius: var(--radius-lg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.hw-wiz-subject:active {
  transform: scale(0.95);
}

.hw-wiz-subject-selected {
  outline: 3px solid #fff;
  outline-offset: -3px;
  box-shadow: 0 0 0 5px rgba(0,0,0,0.25);
}

/* Step 2: Description */
.hw-wiz-textarea-wrap {
  margin-bottom: 16px;
}

.hw-wiz-textarea {
  width: 100%;
  min-height: 120px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 14px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  outline: none;
  color: var(--text);
  background: var(--card-bg);
}

.hw-wiz-textarea:focus {
  border-color: var(--primary);
}

.hw-wiz-voice-btn {
  width: 100%;
  min-height: var(--tap-zone);
  border: 2px dashed var(--warning);
  border-radius: var(--radius);
  background: #FFF8E1;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #92400e;
  -webkit-tap-highlight-color: transparent;
}

/* Step 3: Day grid */
.hw-wiz-day-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hw-wiz-day-btn {
  min-height: 64px;
  border-radius: var(--radius);
  border: 2px solid #e5e7eb;
  background: var(--card-bg);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.hw-wiz-day-btn:active,
.hw-wiz-day-btn.selected {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
}

.hw-wiz-day-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.hw-wiz-day-btn.selected .hw-wiz-day-sub {
  color: var(--primary);
}

/* Buttons */
.hw-wiz-btn {
  width: 100%;
  min-height: var(--tap-zone);
  border-radius: var(--radius);
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  -webkit-tap-highlight-color: transparent;
}

.hw-wiz-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.hw-wiz-btn-primary {
  background: var(--primary);
  color: #fff;
}

.hw-wiz-btn-primary:active:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.hw-wiz-btn-secondary {
  background: #f3f4f6;
  color: #666;
}

.hw-wiz-btn-secondary:active {
  background: #e5e7eb;
}

.hw-wiz-btn-danger {
  background: #fee2e2;
  color: #dc2626;
}

.hw-wiz-btn-danger:active {
  background: #fecaca;
  transform: scale(0.98);
}

/* Confirmation */
.hw-wiz-confirm-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.hw-wiz-confirm-card {
  background: #f0fdf4;
  border: 2px solid #bbf7d0;
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
  width: 100%;
}

.hw-wiz-confirm-emoji {
  font-size: 40px;
  margin-bottom: 8px;
}

.hw-wiz-confirm-subject {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.hw-wiz-confirm-desc {
  font-size: 16px;
  color: #555;
  margin-top: 8px;
}

.hw-wiz-confirm-deadline {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.hw-wiz-confirm-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.hw-wiz-confirm-xp {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hw-wiz-error {
  color: #d32f2f;
  font-size: 14px;
  text-align: center;
  padding: 8px;
  margin-top: 12px;
  animation: fadeIn 0.2s ease;
}

/* --- Events (GP-018) --- */
.events-page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.events-back-btn {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  background: var(--card-bg);
  -webkit-tap-highlight-color: transparent;
}

.events-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.event-card {
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.event-card.upcoming {
  border-color: #fde68a;
  background: #fffbeb;
}

.event-card.past {
  border-color: #e5e7eb;
  background: #f9fafb;
  opacity: 0.6;
}

.event-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  cursor: pointer;
}

.event-icon {
  font-size: 24px;
  flex-shrink: 0;
}

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

.event-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.event-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.event-countdown {
  font-size: 12px;
  font-weight: 600;
  color: #f59e0b;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 10px;
}

.event-checklist {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f3f4f6;
}

.event-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  min-height: 56px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.event-check-box {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: all 0.15s;
}

.event-check-box.checked {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.event-check-label {
  font-size: 15px;
  color: var(--text);
}

.event-check-label.checked {
  text-decoration: line-through;
  color: #999;
}

.event-checklist-progress {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.events-all-link {
  text-align: center;
  padding: 12px;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.events-month-divider {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 20px 0 10px;
}

.events-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 16px;
}

.events-fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ec4899;
  color: #fff;
  border: none;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}

.events-fab:active {
  transform: scale(0.9);
}

.events-form-group {
  margin-bottom: 16px;
}

.events-form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.events-type-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.events-type-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid #e5e7eb;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  -webkit-tap-highlight-color: transparent;
}

.events-type-chip.selected {
  border-color: var(--primary);
  background: #eff6ff;
  color: var(--primary);
  font-weight: 600;
}

.events-check-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.events-check-input {
  flex: 1;
  min-height: 40px;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  color: var(--text);
}

.events-check-input:focus {
  border-color: var(--primary);
}

.events-check-remove {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1.5px solid #fca5a5;
  background: #fef2f2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.events-add-check-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

/* --- Settings (GP-006) --- */
.app-header .settings-btn {
  position: absolute;
  left: 16px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  min-height: var(--tap-zone);
  display: flex;
  align-items: center;
}

/* --- Help button (GP-026) --- */
.app-header .help-btn {
  position: absolute;
  left: 72px;
  background: none;
  border: none;
  font-size: 18px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-zone);
  min-width: var(--tap-zone);
  -webkit-tap-highlight-color: transparent;
}

.app-header .help-btn:active {
  opacity: 0.6;
}

/* --- Help overlay (GP-026) --- */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 300ms ease;
}

.help-content {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 340px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: levelUpPop 400ms ease;
}

.help-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  min-height: var(--tap-zone);
  min-width: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.help-content h2 {
  font-size: 22px;
  margin-bottom: 16px;
}

.help-content p {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 12px;
  color: var(--text);
}

.help-content .help-section {
  margin-bottom: 14px;
}

.help-content .help-ranks {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

.settings-nav {
  padding: 8px 0;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
  min-height: var(--tap-zone);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 16px;
  color: var(--text);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.settings-nav-item:active {
  transform: scale(0.98);
}

.settings-nav-icon {
  font-size: 24px;
}

.settings-nav-label {
  flex: 1;
  font-weight: 500;
}

.settings-nav-arrow {
  color: var(--text-muted);
  font-size: 20px;
}

.settings-top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.settings-back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.settings-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.settings-body {
  padding: 0;
}

.settings-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 6px;
  min-height: 48px;
  box-shadow: var(--shadow);
}

.settings-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.settings-add-form {
  margin-top: 20px;
  padding: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.settings-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--card-bg);
  margin-bottom: 10px;
  min-height: 48px;
  outline: none;
}

.settings-input:focus {
  border-color: var(--primary);
}

.settings-color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.settings-color-pick {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-color-pick.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--text);
}

.settings-add-btn {
  width: 100%;
  min-height: 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-add-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.settings-add-btn:active:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.settings-cancel-btn {
  width: 100%;
  min-height: 48px;
  background: #f3f4f6;
  color: #666;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
  -webkit-tap-highlight-color: transparent;
}

.settings-cancel-btn:active {
  background: #e5e7eb;
}

.settings-delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 16px;
  cursor: pointer;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.settings-delete-btn:active {
  background: #fef2f2;
}

/* Schedule day blocks */
.settings-day-block {
  margin-bottom: 16px;
}

.settings-day-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-day-slots {
  margin-bottom: 6px;
}

.settings-slot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 4px;
  min-height: 44px;
  box-shadow: var(--shadow);
}

.settings-slot-name {
  flex: 1;
  font-weight: 500;
}

.settings-slot-time {
  font-size: 13px;
  color: var(--text-muted);
}

.settings-slot-room {
  font-size: 12px;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 6px;
}

.settings-add-slot-btn {
  background: none;
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  min-height: 44px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.settings-add-slot-btn:active {
  background: #f9fafb;
  border-color: var(--primary);
  color: var(--primary);
}

.settings-slot-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  border: 2px solid var(--primary);
}

.settings-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-time-row .settings-input {
  flex: 1;
}

.settings-form-actions {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-empty-hint {
  color: var(--text-muted);
  font-size: 14px;
  padding: 8px 0;
}

.settings-xp-badge {
  font-size: 12px;
  color: #FF9800;
  font-weight: 600;
  margin-left: auto;
}

.settings-role-badge {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
}

.settings-family-info {
  text-align: center;
  padding: 20px;
  margin-bottom: 16px;
}

.settings-family-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.settings-family-tz {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Summary Screen (GP-020) --- */
.summary-screen {
  padding: 24px 16px;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-header {
  text-align: center;
  padding: 20px 0 8px;
}

.summary-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.summary-date {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.summary-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.summary-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.summary-xp-earned {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.summary-xp-total {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.summary-xp-fill {
  transition: width 1s ease;
}

.summary-habits-icons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-habit-icon {
  font-size: 20px;
}

.summary-hw-stats {
  font-size: 15px;
  color: var(--text);
}

.summary-hw-warning {
  font-size: 14px;
  color: var(--danger);
  margin-top: 6px;
  font-weight: 600;
}

.summary-streak-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--warning);
}

.summary-narrative-text {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.summary-tomorrow-lessons,
.summary-tomorrow-events,
.summary-schedule-list,
.summary-free-day {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.summary-tomorrow-events {
  margin-top: 6px;
  color: var(--text-muted);
}

.summary-event-item {
  font-size: 14px;
  color: var(--text);
  padding: 4px 0;
}

.summary-error {
  text-align: center;
  color: var(--danger);
  padding: 40px 0;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 0 32px;
  margin-top: auto;
}

.summary-btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
}

.summary-btn-primary:active {
  background: var(--primary-dark);
}

.summary-btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
}

.summary-btn-secondary:active {
  background: rgba(59, 130, 246, 0.08);
}

/* Summary button on #day */
.summary-day-btn {
  position: fixed;
  bottom: 80px;
  right: 16px;
  background: var(--card-bg);
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 10;
}

.summary-day-btn:active {
  background: var(--bg);
}

/* --- Habit XP Toast (GP-G06) --- */
.habit-card {
  position: relative;
  overflow: visible;
}

.habit-xp-toast {
  position: absolute;
  right: 12px;
  top: -8px;
  background: var(--accent, #FFD700);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  pointer-events: none;
  animation: xpToastRise 800ms ease forwards;
  z-index: 10;
}

@keyframes xpToastRise {
  0% { opacity: 1; transform: translateY(0); }
  70% { opacity: 1; transform: translateY(-24px); }
  100% { opacity: 0; transform: translateY(-32px); }
}

.hw-xp-toast {
  position: absolute;
  right: 12px;
  top: -8px;
  background: var(--accent, #FFD700);
  color: #000;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  pointer-events: none;
  animation: xpToastRise 800ms ease forwards;
  z-index: 10;
}

/* --- Streak Bonus Toast (GP-G06) --- */
.habit-streak-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #FF6B35, #FF4500);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(255, 69, 0, 0.4);
  z-index: 90;
  pointer-events: none;
  animation: streakToastPop 2000ms ease forwards;
  white-space: nowrap;
}

@keyframes streakToastPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.5); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.1); }
  25% { transform: translateX(-50%) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-20px); }
}

/* --- Full Day Bonus Overlay (GP-G06) --- */
.habit-fullday-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 300ms ease;
  overflow: hidden;
}

.habit-fullday-content {
  text-align: center;
  color: #fff;
  animation: fullDayBounce 600ms ease;
}

.habit-fullday-emoji {
  font-size: 64px;
  margin-bottom: 12px;
}

.habit-fullday-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.habit-fullday-xp {
  font-size: 22px;
  font-weight: 700;
  color: #FFD700;
}

@keyframes fullDayBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* --- Confetti Particles (GP-G06) --- */
.confetti-particle {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 2s ease forwards;
  pointer-events: none;
}

@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* --- Onboarding Wizard (GP-021) --- */

.onboarding-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 0 4px;
}

.onboarding-back {
  font-size: 24px;
  color: var(--primary);
  cursor: pointer;
  width: var(--tap-zone);
  height: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
}

.onboarding-back.invisible {
  visibility: hidden;
}

.onboarding-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.onboarding-step-indicator {
  font-size: 14px;
  color: var(--text-muted);
  min-width: var(--tap-zone);
  text-align: right;
}

.onboarding-progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.onboarding-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e5e7eb;
  transition: background 0.2s;
}

.onboarding-dot.active {
  background: var(--success);
}

.onboarding-dot.done {
  background: #86efac;
}

.onboarding-prompt {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
  line-height: 1.3;
}

.onboarding-prompt-sub {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
}

/* Chips (subjects) */
.onboarding-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
  padding: 0 4px;
}

.onboarding-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 2px solid #e5e7eb;
  background: var(--card-bg);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  min-height: var(--tap-zone);
  transition: all 0.15s;
}

.onboarding-chip:active {
  transform: scale(0.95);
}

.onboarding-chip.selected {
  border-color: var(--success);
  background: #f0fdf4;
}

.onboarding-chip-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.onboarding-chip-check {
  font-size: 16px;
  color: var(--success);
  display: none;
}

.onboarding-chip.selected .onboarding-chip-check {
  display: inline;
}

.onboarding-add-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 2px dashed #d1d5db;
  background: #fafafa;
  font-size: 15px;
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  margin-bottom: 16px;
  min-height: var(--tap-zone);
}

.onboarding-counter {
  text-align: center;
  font-size: 13px;
  color: #bbb;
  margin-top: 8px;
}

/* Buttons */
.onboarding-btn-primary {
  width: 100%;
  min-height: var(--tap-zone);
  border-radius: var(--radius);
  border: none;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  background: var(--success);
  color: #fff;
}

.onboarding-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.onboarding-btn-secondary {
  width: 100%;
  min-height: var(--tap-zone);
  border-radius: var(--radius);
  border: none;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 8px;
  background: #f3f4f6;
  color: #666;
}

/* Inline form (replaces prompt()) */
.onboarding-inline-form {
  background: #f9fafb;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
}

.onboarding-inline-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  min-height: var(--tap-zone);
  margin-bottom: 8px;
  box-sizing: border-box;
}

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

.onboarding-inline-actions button {
  flex: 1;
  min-height: var(--tap-zone);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.onboarding-inline-save {
  background: var(--success);
  color: #fff;
}

.onboarding-inline-cancel {
  background: #f3f4f6;
  color: #666;
}

/* Schedule - day tabs */
.onboarding-day-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.onboarding-day-tab {
  padding: 8px 14px;
  border-radius: 10px;
  border: 2px solid #e5e7eb;
  background: var(--card-bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
  white-space: nowrap;
}

.onboarding-day-tab.active {
  border-color: var(--success);
  background: #f0fdf4;
  color: #16a34a;
}

.onboarding-day-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.onboarding-slot-list {
  margin-bottom: 12px;
}

.onboarding-slot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 12px;
  margin-bottom: 6px;
  min-height: var(--tap-zone);
}

.onboarding-slot-time {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 48px;
}

.onboarding-slot-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.onboarding-slot-subject {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.onboarding-slot-remove {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1.5px solid #fca5a5;
  background: #fef2f2;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
}

.onboarding-add-slot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  border: 2px dashed #d1d5db;
  background: #fafafa;
  font-size: 15px;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  min-height: var(--tap-zone);
}

/* Slot form */
.onboarding-slot-form {
  background: #f9fafb;
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
  border: 1px solid #e5e7eb;
}

.onboarding-slot-form select,
.onboarding-slot-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  margin-bottom: 8px;
  min-height: var(--tap-zone);
}

.onboarding-slot-time-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.onboarding-slot-time-row input {
  flex: 1;
  margin-bottom: 0;
}

.onboarding-slot-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.onboarding-slot-form-actions button {
  flex: 1;
  min-height: var(--tap-zone);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

/* Habit toggles */
.onboarding-habits-list {
  margin-bottom: 16px;
}

.onboarding-habit-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: var(--radius);
  margin-bottom: 8px;
  min-height: var(--tap-zone);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--card-bg);
  width: 100%;
  text-align: left;
  font-size: 16px;
}

.onboarding-habit-toggle:active {
  transform: scale(0.97);
}

.onboarding-habit-toggle.selected {
  border-color: var(--success);
  background: #f0fdf4;
}

.onboarding-habit-icon {
  font-size: 22px;
}

.onboarding-habit-name {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.onboarding-habit-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: transparent;
}

.onboarding-habit-toggle.selected .onboarding-habit-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

/* Final screen */
.onboarding-final {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 0 20px;
}

.onboarding-final-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

.onboarding-final-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.onboarding-final-sub {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.onboarding-final-btn {
  margin-top: 32px;
  width: 240px;
}

/* Child welcome */
.child-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  padding: 0 20px;
}

.child-welcome-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 20px;
}

.child-welcome-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.child-welcome-sub {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 8px;
}

.child-welcome-task {
  background: #FFF8E1;
  border: 2px solid #FFE082;
  border-radius: var(--radius);
  padding: 16px;
  margin: 20px 0;
  width: 100%;
  text-align: left;
}

.child-welcome-task-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.child-welcome-task-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.child-welcome-task-xp {
  font-size: 14px;
  color: #f59e0b;
  font-weight: 600;
  margin-top: 4px;
}

.child-welcome-hint {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.child-welcome-btn {
  width: 240px;
  background: #f59e0b !important;
  color: #333 !important;
}

/* Settings onboarding reset */
.settings-onboarding-reset {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #eee;
}

/* #view-onboarding content padding */
#view-onboarding {
  padding: 16px;
}

/* --- Offline Indicator --- */
.offline-indicator {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--warning);
  color: #333;
  text-align: center;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
}

/* --- Install Banner --- */
.install-banner {
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  z-index: 999;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.install-banner.hidden { display: none !important; }
.install-text {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
}
.install-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: var(--tap-zone);
}
.install-btn:active { background: var(--primary-dark); }
.install-dismiss {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  min-width: var(--tap-zone);
  min-height: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Greeting overlay (GP-028) --- */
.greeting-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(59, 130, 246, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.4s ease;
  cursor: pointer;
}

.greeting-overlay.visible {
  opacity: 1;
}

.greeting-content {
  text-align: center;
  color: #fff;
}

.greeting-avatar {
  font-size: 64px;
  margin-bottom: 16px;
}

.greeting-avatar-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}

.greeting-text {
  font-size: 24px;
  font-weight: 600;
}

/* --- HW Card: Gesture Controls (GP-033) --- */

.hw-card {
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  position: relative;
}

.hw-card-inner {
  position: relative;
  z-index: 1;
  background: inherit;
  /* GP-M11: transition managed by JS — none during drag, ease on snap */
  padding: 0;
}

.hw-card-body {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.hw-status-icon {
  font-size: 20px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hw-action-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  z-index: 0;
}

.hw-action-btn {
  min-width: 72px;
  min-height: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0 8px;
}

.hw-action-btn.edit { background: #3b82f6; }
.hw-action-btn.delete { background: #ef4444; }

.hw-chevron {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 4px;
  transition: transform 0.2s;
}

/* --- HW Attachment Dropdown (GP-032) --- */

.hw-att-dropdown {
  width: 100%;
  overflow: hidden;
  transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
}

.hw-att-dropdown:not(.hidden) {
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  margin-top: 8px;
  animation: att-slide-down 0.2s ease-out;
}

@keyframes att-slide-down {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 400px; }
}

.hw-att-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hw-att-item {
  cursor: pointer;
  text-align: center;
}

.hw-att-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hw-att-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hw-att-thumb.pdf-thumb {
  background: #fff3e0;
}

.hw-att-pdf-icon {
  font-size: 32px;
}

.hw-att-name {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
}

.hw-att-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px;
}

/* --- Fullscreen Image Viewer (GP-032) --- */

.iv-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: iv-fade-in 0.2s ease-out;
}

@keyframes iv-fade-in {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.iv-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
}

.iv-close {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 201;
  background: none;
  border: none;
  color: #fff;
  font-size: 32px;
  cursor: pointer;
  width: var(--tap-zone);
  height: var(--tap-zone);
  display: flex;
  align-items: center;
  justify-content: center;
}

.iv-counter {
  position: absolute;
  top: 20px;
  right: 16px;
  z-index: 201;
  color: #fff;
  font-size: 14px;
  opacity: 0.8;
}

.iv-content {
  position: relative;
  z-index: 200;
  max-width: 100vw;
  max-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iv-image {
  max-width: 100vw;
  max-height: 80vh;
  object-fit: contain;
  touch-action: pinch-zoom pan-x pan-y;
}

.iv-dots {
  position: absolute;
  bottom: 24px;
  z-index: 201;
  display: flex;
  gap: 8px;
  justify-content: center;
}

.iv-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
}

.iv-dot.active {
  width: 10px;
  height: 10px;
  background: #fff;
}

.iv-pdf {
  text-align: center;
  color: #fff;
}

.iv-pdf-icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.iv-pdf-name {
  font-size: 16px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.iv-pdf-open {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 16px;
  cursor: pointer;
  min-height: var(--tap-zone);
}

/* --- Attachment Upload in Wizard (GP-032) --- */

.att-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.att-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.att-thumbs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.att-thumb-item {
  position: relative;
  text-align: center;
}

.att-thumb-item img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.att-thumb-pdf {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: #fff3e0;
  border-radius: 8px;
  font-size: 32px;
}

.att-thumb-delete {
  position: absolute;
  top: -4px;
  right: calc(50% - 44px);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ff4444;
  color: #fff;
  border: 2px solid #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.att-thumb-name {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 80px;
  margin: 4px auto 0;
}

.att-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  border: 2px dashed #d0d0d0;
  border-radius: var(--radius);
  background: #f5f5f5;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
  gap: 4px;
}

.att-file-input {
  display: none;
}

.att-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.att-limit-msg {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px;
}

/* --- GP-031: Recurring HW card --- */
.hw-card.hw-recurring {
  position: relative;
}

.hw-recurring-icon {
  font-size: 16px;
  margin-right: 4px;
  flex-shrink: 0;
}

.hw-card.hw-recurring-done {
  background: #f0faf0;
}

.hw-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.hw-progress-bar {
  flex: 1;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.hw-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.hw-progress-label {
  font-size: 12px;
  color: #666;
  white-space: nowrap;
}

.hw-streak {
  color: #ff6b35;
  font-weight: 600;
}

/* --- GP-031: Wizard type selection --- */
.hw-wiz-type-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 16px;
  margin: 8px 0;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius);
  background: var(--card-bg);
  cursor: pointer;
  min-height: 64px;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
}

.hw-wiz-type-btn.selected {
  border-color: var(--primary);
  background: #f0f6ff;
}

.hw-wiz-type-btn:active {
  transform: scale(0.98);
}

.hw-wiz-type-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.hw-wiz-type-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.hw-wiz-type-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.hw-wiz-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 12px;
}

.hw-wiz-confirm-hint {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0;
}

/* --- Utility --- */
.hidden {
  display: none !important;
}
