:root {
  --accent: #7c6cf6;
  --accent-2: #4fd1c5;
  --bg-0: #0d0f1a;
  --bg-1: #12162a;
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-border: rgba(255, 255, 255, 0.09);
  --text-0: #f4f4fb;
  --text-1: #b7bad3;
  --text-2: #7d80a0;
  --danger: #f4726b;
  --success: #4fd1c5;
  --warn: #f6b93b;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-card: 0 10px 30px -12px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg-0: #eef0fb;
  --bg-1: #f7f8fd;
  --card-bg: rgba(255, 255, 255, 0.75);
  --card-border: rgba(20, 20, 50, 0.08);
  --text-0: #1b1d2e;
  --text-1: #4a4d68;
  --text-2: #7d80a0;
  --shadow-card: 0 10px 30px -14px rgba(30, 30, 70, 0.25);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px circle at 10% -10%, rgba(124, 108, 246, 0.25), transparent 60%),
    radial-gradient(500px circle at 90% 0%, rgba(79, 209, 197, 0.18), transparent 55%),
    var(--bg-0);
  pointer-events: none;
}

.storage-warning {
  display: none;
  max-width: 1240px;
  margin: 14px auto 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(246, 185, 59, 0.14);
  border: 1px solid rgba(246, 185, 59, 0.35);
  color: var(--text-0);
  font-size: 0.82rem;
  line-height: 1.4;
}

.storage-warning strong { color: var(--warn); }

@media (max-width: 700px) {
  .storage-warning { margin: 14px 16px 0; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px) 0;
  max-width: 1240px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.brand-mark {
  color: var(--accent);
}

.clock {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
}

#time {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-0);
}

.clock-date {
  font-size: 0.85rem;
  text-transform: capitalize;
}

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

.btn-icon {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-0);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.2s ease;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}

.btn-icon:hover {
  transform: translateY(-1px);
  background: rgba(124, 108, 246, 0.18);
}

.btn-icon-sm {
  width: 36px;
  height: 36px;
  font-size: 1rem;
  border-radius: 9px;
  flex-shrink: 0;
}

.mini-weather {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-0);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.mini-weather:hover {
  transform: translateY(-1px);
  background: rgba(124, 108, 246, 0.18);
}

.card-header-date {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: capitalize;
}

.greeting {
  max-width: 1240px;
  margin: 8px auto 0;
  padding: 0 clamp(16px, 4vw, 48px);
}

.greeting h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  margin: 4px 0 0;
  letter-spacing: -0.02em;
}

.greeting p {
  color: var(--text-1);
  margin: 4px 0 0;
}

.focus-card {
  max-width: 1240px;
  margin: 18px auto 0;
  padding: 16px clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, rgba(124, 108, 246, 0.16), rgba(79, 209, 197, 0.08));
  border: 1px solid var(--card-border);
}

.focus-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  flex-shrink: 0;
}

#focus-body {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  flex: 1;
  min-width: 0;
}

.focus-title {
  font-size: 1.05rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 140px;
  min-width: 0;
}

.focus-empty {
  color: var(--text-1);
  font-size: 0.9rem;
}

.focus-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.focus-done-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

.focus-done-btn:hover { background: #6a5aef; }

.focus-start-btn {
  flex-shrink: 0;
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 7px 15px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  background: transparent;
  color: var(--accent);
}

.focus-start-btn:hover { background: rgba(124, 108, 246, 0.14); }

/* Mode Focus plein écran */
.focus-mode {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background:
    radial-gradient(700px circle at 20% 10%, rgba(124, 108, 246, 0.25), transparent 60%),
    radial-gradient(600px circle at 85% 90%, rgba(79, 209, 197, 0.18), transparent 55%),
    var(--bg-0);
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.focus-mode.open { display: flex; }

.focus-mode.on-break .focus-mode-clock { color: var(--success); }

.focus-mode-exit {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  color: var(--text-0);
  font-size: 1.1rem;
  cursor: pointer;
}

.focus-mode-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  max-width: 560px;
}

.focus-mode-goal {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--success);
  background: rgba(79, 209, 197, 0.14);
  padding: 4px 12px;
  border-radius: 20px;
}

.focus-mode-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  margin: 4px 0 18px;
  letter-spacing: -0.02em;
}

.focus-mode-mode-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.focus-mode-clock {
  font-size: clamp(3.5rem, 12vw, 6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  margin: 6px 0 18px;
  transition: color 0.3s ease;
}

.focus-mode-timer-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.focus-mode-start {
  border: none;
  border-radius: 14px;
  padding: 14px 36px;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  background: var(--accent);
  color: white;
}

.focus-mode-start:hover { background: #6a5aef; }

.focus-mode-actions {
  display: flex;
  gap: 12px;
  margin-top: 28px;
}

#focusModeNoise.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(124, 108, 246, 0.14);
}

@media (max-width: 500px) {
  .focus-mode-actions { flex-direction: column; width: 100%; }
}

.grid {
  max-width: 1240px;
  margin: 24px auto 40px;
  padding: 0 clamp(16px, 4vw, 48px);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: min-content;
  gap: 18px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 20px;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.card-tall { grid-row: span 2; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-header h2 {
  font-size: 1rem;
  margin: 0;
  font-weight: 700;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(124, 108, 246, 0.06);
  border: 1px solid transparent;
  transition: background 0.15s ease;
}

.list-item:hover { background: rgba(124, 108, 246, 0.12); }

.list-item.done { opacity: 0.5; }
.list-item.done .item-title { text-decoration: line-through; }

.item-check {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1.5px solid var(--text-2);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-0);
  font-size: 12px;
}

.list-item.done .item-check {
  background: var(--success);
  border-color: var(--success);
}

.item-body { flex: 1; min-width: 0; }

.item-title {
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 2px;
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-high { background: rgba(244, 114, 107, 0.18); color: var(--danger); }
.badge-medium { background: rgba(246, 185, 59, 0.18); color: var(--warn); }
.badge-low { background: rgba(79, 209, 197, 0.18); color: var(--success); }

.item-delete {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.list-item:hover .item-delete { opacity: 1; }
.item-delete:hover { color: var(--danger); }

.habit-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(124, 108, 246, 0.06);
  border: 1px solid transparent;
  transition: background 0.15s ease;
}

.habit-item:hover { background: rgba(124, 108, 246, 0.12); }
.habit-item.done .item-check { background: var(--success); border-color: var(--success); }

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

.habit-row .item-delete { opacity: 0; }
.habit-item:hover .habit-row .item-delete { opacity: 1; }

.habit-heatmap {
  display: grid;
  grid-template-rows: repeat(7, 1fr);
  grid-auto-flow: column;
  grid-auto-columns: 8px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.heatmap-cell {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: rgba(124, 108, 246, 0.12);
}

.heatmap-cell.filled { background: var(--accent); }

.focus-goal-badge {
  background: rgba(79, 209, 197, 0.18);
  color: var(--success);
}

.empty-state {
  color: var(--text-2);
  font-size: 0.85rem;
  text-align: center;
  padding: 18px 6px;
  margin: 0;
}

.hint {
  color: var(--text-2);
  font-size: 0.75rem;
  margin: 10px 0 0;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-1);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.priorities {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: prio;
}

.priorities li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(124, 108, 246, 0.12), transparent);
  border: 1px solid var(--card-border);
  font-size: 0.9rem;
  font-weight: 500;
}

.priorities li::before {
  counter-increment: prio;
  content: counter(prio);
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.notes-datenav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

#notesDate {
  flex: 1;
  min-width: 0;
  background: rgba(124, 108, 246, 0.08);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  color: var(--text-0);
  font: inherit;
  font-size: 0.8rem;
}

.notes-datenav .link-btn { flex-shrink: 0; padding: 4px; }

#notes {
  flex: 1;
  min-height: 140px;
  resize: vertical;
  background: rgba(124, 108, 246, 0.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  padding: 12px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.5;
}

#notes:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.save-indicator {
  font-size: 0.72rem;
  color: var(--text-2);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.save-indicator.show { opacity: 1; }

.goal-item {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(124, 108, 246, 0.06);
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-item.done { opacity: 0.6; }
.goal-item.done .item-title { text-decoration: line-through; }

.goal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.goal-top .item-delete { opacity: 0; }
.goal-item:hover .goal-top .item-delete { opacity: 1; }

.goal-progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.goal-progress-track {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(124, 108, 246, 0.15);
  overflow: hidden;
}

.goal-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.25s ease;
}

.goal-percent {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-1);
  min-width: 34px;
  text-align: right;
}

.goal-controls { display: flex; gap: 6px; align-items: center; }

.goal-linked-note {
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 600;
}

.btn-tiny {
  padding: 4px 10px;
  font-size: 0.72rem;
  border-radius: 8px;
}

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

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 14px 6px;
  border-radius: var(--radius-sm);
  background: rgba(124, 108, 246, 0.06);
  border: 1px solid var(--card-border);
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-0);
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-2);
  font-weight: 600;
}

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 70px;
  margin-top: 14px;
  padding-top: 6px;
  border-top: 1px solid var(--card-border);
}

.trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.trend-bar {
  width: 100%;
  max-width: 20px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
  min-height: 3px;
}

.trend-day {
  font-size: 0.62rem;
  color: var(--text-2);
  text-transform: uppercase;
  font-weight: 600;
}

.energy-summary {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--text-1);
}

/* Sections repliables */
.collapse-toggle {
  transition: transform 0.2s ease;
}

.card.collapsed .card-collapsible {
  display: none;
}

.card.collapsed .collapse-toggle {
  transform: rotate(-90deg);
}

/* Bilan du soir */
.checkin-banner {
  display: none;
  position: relative;
  max-width: 1240px;
  margin: 18px auto 0;
  padding: 16px clamp(16px, 4vw, 48px);
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, rgba(246, 185, 59, 0.14), rgba(124, 108, 246, 0.1));
  border: 1px solid var(--card-border);
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.checkin-banner.show { display: flex; }

.checkin-dismiss {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px;
}

.checkin-dismiss:hover { color: var(--text-0); }

.checkin-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.checkin-title { font-weight: 800; font-size: 0.9rem; }
.checkin-sub { font-size: 0.72rem; color: var(--text-2); }

.checkin-input {
  flex: 1 1 220px;
  min-width: 0;
  background: rgba(124, 108, 246, 0.08);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-0);
  font: inherit;
  font-size: 0.85rem;
}

.checkin-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.checkin-energy { display: flex; gap: 4px; flex-shrink: 0; }

.energy-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.energy-btn:hover { transform: translateY(-1px); }
.energy-btn.selected { background: var(--accent); border-color: var(--accent); }

.checkin-save { flex-shrink: 0; padding: 9px 20px; }

.checkin-energy.shake { animation: shake 0.4s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (max-width: 640px) {
  .checkin-banner { padding-top: 44px; }
}

.footer {
  text-align: center;
  color: var(--text-2);
  font-size: 0.75rem;
  padding: 12px 16px 40px;
}

.footer p { margin: 0; }

.footer-actions {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-top: 10px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.link-btn:hover { text-decoration: underline; }

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--bg-1);
  color: var(--text-0);
  box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.5);
  width: min(420px, 92vw);
}

.modal::backdrop {
  background: rgba(10, 10, 20, 0.55);
  backdrop-filter: blur(3px);
}

.modal-form {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-form h3 { margin: 0 0 6px; font-size: 1.05rem; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-1);
}

.field input,
.field select,
.field textarea {
  background: rgba(124, 108, 246, 0.08);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--text-0);
  font: inherit;
  font-size: 0.9rem;
}

.field select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%237d80a0'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='%237d80a0' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px;
  padding-right: 34px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.btn-primary,
.btn-secondary {
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
}

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

.btn-primary:hover { background: #6a5aef; }

.btn-secondary {
  background: transparent;
  border-color: var(--card-border);
  color: var(--text-1);
}

@media (max-width: 980px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card-tall { grid-row: auto; }
}

@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .grid { grid-template-columns: 1fr; }
}
