:root {
  --bg: #0a1020;
  --bg-2: #0f1830;
  --card: #14203d;
  --card-2: #1a2a4d;
  --line: rgba(190, 205, 255, 0.13);
  --line-2: rgba(190, 205, 255, 0.24);
  --text: #ebe7dc;
  --muted: #98a3c0;
  --faint: #66728f;
  --gold: #f3dfa6;
  --gold-ink: #2b2309;
  --teal: #62d4c4;
  --rose: #f07a9b;
  --blue: #8db6ff;
  --violet: #bfa4ff;
  --ok: #7fd9a0;
  --warn: #f0b36b;
  --z-zenith: #f3dfa6;
  --z-south: #8db6ff;
  --z-west: #bfa4ff;
  --z-east: #62d4c4;
  --z-north: #f07a9b;
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

/* Mode rouge : préserve la vision nocturne au télescope */
html.red {
  --bg: #100303; --bg-2: #180606; --card: #210a0a; --card-2: #2c0f0f;
  --line: rgba(255, 120, 100, 0.16); --line-2: rgba(255, 120, 100, 0.3);
  --text: #ff9d8c; --muted: #c46a5d; --faint: #8a4a42;
  --gold: #ff8a70; --gold-ink: #1a0504; --teal: #ff7a64; --rose: #ff6a5a; --blue: #ff8a78; --violet: #ff7f6e;
  --ok: #ff8a70; --warn: #ff9a6a;
  --z-zenith: #ff9a80; --z-south: #ff7a64; --z-west: #ff6a58; --z-east: #ff8a70; --z-north: #ff6a5a;
}
html.red .pic img, html.red .pic canvas, html.red .dome-bg {
  filter: grayscale(1) sepia(1) saturate(5) hue-rotate(-38deg) brightness(0.6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 15px; line-height: 1.5;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; min-height: 100vh;
  background-image: radial-gradient(1200px 600px at 80% -10%, rgba(80, 110, 200, 0.14), transparent 60%),
                    radial-gradient(900px 500px at -10% 30%, rgba(98, 212, 196, 0.06), transparent 60%);
  background-attachment: fixed;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 6px; }

/* ---------- Navigation ---------- */
#nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b); display: flex; background: rgba(10, 16, 32, 0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
html.red #nav { background: rgba(16, 3, 3, 0.94); }
#nav .brand { display: none; }
#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11.5px; position: relative;
}
#nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#nav a.on { color: var(--gold); }
#nav .tools { display: none; }
main { padding: calc(14px + var(--safe-t)) 16px calc(var(--nav-h) + var(--safe-b) + 28px); max-width: 1180px; margin: 0 auto; }

@media (min-width: 980px) {
  #nav {
    top: 0; bottom: auto; right: auto; width: 230px; height: 100vh; flex-direction: column; padding: 26px 14px;
    border-top: 0; border-right: 1px solid var(--line); gap: 4px;
  }
  #nav .brand { display: block; font-family: var(--serif); font-size: 26px; padding: 0 12px 20px; color: var(--text); }
  #nav .brand small { display: block; font-family: var(--sans); font-size: 12px; color: var(--muted); margin-top: 2px; }
  #nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 12px; border-radius: 10px; font-size: 15px; }
  #nav a.on { background: var(--card); }
  #nav a:hover { background: rgba(255, 255, 255, 0.04); }
  #nav .tools { display: block; margin-top: auto; padding: 0 4px; }
  main { margin-left: 230px; max-width: none; padding: 28px 40px 60px; }
  main > * { max-width: 1120px; }
}

/* ---------- Éléments communs ---------- */
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.sp { height: 18px; }
.title { font-size: 1.55rem; }
.sub { color: var(--muted); font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.04); border-radius: 999px; padding: 10px 18px; cursor: pointer; font-weight: 600;
  font-size: 14.5px; transition: background 0.15s, border-color 0.15s; color: var(--text);
}
.btn:hover { background: rgba(255, 255, 255, 0.09); border-color: var(--gold); }
.btn.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(240, 122, 155, 0.5); color: var(--rose); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); cursor: pointer; color: var(--text);
}
.icon-btn:hover { border-color: var(--gold); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.on { color: var(--gold); border-color: var(--gold); }
.icon-btn.on svg.fillable { fill: currentColor; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted); user-select: none;
}
.chip:hover { color: var(--text); }
.chip.on { background: rgba(243, 223, 166, 0.14); border-color: var(--gold); color: var(--gold); }
.chip i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--c, var(--muted)); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; background: rgba(255, 255, 255, 0.07); color: var(--text); white-space: nowrap; }
.pill.done { background: rgba(127, 217, 160, 0.14); color: var(--ok); }
.pill.warn { background: rgba(240, 179, 107, 0.15); color: var(--warn); }
.pill.gold { background: rgba(243, 223, 166, 0.15); color: var(--gold); }
.pill.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.panel { background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.section { margin-top: 34px; }
.section > h2 { font-size: 1.3rem; margin-bottom: 12px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- Vignettes ---------- */
.pic { position: relative; overflow: hidden; background: #060a16; }
.pic canvas, .pic img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.pic img { object-fit: cover; opacity: 0; transition: opacity 0.5s; }
.pic img.ready { opacity: 1; }
.thumb { width: 64px; height: 64px; border-radius: 10px; flex: none; }

/* ---------- Page « Ce soir » ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.topbar h1 { font-size: 1.15rem; color: var(--muted); font-family: var(--sans); font-weight: 500; }
.topbar .day { font-family: var(--serif); font-size: 1.6rem; color: var(--text); font-weight: 500; }

.hero { position: relative; border-radius: 22px; overflow: hidden; min-height: 400px; display: flex; align-items: flex-end; border: 1px solid var(--line); }
.hero .pic { position: absolute; inset: 0; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(8,13,28,0.15) 0%, rgba(8,13,28,0.55) 45%, rgba(8,13,28,0.95) 100%); pointer-events: none; }
html.red .hero::after { background: linear-gradient(180deg, rgba(16,3,3,0.15) 0%, rgba(16,3,3,0.6) 45%, rgba(16,3,3,0.96) 100%); }
.hero-in { position: relative; z-index: 2; padding: 26px; width: 100%; }
.hero h2 { font-size: clamp(2rem, 7vw, 3.7rem); line-height: 1.04; max-width: 15ch; font-variation-settings: "opsz" 144, "SOFT" 60; }
.hero .meta { margin-top: 8px; color: #cfd6ea; font-size: 15px; display: flex; gap: 14px; flex-wrap: wrap; }
.hero .facts { display: flex; gap: 26px; flex-wrap: wrap; margin: 20px 0; }
.fact b { display: block; font-family: var(--serif); font-weight: 500; font-size: 1.55rem; line-height: 1.1; }
.fact span { font-size: 13px; color: #b7c0d9; }
.hero .ring { position: absolute; top: 18px; right: 18px; z-index: 3; }
.hero .why { position: absolute; top: 20px; left: 22px; z-index: 3; }
.empty { padding: 40px 22px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); font-size: 1.3rem; margin-bottom: 6px; }

.ring { width: 64px; height: 64px; position: relative; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 21px; }
.ring.sm { width: 42px; height: 42px; }
.ring.sm .num { font-size: 14px; }

.conditions { display: grid; grid-template-columns: 1fr; margin-top: 14px; border: 1px solid var(--line); border-radius: var(--r); background: rgba(255,255,255,0.03); }
.conditions > div { padding: 14px 18px; display: flex; gap: 14px; align-items: center; }
.conditions > div + div { border-top: 1px solid var(--line); }
@media (min-width: 760px) {
  .conditions { grid-template-columns: repeat(3, 1fr); }
  .conditions > div + div { border-top: 0; border-left: 1px solid var(--line); }
}
.conditions b { font-weight: 600; display: block; }
.conditions small { color: var(--muted); font-size: 13px; }
.cloudbars { display: flex; gap: 2px; align-items: flex-end; height: 34px; margin-top: 6px; }
.cloudbars i { flex: 1; min-width: 4px; background: var(--blue); opacity: 0.85; border-radius: 2px 2px 0 0; }

.filters { margin-top: 26px; display: grid; gap: 12px; }
.filters .grp { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.filters .lab { width: 76px; color: var(--muted); font-size: 13px; flex: none; }
.scroll-x { overflow-x: auto; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }

.sky-grid { display: grid; gap: 18px; margin-top: 16px; }
@media (min-width: 900px) { .sky-grid { grid-template-columns: 420px 1fr; } }
.dome { width: 100%; max-width: 460px; margin: 0 auto; display: block; }
.dome text, .chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

.plan-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); cursor: pointer; }
.plan-item:first-of-type { border-top: 0; }
.plan-item .t { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.plan-item .n { font-family: var(--serif); font-size: 1.1rem; }

.list { margin-top: 14px; }
.target-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px 6px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.target-row:first-child { border-top: 0; }
.target-row:hover { background: rgba(255,255,255,0.04); }
.target-row .nm { font-family: var(--serif); font-size: 1.15rem; line-height: 1.2; }
.target-row .inf { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.target-row .win { text-align: right; font-size: 13.5px; }
.target-row .win b { font-weight: 600; display: block; }
.target-row .end { display: flex; align-items: center; gap: 14px; }
@media (max-width: 560px) { .target-row .end .ring { display: none; } }
.zonedot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* ---------- Catalogue ---------- */
.search { width: 100%; background: rgba(255,255,255,0.05); border: 1px solid var(--line-2); border-radius: 999px; padding: 12px 18px; font-size: 16px; }
.search:focus { outline: none; border-color: var(--gold); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; margin-top: 16px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 8px 20px 8px 20px; overflow: hidden; cursor: pointer; border: 1px solid var(--line); }
.tile .pic { position: absolute; inset: 0; }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 38%, rgba(6,10,22,0.92)); }
.tile .cap { position: absolute; left: 11px; right: 11px; bottom: 10px; z-index: 2; }
.tile .cap b { font-family: var(--serif); font-weight: 500; font-size: 1.02rem; line-height: 1.15; display: block; }
.tile .cap small { color: #b9c2dc; font-size: 12px; }
.tile .tag { position: absolute; z-index: 2; top: 9px; left: 9px; }
.tile .st { position: absolute; z-index: 2; top: 9px; right: 9px; display: flex; gap: 6px; }
.tile .st span { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: rgba(8,13,28,0.7); }
.tile .st svg { width: 14px; height: 14px; stroke: var(--ok); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tile .st .fav svg { stroke: var(--gold); fill: var(--gold); }

/* ---------- Fiche cible ---------- */
.detail-hero { display: grid; gap: 18px; }
@media (min-width: 900px) { .detail-hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } }
.frame { position: relative; aspect-ratio: 1; border-radius: 22px; overflow: hidden; border: 1px solid var(--line); max-height: 640px; width: 100%; }
.frame .pic { position: absolute; inset: 0; }
.fov { position: absolute; border: 1.5px solid var(--gold); box-shadow: 0 0 0 9999px rgba(6, 10, 22, 0.45); border-radius: 3px; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3; pointer-events: none; transition: all 0.25s; }
.fov::after { content: "Champ du Seestar"; position: absolute; left: 6px; bottom: 5px; font-size: 11.5px; color: var(--gold); background: rgba(6,10,22,0.6); padding: 1px 7px; border-radius: 99px; }
.frame .tools { position: absolute; z-index: 4; right: 12px; top: 12px; display: flex; gap: 8px; }
.facts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-top: 16px; }
.facts-grid > div { background: var(--bg-2); padding: 12px 14px; }
.facts-grid small { color: var(--muted); display: block; font-size: 12.5px; }
.facts-grid b { font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.09); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 120px; margin-top: 12px; }
.months .m { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 6px; font-size: 12px; color: var(--muted); }
.months .m i { width: 100%; border-radius: 5px 5px 2px 2px; background: var(--gold); min-height: 3px; opacity: 0.85; }
.months .m.now { color: var(--gold); }
.months .m.now i { outline: 2px solid var(--gold); outline-offset: 2px; }
.session { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.session:first-child { border-top: 0; }
.stars { color: var(--gold); letter-spacing: 2px; font-size: 14px; }
textarea.note { width: 100%; min-height: 96px; background: rgba(255,255,255,0.04); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px; resize: vertical; }
textarea.note:focus, .field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.parts { display: grid; gap: 8px; margin-top: 12px; }
.parts .p { display: grid; grid-template-columns: 130px 1fr 40px; gap: 10px; align-items: center; font-size: 13.5px; }

/* ---------- Journal ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { padding: 16px; border-radius: var(--r); border: 1px solid var(--line); background: rgba(255,255,255,0.03); }
.stat b { display: block; font-family: var(--serif); font-size: 2.1rem; font-weight: 500; line-height: 1; }
.stat span { color: var(--muted); font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 90px; margin-top: 10px; }
.bars div { flex: 1; text-align: center; font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 4px; }
.bars i { display: block; background: var(--teal); border-radius: 4px 4px 1px 1px; min-height: 3px; }
.month-h { font-family: var(--serif); font-size: 1.1rem; margin: 22px 0 4px; color: var(--muted); }
.jrow { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.jrow .thumb { width: 52px; height: 52px; border-radius: 9px; }

/* ---------- Réglages ---------- */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field label { font-size: 13.5px; color: var(--muted); }
.field input, .field select { background: rgba(255,255,255,0.05); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; width: 100%; font-size: 15px; }
.cols { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch input { appearance: none; width: 46px; height: 27px; border-radius: 99px; background: rgba(255,255,255,0.14); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: var(--text); transition: transform .2s; }
.switch input:checked { background: var(--gold); }
.switch input:checked::after { transform: translateX(19px); background: var(--gold-ink); }
.hz { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .hz { grid-template-columns: 300px 1fr; align-items: center; } }
.hz-sliders { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.hz-sliders label { font-size: 12.5px; color: var(--muted); display: block; }
.hz-sliders input[type=range] { width: 100%; accent-color: var(--gold); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: rgba(0,0,0,0.3); padding: 10px 12px; border-radius: 10px; overflow-x: auto; white-space: pre; color: var(--muted); }

/* ---------- Feuille, toast ---------- */
#sheet { position: fixed; inset: 0; z-index: 60; display: none; background: rgba(4, 7, 16, 0.65); align-items: flex-end; justify-content: center; }
#sheet.open { display: flex; }
#sheet .box { width: 100%; max-width: 520px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + var(--safe-b)); max-height: 92vh; overflow-y: auto; animation: up 0.25s ease-out; }
@media (min-width: 700px) { #sheet { align-items: center; } #sheet .box { border-radius: 22px; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
#toast { position: fixed; z-index: 80; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
@media (min-width: 980px) { #toast { bottom: 24px; } }
.toast { background: var(--card-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 16px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.4); }
.toast.err { border-color: rgba(240,122,155,0.6); }
.rate { display: flex; gap: 6px; font-size: 26px; color: var(--faint); }
.rate span { cursor: pointer; }
.rate span.on { color: var(--gold); }
.skeleton { height: 200px; border-radius: var(--r); background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.07), rgba(255,255,255,0.03)); background-size: 200% 100%; animation: sh 1.4s infinite; }
@keyframes sh { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.savebar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 12px 16px; border: 1px solid var(--line-2); border-radius: 16px; background: rgba(15, 24, 48, 0.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 20; }
@media (min-width: 980px) { .savebar { bottom: 16px; } }
