/* ---------- Tokens ---------- */
:root {
  --ink: #0F2A3D;
  --surface: #16374B;
  --surface-2: #1C4257;
  --surface-3: #234C63;
  --gold: #F2B84B;
  --gold-dim: #C99A44;
  --coral: #FF7A59;
  --mist: #EAF2F5;
  --muted: #9FB8C6;
  --line: rgba(234, 242, 245, 0.09);
  --good: #6FCF97;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--mist);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(1100px 500px at 20% -10%, rgba(242, 184, 75, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(255, 122, 89, 0.08), transparent 55%),
    var(--ink);
}

button, input { font-family: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Écran de connexion ---------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}
.login-screen[hidden] {
  display: none !important;
}


.login-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-sun {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  color: var(--gold);
  filter: drop-shadow(0 0 24px rgba(242, 184, 75, 0.45));
}
.login-sun svg { width: 100%; height: 100%; }
.login-sun circle { fill: currentColor; }

.login-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 42px;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

.login-sub {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 15px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-password {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--mist);
}
#login-password::placeholder { color: var(--muted); }

#login-form button {
  background: linear-gradient(135deg, var(--gold), var(--coral));
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-weight: 600;
  font-size: 16px;
  color: #14202b;
}

.login-error {
  color: var(--coral);
  font-size: 14px;
  margin-top: 14px;
}

/* ---------- Layout général ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px 110px;
  min-height: 100dvh;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }
.icon-btn:hover { color: var(--gold); background: var(--surface-2); }

/* Widget saison — l'élément signature : un arc solaire qui trace la progression de l'été */
.season-widget {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.season-arc {
  width: 96px;
  height: 40px;
  flex-shrink: 0;
  overflow: visible;
}
#arc-track {
  fill: none;
  stroke: var(--surface-2);
  stroke-width: 6;
  stroke-linecap: round;
}
#arc-fill {
  fill: none;
  stroke: url(#none);
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dasharray .6s ease;
}
#arc-sun circle {
  fill: var(--gold);
  filter: drop-shadow(0 0 6px rgba(242, 184, 75, .8));
}

.season-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.season-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold-dim);
  font-weight: 600;
}
.season-count {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Onglets ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14.5px;
  padding: 10px 12px;
  border-radius: 999px;
  transition: background .18s, color .18s;
}
.tab.active {
  background: var(--surface-3);
  color: var(--mist);
}

/* ---------- Panneaux ---------- */
.panel { display: none; }
.panel.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px);} to { opacity: 1; transform: none; } }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
}
.panel-sub {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.empty {
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 22px;
  text-align: center;
}

/* ---------- Liste de tâches (style "ticket") ---------- */
.task-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  position: relative;
  overflow: hidden;
  transition: background .15s, opacity .15s;
}

.task-item::before {
  /* pointillé façon souche de ticket, séparant la case à cocher du reste */
  content: "";
  position: absolute;
  left: 46px;
  top: 8px;
  bottom: 8px;
  border-left: 1.5px dashed var(--line);
}

.check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background .15s, border-color .15s, transform .1s;
}
.check svg {
  width: 14px; height: 14px;
  stroke: var(--ink);
  stroke-width: 3;
  fill: none;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .12s, transform .12s;
}
.task-item.done .check {
  background: var(--good);
  border-color: var(--good);
}
.task-item.done .check svg { opacity: 1; transform: scale(1); }
.check:active { transform: scale(.9); }

.task-body {
  flex: 1;
  min-width: 0;
  padding-left: 4px;
}
.task-title {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}
.task-item.done .task-title {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}
.task-note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.streak {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--gold);
  background: rgba(242, 184, 75, 0.12);
  border-radius: 999px;
  padding: 3px 8px;
  flex-shrink: 0;
  white-space: nowrap;
}

.task-delete {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  transition: opacity .15s, color .15s, background .15s;
}
.task-delete svg { width: 16px; height: 16px; fill: currentColor; }
.task-delete:hover { opacity: 1; color: var(--coral); background: var(--surface-2); }

/* ---------- Formulaire d'ajout (barre flottante) ---------- */
.add-form {
  display: flex;
  gap: 8px;
  position: sticky;
  bottom: max(14px, env(safe-area-inset-bottom));
}
.add-form input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.add-form input::placeholder { color: var(--muted); }
.add-form button {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--gold);
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 13px 18px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

/* ---------- Modale réglages ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 16, 23, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
.modal[hidden] {
  display: none !important;
}

@media (min-width: 640px) {
  .modal { align-items: center; }
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px max(20px, env(safe-area-inset-bottom));
  max-height: 88dvh;
  overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-card { border-radius: var(--radius-lg); margin: 20px; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-head h3 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0;
}

.modal-section {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.modal-section:first-of-type { border-top: none; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
}
.row-title { margin: 0; font-size: 14.5px; font-weight: 600; }
.row-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }

input[type="time"] {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--mist);
  font-family: var(--font-mono);
}

.btn-secondary {
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--gold);
  font-weight: 600;
  font-size: 13.5px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.btn-secondary.full, .btn-ghost.full { width: 100%; padding: 13px; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
}

/* Switch (toggle) */
.switch { position: relative; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background .15s;
}
.switch span::before {
  content: "";
  position: absolute;
  width: 21px; height: 21px;
  left: 2px; top: 2px;
  background: var(--mist);
  border-radius: 50%;
  transition: transform .18s;
}
.switch input:checked + span { background: var(--gold-dim); }
.switch input:checked + span::before { transform: translateX(19px); background: var(--ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--mist);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  z-index: 100;
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Desktop ---------- */
@media (min-width: 860px) {
  .app { max-width: 720px; padding-top: 40px; }
  .login-title { font-size: 48px; }
}
