/* =========================================================
   MON BUREAU — Design System v4
   Moderne · Fluide · Mobile-first
   ========================================================= */

/* ============ FONTS ============ */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500;9..144,700;9..144,900&family=JetBrains+Mono:wght@400;500;700&display=swap');

/* ============ VARIABLES ============ */
:root {
  /* Palette principale — une vraie couleur de marque (sauge/foret), pas
     un gris-beige neutre : c'est ce qui evite l'effet "fond par defaut". */
  --bg:          #eef4f0;
  --bg-elev:     #ffffff;
  --bg-card:     #ffffff;
  --line:        #dbe6df;
  --ink:         #16211b;
  --ink-mid:     #5c6e63;
  --ink-low:     #b7c4bc;

  /* Accents */
  --accent:      #2d6a4f;
  --accent-deep: #16382a;
  --accent-1:    #e2f0e8;
  --accent-2:    #e63946;
  --accent-3:    #2d9c6a;
  --accent-4:    #f4a261;
  --accent-5:    #e63946;

  /* Typographie */
  --font-serif:  'Fraunces', Georgia, serif;
  --font-mono:   'JetBrains Mono', monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;

  /* Espacements */
  --gap:         16px;
  --gap-sm:      10px;
  --gap-lg:      24px;
  --radius:      18px;
  --radius-sm:   10px;
  --radius-lg:   26px;

  /* Ombres */
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow:      0 2px 8px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.12), 0 24px 64px rgba(0,0,0,0.08);
}

/* ============ DARK MODE ============ */
[data-theme="dark"] {
  --bg:          #15140f;
  --bg-elev:     #201f1a;
  --bg-card:     #201f1a;
  --line:        #322f27;
  --ink:         #f0ede8;
  --ink-mid:     #928d80;
  --ink-low:     #423e35;
  --accent:      #52b788;
  --accent-1:    #1e3128;
  --shadow-sm:   0 1px 4px rgba(0,0,0,0.3);
  --shadow:      0 2px 8px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
}

[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 1100px 750px at 12% -8%, rgba(82, 183, 136, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 900px 650px at 105% 0%, rgba(244, 162, 97, 0.06) 0%, transparent 52%),
    radial-gradient(ellipse 800px 900px at -5% 100%, rgba(45, 106, 79, 0.10) 0%, transparent 50%),
    var(--bg);
}

/* Dark mode - composants supplémentaires */
[data-theme="dark"] .sheet { background: var(--bg-elev); }
[data-theme="dark"] .tile { background: var(--bg-card); border-color: var(--line); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}
[data-theme="dark"] .modal { background: var(--bg-elev); }
[data-theme="dark"] .dropdown { background: var(--bg-elev); border-color: var(--line); }
[data-theme="dark"] ::placeholder { color: var(--ink-mid); }
[data-theme="dark"] .toast { background: var(--ink); color: var(--bg); }

/* Auto: media query system */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) {
    --bg:          #15140f;
    --bg-elev:     #201f1a;
    --bg-card:     #201f1a;
    --line:        #322f27;
    --ink:         #f0ede8;
    --ink-mid:     #928d80;
    --ink-low:     #423e35;
    --accent:      #52b788;
    --accent-1:    #1e3128;
  }
  html:not([data-theme="light"]) body {
    background:
      radial-gradient(ellipse 1100px 750px at 12% -8%, rgba(82, 183, 136, 0.09) 0%, transparent 55%),
      radial-gradient(ellipse 900px 650px at 105% 0%, rgba(244, 162, 97, 0.06) 0%, transparent 52%),
      radial-gradient(ellipse 800px 900px at -5% 100%, rgba(45, 106, 79, 0.10) 0%, transparent 50%),
      var(--bg);
  }
  html:not([data-theme="light"]) .topbar { background: rgba(21, 20, 15, 0.85); }
  html:not([data-theme="light"]) .sheet { background: var(--bg-elev); }
}

/* ============ RESET ============ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(ellipse 1200px 800px at 8% -10%, rgba(45, 106, 79, 0.16) 0%, transparent 56%),
    radial-gradient(ellipse 950px 700px at 108% -2%, rgba(244, 162, 97, 0.16) 0%, transparent 54%),
    radial-gradient(ellipse 900px 950px at -8% 105%, rgba(45, 106, 79, 0.13) 0%, transparent 52%),
    radial-gradient(ellipse 700px 600px at 100% 100%, rgba(139, 122, 184, 0.07) 0%, transparent 50%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  min-height: 100%;
  padding-bottom: 20px;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ============ GRAIN OVERLAY ============ */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
}

/* ============ TOPBAR ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px var(--gap) 12px;
  background: linear-gradient(180deg, rgba(226, 240, 232, 0.92) 0%, rgba(238, 244, 240, 0.85) 100%);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
}

[data-theme="dark"] .topbar {
  background: rgba(17, 17, 16, 0.85);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(22, 56, 42, 0.28);
}

[data-theme="dark"] .logo-mark {
  background: linear-gradient(135deg, var(--accent) 0%, #1b4332 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.logo-mark svg {
  width: 18px;
  height: 18px;
}

.greeting {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}

.datetime {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-mid);
  margin-top: 1px;
  text-transform: lowercase;
}

.topbar-actions {
  display: flex;
  gap: 6px;
}

/* ============ ICON BUTTON ============ */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--bg-elev);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.icon-btn:active {
  transform: scale(0.88);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

/* ============ DESKTOP GRID ============ */
.desktop {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gap-sm);
  padding: var(--gap) var(--gap-sm);
  max-width: 768px;
  margin: 0 auto;
}

/* ============ TILES ============ */
.tile {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 16px 14px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.tile:active {
  transform: scale(0.96);
  box-shadow: var(--shadow-sm);
}

/* Lever la tuile au survol (souris/trackpad uniquement — sur mobile le
   survol resterait "coince" apres un tap, d'ou le garde-fou hover:hover). */
@media (hover: hover) and (pointer: fine) {
  .tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: color-mix(in srgb, var(--accent) 25%, var(--line));
  }
  .tile:hover .tile-photo img { transform: scale(1.05); }
}

/* Vague au point de contact — pur CSS + une origine posee par bindTiles(). */
.tile-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  opacity: 0.9;
  pointer-events: none;
  animation: tileRipple 0.6s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
  z-index: 5;
}
[data-theme="dark"] .tile-ripple,
.tile-feature .tile-ripple,
.tile-tasks .tile-ripple,
.tile-veille .tile-ripple,
.tile-alerte .tile-ripple { background: rgba(255,255,255,0.18); }
.tile:not(.tile-feature):not(.tile-tasks):not(.tile-veille):not(.tile-alerte) .tile-ripple {
  background: rgba(45,106,79,0.14);
}
@keyframes tileRipple {
  to { transform: scale(1); opacity: 0; }
}

/* La photo repond au toucher, comme le reste de la tuile. */
.tile-photo img {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.tile:active .tile-photo img {
  transform: scale(1.08);
}

/* Tile feature (pleine largeur) */
.tile-feature {
  grid-column: 1 / -1;
  min-height: 120px;
  background: var(--ink);
  color: var(--bg);
  border-color: transparent;
}

.tile-feature .tile-label,
.tile-feature .tile-count,
.tile-feature .tile-foot,
.tile-feature .event-time,
.tile-feature .event-title {
  color: var(--bg) !important;
}

.tile-feature .event-time {
  opacity: 0.6;
}

/* Tiles colorées */
.tile-tasks {
  background: #1a1a18;
  color: white;
  border-color: transparent;
}
.tile-tasks .tile-label,
.tile-tasks .tile-count,
.tile-tasks .tile-foot { color: rgba(255,255,255,0.9) !important; }
.tile-tasks .mini-list li { color: rgba(255,255,255,0.75); }
.tile-tasks .empty { color: rgba(255,255,255,0.4) !important; }

.tile-habits {
  background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%);
  color: white;
  border-color: transparent;
}
.tile-habits .tile-label,
.tile-habits .tile-foot { color: rgba(255,255,255,0.9) !important; }

.tile-veille {
  background: linear-gradient(135deg, #e63946 0%, #c1121f 100%);
  color: white;
  border-color: transparent;
}
.tile-veille .tile-label,
.tile-veille .tile-foot,
.tile-veille .news-snippet,
.tile-veille .badge-live { color: rgba(255,255,255,0.9) !important; }

/* ===== WIDGET VEILLE : 5 dernières actus, responsive ===== */
.tile-veille-widget {
  grid-column: span 2;          /* 2 colonnes : de la place pour 5 actus */
  min-height: 210px;
}
/* Très petits écrans : le widget prend toute la largeur */
@media (max-width: 400px) {
  .tile-veille-widget { grid-column: 1 / -1; }
}
.tile-veille-widget .tile-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.tile-veille .veille-widget-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tile-veille .veille-widget-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255,255,255,0.16);
}
.tile-veille .veille-widget-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.tile-veille .veille-widget-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  color: #fff !important;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-veille .veille-widget-meta {
  font-size: 10px;
  color: rgba(255,255,255,0.72) !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-veille .veille-widget-empty {
  list-style: none;
  text-align: center;
  padding: 24px 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.82) !important;
}
.tile-veille .veille-refresh-btn {
  background: rgba(255,255,255,0.16);
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.tile-veille .veille-refresh-btn:hover { background: rgba(255,255,255,0.30); }
.tile-veille .veille-refresh-btn:active { transform: scale(0.9); }
.tile-veille .veille-refresh-btn.spinning { animation: veille-spin 0.9s linear infinite; }
@keyframes veille-spin { to { transform: rotate(360deg); } }
/* Sur écrans confortables, on peut afficher un peu plus haut */
@media (min-width: 769px) {
  .tile-veille-widget { min-height: 240px; }
}

/* ===== TUILE ALERTE : vigilance météo / catastrophes / sécurité ===== */
.tile-alerte {
  background: linear-gradient(135deg, #22223b 0%, #1a1a2e 100%);
  color: #fff;
  border-color: transparent;
}
.tile-alerte .tile-label,
.tile-alerte .tile-foot { color: rgba(255,255,255,0.9) !important; }
.tile-alerte-widget {
  grid-column: span 2;
  min-height: 200px;
}
@media (max-width: 400px) {
  .tile-alerte-widget { grid-column: 1 / -1; }
}
@media (min-width: 769px) {
  .tile-alerte-widget { min-height: 230px; }
}
.tile-alerte .alerte-banner {
  border-radius: 8px;
  padding: 9px 10px;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  margin: 4px 0 9px;
  text-align: center;
  background: #2d6a4f;
  line-height: 1.3;
}
.tile-alerte .alerte-widget-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tile-alerte .alerte-widget-item { line-height: 1.3; }
.tile-alerte .alerte-widget-item a {
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 11.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-alerte .alerte-widget-meta {
  font-size: 9.5px;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-alerte .alerte-refresh-btn {
  background: rgba(255,255,255,0.16);
  border: none;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  cursor: pointer;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}
.tile-alerte .alerte-refresh-btn:hover { background: rgba(255,255,255,0.30); }
.tile-alerte .alerte-refresh-btn:active { transform: scale(0.9); }
.tile-alerte .alerte-refresh-btn.spinning { animation: veille-spin 0.9s linear infinite; }

/* ===========================================================
   ICONOGRAPHIE — remplace les emojis + les 11 fonds "arc-en-ciel"
   qui n'avaient aucun lien avec la palette (indigo, violet, rose...).
   Toutes les tuiles utilitaires reviennent au fond crème standard
   (.tile) ; l'identité visuelle passe par un badge d'icône dans le
   corps de la tuile, dans les 4 teintes de la palette existante.
   =========================================================== */

.tile-icon-slot {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px auto 12px;
  flex-shrink: 0;
}
.tile-icon-slot svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}

/* 4 teintes puisées dans la palette existante (--accent, --accent-2,
   --accent-4) + un bleu discret pour les tuiles "communication". */
.tile-icon-green  { background: var(--accent-1); color: var(--accent); }
.tile-icon-orange { background: #fdf1e6; color: var(--accent-4); }
.tile-icon-red    { background: #fdeceb; color: var(--accent-2); }
.tile-icon-blue   { background: #e8f0f7; color: #3a6ea5; }

[data-theme="dark"] .tile-icon-green  { background: rgba(82,183,136,0.16); }
[data-theme="dark"] .tile-icon-orange { background: rgba(244,162,97,0.16); }
[data-theme="dark"] .tile-icon-red    { background: rgba(230,57,70,0.16); }
[data-theme="dark"] .tile-icon-blue   { background: rgba(58,110,165,0.20); color: #7fb0e0; }

/* Petit badge translucide pour les tuiles "hero" à fond sombre
   (Veille, Alerte) : l'icône se pose directement sur le dégradé. */
.tile-icon-ghost {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: rgba(255,255,255,0.18);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tile-icon-ghost svg { width: 16px; height: 16px; stroke-width: 1.8; }

/* Petite icône dans l'en-tête, pour les tuiles qui gardent du contenu
   dynamique dans le corps (pas de place pour le grand badge). */
.tile-header-icon {
  width: 22px; height: 22px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 7px;
  flex-shrink: 0;
}
.tile-header-icon svg { width: 13px; height: 13px; stroke-width: 2; }
.tile-header-label-row { display: flex; align-items: center; }

/* Icône inline dans un bouton (ex : rafraîchir), remplace les 🔄 */
.icon-inline { width: 14px; height: 14px; stroke-width: 2; vertical-align: -2px; }
.veille-refresh-btn svg, .alerte-refresh-btn svg { width: 14px; height: 14px; stroke-width: 2; }

/* ===== BANDE PHOTO (tuiles "univers" : Musique, Courses, Podcasts...) ===== */
.tile-has-photo { padding: 0; }
.tile-photo {
  position: relative;
  height: 72px;
  overflow: hidden;
  border-radius: var(--radius) var(--radius) 0 0;
}
.tile-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.tile-photo::after {
  /* voile doux en bas de la photo pour que l'icône reste lisible */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,0.35) 100%);
}
.tile-photo .tile-photo-icon {
  position: absolute;
  bottom: 8px; left: 10px;
  width: 26px; height: 26px;
  color: #fff;
  z-index: 1;
}
.tile-photo .tile-photo-icon svg { width: 100%; height: 100%; stroke-width: 1.8; }
.tile-photo.tile-photo-placeholder { background: linear-gradient(135deg, var(--ph-a, #2d6a4f) 0%, var(--ph-b, #1b4332) 100%); }
.tile-body-wrap { padding: 12px 16px 14px; flex: 1; display: flex; flex-direction: column; }
.tile-has-photo .tile-body { flex: 1; }

/* ============ TILE STRUCTURE ============ */
.tile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tile-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mid);
}

.tile-count {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}

.tile-body {
  flex: 1;
}

.tile-foot {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-low);
  margin-top: 12px;
  font-weight: 500;
}

/* ============ TILE CONTENTS ============ */
.next-event {
  padding: 4px 0;
}

.event-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-mid);
  margin-bottom: 4px;
}

.event-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
}

.mini-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mini-list li {
  font-size: 13px;
  color: var(--ink);
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-list li.empty {
  color: var(--ink-low);
  border-bottom: none;
  font-style: italic;
}

.mini-list li.overdue {
  color: var(--accent-2);
}

.note-snippet {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink-mid);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.habit-ring {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto;
}

.habit-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  color: white;
  transform: rotate(0deg);
}

.ring-text small {
  font-size: 11px;
  margin-top: 4px;
  opacity: 0.8;
}

.badge-live {
  font-size: 10px;
  color: rgba(255,255,255,0.9);
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.news-snippet {
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.4;
}

.drive-glyph {
  width: 48px;
  height: 48px;
  margin: 8px auto;
  display: block;
  opacity: 0.3;
}

.factcheck-prompt {
  font-size: 13px;
  color: white;
  line-height: 1.4;
  opacity: 0.9;
}

.loisir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  color: var(--ink-mid);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-a { background: var(--accent); }
.dot-b { background: var(--accent-4); }
.dot-c { background: var(--accent-2); }

/* ============ SHEET ============ */
.sheet {
  position: fixed;
  inset: 0;
  top: auto;
  height: 92vh;
  background: var(--bg-elev);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-lg);
  will-change: transform, border-radius;
}

/* Pendant l'animation "la tuile grandit en panneau" pilotee par openSheet(),
   le contenu reste invisible le temps que la forme finisse de grandir — sinon
   le texte, etire de force dans le format tuile puis dans le format panneau,
   se voit deformer une fraction de seconde. */
.sheet-body.sheet-body-entering {
  opacity: 0;
}

.sheet.active {
  transform: translateY(0);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--ink-low);
  margin: 12px auto 0;
}

.sheet-header {
  padding: 16px 20px 0;
  position: sticky;
  top: 0;
  background: var(--bg-elev);
  z-index: 10;
}

.sheet-header h2 {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
}

.sheet-body {
  padding: 16px 20px 40px;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ============ APP COMPONENTS ============ */
.app-section {
  margin-bottom: 20px;
}

.hint {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mid);
  margin-bottom: 10px;
}

.app-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  font-family: var(--font-sans);
  transition: border-color 0.2s;
  outline: none;
}

.app-input:focus {
  border-color: var(--accent);
}

.app-btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: var(--font-sans);
}

.app-btn:active {
  transform: scale(0.95);
}

.app-btn.ghost {
  background: var(--bg);
  color: var(--ink);
  border: 1.5px solid var(--line);
}

.app-btn.ghost:hover {
  border-color: var(--ink-mid);
}

.flex-row {
  display: flex;
  gap: var(--gap-sm);
  align-items: center;
}

/* ============ ROW LIST ============ */
.row-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  transition: background 0.15s;
}

.row-item.read-article {
  opacity: 0.5;
}

.row-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  min-width: 0;
}

.row-del {
  background: none;
  border: none;
  color: var(--ink-low);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.row-del:hover {
  background: var(--accent-2);
  color: white;
}

.empty {
  color: var(--ink-low);
  font-style: italic;
  font-size: 13px;
  padding: 8px 0;
}

/* ============ PRIORITY ============ */
.priority-high {
  color: var(--accent-2);
  font-weight: 600;
}

/* ============ UNREAD BADGE ============ */
.unread-badge {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-top: 4px;
}

/* ============ FILTER CHIPS ============ */
.filter-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink-mid);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.filter-chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ============ PLACEHOLDER CARD ============ */
/* Utilisee partout ou une liste est vide ("Aucun evenement", "Rien pour le
   moment"...). Une seule regle ici ameliore d'un coup l'allure des ~35
   endroits qui s'en servent, sans toucher a chacun individuellement. */
.placeholder-card {
  padding: 28px 22px;
  background: var(--bg);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-mid);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  animation: mbFadeIn 0.35s ease both;
}

@keyframes mbFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ CHARGEMENT (remplace le texte brut "Chargement...") ======= */
.mb-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 16px;
  color: var(--ink-mid);
  font-size: 13.5px;
  animation: mbFadeIn 0.25s ease both;
}
.mb-loader-spin {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
/* Variante compacte, pour remplacer un bouton "⏳ Chargement..." sans
   changer sa taille (le texte du bouton reste, seule l'icone change). */
.mb-loader-inline {
  display: inline-block;
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-right: 6px;
  border-radius: 50%;
  /* color-mix plutot qu'une couleur fixe : le contraste reste bon que le
     bouton soit clair (.app-btn.ghost) ou fonce (.app-btn plein). */
  border: 2px solid color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
  animation: spin 0.7s linear infinite;
}

/* ============ SEARCH OVERLAY ============ */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-elev);
  z-index: 300;
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  overflow-y: auto;
}

.search-overlay.active {
  transform: translateY(0);
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-elev);
}

.search-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--ink-mid);
}

#searchInput {
  flex: 1;
  border: none;
  background: none;
  font-size: 17px;
  color: var(--ink);
  outline: none;
  font-family: var(--font-sans);
}

.search-results {
  padding: 16px;
}

.search-hint {
  color: var(--ink-mid);
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  padding: 40px 20px;
}

.search-result-item {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 8px;
  cursor: pointer;
}

.search-result-item .sr-type {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mid);
  margin-bottom: 4px;
}

.search-result-item .sr-text {
  font-size: 14px;
  line-height: 1.4;
}

/* ============ NOTIFICATIONS STYLES ============ */
.notif-settings {
  padding: 4px 0;
}

.notif-settings h3 {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 20px;
}

.notif-settings h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mid);
  margin-top: 20px;
  margin-bottom: 10px;
}

.notif-toggle {
  background: var(--ink);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}

.notif-toggle label {
  display: flex;
  align-items: center;
  color: white;
  font-weight: 600;
  cursor: pointer;
  gap: 10px;
}

.notif-section {
  background: var(--bg);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border: 1.5px solid var(--line);
}

.notif-section label {
  display: block;
  margin: 8px 0;
  color: var(--ink);
  font-size: 14px;
}

.notif-section input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 8px;
  cursor: pointer;
  vertical-align: middle;
  accent-color: var(--accent);
}

.notif-section input[type="number"],
.notif-section input[type="time"] {
  background: var(--bg-elev);
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  margin-left: 8px;
  width: 100px;
  font-size: 14px;
  font-family: var(--font-mono);
}

.btn {
  background: var(--bg);
  border: 1.5px solid var(--line);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  margin: 8px 6px 0 0;
  transition: all 0.2s;
  font-weight: 600;
  font-family: var(--font-sans);
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* ============ ANIMATIONS ============ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tile {
  animation: fadeUp 0.4s ease backwards;
}

.tile:nth-child(1)  { animation-delay: 0.05s; }
.tile:nth-child(2)  { animation-delay: 0.08s; }
.tile:nth-child(3)  { animation-delay: 0.11s; }
.tile:nth-child(4)  { animation-delay: 0.14s; }
.tile:nth-child(5)  { animation-delay: 0.17s; }
.tile:nth-child(6)  { animation-delay: 0.20s; }
.tile:nth-child(7)  { animation-delay: 0.23s; }
.tile:nth-child(8)  { animation-delay: 0.26s; }
.tile:nth-child(9)  { animation-delay: 0.29s; }
.tile:nth-child(10) { animation-delay: 0.32s; }
.tile:nth-child(11) { animation-delay: 0.35s; }
.tile:nth-child(12) { animation-delay: 0.38s; }
.tile:nth-child(13) { animation-delay: 0.41s; }
.tile:nth-child(14) { animation-delay: 0.44s; }

/* ============ MINI PLAYER ============ */
#miniPlayer {
  border-radius: 16px 16px 0 0;
  box-shadow: var(--shadow-lg);
}


/* ============ NAV VERTICALE ============ */
/* Masquée par défaut (mobile-first) : les points de 8px sont une aide de
   navigation pensée pour la souris (survol pour voir le libellé) — sur un
   écran tactile étroit, la cible de toucher est trop petite et le nav
   flottant peut chevaucher le contenu. Réapparaît sur grand écran. */
#vertical-nav {
  display: none;
}
@media (min-width: 769px) {
  #vertical-nav {
    position: fixed;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    transition: opacity 0.2s;
  }
}

.vnav-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-low);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

.vnav-dot:hover {
  transform: scale(1.6);
  background: var(--ink);
}

.vnav-dot.active {
  background: var(--accent);
  transform: scale(1.4);
  box-shadow: 0 0 0 3px rgba(45,106,79,0.25);
}

.vnav-label {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.vnav-label::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--ink);
  border-right: none;
}

.vnav-dot:hover .vnav-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ============ LECTEUR YOUTUBE INTÉGRÉ ============ */
#yt-player-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #0f0f0f;
  color: white;
  z-index: 9000;
  display: none;
  flex-direction: column;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  transition: height 0.3s cubic-bezier(0.32,0.72,0,1);
}

#yt-player-bar.mini {
  height: 72px;
}

#yt-player-bar.expanded {
  height: 60vh;
}

#yt-player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #0f0f0f;
  flex-shrink: 0;
}

#yt-player-iframe {
  width: 100%;
  flex: 1;
  border: none;
  display: none;
}

#yt-player-bar.expanded #yt-player-iframe {
  display: block;
}

.yt-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.1);
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.yt-ctrl-btn:hover {
  background: rgba(255,255,255,0.2);
}

.yt-ctrl-btn.play {
  width: 44px;
  height: 44px;
  font-size: 20px;
  background: #ff0000;
}

.yt-ctrl-btn.play:hover {
  background: #cc0000;
}

#yt-track-info {
  flex: 1;
  min-width: 0;
}

#yt-track-title {
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#yt-track-artist {
  font-size: 11px;
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============ NOTIFICATION SETTINGS ============ */
.notif-settings {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.notif-settings h3 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 4px;
}

.notif-settings h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mid);
  margin-bottom: 6px;
}

.notif-toggle {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.notif-toggle label,
.notif-section label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  padding: 4px 0;
}

.notif-section {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notif-section input[type="number"],
.notif-section input[type="time"] {
  width: 80px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1.5px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 13px;
  font-family: var(--font-mono);
}

.notif-settings .btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.notif-settings .btn:active {
  transform: scale(0.95);
}

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

/* ============ RESPONSIVE ============ */
@media (min-width: 480px) {
  .desktop {
    grid-template-columns: repeat(3, 1fr);
    padding: 20px 16px;
    gap: 12px;
  }
  .tile-feature {
    grid-column: 1 / -1;
  }
}

@media (min-width: 769px) {
  .desktop {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    padding: 24px;
    /* Le cap à 768px cramponnait 4 colonnes dans un espace mobile : on laisse
       la grille respirer sur tablette/desktop tout en restant lisible. */
    max-width: 1100px;
  }
  .mobile-nav { display: none !important; }
  body { padding-bottom: 20px; }
}

/* Grands écrans : une colonne de plus pour exploiter la largeur */
@media (min-width: 1200px) {
  .desktop {
    grid-template-columns: repeat(5, 1fr);
    max-width: 1320px;
  }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--ink-low);
  border-radius: 2px;
}

/* ============ GLOBAL PROGRESS BAR ============ */
#global-progress {
  position: sticky;
  top: 0;
  z-index: 101;
  height: 3px;
  background: var(--line);
  overflow: hidden;
}
#global-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-3));
  transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 0 2px 2px 0;
}

/* ============ SKELETON SCREENS ============ */
.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, var(--bg-elev) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  width: 100%;
}
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

/* ============ PULL TO REFRESH ============ */
.pull-indicator {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  z-index: 99;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}
.pull-indicator.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
.pull-indicator.spinning svg {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============ NOTIFICATION BADGE ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============ ORIENTATION ============ */
/* Téléphone en paysage : la largeur seule (min-width) ne suffit pas à
   distinguer un petit paysage d'un vrai tablette portrait — on force ici
   plus de colonnes et moins de hauteur perdue quand l'écran est court. */
@media (orientation: landscape) and (max-width: 900px) {
  .desktop {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px 16px;
    max-width: 1100px;
  }
  .tile {
    padding: 12px 14px 10px;
  }
  body {
    padding-bottom: 8px;
  }
  .mobile-nav {
    padding-top: 4px;
    padding-bottom: 4px;
  }
}

/* Paysage large (tablette/desktop) : on laisse les règles min-width
   existantes (769px/1200px) piloter, l'orientation n'ajoute rien ici. */
