:root {
  --bg: #080E1D;
  --surface: #142037;
  --surface-2: #1B2A47;
  --text: #E8EDF5;
  --muted: #A3AEC2;
  --gold: #E8C78A;
  --danger: #E89A8A;
  --radius: 14px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#sky-screen { position: fixed; inset: 0; }
#sky { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#sky:active { cursor: grabbing; }

.top-bar {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: var(--gutter); left: var(--gutter);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}
.chip {
  background: rgba(20, 32, 55, 0.85); border: 1px solid rgba(232, 237, 245, 0.12);
  color: var(--text); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-size: 14px;
  backdrop-filter: blur(6px); min-height: 40px; display: inline-flex; align-items: center;
}
.chip.icon { padding: 8px 12px; font-size: 18px; }

.zoom { position: absolute; right: var(--gutter); bottom: calc(env(safe-area-inset-bottom) + 100px); display: flex; flex-direction: column; gap: 8px; }
.zoom button {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(232, 237, 245, 0.15);
  background: rgba(20, 32, 55, 0.85); font-size: 20px; cursor: pointer;
}

.add-btn {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 24px);
  width: 64px; height: 64px; border-radius: 50%; background: var(--gold); color: var(--bg);
  font-size: 34px; line-height: 64px; text-align: center; text-decoration: none; font-weight: 300;
  box-shadow: 0 0 24px rgba(232, 199, 138, 0.35);
}

#panel, #overlay {
  position: fixed; inset: 0; background: var(--bg); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 12px) var(--gutter) calc(env(safe-area-inset-bottom) + 32px);
}
.panel-inner { max-width: 640px; margin: 0 auto; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h1 { font-size: 20px; margin: 0; font-weight: 600; flex: 1; }
.back { background: none; border: 0; color: var(--text); font-size: 24px; width: 44px; height: 44px; cursor: pointer; border-radius: 50%; }

h2 { font-size: 15px; font-weight: 600; color: var(--muted); margin: 24px 0 8px; text-transform: none; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.card { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { margin-bottom: 8px; }
.list a, .list button.item {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 0; border-radius: var(--radius);
  padding: 12px 14px; color: var(--text); text-decoration: none; cursor: pointer;
}
.item-meta { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.badge {
  display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--gold);
  color: var(--gold); margin-left: 6px; vertical-align: 1px;
}
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

label { display: block; margin: 14px 0 6px; font-weight: 500; }
input[type=text], input[type=search], input[type=date], input[type=password], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid rgba(232, 237, 245, 0.15); border-radius: 10px;
  padding: 12px; min-height: 44px;
}
textarea { min-height: 96px; resize: vertical; }
input[type=color] { width: 44px; height: 44px; border: 0; background: none; padding: 0; }
.check { display: flex; gap: 10px; align-items: center; margin: 14px 0; font-weight: 400; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--muted); padding: 8px 0; min-height: 44px; display: flex; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 18px; border-radius: 999px;
  border: 1px solid rgba(232, 237, 245, 0.2); background: var(--surface-2); cursor: pointer; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 600; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: none; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.error { color: var(--danger); margin-top: 8px; min-height: 1.2em; }

.const-canvas { width: 100%; height: 46vh; min-height: 260px; max-height: 420px; display: block; border-radius: var(--radius); background: var(--bg); touch-action: none; }

.theme-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.theme-pick label {
  margin: 0; background: var(--surface); border-radius: var(--radius); padding: 12px; cursor: pointer; border: 1px solid transparent; font-weight: 400;
}
.theme-pick input { position: absolute; opacity: 0; pointer-events: none; }
.theme-pick input:checked + span { color: var(--gold); }
.theme-pick label:has(input:checked) { border-color: var(--gold); }
.theme-pick label:has(input:focus-visible) { outline: 2px solid var(--gold); }
.theme-pick strong { display: block; }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.row > .shrink { flex: 0 0 auto; }

#toast {
  position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(env(safe-area-inset-bottom) + 100px);
  max-width: 520px; margin: 0 auto; background: var(--surface); border: 1px solid rgba(232, 199, 138, 0.35);
  border-radius: var(--radius); padding: 14px 16px; display: none;
}
#toast.show { display: block; }
#toast .actions { margin-top: 10px; }

dialog {
  background: var(--surface); color: var(--text); border: 1px solid rgba(232, 237, 245, 0.15); border-radius: var(--radius);
  padding: 20px; width: min(480px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(4, 8, 18, 0.7); }
dialog h2 { margin-top: 0; color: var(--text); font-size: 18px; }

.hero { text-align: center; padding: 40px 0 8px; }
.hero h1 { font-size: 30px; letter-spacing: 0.02em; margin: 0 0 8px; font-weight: 600; }
.hero .tagline { color: var(--gold); font-style: italic; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.stat-grid .card { margin: 0; }
.stat-grid strong { font-size: 22px; display: block; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

#overlay { z-index: 10; display: flex; align-items: center; }
#overlay[hidden] { display: none; }
.overlay-inner { width: 100%; }
#lock-pin { font-size: 24px; letter-spacing: 0.3em; text-align: center; }
.card.warn { border: 1px solid rgba(232, 154, 138, 0.5); }
button.chip { cursor: pointer; font: inherit; }
/* Verrouillage immédiat : rien n'est visible dans l'aperçu du sélecteur d'applications. */
body.privacy-blank > *:not(#overlay) { visibility: hidden; }
[hidden] { display: none !important; }
/* Le focus programmatique des titres (annonce aux lecteurs d'écran) n'a pas à être encadré. */
h1[tabindex="-1"]:focus { outline: none; }
