:root {
  --bg: #0d0f12;
  --panel: #15181d;
  --panel-2: #1b1f25;
  --line: #262b33;
  --text: #e6e8eb;
  --muted: #8a919c;
  --accent: #d9a441;
  --accent-soft: rgba(217, 164, 65, 0.12);
  --red: #e5534b;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 22px 60px; }

/* En-tête */
header.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.hello h1 { margin: 0; font-size: 28px; font-weight: 650; letter-spacing: -0.02em; }
.hello p { margin: 4px 0 0; color: var(--muted); }
.hello p::first-letter { text-transform: uppercase; }
.clock { font-size: 44px; font-weight: 300; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  display: inline-grid; place-items: center; color: var(--muted); transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: #3a414c; }
.icon-btn svg { width: 18px; height: 18px; }
.spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Grille */
.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h2 {
  margin: 0 0 14px; font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card h2 .meta { letter-spacing: 0; text-transform: none; font-weight: 400; font-size: 12px; }
.empty { color: var(--muted); padding: 6px 0; }

/* Mails */
.mail { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px 10px; margin: 0 -10px; border-radius: 10px; }
.mail:hover { background: var(--panel-2); }
.mail .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; background: transparent; }
.mail.unread .dot { background: var(--accent); }
.mail .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail.unread .who { color: #fff; }
.mail .what { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.mail .side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.mail time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.travail { color: #7cb7ff; } .tag.commande { color: #8fd18f; } .tag.facture, .tag.admin { color: #e6c06b; }
.tag.securite { color: var(--red); } .tag.rdv { color: #c79cff; } .tag.perso { color: #ff9ec4; }
.mail.flash { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }

/* Météo */
.weather-now { display: flex; align-items: center; gap: 14px; }
.weather-now .big { font-size: 46px; line-height: 1; }
.weather-now .temp { font-size: 34px; font-weight: 300; letter-spacing: -0.02em; }
.weather-now .desc { color: var(--muted); font-size: 13px; }
.days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.day { background: var(--panel-2); border-radius: 10px; padding: 10px; text-align: center; }
.day .d { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.day .e { font-size: 22px; margin: 4px 0; }
.day .t { font-size: 13px; font-variant-numeric: tabular-nums; }
.day .r { color: #7cb7ff; font-size: 11px; margin-top: 2px; }

/* Agenda */
.agenda-day { color: var(--muted); font-size: 12px; margin: 12px 0 6px; text-transform: capitalize; }
.agenda-day:first-child { margin-top: 0; }
.event { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.event:first-of-type { border-top: 0; }
.event .h { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 14px; }
.event .l { color: var(--muted); font-size: 13px; }

/* Star Citizen */
.sc { border-color: rgba(217, 164, 65, 0.35); background: linear-gradient(180deg, rgba(217,164,65,0.07), transparent 60%), var(--panel); }
.sc .body h3 { margin: 10px 0 6px; font-size: 17px; }
.sc .body h3:first-child { margin-top: 0; }
.sc .body p { margin: 6px 0; color: #cfd3d8; }
.sc .body ul { margin: 6px 0; padding-left: 20px; color: #cfd3d8; }

/* Liens */
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.link {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; background: var(--panel-2);
  border: 1px solid transparent; transition: border-color .15s; min-width: 0;
}
.link:hover { border-color: #3a414c; }
.link img { width: 18px; height: 18px; border-radius: 4px; flex: none; }
.link span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; margin-bottom: 8px; }
.edit-row input, .add-row input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px 10px; font: inherit; min-width: 0;
}
.btn { border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px; padding: 8px 12px; }
.btn.primary { background: var(--accent); color: #1a1406; border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--red); }
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

/* Bandeau et toast */
.banner { background: var(--accent-soft); border: 1px solid rgba(217,164,65,0.4); color: var(--text); padding: 12px 16px; border-radius: 12px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #22272e; border: 1px solid #3a414c; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  transition: opacity .25s, transform .25s; max-width: calc(100% - 32px); z-index: 10;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast b { color: var(--accent); }

/* Connexion */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 360px; text-align: center; }
.login img { width: 84px; height: 84px; border-radius: 20px; }
.login h1 { font-size: 24px; margin: 18px 0 6px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.google-btn { display: inline-flex; align-items: center; gap: 10px; background: #fff; color: #1f1f1f; padding: 12px 20px; border-radius: 99px; font-weight: 600; }
.error { color: var(--red); margin-top: 18px; }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  .clock { font-size: 34px; }
  .hello h1 { font-size: 23px; }
  .wrap { padding: 20px 14px 50px; }
}
@media (max-width: 520px) {
  header.top { flex-wrap: wrap; align-items: center; }
  .clock { display: none; }
  .edit-row { grid-template-columns: 1fr; }
}
