@font-face { font-family: Manrope; font-weight: 400; font-display: swap; src: url(fonts/manrope-400-latin.woff2) format('woff2'); }
@font-face { font-family: Manrope; font-weight: 500; font-display: swap; src: url(fonts/manrope-500-latin.woff2) format('woff2'); }
@font-face { font-family: Manrope; font-weight: 600; font-display: swap; src: url(fonts/manrope-600-latin.woff2) format('woff2'); }
@font-face { font-family: Manrope; font-weight: 700; font-display: swap; src: url(fonts/manrope-700-latin.woff2) format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 400; font-display: swap; src: url(fonts/space-mono-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Space Mono'; font-weight: 700; font-display: swap; src: url(fonts/space-mono-700-latin.woff2) format('woff2'); }

/* Charte Upfull : rouge #EA0D43 et anthracite #1E1F23, sur fond clair */
:root {
  --bg: #F3F1EC;
  --card: #FFFFFF;
  --line: #E7E4DD;
  --text: #1E1F23;
  --muted: #6F7077;
  --red: #EA0D43;
  --green: #128A55;
  --mono: 'Space Mono', ui-monospace, Menlo, monospace;
  --pad: clamp(14px, 1.6vw, 22px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 500 16px/1.35 Manrope, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
  -webkit-user-select: none; user-select: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: filter 1.5s ease;
}
body.night { filter: brightness(.4); }

/* ---------- Grille : paysage = 3 colonnes, portrait = 2 ---------- */
.grid {
  height: 100%; padding: var(--pad); gap: var(--pad);
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas: "clock agenda streams" "clock sorties maison";
}
@media (orientation: portrait) {
  .grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr 1fr;
    grid-template-areas: "clock clock" "agenda streams" "sorties maison";
  }
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: var(--pad); min-height: 0; overflow: hidden; position: relative;
  box-shadow: 0 1px 2px rgba(30,31,35,.04), 0 6px 18px rgba(30,31,35,.05);
}
.clock { grid-area: clock; display: flex; flex-direction: column; container-type: inline-size; }
.agenda { grid-area: agenda; } .streams { grid-area: streams; }
.sorties { grid-area: sorties; } .maison { grid-area: maison; }

h2 {
  font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px;
}
h2::before { content: ''; width: 8px; height: 8px; border-radius: 2px; background: var(--red); flex: none; align-self: center; }
h2 small { font-weight: 500; letter-spacing: 0; text-transform: none; font-size: 12px; margin-left: auto; }

/* ---------- Horloge + météo ---------- */
.time {
  font: 700 min(31cqi, 168px)/.9 var(--mono); letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.date { font-size: clamp(20px, 2.3vw, 28px); font-weight: 600; margin-top: 10px; text-transform: capitalize; }
.weather { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--line); }
@media (orientation: portrait) { .clock { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 0 28px; } .weather { margin-top: 18px; width: 100%; } }
.w-now { display: flex; align-items: center; gap: 14px; }
.w-icon { font-size: 52px; line-height: 1; }
.w-temp { font: 700 56px/1 var(--mono); }
.w-meta { color: var(--muted); margin-top: 8px; font-size: 15px; }
.w-days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.w-day {
  background: var(--bg); border-radius: 14px; padding: 10px 12px;
  display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; font-size: 15px;
}
.w-day > span:first-child { text-transform: capitalize; color: var(--muted); }
.w-di { font-size: 22px; justify-self: end; }
.w-day em { font-style: normal; color: var(--muted); }
.rain { color: #1F6FC0; font-size: 13px; justify-self: end; }

/* ---------- Listes ---------- */
.list { list-style: none; overflow: hidden; height: calc(100% - 30px); }
.list li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.list li:last-child { border-bottom: 0; }
.list li.day { color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; border: 0; padding: 10px 0 2px; }
.list li.day:first-child { padding-top: 0; }
.when { font: 400 14px/1.6 var(--mono); color: var(--muted); min-width: 64px; flex: none; }
.list small { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); font-size: 15px; border: 0 !important; }

/* ---------- Streams ---------- */
.big { font: 700 clamp(28px, 3.3vw, 42px)/1 var(--mono); letter-spacing: -.03em; }
.sub { color: var(--muted); margin: 8px 0 12px; font-size: 14px; }
.sub b { color: var(--green); }
.rank { list-style: none; counter-reset: r; }
.rank li { counter-increment: r; display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.rank li::before { content: counter(r); font: 700 13px/1.7 var(--mono); color: var(--red); width: 14px; }
.rank li span { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank li b { font: 400 14px/1.6 var(--mono); color: var(--green); }

/* ---------- Maison ---------- */
.devices { display: flex; flex-direction: column; gap: 14px; }
.dev-name { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.dev-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dev-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  font: 600 16px Manrope, system-ui, sans-serif; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, background .2s ease, border-color .2s ease;
}
.dev-btn:active { transform: scale(.96); background: #ECE9E2; }
.dev-btn.sent { border-color: var(--red); }
.dev-ico { font-size: 22px; }

.status { position: fixed; right: 18px; bottom: 10px; font-size: 12px; color: var(--muted); }

/* ---------- Connexion ---------- */
body.login { display: grid; place-items: center; overflow: auto; }
.login-box { width: min(360px, 90vw); display: flex; flex-direction: column; gap: 12px; }
.brand { font: 700 22px/1 Manrope; letter-spacing: .04em; margin-bottom: 18px; }
.brand span { color: var(--red); }
.login-box label { color: var(--muted); font-size: 14px; }
.login-box input {
  font: 700 28px var(--mono); letter-spacing: .3em; text-align: center;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 14px;
}
.login-box input:focus { outline: 2px solid var(--red); outline-offset: 2px; }
.login-box button {
  background: var(--red); color: #fff; border: 0; border-radius: 14px; padding: 15px;
  font: 700 17px Manrope; cursor: pointer;
}
.err { color: #C40A37; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }
.cal { font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--red); border: 1px solid currentColor; border-radius: 6px; padding: 0 5px; margin-left: 6px; vertical-align: 2px; }
.dev-btn:only-child { grid-column: 1 / -1; }
.list li.rel { display: block; padding: 5px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.list li.rel small { margin-left: 8px; }
#sorties li.rel { padding: 3px 0; border-bottom: 0; }
#sorties li.day { padding: 7px 0 1px; }
#sorties li.day:first-child { padding-top: 0; }
