/* Ma journée — lisible d'abord : texte en 17 px, titres clairs, peu de traits, beaucoup d'air. */
:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --text: #17191c;
  --muted: #565b63;
  --faint: #8a8f97;
  --line: #ebe7df;
  --accent: #b24f26;
  --accent-soft: #fbe9df;
  --warn: #b42318;
  --warn-soft: #fde8e5;
  --ok: #24724a;
  --ok-soft: #e3f3e9;
  --info: #2f4bbf;
  --info-soft: #e8ecfc;
  --src-google: #3b78e7;
  --src-outlook: #0f6cbd;
  --src-icloud: #9a9fa7;
  --radius: 20px;
  --shadow: 0 1px 2px rgb(30 25 15 / 5%), 0 6px 20px rgb(30 25 15 / 5%);
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418;
    --surface: #1c1f24;
    --surface-2: #252930;
    --text: #f1efea;
    --muted: #b3b8c0;
    --faint: #8b9099;
    --line: #2c3037;
    --accent: #f2925f;
    --accent-soft: #3a2519;
    --warn: #ff8f80;
    --warn-soft: #3a1d1a;
    --ok: #74d39d;
    --ok-soft: #1a3324;
    --info: #9fb0ff;
    --info-soft: #20264a;
    --src-google: #7aa7f5;
    --src-outlook: #5aa0e6;
    --src-icloud: #a3a8b0;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  padding-top: env(safe-area-inset-top);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
}

/* --- En-tête -------------------------------------------------------------------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 12px;
  max-width: 600px;
  margin: 0 auto;
  padding: 8px 16px 14px;
}

.top-greeting {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.top-date {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 32px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.top-date::first-letter {
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.weather-pill {
  margin-right: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: var(--shadow);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--line);
}

.icon-btn svg,
.tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.spinning svg {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .icon-btn.spinning svg {
    animation: none;
  }
}

.banner {
  max-width: 568px;
  margin: 0 auto 12px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  color: var(--info);
  background: var(--info-soft);
}

@media (max-width: 600px) {
  .banner {
    margin: 0 16px 12px;
  }
}

main {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
}

.loading {
  color: var(--muted);
  text-align: center;
  padding: 48px 0;
}

/* --- Barre d'onglets ------------------------------------------------------------- */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-top: 1px solid var(--line);
}

.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 600px;
  height: var(--tabbar-h);
  margin: 0 auto;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  color: var(--accent);
}

/* --- Cartes ------------------------------------------------------------------------ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 0 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .card {
    border: 1px solid var(--line);
  }
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.card-meta {
  font-size: 14px;
  color: var(--muted);
  text-align: right;
}

.group-label {
  margin: 18px 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}

.group-label:first-child {
  margin-top: 0;
}

.muted {
  color: var(--muted);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.note {
  margin: 12px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* Une source qui ne répond pas ou pas encore connectée */
.source-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--muted);
  background: var(--surface-2);
}

.source-note.error {
  color: var(--warn);
  background: var(--warn-soft);
}

/* --- Briefing ----------------------------------------------------------------------- */
.must {
  margin: 0 0 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
}

.must-label {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.must-text {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.35;
}

.briefing-lines {
  margin: 0;
  padding: 0;
  list-style: none;
}

.briefing-lines li {
  position: relative;
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 18px;
  line-height: 1.4;
}

.briefing-lines li:last-child {
  margin-bottom: 0;
}

.briefing-lines li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* --- Alertes -------------------------------------------------------------------------- */
.alerts {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.alerts li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 8px;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
  background: var(--info-soft);
  color: var(--info);
}

.alerts li.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* --- Boutons ---------------------------------------------------------------------------- */
.btn {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}

.btn:active {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.6;
}

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

.btn-block {
  display: block;
  width: 100%;
  margin-top: 16px;
}

.btn-soft {
  border: 0;
  background: var(--surface-2);
}

.link-btn {
  min-height: 44px;
  margin-top: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* --- Lignes (agenda, mails, tâches…) ------------------------------------------------------ */
.items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.item:first-child {
  border-top: 0;
  padding-top: 2px;
}

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

.item-title {
  font-weight: 600;
  line-height: 1.3;
}

.item-sub {
  margin-top: 2px;
  font-size: 15px;
  color: var(--muted);
}

.item-side {
  flex: none;
  font-size: 15px;
  color: var(--muted);
  text-align: right;
}

.item-side.late {
  color: var(--warn);
  font-weight: 600;
}

.item.past {
  opacity: 0.45;
}

/* Heure d'un rendez-vous avec la couleur de son agenda */
.time {
  flex: none;
  width: 58px;
  padding-left: 10px;
  border-left: 3px solid var(--src-icloud);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.3;
}

.time small {
  display: block;
  font-weight: 400;
  font-size: 14px;
  color: var(--muted);
}

.time.google {
  border-color: var(--src-google);
}

.time.outlook {
  border-color: var(--src-outlook);
}

.time.icloud {
  border-color: var(--src-icloud);
}

.icon {
  flex: none;
  width: 28px;
  font-size: 22px;
  line-height: 1.2;
  text-align: center;
}

.dot-marker {
  flex: none;
  width: 12px;
  height: 12px;
  margin: 6px 8px 0 4px;
  border-radius: 50%;
  border: 2px solid var(--faint);
}

.dot-marker.late {
  border-color: var(--warn);
  background: var(--warn-soft);
}

.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  vertical-align: 2px;
  background: var(--surface-2);
  color: var(--muted);
}

.tag.reply {
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.urgent {
  background: var(--warn-soft);
  color: var(--warn);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.legend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: -1px;
  background: var(--src-icloud);
}

.legend .google::before {
  background: var(--src-google);
}

.legend .outlook::before {
  background: var(--src-outlook);
}

/* Créneaux libres */
.free {
  margin-top: 14px;
}

.free-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ok);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.chip.free-chip {
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
}

/* --- Trajet ----------------------------------------------------------------------------- */
.departure {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.line-badge {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--text);
  color: var(--bg);
  font-weight: 800;
}

.departure-dest {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.departure-min {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.advice {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 600;
  background: var(--ok-soft);
  color: var(--ok);
}

.advice.bad {
  background: var(--warn-soft);
  color: var(--warn);
}

/* --- Météo ------------------------------------------------------------------------------- */
.weather-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin: 0 0 14px;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}

.weather-strip .big-icon {
  font-size: 34px;
  line-height: 1;
}

.weather-strip strong {
  display: block;
  font-size: 18px;
}

.weather-strip span {
  color: var(--muted);
  font-size: 15px;
}

.weather-now {
  display: flex;
  align-items: center;
  gap: 16px;
}

.weather-now .big-icon {
  font-size: 48px;
  line-height: 1;
}

.weather-temp {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.weather-days {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}

.weather-day {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-2);
}

.weather-day strong {
  display: block;
}

.hours {
  display: flex;
  gap: 8px;
  margin: 16px -18px 0;
  padding: 0 18px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.hours::-webkit-scrollbar {
  display: none;
}

.hour {
  flex: none;
  width: 62px;
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
  font-size: 15px;
}

.hour .h-icon {
  display: block;
  font-size: 22px;
  margin: 2px 0;
}

.hour .h-rain {
  display: block;
  color: var(--info);
  font-size: 13px;
}

/* --- Habitudes --------------------------------------------------------------------------- */
.habits {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.habit {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 16px;
  background: var(--surface-2);
  text-align: left;
  cursor: pointer;
}

.habit.done {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.habit-emoji {
  font-size: 24px;
}

.habit-name {
  display: block;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
}

.habit-streak {
  display: block;
  font-size: 14px;
  color: var(--muted);
}

/* --- Objectif ----------------------------------------------------------------------------- */
.goal-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.progress {
  height: 12px;
  margin: 14px 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* --- Journal -------------------------------------------------------------------------------- */
.moods {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
}

.mood {
  flex: 1;
  min-height: 50px;
  border: 2px solid transparent;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 24px;
  cursor: pointer;
}

.mood[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* --- Formulaires ------------------------------------------------------------------------------ */
.inline-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.inline-form .two {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

input[type="text"],
input[type="date"],
input[type="time"],
input[type="password"],
textarea,
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 17px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

/* --- Actualités et idée de code ------------------------------------------------------------- */
.news-item {
  display: block;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
}

.news-item:first-child {
  border-top: 0;
  padding-top: 2px;
}

.news-source {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.news-title {
  display: block;
  margin-top: 2px;
  font-weight: 600;
  line-height: 1.3;
}

.news-summary {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.code-title {
  margin: 0 0 6px;
  font-size: 20px;
}

.steps {
  margin: 12px 0 0;
  padding-left: 24px;
}

.steps li {
  margin-bottom: 6px;
}

/* --- Sources ------------------------------------------------------------------------------- */
.status {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--faint);
}

.status.ok {
  background: var(--ok);
}

.status.error {
  background: var(--warn);
}

.status.demo {
  background: var(--info);
}

/* --- Feuille de réglages ---------------------------------------------------------------------- */
.sheet {
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: 22px 22px 0 0;
  background: var(--surface);
  color: var(--text);
}

@media (min-width: 632px) {
  .sheet {
    margin: auto;
    border-radius: 22px;
  }
}

.sheet::backdrop {
  background: rgb(0 0 0 / 45%);
}

.sheet form {
  display: flex;
  flex-direction: column;
  max-height: 92vh;
}

.sheet-head,
.sheet-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 18px;
}

.sheet-head {
  border-bottom: 1px solid var(--line);
}

.sheet-head h2 {
  margin: 0;
  font-size: 20px;
}

.sheet-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.sheet-body {
  overflow-y: auto;
  padding: 4px 18px 20px;
}

.field {
  display: grid;
  gap: 6px;
  margin: 16px 0 0;
}

.field > span {
  font-weight: 600;
}

.field .hint {
  font-size: 15px;
  font-weight: 400;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface-2);
}

.sheet-section {
  margin: 26px 0 0;
  font-size: 18px;
  font-weight: 700;
}

/* --- Écran verrouillé -------------------------------------------------------------------------- */
.lock {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  padding: 48px 24px calc(48px + env(safe-area-inset-bottom));
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

body.is-locked .lock {
  display: flex;
}

body.is-locked .top,
body.is-locked .banner,
body.is-locked main,
body.is-locked .tabbar {
  display: none !important;
}

.lock-icon {
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.lock-title {
  margin: 18px 0 6px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.lock-text {
  margin: 0 0 24px;
  color: var(--muted);
}

.lock-actions {
  display: grid;
  gap: 12px;
  width: 100%;
}

.lock-actions .btn {
  min-height: 54px;
  font-size: 18px;
}

.lock-actions input {
  text-align: center;
  letter-spacing: 0.04em;
}

.lock-error {
  margin: 16px 0 0;
  color: var(--warn);
  font-weight: 600;
}

/* --- Toast ------------------------------------------------------------------------------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 16px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 6px 24px rgb(0 0 0 / 20%);
  z-index: 20;
}
