@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #06080c;
  --bg-2: #0a0f17;
  --surface: rgba(15, 23, 36, .62);
  --surface-2: rgba(22, 32, 48, .72);
  --border: #1b2432;
  --border-2: #26334a;
  --text: #f8fafc;
  --muted: #8a97ab;
  --accent: #008cff;
  --accent-2: #38b0ff;
  --accent-tint: rgba(0, 140, 255, .1);
  --accent-tint-2: rgba(0, 140, 255, .18);
  --warn: #ffb020;
  --danger: #ff4d5e;
  --ok: #22d39a;
  --radius: 10px;
  --font: "Space Grotesk", Inter, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); letter-spacing: -.01em; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(0, 140, 255, .14), transparent 60%),
    radial-gradient(700px 400px at -10% 30%, rgba(0, 90, 200, .08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- En-tête ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 18px 12px;
  background: rgba(6, 8, 12, .78); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.logo { font-weight: 700; font-size: 19px; letter-spacing: .14em; text-transform: uppercase; }
.logo b { color: var(--accent); font-weight: 700; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius);
  background: var(--accent-tint); color: var(--accent); border: 0; cursor: pointer; font-size: 17px;
}
.icon-btn:active { transform: scale(.96); }
.icon-btn.spin span { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(96px + var(--safe-b)); }

/* ---------- Titres ---------- */
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); margin: 0 0 6px; }
h1.page { font-size: 28px; font-weight: 700; letter-spacing: -.035em; margin: 0 0 4px; }
h2.section { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; margin: 26px 0 10px; }
h2.section .count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--muted); }
h2.section a.more { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--accent); }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.card.pad { padding: 16px; }
.hero { padding: 18px; margin-top: 14px; background: linear-gradient(135deg, rgba(0, 140, 255, .16), rgba(15, 23, 36, .6) 60%); border-color: var(--border-2); }
.hero .title { font-weight: 700; font-size: 17px; margin: 0 0 6px; }
.hero .body { color: #c9d4e3; font-size: 14px; line-height: 1.45; white-space: pre-line; margin: 0; }
.hero .meta { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.list { display: flex; flex-direction: column; gap: 8px; }
.art { padding: 13px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.art.read { opacity: .58; }
.art .src { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.art .t { font-weight: 600; font-size: 15px; line-height: 1.32; grid-column: 1; }
.art .t a:active { color: var(--accent-2); }
.art .sum { grid-column: 1 / -1; font-size: 13.5px; line-height: 1.5; color: #b8c4d6; margin: 6px 0 0; }
.art .actions { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; gap: 6px; }
.art .actions button { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.art .actions button.on { color: var(--warn); border-color: rgba(255, 176, 32, .35); background: rgba(255, 176, 32, .08); }
.art.p1 { border-color: rgba(0, 140, 255, .45); }
.art.p2 { border-color: rgba(255, 77, 94, .55); background: linear-gradient(135deg, rgba(255, 77, 94, .1), var(--surface) 55%); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-tint); color: var(--accent-2); }
.badge.red { background: rgba(255, 77, 94, .14); color: #ff8592; }
.badge.ok { background: rgba(34, 211, 154, .12); color: var(--ok); }
.badge.warn { background: rgba(255, 176, 32, .12); color: var(--warn); }

/* ---------- Puces catégories ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent-tint-2); border-color: rgba(0, 140, 255, .5); color: #d8ecff; }
.chip .n { font-size: 11px; color: var(--muted); }

/* ---------- Boutons & formulaires ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--border-2); background: var(--surface-2); font-weight: 500; font-size: 14px; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 24px rgba(0, 140, 255, .28); }
.btn.ghost { background: var(--accent-tint); border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--danger); background: rgba(255, 77, 94, .08); border-color: rgba(255, 77, 94, .25); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=url], input[type=time], input[type=number], input[type=search], select {
  width: 100%; min-height: 44px; padding: 0 12px; border-radius: var(--radius); border: 1px solid var(--border-2);
  background: rgba(6, 8, 12, .6); color: var(--text); font-size: 15px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint-2); }
input[type=time] { color-scheme: dark; width: auto; }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #1d2636; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #cbd5e1; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border-top: 1px solid var(--border); }
.setting:first-child { border-top: 0; }
.setting .lbl { font-size: 14px; font-weight: 500; }
.setting .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }

.feed-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--border); }
.feed-row:first-child { border-top: 0; }
.feed-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.feed-row .dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(34, 211, 154, .6); }
.feed-row .dot.err { background: var(--danger); box-shadow: 0 0 8px rgba(255, 77, 94, .6); }
.feed-row .name { flex: 1; min-width: 0; font-size: 14px; }
.feed-row .name small { display: block; color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ---------- Barre d'onglets ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(6, 8, 12, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: var(--radius); font-size: 11px; font-weight: 500; color: var(--muted); }
.tabbar a .i { font-size: 19px; line-height: 1; filter: grayscale(1); opacity: .8; }
.tabbar a.on { color: var(--accent); background: var(--accent-tint); }
.tabbar a.on .i { filter: none; opacity: 1; }

/* ---------- Toast & feuille ---------- */
.toast { position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0; transition: .25s; z-index: 50;
  background: #0f1a2b; border: 1px solid var(--border-2); padding: 10px 16px; border-radius: var(--radius); font-size: 14px; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: #0b111b; border: 1px solid var(--border-2); border-bottom: 0; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); max-height: 88dvh; overflow: auto; }
.sheet h3 { margin: 0 0 14px; font-size: 18px; }

/* ---------- Connexion / installation ---------- */
.login-wrap, body.install { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.install-card, .login-card { width: 100%; max-width: 400px; padding: 26px 22px; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { font-size: 24px; }
.brand p { margin: 8px 0 0; }
p.err { color: #ff8592; } p.ok { color: var(--ok); }
pre.code { white-space: pre-wrap; word-break: break-all; background: #05070a; border: 1px solid var(--border); padding: 12px; border-radius: var(--radius); font-size: 12px; }

.loader { height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: load 1.1s linear infinite; position: fixed; top: 0; left: 0; right: 0; z-index: 99; }
@keyframes load { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (min-width: 900px) {
  .tabbar { top: 0; bottom: auto; left: auto; right: 24px; width: 420px; background: transparent; border: 0; backdrop-filter: none; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .tabbar a { flex-direction: row; justify-content: center; font-size: 13px; gap: 6px; }
  .topbar { padding-right: 470px; }
  main { padding-bottom: 40px; }
  .toast { bottom: 30px; }
}