/* Ciel — même famille visuelle que Viseur : fond sombre, commandes sur bandes sombres, accent ambre.
   Un seul thème sombre, volontairement (usage en extérieur, écran de visée). */
:root {
  --ink: #0b0c0e;
  --panel: rgba(16, 18, 21, .9);
  --panel-solid: #15171b;
  --raise: rgba(255, 255, 255, .07);
  --raise-2: rgba(255, 255, 255, .12);
  --line: rgba(255, 255, 255, .13);
  --text: #edebe5;
  --dim: #979ba2;
  --accent: #ffbe3b;
  --accent-ink: #1a1405;
  --sun: #ffd25e;
  --shade: #3d4a63;
  --night: #161b26;
  --golden: #f0a14a;
  --blue: #4d6fb8;
  --ok: #5ccf86;
  --warn: #ff9d4d;
  --bad: #ff6b5c;
  --ui: 'Barlow Semi Condensed', 'Arial Narrow', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --rail: 76px;
  --side: 340px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: var(--ink); color: var(--text); }
body { font: 15px/1.35 var(--ui); -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }

#app { position: fixed; inset: 0; }

/* ---------- onglets ---------- */
#onglets {
  position: absolute; z-index: 30; left: 0; top: 0; bottom: 0; width: var(--rail);
  padding: calc(14px + var(--sat)) 0 calc(14px + var(--sab)) var(--sal);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--panel-solid); border-right: 1px solid var(--line);
}
#onglets .marque { color: var(--accent); margin-bottom: 14px; }
#onglets .marque svg { width: 28px; height: 28px; }
#onglets button {
  width: 62px; padding: 9px 0 7px; border-radius: 12px; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 13px; letter-spacing: .02em;
}
#onglets button:hover { color: var(--text); background: var(--raise); }
#onglets button[aria-current="page"] { color: var(--accent); background: var(--raise-2); }

/* ---------- scène ---------- */
#scene, #meteo { position: absolute; left: var(--rail); right: 0; top: 0; bottom: 0; }
#scene { background: #0e1116; touch-action: none; }
#c3d, #surcouche, #video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#video { object-fit: cover; background: #000; }
#surcouche { pointer-events: none; }
#meteo { background: #10161c; z-index: 1; }

.pastille {
  position: absolute; left: 50%; top: calc(76px + var(--sat)); transform: translateX(-50%); z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 14px; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis;
}
.pastille.alerte { border-color: var(--warn); color: #ffd0a8; }

/* ---------- barre du haut ---------- */
#haut {
  position: absolute; z-index: 20; top: calc(12px + var(--sat)); left: calc(var(--rail) + 12px);
  width: min(440px, calc(100% - var(--rail) - var(--side) - 36px)); display: flex; gap: 8px;
}
.recherche { position: relative; flex: 1; }
.recherche > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); width: 18px; height: 18px; pointer-events: none; }
#q {
  width: 100%; height: 44px; padding: 0 14px 0 38px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); outline: none; font-size: 16px;
}
#q:focus { border-color: var(--accent); }
#resultats {
  position: absolute; left: 0; right: 0; top: 48px; margin: 0; padding: 4px; list-style: none;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 12px; max-height: 50vh; overflow: auto;
}
#resultats li { padding: 9px 10px; border-radius: 8px; cursor: pointer; }
#resultats li small { display: block; color: var(--dim); font-size: 13px; }
#resultats li:hover, #resultats li[aria-selected="true"] { background: var(--raise-2); }
.rond {
  width: 44px; height: 44px; flex: none; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
}
.rond:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- panneau ---------- */
#panneau {
  position: absolute; z-index: 15; right: 12px; top: calc(12px + var(--sat)); bottom: 104px; width: var(--side);
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  overflow: auto; overscroll-behavior: contain; padding: 14px 16px 18px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
#poignee { display: none; }
#panneau h2 { margin: 0 0 2px; font-size: 21px; font-weight: 600; letter-spacing: .01em; }
#panneau h3 { margin: 18px 0 8px; font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); }
#panneau p { margin: 6px 0; }
.lieu { color: var(--dim); font-size: 14px; margin-bottom: 4px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--dim); }
.kv b { font-weight: 500; font-family: var(--mono); font-size: 14px; text-align: right; }
.grand { font-size: 30px; font-weight: 500; font-family: var(--mono); letter-spacing: -.02em; }
.etat-soleil { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.etat-soleil i { width: 14px; height: 14px; border-radius: 50%; background: var(--sun); box-shadow: 0 0 12px var(--sun); flex: none; }
.etat-soleil.couche i { background: var(--night); box-shadow: none; border: 1px solid var(--dim); }
.etat-soleil.cache i { background: var(--shade); box-shadow: none; }
.note { font-size: 13px; color: var(--dim); }
.alerte-txt { color: #ffcf9e; font-size: 14px; }

.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puce {
  padding: 6px 11px; border-radius: 999px; background: var(--raise); border: 1px solid var(--line); font-size: 14px;
  white-space: nowrap; flex: none;
}
.puce:hover { border-color: var(--dim); }
.puce[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
}
.bouton.second { background: var(--raise-2); color: var(--text); font-weight: 500; }
.bouton:disabled { opacity: .45; cursor: default; }
.bouton svg { width: 18px; height: 18px; }
.rangee { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* Frise 24 h (soleil/ombre/nuit d'un point, créneaux d'un plan) */
.frise { position: relative; height: 18px; border-radius: 5px; overflow: hidden; background: var(--night); margin: 6px 0 2px; }
.frise > i { position: absolute; top: 0; bottom: 0; }
.frise .soleil { background: var(--sun); }
.frise .ombre { background: var(--shade); }
.frise .ok { background: var(--ok); }
.frise .curseur { width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.graduation { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.legende { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--dim); margin-top: 6px; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.carte-plan { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin-top: 10px; background: rgba(255,255,255,.03); }
.carte-plan.choisi { border-color: var(--accent); }
.carte-plan .rangee { margin-top: 8px; }
.carte-plan .bouton { min-height: 34px; padding: 0 12px; font-size: 14px; }
input[type="time"].saisie { padding: 0 6px; font-family: var(--mono); }

label.champ { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--dim); }
input.saisie, select.saisie {
  width: 100%; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--raise); outline: none;
}
input.saisie:focus, select.saisie:focus { border-color: var(--accent); }
select.saisie option { background: var(--panel-solid); }

/* ---------- barre du temps ---------- */
#temps {
  position: absolute; z-index: 16; left: calc(var(--rail) + 12px); right: calc(var(--side) + 24px); bottom: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px 8px;
  display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 4px 12px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
#temps .heure { font-family: var(--mono); font-size: 26px; font-weight: 500; min-width: 84px; }
#temps input[type="date"] {
  height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--raise); padding: 0 8px; outline: none;
}
#temps .lecture { width: 40px; height: 40px; border-radius: 50%; background: var(--raise-2); display: grid; place-items: center; }
#temps .lecture[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.piste { position: relative; height: 38px; }
.piste .fond { position: absolute; left: 0; right: 0; top: 13px; height: 12px; border-radius: 6px; background: var(--night); overflow: hidden; }
.piste .fond i { position: absolute; top: 0; bottom: 0; }
.piste input[type="range"] { position: absolute; inset: 0; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.piste input[type="range"]::-webkit-slider-runnable-track { height: 38px; background: transparent; }
.piste input[type="range"]::-moz-range-track { height: 38px; background: transparent; }
.piste input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 8px; height: 30px; margin-top: 4px; border-radius: 4px; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.55); }
.piste input[type="range"]::-moz-range-thumb { width: 8px; height: 30px; border: 0; border-radius: 4px; background: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.55); }
.piste .reperes { position: absolute; left: 0; right: 0; bottom: -2px; height: 10px; font-family: var(--mono); font-size: 10px; color: var(--dim); pointer-events: none; }
.piste .reperes span { position: absolute; transform: translateX(-50%); }
#temps .dates { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#temps .dates .puce { padding: 3px 10px; font-size: 13px; }

#app[data-camera] #c3d { visibility: hidden; }

/* ---------- onglet Météo : pas de barre du temps ---------- */
#app[data-tab="meteo"] #temps, #app[data-tab="meteo"] #scene { display: none; }

/* ---------- téléphone ---------- */
@media (max-width: 899px) {
  :root { --rail: 0px; --side: 0px; }
  #onglets {
    top: auto; right: 0; width: auto; height: calc(58px + var(--sab)); flex-direction: row; justify-content: space-around;
    padding: 4px calc(8px + var(--sar)) var(--sab) calc(8px + var(--sal)); border-right: 0; border-top: 1px solid var(--line);
  }
  #onglets .marque { display: none; }
  #onglets button { flex: 1; max-width: 96px; padding: 6px 0 4px; }
  #scene, #meteo { left: 0; bottom: calc(58px + var(--sab)); }
  #haut { left: 10px; right: 10px; width: auto; top: calc(10px + var(--sat)); }
  #temps {
    left: 8px; right: 8px; bottom: calc(66px + var(--sab)); padding: 8px 10px 6px; gap: 4px 8px;
    grid-template-columns: auto auto 1fr;
  }
  #temps input[type="date"] { grid-row: 2; grid-column: 1 / 3; height: 32px; }
  #temps .heure { font-size: 22px; min-width: 66px; }
  #temps .dates { grid-row: 2; grid-column: 3; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  #temps .dates::-webkit-scrollbar { display: none; }
  #panneau {
    left: 8px; right: 8px; top: auto; width: auto; bottom: calc(66px + var(--sab) + var(--temps-h, 104px));
    max-height: 42vh; padding: 0 14px 14px; border-radius: 16px;
  }
  #panneau.ferme { max-height: 44px; overflow: hidden; }
  #poignee { display: block; position: sticky; top: 0; width: calc(100% + 28px); margin: 0 -14px 6px; height: 22px; background: inherit; z-index: 1; }
  #poignee span { display: block; width: 44px; height: 4px; border-radius: 2px; background: var(--dim); margin: 8px auto 0; }
  #panneau h2 { font-size: 19px; }
  #app[data-tab="meteo"] #panneau { bottom: calc(66px + var(--sab)); }
  .pastille { top: calc(64px + var(--sat)); }
}
