/* diasPOCKET — cabinet de lecture
   Jour : papier ivoire, encre, filet rouge sang.
   Nuit : encre chaude, papier terni, rouge éclairci en terre cuite. */

:root {
  --paper:      #F3EDE1;
  --paper-up:   #FBF8F1;
  --ink:        #1C1A17;
  --ink-soft:   #54504A;
  --muted:      #8A8377;
  --faint:      #B0A897;
  --rule:       #D9D1C0;
  --rule-soft:  #E4DDCC;
  --red:        #8B0000;
  --red-ink:    #F6EFE3;
  --olive:      #6B8E23;
  --mark:       #F0D9C0;
  --mark-ink:   #6E3A12;
  --shadow:     rgba(28, 26, 23, .16);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Hoefler Text", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 34rem;
  --step: .5rem;
  --radius: 4px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:      #16130F;
    --paper-up:   #1E1A15;
    --ink:        #F2EADC;
    --ink-soft:   #A79E8E;
    --muted:      #8C8375;
    --faint:      #6E675C;
    --rule:       #2E2922;
    --rule-soft:  #241F1A;
    --red:        #D4574E;
    --red-ink:    #1A1410;
    --olive:      #8FA83F;
    --mark:       #3E3410;
    --mark-ink:   #F0D9A8;
    --shadow:     rgba(0, 0, 0, .5);
  }
}

/* Le réglage forcé depuis le panneau l'emporte sur celui du téléphone */
html[data-theme="light"] {
  --paper: #F3EDE1; --paper-up: #FBF8F1; --ink: #1C1A17; --ink-soft: #54504A;
  --muted: #8A8377; --faint: #B0A897; --rule: #D9D1C0; --rule-soft: #E4DDCC;
  --red: #8B0000; --red-ink: #F6EFE3; --olive: #6B8E23; --mark: #F0D9C0;
  --mark-ink: #6E3A12; --shadow: rgba(28,26,23,.16); color-scheme: light;
}
html[data-theme="dark"] {
  --paper: #16130F; --paper-up: #1E1A15; --ink: #F2EADC; --ink-soft: #A79E8E;
  --muted: #8C8375; --faint: #6E675C; --rule: #2E2922; --rule-soft: #241F1A;
  --red: #D4574E; --red-ink: #1A1410; --olive: #8FA83F; --mark: #3E3410;
  --mark-ink: #F0D9A8; --shadow: rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

/* Le grain : une trame très légère, pas une texture */
html[data-grain="1"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='90' height='90'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/></filter><rect width='90' height='90' filter='url(%23n)' opacity='0.055'/></svg>");
}

@media (prefers-color-scheme: dark) {
  html[data-grain="1"] body::before { opacity: .3; }
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 2px;
}

.hidden { display: none !important; }

.wrap {
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.15rem;
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------------ */
/* La marque                                                           */
/* ------------------------------------------------------------------ */

.mark {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  text-decoration: none;
}

.glyph {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--ink);
  position: relative;
  flex: none;
}
.glyph::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px; top: 5px; bottom: 5px;
  background: var(--paper);
  border-radius: 1px;
  clip-path: polygon(0 0, 68% 0, 100% 26%, 100% 100%, 0 100%);
}
.glyph::before {
  content: "";
  position: absolute;
  left: 6px; right: 6px; bottom: 5px;
  height: 5px;
  background: var(--red);
  z-index: 2;
  border-radius: 0 0 1px 1px;
}

.wordmark {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -.025em;
}

/* ------------------------------------------------------------------ */
/* Page d'entrée : la couverture                                        */
/* ------------------------------------------------------------------ */

.gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem calc(2rem + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.gate-inner { width: 100%; max-width: 21rem; }

.gate .mark { margin-bottom: .35rem; }

.gate .wordmark { font-size: 1.7rem; letter-spacing: -.035em; }
.gate .glyph { width: 34px; height: 34px; border-radius: 8px; }
.gate .glyph::after { left: 8px; right: 8px; top: 7px; bottom: 6px; }
.gate .glyph::before { left: 8px; right: 8px; bottom: 6px; height: 6px; }

.exergue {
  margin: .1rem 0 0;
  color: var(--ink-soft);
  font-style: italic;
  font-size: .95rem;
}

.rule {
  height: 3px;
  width: 46px;
  background: var(--red);
  margin: 1rem 0 1.6rem;
  transform-origin: left center;
  transition: transform .42s var(--ease);
}
.rule.stretched { transform: scaleX(9); }

.step { display: block; }
.step.leaving { animation: slide-out .26s ease-out forwards; }
.step.arriving { animation: slide-in .3s var(--ease) both; }

@keyframes slide-out { to { opacity: 0; transform: translateX(-2.2rem); } }
@keyframes slide-in { from { opacity: 0; transform: translateX(2.2rem); } }

.field-label {
  display: block;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .45rem;
}

input[type="password"],
input[type="text"],
input[type="search"],
textarea {
  width: 100%;
  background: var(--paper-up);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: .7rem .75rem;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1rem;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, textarea:focus { border-color: var(--red); outline: none; }

.code-input {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: .42em;
  text-align: center;
  padding: .8rem .5rem .8rem .9rem;
}
.backup-input { font-size: 1.05rem; letter-spacing: .18em; }

.check {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: .9rem 0 1.3rem;
  font-size: .9rem;
  color: var(--ink-soft);
}
.check input { accent-color: var(--red); width: 1rem; height: 1rem; }

.button {
  display: inline-block;
  width: 100%;
  text-align: center;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: .72rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--red);
  text-decoration: none;
  transition: transform .12s ease-out, background-color .2s ease-out;
}
.button.primary { background: var(--red); color: var(--red-ink); }
.button:active { transform: translateY(1px); }

.linkish {
  display: block;
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
  text-align: left;
  letter-spacing: .02em;
}
.linkish:hover { color: var(--red); }

.gate-error {
  margin: 1rem 0 0;
  color: var(--red);
  font-size: .9rem;
  min-height: 1.4em;
}

.gate-title { font-size: 1.35rem; margin: 0 0 .6rem; letter-spacing: -.02em; }
.gate-text { color: var(--ink-soft); font-size: .98rem; margin: 0 0 1.4rem; }

/* ------------------------------------------------------------------ */
/* Barre du haut                                                        */
/* ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  padding: calc(.9rem + env(safe-area-inset-top)) 0 0;
}

.topbar-row,
.searchbar {
  max-width: 42rem;
  margin: 0 auto;
  padding: 0 1.15rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.topbar-actions { margin-left: auto; display: flex; gap: .3rem; }

.icon-button {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: var(--radius);
}
#open-search { color: var(--red); }
.icon-button svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.searchbar input { flex: 1; }

.topbar-rule {
  max-width: 42rem;
  margin: .55rem auto 0;
  padding: 0 1.15rem;
}
.topbar-rule span {
  display: block;
  height: 3px;
  width: 30px;
  background: var(--red);
  transform-origin: left center;
  transition: transform .28s var(--ease);
}
.topbar-rule span.wide { transform: scaleX(20); }

.recall {
  display: block;
  width: 100%;
  max-width: 42rem;
  margin: 0 auto;
  padding: .5rem 1.15rem;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red);
  text-align: left;
  animation: fade-in .25s ease-out;
}

@keyframes fade-in { from { opacity: 0; } }

/* ------------------------------------------------------------------ */
/* La Pile : un bandeau qui se déplie, et qui disparaît quand elle est  */
/* vide. Elle ne dispute jamais l'écran au reste.                       */
/* ------------------------------------------------------------------ */

.pile-zone {
  max-width: 42rem;
  margin: .9rem auto 0;
  padding: 0 1.15rem;
  position: relative;
  z-index: 1;
}

.pile-band {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--red);
  color: var(--red-ink);
  border-radius: 5px;
  padding: .6rem .75rem;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  transition: border-radius .2s ease-out;
}
.pile-band.open { border-radius: 5px 5px 0 0; }
.pile-band .grow { flex: 1; }
.pile-band svg {
  width: 17px; height: 17px;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
  transition: transform .24s var(--ease);
}
.pile-band.open .chev { transform: rotate(180deg); }

.pile-body {
  border: 1px solid var(--red);
  border-top: none;
  border-radius: 0 0 5px 5px;
  overflow: hidden;
  animation: pile-open .26s var(--ease);
}
@keyframes pile-open { from { opacity: 0; transform: translateY(-8px); } }

.pile-body .swipe:last-child { border-bottom: none; }

/* ------------------------------------------------------------------ */
/* Sections : intertitres de journal                                    */
/* ------------------------------------------------------------------ */

.main {
  padding-bottom: calc(4rem + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.section-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  max-width: 42rem;
  margin: 2rem auto .2rem;
  padding: 0 1.15rem;
}
.section-head .label {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.section-head .line { flex: 1; height: 1px; background: var(--rule); }
.section-head .count {
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted);
}
.section-head.strong .label,
.section-head.strong .count { color: var(--red); }
.section-head.strong .line { height: 2px; background: var(--red); }

/* Le tri, à droite de l'intertitre */
.sort-button {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--red);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .25rem;
}
.sort-button svg {
  width: 13px; height: 13px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}

.sort-sheet {
  max-width: 42rem;
  margin: .5rem auto 0;
  padding: 0 1.15rem;
  animation: fade-in .2s ease-out;
}
.sort-sheet .card {
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: var(--paper-up);
  padding: .8rem .9rem;
}
.sort-sheet .head {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--muted);
  margin: .7rem 0 .45rem;
}
.sort-sheet .head:first-child { margin-top: 0; }
.sort-sheet .row { display: flex; gap: .35rem; flex-wrap: wrap; }
.sort-sheet .opt {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .05em;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .28rem .55rem;
}
.sort-sheet .opt.on { background: var(--red); color: var(--red-ink); border-color: var(--red); }

/* ------------------------------------------------------------------ */
/* Entrées                                                              */
/* ------------------------------------------------------------------ */

.entries { max-width: 42rem; margin: 0 auto; }

.swipe {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--rule-soft);
}
.swipe:last-child { border-bottom: none; }

.swipe-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.3rem;
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--red-ink);
  background: var(--olive);
}
.swipe-bg.to-trash { background: var(--red); }
.swipe-bg .right { margin-left: auto; }

.entry {
  position: relative;
  touch-action: pan-y;
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  padding: .8rem 1.15rem;
  background: var(--paper);
  will-change: transform;
}
.entry.dragging { transition: none; }
.entry.settling { transition: transform .22s var(--ease); }

.pastille {
  width: 26px; height: 26px;
  border-radius: var(--radius);
  flex: none;
  display: grid;
  place-items: center;
  margin-top: .12rem;
  background: var(--red);
}
.pastille.k-extrait { background: var(--olive); }
.pastille.k-site { background: var(--faint); }
.pastille svg {
  width: 15px; height: 15px;
  fill: none;
  stroke: var(--red-ink);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.entry-body { min-width: 0; flex: 1; }

.entry-title {
  font-size: .97rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin: 0;
}

.entry-meta {
  font-family: var(--mono);
  font-size: .63rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: .2rem;
}

.entry-snippet {
  font-size: .88rem;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-top: .3rem;
}
.entry-snippet mark {
  background: var(--mark);
  color: var(--mark-ink);
  padding: 0 .1em;
  border-radius: 1px;
}

.progress {
  display: block;
  height: 2px;
  background: var(--rule-soft);
  margin-top: .45rem;
}
.progress span { display: block; height: 2px; background: var(--red); }

.entry-tags { margin-top: .35rem; display: flex; gap: .3rem; flex-wrap: wrap; }
.tag-chip {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .06em;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: .1rem .4rem;
}

/* La manchette : la dernière arrivée */
.lede {
  display: block;
  padding: 1.15rem 1.15rem 1.25rem;
}
.lede .pastille-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .55rem;
}
.lede .kicker {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--red);
}
.lede .entry-title {
  font-size: 1.42rem;
  line-height: 1.2;
  letter-spacing: -.025em;
}
.lede .entry-meta { margin-top: .4rem; }
.lede .entry-snippet { font-size: .93rem; margin-top: .45rem; }

.entry-note {
  border-left: 2px solid var(--rule);
  padding-left: .6rem;
  margin-top: .6rem;
  font-style: italic;
  font-size: .88rem;
  color: var(--muted);
}

.empty {
  max-width: 26rem;
  margin: 3.5rem auto;
  padding: 0 1.5rem;
  text-align: center;
}
.empty h2 { font-size: 1.25rem; margin: .9rem 0 .5rem; letter-spacing: -.02em; }
.empty p { color: var(--ink-soft); font-size: .95rem; margin: 0 0 1.3rem; }
.empty .button { width: auto; padding-left: 1.6rem; padding-right: 1.6rem; }
.empty-glyph {
  width: 34px; height: 34px;
  margin: 0 auto;
  stroke: var(--faint);
  fill: none;
  stroke-width: 1.4;
}

.loading {
  padding: 3rem 1.15rem;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.more {
  display: block;
  width: 100%;
  padding: 1.1rem;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 1px solid var(--rule);
}

/* ------------------------------------------------------------------ */
/* Lecture                                                              */
/* ------------------------------------------------------------------ */

.reader {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: reader-in .26s var(--ease);
}
@keyframes reader-in { from { opacity: 0; transform: translateY(14px); } }

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--paper);
  border-bottom: 1px solid var(--rule-soft);
  padding: calc(.55rem + env(safe-area-inset-top)) 1.15rem .55rem;
  display: flex;
  align-items: center;
  gap: .35rem;
}
.reader-bar .spacer { flex: 1; }
.reader-progress {
  position: absolute;
  left: 0; bottom: -1px;
  height: 2px;
  background: var(--red);
  width: 0;
}

.reader-body {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.5rem 1.3rem calc(5rem + env(safe-area-inset-bottom));
  font-size: var(--reader-size, 1.06rem);
  line-height: 1.72;
}
.reader-body h1 {
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -.03em;
  margin: 0 0 .5rem;
}
.reader-kicker {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .7rem;
}
.reader-source {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted);
  margin: .5rem 0 1.2rem;
  display: block;
  word-break: break-all;
}
.reader-source a { color: var(--red); text-decoration: none; border-bottom: 1px solid var(--rule); }

.reader-body h2 { font-size: 1.2rem; margin: 2rem 0 .6rem; letter-spacing: -.015em; }
.reader-body h3 { font-size: 1.05rem; margin: 1.6rem 0 .5rem; }
.reader-body p { margin: 0 0 1.1rem; }
.reader-body blockquote {
  margin: 1.3rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--red);
  font-style: italic;
  color: var(--ink-soft);
}
.reader-body ul, .reader-body ol { margin: 0 0 1.1rem 1.1rem; padding: 0; }
.reader-body li { margin-bottom: .4rem; }
.reader-body a { color: var(--red); text-decoration: none; border-bottom: 1px solid var(--rule); }
.reader-body hr { border: none; border-top: 1px solid var(--rule); margin: 2rem 0; }
.reader-body pre {
  font-family: var(--mono);
  font-size: .82rem;
  background: var(--paper-up);
  border: 1px solid var(--rule);
  padding: .8rem;
  overflow-x: auto;
}
.reader-body mark {
  background: var(--mark);
  color: var(--mark-ink);
  border-radius: 2px;
  padding: .05em .1em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.reader-body p.hl { border-left: 2px solid var(--mark); padding-left: .6rem; margin-left: -.8rem; }

/* Modification d'une pièce */
.editor { margin: 1rem 0 1.6rem; }
.editor input, .editor textarea { margin-bottom: .7rem; }
.editor textarea { min-height: 16rem; font-family: var(--mono); font-size: .82rem; line-height: 1.6; }
.editor .row { display: flex; gap: .5rem; }
.editor .button { width: auto; padding: .5rem 1rem; font-size: .9rem; }

.reader-empty {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1.4rem;
  background: var(--paper-up);
}
.reader-empty p { font-size: .93rem; color: var(--ink-soft); margin: 0 0 .9rem; }
.reader-empty .row { display: flex; gap: .5rem; flex-wrap: wrap; }
.reader-empty .button { width: auto; padding: .5rem .9rem; font-size: .85rem; }

.note-box { margin: 1.6rem 0; }
.note-box textarea { min-height: 3.4rem; font-style: italic; resize: vertical; }

.selection-menu {
  position: absolute;
  z-index: 60;
  display: flex;
  background: var(--ink);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 6px 20px var(--shadow);
}
.selection-menu button {
  color: var(--paper);
  padding: .5rem .8rem;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.selection-menu button + button { border-left: 1px solid rgba(255,255,255,.16); }

.highlight-list { margin-top: 2.2rem; border-top: 1px solid var(--rule); padding-top: 1.2rem; }
.highlight-item {
  background: var(--mark);
  color: var(--mark-ink);
  border-radius: 2px;
  padding: .6rem .7rem;
  font-size: .92rem;
  font-style: italic;
  margin-bottom: .55rem;
  position: relative;
}
.highlight-item .acts {
  display: flex;
  gap: .8rem;
  margin-top: .45rem;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  font-style: normal;
  opacity: .75;
}

/* ------------------------------------------------------------------ */
/* Panneau                                                              */
/* ------------------------------------------------------------------ */

.panel-scrim {
  position: fixed;
  inset: 0;
  background: var(--shadow);
  z-index: 45;
  animation: fade-in .2s ease-out;
}

.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(20rem, 88vw);
  z-index: 46;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  overflow-y: auto;
  padding: calc(1.1rem + env(safe-area-inset-top)) 1.2rem calc(2rem + env(safe-area-inset-bottom));
  animation: panel-in .28s var(--ease);
}
@keyframes panel-in { from { transform: translateX(100%); } }

.panel h2 { font-size: 1.1rem; margin: 0; letter-spacing: -.02em; }
.panel .rule { margin: .55rem 0 1.4rem; width: 30px; }

.panel-group { margin-bottom: 1.5rem; }
.panel-group > .head {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .6rem;
}

.panel-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  text-align: left;
  padding: .5rem 0 .5rem .6rem;
  border-left: 2px solid transparent;
  font-size: .96rem;
}
.panel-item.active { border-left-color: var(--red); font-weight: 700; }
.panel-item .n { margin-left: auto; font-family: var(--mono); font-size: .72rem; color: var(--muted); }

.panel-note {
  font-size: .82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: .5rem 0 0;
}

.seg { display: flex; border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg button {
  flex: 1;
  padding: .45rem 0;
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.seg button.on { background: var(--red); color: var(--red-ink); }

.range-row { display: flex; align-items: center; gap: .7rem; margin-top: .7rem; }
.range-row input[type="range"] { flex: 1; accent-color: var(--red); }

.warn {
  border: 1px solid var(--red);
  border-left-width: 3px;
  border-radius: 0;
  padding: .8rem .9rem;
  margin-bottom: 1.4rem;
  font-size: .87rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper-up);
}
.warn strong { color: var(--red); }

.installer-flag {
  position: relative;
  z-index: 30;
  background: var(--red);
  color: var(--red-ink);
  padding: .6rem 1.15rem;
  font-size: .85rem;
  text-align: center;
  line-height: 1.4;
}

.log-line {
  display: flex;
  gap: .5rem;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted);
  padding: .3rem 0;
  border-bottom: 1px solid var(--rule-soft);
}
.log-line .ko { color: var(--red); }
.log-line .ok { color: var(--olive); }

/* ------------------------------------------------------------------ */
/* Messages passagers                                                   */
/* ------------------------------------------------------------------ */

.toast-zone {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  pointer-events: none;
  padding: 0 1rem;
}

.toast {
  pointer-events: auto;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: .6rem .9rem;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  max-width: 26rem;
  width: 100%;
  box-shadow: 0 6px 22px var(--shadow);
  animation: toast-in .22s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast button {
  color: var(--red);
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-left: auto;
  white-space: nowrap;
}
@media (prefers-color-scheme: dark) {
  .toast { background: var(--paper-up); color: var(--ink); border: 1px solid var(--rule); }
}

.offline-flag {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 65;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  text-align: center;
  padding: .45rem 1rem calc(.45rem + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ */
/* Grands écrans                                                        */
/* ------------------------------------------------------------------ */

@media (min-width: 46rem) {
  body { font-size: 18px; }
  .lede .entry-title { font-size: 1.7rem; }
  .entry:hover { background: var(--paper-up); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
