/* ---------- Thème (clair par défaut, sombre auto ou forcé via data-theme) ---------- */
:root {
  --bg: #f3f4f8;
  --card: #ffffff; --card2: #f6f7fb; --line: #e4e7ef; --line2: #d5d9e5;
  --text: #121521; --muted: #6a7184;
  --accent: #5b6cff; --accent2: #9b6bff; --accent-soft: rgba(91, 108, 255, .12); --on-accent: #fff;
  --ok: #17a362; --warn: #d98a1f; --bad: #e0494f;
  --ok-soft: rgba(23, 163, 98, .12); --bad-soft: rgba(224, 73, 79, .12); --warn-soft: rgba(217, 138, 31, .14);
  --shadow: 0 1px 2px rgba(18, 21, 33, .04), 0 8px 24px rgba(18, 21, 33, .05);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d14; --card: #141824; --card2: #1a1f2e; --line: #232a3b; --line2: #303852;
    --text: #e9ecf6; --muted: #8b94ab; --accent: #7c8aff; --accent-soft: rgba(124, 138, 255, .16);
    --ok: #3ddc97; --warn: #f0b04a; --bad: #ff6b72;
    --ok-soft: rgba(61, 220, 151, .13); --bad-soft: rgba(255, 107, 114, .14); --warn-soft: rgba(240, 176, 74, .14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d14; --card: #141824; --card2: #1a1f2e; --line: #232a3b; --line2: #303852;
  --text: #e9ecf6; --muted: #8b94ab; --accent: #7c8aff; --accent-soft: rgba(124, 138, 255, .16);
  --ok: #3ddc97; --warn: #f0b04a; --bad: #ff6b72;
  --ok-soft: rgba(61, 220, 151, .13); --bad-soft: rgba(255, 107, 114, .14); --warn-soft: rgba(240, 176, 74, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  background: radial-gradient(1100px 500px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg);
  font: 14.5px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; margin-bottom: 14px; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }
.end { justify-content: flex-end; }
.spacer { flex: 1; }
.err { color: var(--bad); min-height: 1.3em; margin: 0 0 8px; font-size: .85rem; }
svg { width: 1em; height: 1em; display: block; }
[hidden] { display: none !important; }

/* ---------- Contrôles ---------- */
input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line2); border-radius: 10px;
  background: var(--card2); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid transparent;
  border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 550; cursor: pointer;
  transition: filter .15s, background .15s;
}
.btn svg { font-size: 16px; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line2); }
.btn.ghost:hover { background: var(--card2); filter: none; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; font-size: 18px;
  border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--line2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: .82rem; font-weight: 550; color: var(--muted); margin-bottom: 12px; }
label input, label select { margin-top: 5px; color: var(--text); font-weight: 400; }

/* ---------- Structure ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; max-width: 1360px; margin: 0 auto; padding: 18px 28px 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-size: 17px; }
.shell { max-width: 1360px; margin: 0 auto; padding: 0 28px 48px; }
.layout {
  display: grid; gap: 20px; align-items: start;
  grid-template-columns: minmax(0, 1fr) 410px;
  grid-template-areas: "today status" "quick status" "favs status" "repos status" "notes status";
}
.area-today { grid-area: today; } .area-quick { grid-area: quick; } .area-status { grid-area: status; } .area-favs { grid-area: favs; } .area-repos { grid-area: repos; } .area-notes { grid-area: notes; }
.area-status { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; scrollbar-width: thin; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }

/* ---------- Bloc 1 : aujourd'hui ---------- */
.hero { background: linear-gradient(160deg, var(--accent-soft), transparent 55%), var(--card); }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-weight: 550; margin-bottom: 2px; }
.clock { font-size: clamp(3.2rem, 7vw, 5rem); font-weight: 300; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.clock .secs { font-size: .4em; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.date { margin-top: 8px; color: var(--muted); font-size: 1.05rem; }
.wnow { display: flex; align-items: center; gap: 16px; padding: 14px 20px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.wicon { font-size: 52px; display: grid; }
.wtemp { font-size: 2.3rem; font-weight: 600; letter-spacing: -.03em; line-height: 1.05; }
.wmeta { font-size: .85rem; color: var(--muted); }
.tone-sun { color: #f2a93b; } .tone-cloud { color: #8d9ab8; } .tone-rain { color: #4a8df0; } .tone-snow { color: #7cc3ee; } .tone-storm { color: #a46bf0; }
.whours { display: flex; gap: 8px; overflow-x: auto; margin: 20px 0 6px; padding-bottom: 8px; scrollbar-width: thin; }
.wh { flex: none; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; padding: 10px 6px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: .85rem; }
.wh:first-child { border-color: var(--accent); background: var(--accent-soft); }
.wh .wi { font-size: 22px; } .wh b { font-size: 1rem; font-weight: 600; }
.wh .rain { font-size: .72rem; color: var(--muted); min-height: 1em; }
.hero-foot { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.journal { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 240px; }
.play { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--accent-soft); color: var(--accent); font-size: 16px; }
.play:disabled { opacity: .55; cursor: not-allowed; }
.jtxt { display: flex; flex-direction: column; line-height: 1.3; }
.journal audio { flex: 1; min-width: 0; height: 36px; }
.cityform { position: relative; width: 210px; }
.cityform #pin { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.cityform input { padding-left: 34px; }

/* ---------- Bloc 2 : statuts ---------- */
.status-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--card2); color: var(--muted); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); } .pill.bad { color: var(--bad); background: var(--bad-soft); }
.sys { display: grid; gap: 10px; margin-bottom: 8px; padding: 14px; border-radius: 14px; background: var(--card2); }
.meter { display: grid; grid-template-columns: 50px 1fr auto; align-items: center; gap: 10px; font-size: .8rem; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.fill { height: 100%; border-radius: 99px; background: var(--ok); transition: width .4s; }
.fill.mid { background: var(--warn); } .fill.hot { background: var(--bad); }
.sysline { font-size: .76rem; color: var(--muted); }
.sec { border-top: 1px solid var(--line); padding: 12px 0 4px; margin-top: 10px; }
.sec > summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; list-style: none; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::after { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin: 0 4px 3px 10px; transition: transform .2s; }
.sec[open] > summary::after { transform: rotate(-135deg); margin-bottom: -2px; }
.sec > summary span:first-child { flex: 1; }
.count { font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--card2); border-radius: 99px; padding: 1px 9px; }
.count.bad { color: var(--bad); background: var(--bad-soft); }
.list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; }
.list li, .peer { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 9px; font-size: .86rem; }
.list li:hover, .peer:hover { background: var(--card2); }
.list .r { margin-left: auto; font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.up .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.slow .dot, .stale .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.glabel { margin: 8px 8px 2px; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.peer { align-items: flex-start; } .peer .dot { margin-top: 6px; }
.peer.down { opacity: .55; }
.pinfo { display: flex; flex-direction: column; min-width: 0; }
.pinfo small { color: var(--muted); font-size: .74rem; }
.pstat { margin-left: auto; text-align: right; display: flex; flex-direction: column; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.wghead { margin: 0 8px 4px; font-size: .78rem; color: var(--muted); }
.updated { font-size: .72rem; margin-top: 10px; text-align: right; }

/* ---------- Bloc 3 : favoris ---------- */
#favs, #repos, #notes { margin-top: 16px; display: grid; gap: 22px; }
.links { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.group-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--muted); font-size: .78rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; cursor: pointer; list-style: none; }
.group-h::-webkit-details-marker { display: none; }
.group-h svg { font-size: 15px; }
.group-h .count { text-transform: none; letter-spacing: 0; }
.group-h .chev { margin-left: 2px; transition: transform .2s; }
details.folder:not([open]) .chev { transform: rotate(-90deg); }
.group-h .tools { margin-left: auto; }
details.folder .nested { display: grid; gap: 14px; }
details.folder details.folder { margin-left: 4px; padding-left: 14px; border-left: 2px solid var(--line); }
.link { position: relative; display: flex; align-items: center; border: 1px solid var(--line); border-radius: 14px; background: var(--card2); transition: transform .15s, border-color .15s, box-shadow .15s; }
.link:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.link a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px; color: inherit; text-decoration: none; }
.tile { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 11px; font-weight: 700; font-size: 1.05rem; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.tile.has-icon { background: #fff; border: 1px solid var(--line); }
.tile img { width: 24px; height: 24px; object-fit: contain; }
.ltxt { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.ltxt b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltxt small { color: var(--muted); font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools { display: inline-flex; gap: 2px; padding-right: 8px; }
.mini { display: grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 15px; cursor: pointer; }
.mini:hover { background: var(--line); color: var(--text); }
.mini.danger:hover { background: var(--bad-soft); color: var(--bad); }
.empty { text-align: center; padding: 28px 0; color: var(--muted); }

/* ---------- Dialogue ---------- */
dialog { border: 1px solid var(--line2); border-radius: 18px; background: var(--card); color: var(--text); width: min(440px, 92vw); padding: 24px; box-shadow: 0 24px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(5, 7, 12, .55); backdrop-filter: blur(3px); }

/* ---------- Connexion ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card .logo { width: 44px; height: 44px; font-size: 24px; margin-bottom: 18px; border-radius: 13px; }
.login-card h1 { font-size: 1.4rem; font-weight: 650; margin-bottom: 4px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1060px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "today" "quick" "status" "favs" "repos" "notes"; }
  .area-status { position: static; max-height: none; }
}
@media (max-width: 600px) {
  .topbar { padding: 14px 16px 10px; } .shell { padding: 0 16px 32px; } .card { padding: 18px; }
  .wnow { width: 100%; } .cityform { width: 100%; } .links { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Accès rapide ---------- */
.quick { margin-top: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.qtile { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card2); color: inherit; text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.qtile:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.qicon { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; font-size: 22px; color: var(--accent); background: var(--accent-soft); }
.qicon.c-tasks { color: #4a8df0; background: rgba(74, 141, 240, .14); }
.qicon.c-db { color: #a46bf0; background: rgba(164, 107, 240, .14); }
.qicon.c-shield { color: var(--ok); background: var(--ok-soft); }
.qicon.c-activity { color: var(--warn); background: var(--warn-soft); }
.qtxt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.qtxt b { font-weight: 600; }
.qtxt small { color: var(--muted); font-size: .78rem; }
.qicon.c-server { color: #e5731f; background: rgba(229, 115, 31, .14); }

/* ---------- Notes ---------- */
.nlist { display: grid; gap: 6px; }
.note { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--card2); transition: border-color .15s, transform .15s; }
.note:hover { border-color: var(--accent); transform: translateY(-1px); }
.note-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 10px 14px; border: 0; background: none; color: inherit; text-align: left; cursor: pointer; }
.ntitle { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.npreview { color: var(--muted); font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ndate { flex: none; color: var(--muted); font-size: .75rem; padding-right: 10px; }
dialog.wide-dlg { width: min(780px, 94vw); }
.n-head { margin-bottom: 12px; } .n-head input { font-weight: 600; font-size: 1.05rem; } .n-head select { width: 190px; flex: none; }
#n-content { display: block; width: 100%; min-height: min(52vh, 480px); resize: vertical; padding: 14px; border: 1px solid var(--line2); border-radius: 12px; background: var(--card2); color: var(--text); font: inherit; line-height: 1.65; outline: none; }
#n-content:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.n-foot { margin-top: 12px; } #n-status { font-size: .8rem; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); } .btn.danger:hover { background: var(--bad-soft); }
@media (max-width: 600px) { .n-head { flex-direction: column; align-items: stretch; } .n-head select { width: 100%; } }
