/* ================= FOYER — Y2K / retro theme ================= */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Nunito:wght@400;600;700;800&display=swap');

:root{
  --radius:14px; --radius-sm:8px;
  --gap:18px;
  --border:2.5px solid #1a1420;
  --shadow:5px 5px 0 #1a1420;
  --shadow-sm:3px 3px 0 #1a1420;
  --pixel:'VT323', monospace;
  --font:'Nunito', system-ui, -apple-system, sans-serif;
  /* default palette (terracotta/rose Y2K) so the login screen is styled before a theme is set */
  --accent:#ff5e7e; --accent-soft:#ffd0dc; --accent-bg:#ffe0e9; --bg:#ffe9f2; --card:#fffafc; --text:#1a1420; --muted:#9a7f8c; --line:#1a1420;
}

/* ---- Palettes (choisies dans Réglages) — Y2K flavored ---- */
[data-theme="terracotta"]{ --accent:#ff5e7e; --accent-soft:#ffd0dc; --accent-bg:#ffe0e9; --bg:#ffe9f2; --card:#fffafc; --text:#1a1420; --muted:#9a7f8c; --line:#1a1420; }
[data-theme="sauge"]{      --accent:#3fb98f; --accent-soft:#bdead9; --accent-bg:#d3f2e6; --bg:#e4f7ef; --card:#fbfffd; --text:#12241d; --muted:#6f8a80; --line:#12241d; }
[data-theme="ardoise"]{    --accent:#5b8dff; --accent-soft:#cadaff; --accent-bg:#dde8ff; --bg:#e6eeff; --card:#fbfdff; --text:#141a2a; --muted:#78839d; --line:#141a2a; }
[data-theme="prune"]{      --accent:#b45ee0; --accent-soft:#e6caf5; --accent-bg:#efdcfa; --bg:#f4e8fc; --card:#fefaff; --text:#221430; --muted:#8a78a0; --line:#221430; }
[data-theme="ocre"]{       --accent:#ffb32e; --accent-soft:#ffe6b0; --accent-bg:#fff0cf; --bg:#fff5e0; --card:#fffdf6; --text:#2a2010; --muted:#8a8168; --line:#2a2010; }

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:var(--font); background:var(--bg); color:var(--text);
  -webkit-tap-highlight-color:transparent; transition:background .3s,color .3s;
  background-image:radial-gradient(var(--accent-soft) 1.5px, transparent 1.5px);
  background-size:22px 22px;
}
.hidden{display:none !important}

/* ---- Top bar ---- */
.topbar{ display:flex; align-items:center; gap:14px; padding:14px 20px; position:sticky; top:0; z-index:20; flex-wrap:wrap;
  background:var(--card); border-bottom:var(--border); }
.brand{ display:flex; align-items:center; gap:10px; font-weight:800; font-size:22px; font-family:var(--pixel); letter-spacing:.5px; }
.brand .logo{ background:var(--accent); color:#fff; width:38px;height:38px;border-radius:9px; display:grid;place-items:center; font-size:19px; border:var(--border); box-shadow:var(--shadow-sm); }
.brand.big{ font-size:34px; justify-content:center; margin-bottom:8px; }
.brand.big .logo{ width:52px;height:52px; font-size:26px; }
.tabs{ display:flex; gap:6px; margin-left:8px; flex-wrap:wrap; }
.tab{ border:2px solid transparent; background:transparent; color:var(--muted); font-weight:700; font-size:14px; padding:7px 14px; border-radius:999px; cursor:pointer; }
.tab.active{ background:var(--accent); color:#fff; border:var(--border); box-shadow:var(--shadow-sm); }
.topbar-right{ margin-left:auto; display:flex; gap:8px; }

/* ---- Buttons ---- */
.btn{ border:var(--border); background:var(--card); color:var(--text); padding:9px 14px; border-radius:10px; cursor:pointer; font-size:14px; font-weight:700; box-shadow:var(--shadow-sm); transition:transform .05s, box-shadow .05s; }
.btn.ghost{ background:var(--card); }
.btn.primary{ background:var(--accent); color:#fff; }
.btn.mini{ padding:6px 11px; font-size:15px; line-height:1; box-shadow:2px 2px 0 var(--line); }
.btn:hover{ transform:translate(-1px,-1px); box-shadow:4px 4px 0 var(--line); }
.btn:active{ transform:translate(2px,2px); box-shadow:1px 1px 0 var(--line); }

/* ---- Grid & cards (as retro windows) ---- */
.view{ padding:18px 20px 44px; }
.grid{ display:grid; grid-template-columns:1fr 1fr; gap:var(--gap); max-width:900px; margin:0 auto; align-items:start; }
.grid > .card.span2{ grid-column:span 2; }
.card{ background:var(--card); border-radius:var(--radius); border:var(--border); box-shadow:var(--shadow);
  display:flex; flex-direction:column; gap:10px; min-height:0; overflow:hidden; padding:0; }
/* window title-bar with 3 dots, built from .card-head */
.card-head{ display:flex; align-items:center; gap:8px; padding:8px 12px; background:var(--accent-bg); border-bottom:var(--border); position:relative; }
.card-head::before{ content:""; width:10px;height:10px;border-radius:50%; background:#ff5f57; border:1.5px solid var(--line);
  box-shadow:16px 0 0 #febc2e, 16px 0 0 1.5px var(--line), 32px 0 0 #28c840, 32px 0 0 1.5px var(--line); flex:none; margin-right:34px; }
.card-head h3{ margin:0; font-size:15px; font-weight:800; font-family:var(--pixel); letter-spacing:.5px; }
.card-head .ic{ font-size:17px; }
.card-head .cal-nav{ margin-left:auto; display:flex; gap:6px; }
/* card body padding wrapper: apply to direct children except head */
.card > *:not(.card-head){ margin-left:16px; margin-right:16px; }
.card > *:not(.card-head):last-child{ margin-bottom:16px; }
.card > .card-head + *{ margin-top:14px; }
.card.span2{ grid-column:span 2; }
.card.accent{ background:var(--accent-bg); }
.card.accent .big-num{ color:var(--accent); }

.big-num{ font-size:38px; font-weight:800; line-height:1.1; font-family:var(--pixel); }
.muted{ color:var(--muted); font-size:14px; }
code{ background:var(--accent-bg); padding:2px 6px; border-radius:6px; font-size:13px; border:1.5px solid var(--line); }

/* ---- 16:9 fit: wider dashboard on large screens ---- */
@media (min-width:900px) and (min-aspect-ratio:5/4){
  #view-dashboard:not(.hidden){ padding:18px 24px; gap:20px; max-width:1150px; }
}

/* ---- Lists ---- */
.list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.list.compact li{ font-size:14px; }
.list li{ display:flex; align-items:center; gap:10px; padding:7px 8px; border-radius:9px; border:1.5px solid var(--line); background:var(--bg); min-width:0; }
.list li.muted{ border-style:dashed; background:transparent; }
.list li .chk{ width:22px;height:22px; border:var(--border); border-radius:6px; cursor:pointer; flex:none; display:grid;place-items:center; font-size:14px; color:#fff; background:var(--card); }
.list li.done .chk{ background:var(--accent); }
.list li.done .txt{ text-decoration:line-through; color:var(--muted); }
.list li .txt{ flex:1 1 0; min-width:0; overflow-wrap:anywhere; }
.list li .del{ opacity:.4; cursor:pointer; color:var(--text); border:none; background:none; font-size:16px; font-weight:800; }
.list li:hover .del{ opacity:1; }
.add-row{ display:flex; gap:8px; margin-top:8px; }
/* min-width:0 obligatoire : un input a une largeur intrinsèque (~170px) et,
   sans ça, un flex item refuse de descendre en dessous — il déborde de la
   carte dès que la colonne est étroite. */
.add-row input{ flex:1 1 0; min-width:0; }
input,select,textarea{ font-family:inherit; font-size:14px; padding:9px 11px; border:var(--border); border-radius:9px; background:var(--card); color:var(--text); max-width:100%; }
input:focus,select:focus{ outline:none; box-shadow:var(--shadow-sm); }

/* ---- Tools ---- */
.tools{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.tools li{ display:flex; align-items:center; }
.tools li a{ display:flex; align-items:center; gap:10px; color:var(--accent); text-decoration:none; font-weight:700; }
.link-add{ border:none; background:none; color:var(--muted); cursor:pointer; text-align:left; font-weight:700; font-size:14px; padding:2px; }

/* ---- Calendar ---- */
.cal-layout{ display:grid; grid-template-columns:1.4fr 1fr; gap:var(--gap); max-width:1150px; margin:0 auto; align-items:start; }
.calendar-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:5px; }
.calendar-grid .dow{ text-align:center; font-size:12px; color:var(--muted); font-weight:800; padding:4px 0; }
.calendar-grid .day{ aspect-ratio:1; border-radius:8px; padding:6px; font-size:13px; background:var(--bg); cursor:pointer; position:relative; border:1.5px solid var(--line); font-weight:700; }
.calendar-grid .day.other{ opacity:.3; border-style:dashed; }
.calendar-grid .day.today{ background:var(--accent); color:#fff; }
.calendar-grid .day .dot{ width:6px;height:6px;border-radius:50%; background:var(--accent); border:1px solid var(--line); position:absolute; bottom:5px; left:50%; transform:translateX(-50%); }
.calendar-grid .day.today .dot{ background:#fff; }
.event-form{ display:flex; flex-direction:column; gap:8px; margin-top:12px; }

/* ---- Chips (preset chores) ---- */
.chip-row{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:6px; }
.chip{ border:2px solid var(--line); background:var(--card); color:var(--text); border-radius:999px; padding:6px 12px; font-size:13px; font-weight:700; cursor:pointer; box-shadow:2px 2px 0 var(--line); }
.chip:hover{ background:var(--accent); color:#fff; }

/* ---- HA cards ---- */
.ha-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:10px; }
.ha-tile{ background:var(--bg); border-radius:10px; padding:12px 8px; text-align:center; border:1.5px solid var(--line); }
.ha-tile .ha-ic{ font-size:20px; }
/* la police pixel ne descend pas bien : on borne la casse longue ("Peu nuageux") */
.ha-tile .ha-val{ font-size:20px; font-weight:800; margin:4px 0; font-family:var(--pixel);
  line-height:1.1; overflow-wrap:anywhere; hyphens:auto; }
.ha-tile .ha-lbl{ font-size:12px; color:var(--muted); overflow-wrap:anywhere; }
/* entité injoignable ou éteinte : présente mais en retrait */
.ha-tile.dim{ opacity:.5; border-style:dashed; }

/* ---- Chores ---- */
.chore-meta{ font-size:12px; color:var(--muted); }
.chore-badge{ display:inline-block; background:var(--card); color:var(--text); border:1.5px solid var(--line); border-radius:8px; padding:2px 8px; font-size:12px; font-weight:700; }
.chore-badge.late{ background:#ff5e7e; color:#fff; }
.list li .done-btn{ border:var(--border); background:var(--accent); color:#fff; border-radius:8px; padding:5px 11px; cursor:pointer; font-size:13px; font-weight:800; box-shadow:2px 2px 0 var(--line); }

/* ---- Meals ---- */
.meals-grid{ display:grid; grid-template-columns:repeat(7,1fr); gap:8px; }
.meal-day{ background:var(--bg); border-radius:10px; padding:8px; min-height:120px; display:flex; flex-direction:column; gap:6px; border:1.5px solid var(--line); }
.meal-day .md-head{ font-size:12px; font-weight:800; color:var(--muted); text-align:center; }
.meal-day .md-head.today{ color:var(--accent); }
.meal-slot{ font-size:12px; }
.meal-slot .ms-label{ font-weight:700; }
.meal-slot input{ width:100%; padding:5px 7px; font-size:12px; }
.meals-actions{ margin-top:14px; }

/* ---- Cats simplified ---- */
#cats-grid{ display:grid; grid-template-columns:1fr 1fr; gap:var(--gap); max-width:1150px; margin:0 auto; align-items:stretch; }
.litter-full{ grid-column:1 / -1; }
.litter-body{ display:flex; align-items:center; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.cat-toggles{ display:flex; gap:10px; }
.cat-toggle{ flex:1; border:var(--border); background:var(--bg); color:var(--text); border-radius:10px; padding:12px 8px; font-size:14px; font-weight:800; cursor:pointer; box-shadow:var(--shadow-sm); }
.cat-toggle:hover{ transform:translate(-1px,-1px); }
.cat-toggle.on{ background:var(--accent); color:#fff; }
.vet-block{ display:flex; flex-direction:column; gap:8px; margin-top:auto; padding-top:10px; border-top:1.5px dashed var(--line); }
.vet-info{ background:var(--bg); border:1.5px solid var(--line); border-radius:9px; padding:8px 10px; font-size:14px; }
.vet-form{ display:flex; flex-direction:column; gap:8px; }
.vet-form input{ width:100%; }
.vet-form-row{ display:flex; gap:8px; }
.vet-form-row .btn{ flex:none; }

/* ---- Settings ---- */
.field{ display:flex; flex-direction:column; gap:6px; font-size:14px; font-weight:700; color:var(--muted); margin-bottom:12px; }
.field input{ font-weight:600; color:var(--text); }
.palettes{ display:flex; gap:10px; flex-wrap:wrap; }
.pal{ width:44px;height:44px; border-radius:10px; cursor:pointer; border:var(--border); box-shadow:var(--shadow-sm); }
.pal.sel{ outline:3px solid var(--text); outline-offset:2px; }
.token-out{ background:var(--bg); padding:12px; border:1.5px dashed var(--line); border-radius:10px; font-family:monospace; word-break:break-all; margin:10px 0; }
.chk-row{ display:flex; align-items:center; gap:8px; font-size:14px; color:var(--muted); font-weight:700; }
.chk-row input{ width:auto; }
.push-actions{ display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
#push-targets input[type=checkbox]{ width:auto; flex:none; }

/* ---- Auth overlay (retro login window) ---- */
.overlay{ position:fixed; inset:0; background:rgba(26,20,32,.35); display:grid; place-items:center; z-index:50; padding:20px;
  background-image:radial-gradient(var(--accent-soft) 1.5px, transparent 1.5px); background-size:22px 22px; }
.auth-card{ background:var(--card); border-radius:var(--radius); border:var(--border); padding:28px; width:100%; max-width:380px; box-shadow:var(--shadow); }
.auth-card h2{ margin:6px 0; font-family:var(--pixel); font-size:26px; }
.auth-card form{ display:flex; flex-direction:column; gap:12px; margin-top:14px; }
.error{ color:#ff3860; font-size:13px; min-height:16px; font-weight:700; }

/* ---- Tabs: icon + label (icône seule sur téléphone) ---- */
.tab{ display:inline-flex; align-items:center; gap:6px; }
.tab-ic{ font-size:15px; line-height:1; }

/* ================= Responsive: téléphone =================
   Le desktop garde la grille 2 colonnes ; sous 720px on passe en pile
   verticale et la navigation descend en barre d'onglets fixe en bas,
   à portée de pouce. `safe-area-inset` évite l'encoche / la barre
   d'accueil iOS. */
@media (max-width:720px){
  :root{ --gap:12px; --shadow:4px 4px 0 #1a1420; }

  /* une seule colonne : .span2 ne doit plus réclamer 2 pistes */
  .grid,
  #cats-grid{ grid-template-columns:1fr; max-width:100%; }
  .grid > .card.span2,
  .card.span2,
  .litter-full{ grid-column:1 / -1; }

  .cal-layout{ grid-template-columns:1fr; max-width:100%; }
  .meals-grid{ grid-template-columns:1fr; }

  .view{ padding:14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .big-num{ font-size:30px; }
  .card > *:not(.card-head){ margin-left:12px; margin-right:12px; }
  .card > *:not(.card-head):last-child{ margin-bottom:12px; }

  /* --- Topbar compacte --- */
  .topbar{ padding:10px 12px; padding-top:calc(10px + env(safe-area-inset-top)); gap:8px; flex-wrap:nowrap; }
  .brand{ font-size:19px; gap:8px; min-width:0; }
  .brand span:not(.logo){ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .brand .logo{ width:32px; height:32px; font-size:16px; }

  /* --- Onglets en barre fixe en bas --- */
  .tabs{
    position:fixed; left:0; right:0; bottom:0; z-index:30;
    margin:0; gap:0; flex-wrap:nowrap; justify-content:space-around;
    background:var(--card); border-top:var(--border);
    padding:6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab{
    flex:1 1 0; min-width:0; flex-direction:column; gap:2px;
    padding:6px 2px; border-radius:10px; font-size:10px; box-shadow:none;
  }
  .tab.active{ box-shadow:none; border:2px solid var(--line); }
  .tab-ic{ font-size:19px; }
  .tab-lbl{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:100%; }

  /* --- Confort tactile --- */
  /* 16px minimum : en dessous, iOS zoome tout seul au focus */
  input,select,textarea{ font-size:16px; padding:11px 12px; }
  .btn{ padding:11px 15px; min-height:44px; }
  .btn.mini{ min-height:38px; padding:8px 12px; }
  .list li{ padding:10px 9px; }
  .list li .chk{ width:26px; height:26px; }
  .list li .del{ opacity:1; padding:4px 8px; font-size:18px; }
  .btn:hover{ transform:none; box-shadow:var(--shadow-sm); }

  /* --- Calendrier : cases lisibles au pouce --- */
  .calendar-grid{ gap:3px; }
  .calendar-grid .day{ padding:3px; font-size:12px; border-radius:6px; }
  .calendar-grid .dow{ font-size:10px; }

  /* --- Repas : une journée par ligne --- */
  .meal-day{ min-height:0; }
  .meals-grid{ gap:10px; }

  .ha-grid{ grid-template-columns:repeat(auto-fill,minmax(96px,1fr)); }
  .palettes{ gap:12px; }
  .pal{ width:48px; height:48px; }
  .cat-toggle{ padding:14px 8px; }
  .vet-form-row{ flex-wrap:wrap; }
}

/* Très petits écrans (iPhone SE) */
@media (max-width:380px){
  .tab-lbl{ display:none; }
  .tab{ padding:9px 2px; }
  .brand{ font-size:17px; }
}

/* Paysage bas de plafond : la barre d'onglets mangerait trop de hauteur */
@media (max-height:450px) and (orientation:landscape){
  .tabs{ position:static; border-top:none; padding:0; }
  .tab{ flex-direction:row; font-size:12px; }
  .view{ padding-bottom:24px; }
}

/* ================= Notifications ================= */
.btn.bell{ position:relative; font-size:16px; padding:9px 12px; }
.badge{
  position:absolute; top:-7px; right:-7px; min-width:20px; height:20px; padding:0 5px;
  background:#ff3860; color:#fff; border:2px solid var(--line); border-radius:999px;
  font-size:11px; font-weight:800; display:grid; place-items:center; line-height:1;
}

.notif-panel{
  position:fixed; z-index:40; top:70px; right:16px; width:min(380px, calc(100vw - 32px));
  max-height:min(70vh, 520px); display:flex; flex-direction:column;
  background:var(--card); border:var(--border); border-radius:var(--radius); box-shadow:var(--shadow);
}
.notif-head{
  display:flex; align-items:center; gap:8px; padding:10px 12px;
  background:var(--accent-bg); border-bottom:var(--border); border-radius:12px 12px 0 0;
}
.notif-head h3{ margin:0; flex:1; font-family:var(--pixel); font-size:17px; letter-spacing:.5px; }
.notif-list{ list-style:none; margin:0; padding:10px; overflow-y:auto; display:flex; flex-direction:column; gap:8px; }
.notif-item{
  display:flex; gap:10px; align-items:flex-start; padding:9px 10px; cursor:pointer;
  background:var(--bg); border:1.5px solid var(--line); border-radius:10px;
  /* le liseré gauche porte la gravité, lisible d'un coup d'œil */
  border-left-width:5px;
}
.notif-item.sev-urgent{ border-left-color:#ff3860; }
.notif-item.sev-warn{   border-left-color:#ffb32e; }
.notif-item.sev-info{   border-left-color:var(--accent); }
.notif-item.read{ opacity:.5; background:transparent; border-style:dashed; }
.notif-ic{ font-size:19px; line-height:1.2; flex:none; }
.notif-txt{ flex:1; min-width:0; }
.notif-title{ font-weight:800; font-size:14px; }
.notif-body{ font-size:13px; color:var(--muted); }
.notif-empty{ text-align:center; color:var(--muted); padding:22px 10px; font-weight:700; }

@media (max-width:720px){
  /* en plein écran sous la topbar : le panneau flottant est trop étroit au pouce */
  .notif-panel{
    top:auto; right:0; left:0; bottom:0; width:100%;
    max-height:75vh; border-radius:var(--radius) var(--radius) 0 0;
    padding-bottom:env(safe-area-inset-bottom);
  }
  .notif-head{ border-radius:12px 12px 0 0; }
}

/* ---- Astral / Ciel card ---- */
.astral-moon{ display:flex; align-items:center; gap:12px; margin-bottom:8px; }
.astral-moon-emoji{ font-size:38px; line-height:1; }
.astral-moon-phase{ font-weight:800; font-size:17px; }
.astral-suns{ font-size:13px; margin-bottom:10px; }
.astral-planets-title{ font-size:12px; text-transform:uppercase; letter-spacing:.5px; margin-bottom:4px; }
.astral-planet{ display:flex; align-items:center; gap:8px; font-size:14px; padding:3px 0; flex-wrap:wrap; }
.astral-planet-sym{ width:22px; height:22px; display:grid; place-items:center; background:var(--accent-bg); border:2px solid var(--line); border-radius:6px; font-size:14px; flex:none; }
.astral-planet-name{ font-weight:700; min-width:64px; }
