/* ============================================================
   VOID TIMER — feuille de style
   Un bureau d'ordinateur des années 90 façon Mac System 7,
   passé en mode nuit : barre des menus en haut, barres de
   titre rayées, boutons arrondis, motifs de bureau en trame.
   La fenêtre du minuteur reste fixée au-dessus des outils.
   ============================================================ */

/* DotGothic16 (sous-ensemble : latin, accents, grec, flèches, opérateurs mathématiques) */
@font-face {
  font-family: 'DotGothic16';
  src: url('../fonts/dotgothic16.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'VT323';
  src: url('../fonts/vt323-latin-ext.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+2113;
}
@font-face {
  font-family: 'VT323';
  src: url('../fonts/vt323-latin.woff2') format('woff2');
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}

:root {
  color-scheme: dark;

  /* encre (traits et textes) sur papier nuit */
  --ink: #ebe6d9;
  --ink-2: #aca799;
  --ink-3: #6e6a60;
  --ink-4: #34322e;
  --paper: #141416;
  --paper-2: #1c1c1f;
  --paper-3: #26262a;
  --void: #09090a;
  --red: #ff9d8f;

  /* phosphore du minuteur (modifiable dans les réglages) */
  --accent: #f3ecda;
  --glow: rgba(255, 238, 200, .42);

  /* bureau : teinte + motif 1 bit */
  --desk: #1e1e22;
  --pat-dither: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0zM1 1h1v1H1z' fill='%23fff' fill-opacity='.075'/%3E%3C/svg%3E");
  --pat-dots: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0z' fill='%23fff' fill-opacity='.16'/%3E%3C/svg%3E");
  --pat-diag: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M7 0h1v1H7zM6 1h1v1H6zM5 2h1v1H5zM4 3h1v1H4zM3 4h1v1H3zM2 5h1v1H2zM1 6h1v1H1zM0 7h1v1H0z' fill='%23fff' fill-opacity='.11'/%3E%3C/svg%3E");
  --pat-bricks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h8v1H0zM0 1h1v3H0zM0 4h8v1H0zM4 5h1v3H4z' fill='%23fff' fill-opacity='.09'/%3E%3C/svg%3E");
  --pattern: var(--pat-dither);

  --mb-h: 24px;
  --deck-h: clamp(160px, 24vh, 214px);

  /* tout le texte en police pixel rétro ; VT323 pour les afficheurs numériques */
  --retro: 'DotGothic16', 'VT323', 'Courier New', monospace;
  --px: 'VT323', 'DotGothic16', 'Courier New', monospace;

  /* petits dessins vectoriels réutilisés */
  --tri-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='5' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h9v1H8v1H7v1H6v1H5v1H4V4H3V3H2V2H1V1H0z' fill='%23ebe6d9'/%3E%3C/svg%3E");
  --tri-up-s: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h1v1h1v1h1v1h1v1H0V3h1V2h1V1h1z' fill='%23ebe6d9'/%3E%3C/svg%3E");
  --tri-dn-s: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z' fill='%23ebe6d9'/%3E%3C/svg%3E");
  --tri-up-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h1v1h1v1h1v1h1v1H0V3h1V2h1V1h1z' fill='%2309090a'/%3E%3C/svg%3E");
  --tri-dn-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='7' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h7v1H6v1H5v1H4v1H3V3H2V2H1V1H0z' fill='%2309090a'/%3E%3C/svg%3E");
  --cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 1l8 8M9 1L1 9' stroke='%23ebe6d9' stroke-width='1.3' stroke-linecap='square'/%3E%3C/svg%3E");
  --sizebox: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' shape-rendering='crispEdges'%3E%3Cpath d='M.5.5h6v6h-6z' fill='none' stroke='%23aca799'/%3E%3Cpath d='M3.5 3.5h7v7h-7z' fill='%231c1c1f' stroke='%23aca799'/%3E%3C/svg%3E");
}

body[data-accent='amber'] { --accent: #ffb63d; --glow: rgba(255, 160, 40, .5); }
body[data-accent='green'] { --accent: #8cff6e; --glow: rgba(90, 255, 60, .42); }
body[data-accent='blue']  { --accent: #8fd9ff; --glow: rgba(80, 190, 255, .45); }

body[data-tint='night']  { --desk: #161b2e; }
body[data-tint='plum']   { --desk: #271826; }
body[data-tint='forest'] { --desk: #14231a; }

body[data-pattern='dots']   { --pattern: var(--pat-dots); }
body[data-pattern='diag']   { --pattern: var(--pat-diag); }
body[data-pattern='bricks'] { --pattern: var(--pat-bricks); }
body[data-pattern='plain']  { --pattern: none; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--desk);
  background-image: var(--pattern);
  color: var(--ink);
  font: 14px/1.45 var(--retro);
  -webkit-user-select: none;
  user-select: none;
  cursor: default;
}
::selection { background: var(--ink); color: var(--void); }
button, input, select, textarea { font: inherit; color: inherit; }
/* police à graisse unique : pas de faux gras baveux, l'italique reste permis */
* { font-synthesis: style; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.selectable { -webkit-user-select: text; user-select: text; cursor: auto; }

/* ---------- icônes pixel-art 1 bit (colorées par le thème) ---------- */
svg.px { shape-rendering: crispEdges; display: block; flex: none; }
.px .k, .px .c { fill: var(--ink); }
.px .w { fill: var(--void); }
.px .m { fill: var(--ink-3); }
.px .g { fill: var(--ink-2); }
/* sur fond clair (élément sélectionné, menu survolé), l'icône s'inverse */
.mb-title.open .px .k, .mb-title.open .px .c,
.menu button:not(:disabled):hover .px .k, .menu button:not(:disabled):hover .px .c,
.menu button:focus-visible .px .k, .menu button:focus-visible .px .c,
.menu button.flash .px .k, .menu button.flash .px .c,
.desk-icon.sel .px .k, .desk-icon.sel .px .c { fill: var(--void); }
.mb-title.open .px .w, .menu button:not(:disabled):hover .px .w, .menu button:focus-visible .px .w,
.menu button.flash .px .w, .desk-icon.sel .px .w { fill: var(--ink); }
.menu button:disabled .px { opacity: .4; }

/* ============================================================
   BARRE DES MENUS
   ============================================================ */
.menubar {
  flex: none;
  height: var(--mb-h);
  position: relative; z-index: 60;
  display: flex; justify-content: space-between; align-items: stretch;
  padding: 0 10px;
  background: var(--void);
  border-bottom: 1px solid var(--ink);
  font: 16px/1 var(--retro);
}
.menus { display: flex; align-items: stretch; }
.mb-title {
  display: flex; align-items: center; gap: 6px;
  padding: 0 10px;
  border: 0; background: none; color: var(--ink);
  font: inherit; white-space: nowrap;
}
.mb-title.open { background: var(--ink); color: var(--void); }
.mb-title:focus-visible { outline: 1px dotted var(--ink); outline-offset: -3px; }
.mb-right { display: flex; align-items: stretch; }
.mb-icon { border: 0; background: none; padding: 0 8px; display: grid; place-items: center; }
.mb-icon:focus-visible { outline: 1px dotted var(--ink); outline-offset: -3px; }
.clock { display: flex; align-items: center; padding: 0 8px 0 6px; }

.menu {
  position: fixed; top: calc(var(--mb-h) - 1px); z-index: 70;
  min-width: 212px; padding: 3px 0;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 #000;
  font: 16px/1 var(--retro);
}
.menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 4px 18px 4px 6px;
  border: 0; background: none; color: var(--ink);
  font: inherit; text-align: left; white-space: nowrap;
}
.menu .mk { width: 12px; flex: none; display: grid; place-items: center; }
.menu .lab { flex: 1; }
.menu .sc { margin-left: 26px; color: var(--ink-2); }
.menu button:not(:disabled):hover, .menu button:focus-visible, .menu button.flash { background: var(--ink); color: var(--void); outline: 0; }
.menu button:not(:disabled):hover .sc, .menu button:focus-visible .sc { color: var(--paper-3); }
.menu button.flash-off { background: none; color: var(--ink); }
.menu button:disabled { color: var(--ink-3); cursor: default; }
.menu hr { margin: 3px 0; border: 0; border-top: 1px dotted var(--ink-3); }

/* ============================================================
   FENÊTRES (outils) et FENÊTRE DU MINUTEUR
   ============================================================ */
.win, .deck {
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 #000;
}
.win { position: absolute; min-width: 240px; min-height: 120px; }
.win.max { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
.win.shade { height: auto !important; min-height: 0; }
.win.shade > :not(.win-title) { display: none !important; }
.win.opening { visibility: hidden; }

.win-title {
  flex: none; position: relative;
  height: 22px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--ink);
  touch-action: none;
}
.win-title::before {        /* les rayures de la fenêtre active */
  content: ''; position: absolute; left: 2px; right: 2px; top: 5px; height: 11px;
  background: repeating-linear-gradient(to bottom, var(--ink-2) 0 1px, transparent 1px 2px);
  opacity: 0;
}
.win.active .win-title::before, .deck .win-title::before { opacity: 1; }
.win-name {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%);
  max-width: calc(100% - 96px);
  padding: 0 9px;
  background: var(--paper-2);
  font: 16px/22px var(--retro);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.win:not(.active) .win-name { color: var(--ink-3); }
.tb {
  position: absolute; top: 4px; z-index: 1;
  width: 13px; height: 13px; padding: 0;
  border: 1px solid var(--ink);
  background: var(--paper-2);
  box-shadow: 0 0 0 2px var(--paper-2);
}
.tb-close { left: 8px; }
.tb-zoom { right: 8px; }
.tb-shade { right: 28px; }
.tb-zoom::after { content: ''; position: absolute; left: 0; top: 0; width: 6px; height: 6px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.tb-shade::after { content: ''; position: absolute; left: 0; right: 0; top: 3px; height: 5px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.tb:active { background: var(--ink); }
.tb:active::after { border-color: var(--void); }
.tb:focus-visible { outline: 1px dotted var(--ink); outline-offset: 2px; }
.win:not(.active) .tb { opacity: .3; }
.win-body { flex: 1; min-height: 0; overflow: auto; position: relative; }
.win-resize {
  position: absolute; right: 0; bottom: 0; z-index: 2;
  width: 15px; height: 15px;
  cursor: nwse-resize; touch-action: none;
  background: var(--paper-2) var(--sizebox) no-repeat 2px 2px;
  border-left: 1px solid var(--ink-3); border-top: 1px solid var(--ink-3);
}
.win.max .win-resize { display: none; }

.zoom-layer { position: fixed; inset: 0; z-index: 150; pointer-events: none; }
.zoom-layer i { position: absolute; border: 1px solid var(--ink); }

/* ---------- la fenêtre du minuteur ---------- */
.deck {
  flex: none;
  position: relative; z-index: 40;
  margin: 8px 10px 0;
  height: var(--deck-h);
  transition: height .32s cubic-bezier(.3, .8, .3, 1);
}
.full .deck { height: calc(100dvh - var(--mb-h) - 18px); }
.deck .win-name { max-width: calc(100% - 60px); }

.deck-body { flex: 1; min-height: 0; display: grid; gap: 10px 14px; padding: 10px; }
.docked .deck-body { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'screen ctrl'; }
.full .deck-body { grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: 'screen' 'ctrl'; gap: 14px; padding: 14px; }

/* l'écran cathodique où s'affiche le temps */
.screen {
  grid-area: screen;
  position: relative;
  min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 4px;
  padding: 6px 18px 10px;
  background: radial-gradient(120% 100% at 50% 42%, #111113, #040405 72%);
  border: 1px solid var(--ink-3);
  border-radius: 14px / 16px;
  box-shadow: inset 0 0 0 1px #000, inset 0 0 30px #000;
  overflow: hidden;
}
.screen::after {           /* lignes de balayage */
  content: ''; position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .3) 2px 3px);
}
.full .screen { padding: clamp(10px, 2.2vh, 24px) clamp(16px, 3.4vw, 52px) clamp(14px, 2.8vh, 30px); border-radius: 26px / 30px; gap: clamp(6px, 1.4vh, 16px); }

.screen-top {
  flex: none; position: relative; z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: baseline; gap: 12px;
  font: 16px/1.2 var(--retro);
  color: var(--accent);
  text-shadow: 0 0 6px var(--glow);
  white-space: nowrap;
}
.full .screen-top { font-size: clamp(16px, 1.8vw, 28px); }
.st-status::before { content: ''; display: inline-block; width: .42em; height: .42em; margin-right: .55em; background: currentColor; vertical-align: .1em; }
.st-running .st-status::before { animation: blink 1s steps(1) infinite; }
.st-label { overflow: hidden; text-overflow: ellipsis; opacity: .85; }
.st-end { text-align: right; }

.digits { flex: 1; min-height: 0; width: 100%; display: block; filter: drop-shadow(0 0 5px var(--glow)); }
.full .digits { filter: drop-shadow(0 0 10px var(--glow)) drop-shadow(0 0 2px var(--glow)); }
.digits path { fill: var(--accent); }
.st-paused .digits, .st-done .digits { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* le petit mot, en bas du grand minuteur */
.love {
  flex: none; position: relative; z-index: 1;
  margin: 0; text-align: center;
  font: clamp(16px, 1.8vw, 28px)/1.3 var(--retro);
  color: var(--accent);
  text-shadow: 0 0 6px var(--glow);
}
.love .heart { display: inline-block; width: 1.05em; height: .93em; margin-left: .45em; vertical-align: -.06em; filter: drop-shadow(0 0 5px rgba(255, 80, 115, .75)); }

.progress { height: 12px; padding: 1px; border: 1px solid var(--ink); background: var(--void); }
.progress i { display: block; height: 100%; width: 0; background: var(--ink); }
.deck-bar { flex: none; position: relative; z-index: 1; height: 11px; border-color: var(--accent); box-shadow: 0 0 6px var(--glow); }
.deck-bar i { background: var(--accent); }
.full .deck-bar { height: clamp(12px, 1.8vh, 18px); }

/* commandes */
.deck-ctrl { grid-area: ctrl; min-width: 0; display: flex; }
.docked .deck-ctrl { flex-direction: column; justify-content: center; gap: 10px; width: 250px; }
.full .deck-ctrl { flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 30px; }

.setup { display: flex; gap: 10px; }
.docked .setup { flex-direction: column; }
.full .setup { flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 28px; }
.docked .only-full { display: none; }
.setup-row { display: flex; align-items: center; gap: 8px; }
.lbl, .unit { font: 15px var(--retro); color: var(--ink-2); }
.spin { display: inline-flex; align-items: center; gap: 4px; }
.spin .field { width: 50px; padding: 1px 6px; font: 22px/1 var(--px); text-align: right; }
.full .spin .field { width: 60px; font-size: 26px; }
.arrows {
  display: inline-flex; flex-direction: column;
  width: 13px; height: 24px;
  border: 1px solid var(--ink); border-radius: 6px;
  background: var(--paper-2);
  overflow: hidden;
}
.arrows button { flex: 1; padding: 0; border: 0; background: no-repeat center / 7px 4px; }
.arrows button:first-child { background-image: var(--tri-up-s); border-bottom: 1px solid var(--ink); }
.arrows button:last-child { background-image: var(--tri-dn-s); }
.arrows button:first-child:active { background-color: var(--ink); background-image: var(--tri-up-i); }
.arrows button:last-child:active { background-color: var(--ink); background-image: var(--tri-dn-i); }
.full .arrows { height: 28px; }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.presets .btn { min-height: 22px; padding: 2px 10px; }

.deck-btns { display: flex; align-items: center; gap: 8px; }
.docked .deck-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.docked .deck-btns .default { grid-column: 1 / -1; margin: 4px 4px 2px; }
.full .deck-btns .btn { padding: 8px 24px; font-size: 18px; border-radius: 9px; }
.full .deck-btns .default { margin: 6px; }
.deck-toggle { align-self: center; }
.docked .deck-toggle { width: 100%; }
/* en grand minuteur, les commandes grandissent aussi */
.full .lbl, .full .unit { font-size: 16px; }
.full .presets .btn { min-height: 26px; padding: 3px 12px; font-size: 16px; }
.full .deck-toggle { padding: 6px 16px; font-size: 16px; }

/* qui est visible selon l'état du minuteur */
.st-idle #btnPause, .st-idle #btnPlus, .st-idle #btnStop,
.st-done #btnPause, .st-done #btnPlus, .st-done #btnStop,
.st-running #setup, .st-running #btnStart,
.st-paused #setup, .st-paused #btnStart { display: none; }

/* ============================================================
   BUREAU
   ============================================================ */
.workspace { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.full .workspace { visibility: hidden; }
.desk-icons {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; flex-wrap: wrap-reverse; align-content: flex-start;
  gap: 6px 6px; padding: 14px 14px;
}
.desk-icon {
  width: 92px; padding: 4px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 0; background: none; color: var(--ink);
  font: 13px/1.25 var(--retro); text-align: center;
}
.desk-icon span { padding: 1px 4px; background: var(--paper); }
.desk-icon.sel span { background: var(--ink); color: var(--void); }
.desk-icon:focus-visible { outline: 0; }
.desk-icon:focus-visible span { outline: 1px dotted var(--ink); outline-offset: 1px; }

/* ============================================================
   CONTRÔLES STANDARD
   ============================================================ */
.btn {
  min-height: 24px; padding: 3px 14px;
  border: 1px solid var(--ink); border-radius: 7px;
  background: var(--paper-2); color: var(--ink);
  font: 15px/1.15 var(--retro);
  white-space: nowrap;
}
.btn:hover { background: var(--paper-3); }
.btn:active, .btn.down, .btn.sel { background: var(--ink); color: var(--void); }
.btn:focus-visible { outline: 1px dotted var(--ink); outline-offset: 2px; }
.btn.default { margin: 5px; box-shadow: 0 0 0 2px var(--paper), 0 0 0 5px var(--ink); }
.btn:disabled { color: var(--ink-3); border-color: var(--ink-3); background: var(--paper-2); cursor: default; }

.field {
  min-height: 24px; padding: 3px 6px;
  border: 1px solid var(--ink-2); border-radius: 0;
  background: var(--void); color: var(--ink);
  font: 14px/1.3 var(--retro);
  -webkit-user-select: text; user-select: text;
}
.field::placeholder { color: var(--ink-3); }
.field:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.field.bad { border-color: var(--red); box-shadow: 0 0 0 1px var(--red); }
.field.mono { font: 20px/1.1 var(--px); }
textarea.field { resize: none; display: block; width: 100%; }
input[type='number'] { -moz-appearance: textfield; appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select.field {
  -webkit-appearance: none; appearance: none;
  padding-right: 26px;
  border-color: var(--ink);
  box-shadow: 1px 1px 0 var(--ink);
  background: var(--paper-2) var(--tri-down) no-repeat right 8px center;
  font: 14px var(--retro);
}
select.field option { background: var(--paper); color: var(--ink); }

input[type='checkbox'], input[type='radio'] {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; margin: 0 7px 0 0; flex: none;
  border: 1px solid var(--ink); background: var(--void);
  vertical-align: -2px;
}
input[type='radio'] { border-radius: 50%; }
input[type='checkbox']:checked { background: var(--void) var(--cross) center / 10px no-repeat; }
input[type='radio']:checked { background: radial-gradient(circle, var(--ink) 0 2.4px, var(--void) 3px); }
input[type='checkbox']:focus-visible, input[type='radio']:focus-visible { outline: 1px dotted var(--ink); outline-offset: 2px; }
label.opt { display: inline-flex; align-items: center; white-space: nowrap; }

fieldset.group { margin: 0; padding: 8px 10px 10px; border: 1px solid var(--ink-3); min-width: 0; }
fieldset.group legend { padding: 0 5px; font: 15px var(--retro); color: var(--ink-2); }

.tabs { display: flex; flex-wrap: wrap; padding: 0 8px; position: relative; z-index: 1; margin-bottom: -1px; }
.tab {
  margin-right: -1px; padding: 4px 12px;
  border: 1px solid var(--ink-3); border-bottom-color: var(--ink);
  border-radius: 7px 7px 0 0;
  background: var(--paper-2); color: var(--ink-2);
  font: 14px var(--retro); white-space: nowrap;
}
.tab.sel { position: relative; z-index: 1; background: var(--paper); color: var(--ink); border-color: var(--ink); border-bottom-color: var(--paper); }
.tab:focus-visible { outline: 1px dotted var(--ink); outline-offset: -4px; }
.tab-panel { border: 1px solid var(--ink); padding: 12px; background: var(--paper); position: relative; }

.sunken { background: var(--void); border: 1px solid var(--ink-2); }
.status { flex: none; display: flex; padding-right: 16px; border-top: 1px solid var(--ink-4); font-size: 13px; color: var(--ink-2); }
.status span { padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 21px; }
.status .grow { flex: 1; }
.hint { margin: 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.5; }
.col { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.listbox { margin: 0; padding: 2px 0; list-style: none; background: var(--void); border: 1px solid var(--ink-2); overflow-y: auto; }
.listbox button { width: 100%; padding: 3px 10px; border: 0; background: none; color: var(--ink); text-align: left; font: 14px var(--retro); white-space: nowrap; }
.listbox button:hover { background: var(--paper-3); }
.listbox button.sel { background: var(--ink); color: var(--void); }
.listbox button:focus-visible { outline: 1px dotted var(--ink); outline-offset: -2px; }

/* barres de défilement d'époque */
* { scrollbar-color: var(--ink-3) var(--paper-2); }
::-webkit-scrollbar { width: 15px; height: 15px; }
::-webkit-scrollbar-track { background-color: var(--paper-2); background-image: var(--pat-dither); border-left: 1px solid var(--ink-3); }
::-webkit-scrollbar-thumb { background: var(--paper-3); border: 1px solid var(--ink-2); }
::-webkit-scrollbar-corner { background: var(--paper-2); }

/* ============================================================
   BOÎTES DE DIALOGUE (cadre double, sans barre de titre)
   ============================================================ */
.modal-layer { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .38); }
.dialog {
  width: min(460px, 100%);
  padding: 20px 20px 14px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 5px var(--ink), 3px 3px 0 #000;
}
.dialog-body { display: flex; gap: 16px; padding: 4px 4px 0; font: 14px/1.6 var(--retro); }
.dialog-body p { margin: 0 0 6px; }
.dialog-body .big { margin-bottom: 8px; font: 24px/1.2 var(--retro); }
.dialog-btns { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px 8px; margin-top: 10px; }
.dialog-btns .btn { min-width: 86px; }

/* ============================================================
   DÉMARRAGE, COINS DE L'ÉCRAN, EFFET CATHODIQUE
   ============================================================ */
.boot {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  background-color: var(--desk); background-image: var(--pattern);
  cursor: pointer;
  transition: opacity .35s;
}
.boot.out { opacity: 0; pointer-events: none; }
.boot-center { display: flex; flex-direction: column; align-items: center; }
.boot-box {
  width: min(380px, calc(100vw - 32px));
  padding: 22px 26px 24px;
  text-align: center;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: inset 0 0 0 2px var(--paper), inset 0 0 0 5px var(--ink), 3px 3px 0 #000;
}
.boot-title { font: 34px/1 var(--retro); letter-spacing: 1px; }
.boot-msg { min-height: 1.3em; margin: 12px 0 14px; font: 15px/1.3 var(--retro); color: var(--ink-2); }
.boot-msg.hi { color: var(--ink); }
.boot-box .progress i { transition: width .15s linear; }
.boot-ext { position: absolute; left: 18px; bottom: 16px; right: 18px; display: flex; flex-wrap: wrap; gap: 10px; }

.corners i {
  position: fixed; z-index: 600; width: 10px; height: 10px; pointer-events: none;
  background: radial-gradient(circle at 100% 100%, transparent 9.5px, #000 10px);
}
.corners i:nth-child(1) { top: 0; left: 0; }
.corners i:nth-child(2) { top: 0; right: 0; transform: scaleX(-1); }
.corners i:nth-child(3) { bottom: 0; left: 0; transform: scaleY(-1); }
.corners i:nth-child(4) { bottom: 0; right: 0; transform: scale(-1); }

.crt { display: none; position: fixed; inset: 0; z-index: 400; pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .2) 2px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, .35)); }
.crt-on .crt { display: block; }

/* ============================================================
   OUTILS
   ============================================================ */

/* --- Calculatrice --- */
.calc { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 8px 8px 10px; }
.lcd {
  flex: 1; min-height: 132px;
  display: flex; flex-direction: column;
  padding: 6px 10px 7px;
  background: var(--void); color: var(--ink);
  border: 1px solid var(--ink); border-radius: 7px;
  box-shadow: inset 0 0 18px #000;
  font-family: var(--px);
}
.lcd-tape { flex: 1; min-height: 0; overflow-y: auto; font-size: 18px; line-height: 1.12; color: var(--ink-2); scrollbar-width: thin; }
.lcd-tape button { display: block; width: 100%; padding: 0 2px; border: 0; background: none; font: inherit; color: inherit; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lcd-tape button:hover { background: var(--paper-3); color: var(--ink); }
.lcd-in {
  flex: none; width: 100%;
  margin-top: 2px; padding: 3px 0 0;
  border: 0; border-top: 1px dashed var(--ink-4); outline: 0; background: transparent;
  font: 27px/1.1 var(--px); color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.lcd-in::placeholder { color: var(--ink-3); }
.lcd-out { flex: none; min-height: 38px; font-size: 38px; line-height: 1; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 0 8px rgba(255, 238, 200, .22); -webkit-user-select: text; user-select: text; }
.lcd-out.live { color: var(--ink-3); text-shadow: none; }
.lcd-out.err { font-size: 24px; line-height: 38px; color: var(--red); }
.lcd-sub { flex: none; min-height: 19px; font-size: 19px; line-height: 1; text-align: right; color: var(--ink-2); }
.lcd sup, table.grid td.n sup { font-size: .62em; line-height: 1; vertical-align: top; }
.lcd-empty { margin: 4px 0; font-size: 18px; line-height: 1.15; color: var(--ink-3); }
.calc-bar { flex: none; display: flex; align-items: center; gap: 14px; font: 14px var(--retro); }
.calc-bar .sp { flex: 1; }
.keys { flex: none; display: grid; grid-template-columns: repeat(5, 1fr) 8px repeat(5, 1fr); gap: 5px; }
.key { min-height: 30px; padding: 0; border-radius: 6px; font: 14px var(--retro); }
.key.num { background: var(--paper-3); font-size: 16px; }
.key.op { font-size: 16px; }
.key.red { color: var(--red); }
.key.eq { background: var(--ink); color: var(--void); font-size: 18px; }
.key.eq:active { background: var(--paper-2); color: var(--ink); }
.key:active { background: var(--ink); color: var(--void); }
.key sup { font-size: .7em; line-height: 0; }
.key i { line-height: 1; }

/* --- Grapheur --- */
.graph { display: flex; flex-direction: column; height: 100%; padding: 8px 8px 0; gap: 6px; }
.graph-main { flex: 1; min-height: 0; display: flex; gap: 8px; }
.graph-side { flex: none; width: 228px; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; }
.fn-row { display: flex; align-items: center; gap: 6px; }
.fn-row label { width: 54px; font: 15px var(--retro); white-space: nowrap; }
.fn-row .field { flex: 1; min-width: 0; font: 19px/1.1 var(--px); }
.chip { width: 9px; height: 20px; flex: none; background: var(--c); box-shadow: 0 0 6px var(--c); }
.graph-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.graph-view { flex: 1; min-width: 0; position: relative; background: var(--void); border: 1px solid var(--ink-2); }
.graph-view canvas { display: block; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.graph-view canvas.grab { cursor: grabbing; }

/* --- Équations --- */
.eq { display: flex; flex-direction: column; height: 100%; padding: 10px 8px 8px; }
.eq .tab-panel { flex: 1; min-height: 0; overflow: auto; }
.eq-line { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font: 16px var(--retro); }
.eq-line .field { width: 62px; text-align: right; font: 19px/1.1 var(--px); }
.eq-line .field.wide { width: auto; flex: 1; min-width: 150px; text-align: left; }
.eq-line .btn { font-style: normal; }
.result {
  min-height: 76px; margin-top: 10px; padding: 9px 12px;
  background: var(--void); border: 1px solid var(--ink-2);
  font: 15px/1.75 var(--retro);
  -webkit-user-select: text; user-select: text; cursor: auto;
}
.result .k { color: var(--ink-2); font-style: italic; }
.result .dim { color: var(--ink-2); font-size: 13px; }
.result .warn { color: var(--red); }
.result p { margin: 0; }

/* --- Cercle trigonométrique --- */
.trig { display: flex; gap: 10px; height: 100%; padding: 8px; }
.trig-view { flex: 1; min-width: 0; background: var(--void); border: 1px solid var(--ink-2); }
.trig-view canvas { display: block; width: 100%; height: 100%; cursor: pointer; touch-action: none; }
.trig-side { flex: none; width: 232px; display: flex; flex-direction: column; gap: 9px; overflow: hidden auto; }
.trig-vals { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; align-items: baseline; font: 15px/1.35 var(--retro); }
.trig-vals dt { font-style: italic; white-space: nowrap; }
.trig-vals dd { margin: 0; text-align: right; -webkit-user-select: text; user-select: text; }
.trig-vals dd small { display: block; font: 16px/1 var(--px); color: var(--ink-2); }
.swatch { display: inline-block; width: 9px; height: 9px; margin-right: 6px; background: var(--c); box-shadow: 0 0 5px var(--c); }
.angle-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.angle-grid .btn { min-height: 24px; padding: 2px 0; border-radius: 5px; font: 14px var(--retro); }

/* --- Convertisseur --- */
.conv { display: flex; gap: 10px; height: 100%; padding: 8px; }
.conv .listbox { flex: none; width: 130px; }
.conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.conv-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 6px; }
.conv-pair input { font: 21px/1.1 var(--px); text-align: right; }
.conv-eq { text-align: center; font: 20px/1 var(--px); color: var(--ink-2); }
.conv-table { flex: 1; min-height: 60px; overflow: auto; background: var(--void); border: 1px solid var(--ink-2); }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; -webkit-user-select: text; user-select: text; }
table.grid th { position: sticky; top: 0; z-index: 1; padding: 4px 8px; background: var(--paper-2); border-bottom: 1px solid var(--ink-2); text-align: left; font: 14px var(--retro); color: var(--ink-2); white-space: nowrap; }
table.grid td { padding: 3px 8px; border-bottom: 1px solid var(--ink-4); vertical-align: baseline; }
table.grid td.n { font: 18px/1.1 var(--px); text-align: right; white-space: nowrap; }
table.grid td.sym { font: 15px var(--retro); white-space: nowrap; }
table.grid td.u { font-size: 14px; white-space: nowrap; color: var(--ink-2); }
table.grid tr.pick { cursor: pointer; }
table.grid tr.pick:hover td { background: var(--ink); color: var(--void); }
table.grid tr.cur td { background: var(--paper-3); }

/* --- Constantes --- */
.consts { display: flex; flex-direction: column; height: 100%; padding: 8px 8px 0; gap: 8px; }
.consts .sunken { flex: 1; min-height: 0; overflow: auto; }
.consts .btn { min-height: 21px; padding: 1px 9px; }

/* --- Formulaire --- */
.help { display: flex; height: 100%; padding: 8px; gap: 8px; }
.help .listbox { flex: none; width: 172px; }
.help-page { flex: 1; min-width: 0; overflow-y: auto; padding: 14px 20px 20px; background: var(--void); border: 1px solid var(--ink-2); -webkit-user-select: text; user-select: text; cursor: auto; }
.help-page h2 { margin: 0 0 8px; padding-bottom: 6px; font: 22px var(--retro); border-bottom: 2px solid var(--ink); }
.help-page h3 { margin: 18px 0 4px; padding-bottom: 3px; font: 15px var(--retro); color: var(--ink-2); border-bottom: 1px dotted var(--ink-3); }
.fml { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 26px; }
.fml > div { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 0; border-bottom: 1px dotted var(--ink-4); font: 16px/1.35 var(--retro); }
.fml .note { margin-left: auto; font: 12.5px var(--retro); color: var(--ink-2); text-align: right; }
.fml.wide { grid-template-columns: 1fr; }
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 2px; line-height: 1.15; font-size: .92em; }
.frac > span:first-child { padding: 0 4px 1px; border-bottom: 1px solid currentColor; }
.frac > span:last-child { padding: 1px 4px 0; }
.binom { display: inline-flex; align-items: center; }
.binom > b { font-weight: 400; display: inline-block; transform: scaleY(2.1); }
.binom .frac > span:first-child { border-bottom: 0; }
.ov { text-decoration: overline; text-decoration-thickness: 1px; text-underline-offset: 0; }
.vec, .hat { position: relative; display: inline-block; }
.vec::before { content: ''; position: absolute; left: 4%; right: 12%; top: .05em; border-top: 1px solid currentColor; }
.vec::after { content: ''; position: absolute; right: 2%; top: calc(.05em - 3px); border: 3.5px solid transparent; border-right: 0; border-left: 6px solid currentColor; }
.hat::after { content: '^'; position: absolute; left: 0; right: 0; top: -.55em; text-align: center; font-size: .85em; font-style: normal; }
.rad { border-top: 1px solid currentColor; padding: 0 2px 0 1px; margin-left: -1px; }
.math i { font-style: italic; }
.math sup, .math sub { font-size: .7em; line-height: 0; }

/* --- Bloc-notes --- */
.notes { display: flex; flex-direction: column; height: 100%; padding: 8px 8px 10px; gap: 7px; }
.notes textarea { flex: 1; min-height: 0; padding: 6px 8px; font: 20px/1.25 var(--px); }
.symbols { display: flex; flex-wrap: wrap; gap: 3px; }
.symbols .btn { min-width: 26px; min-height: 24px; padding: 2px 3px; border-radius: 5px; font: 15px var(--retro); }

/* --- Statistiques --- */
.stats { display: flex; gap: 10px; height: 100%; padding: 8px; }
.stats-in { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.stats-in label { font: 14px var(--retro); }
.stats-in textarea { flex: 1; min-height: 50px; font: 19px/1.2 var(--px); }
.stats-out { flex: 1.25; min-width: 0; overflow: auto; background: var(--void); border: 1px solid var(--ink-2); }

/* --- Réglages, journal, à propos --- */
.prefs { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.prefs .row { gap: 7px 16px; }
.acc-pick { display: inline-block; width: 22px; height: 9px; margin-right: 6px; background: var(--c); box-shadow: 0 0 6px var(--c); }
.tint-pick { display: inline-block; width: 18px; height: 13px; margin-right: 6px; background: var(--c); border: 1px solid var(--ink-3); }
.pat-pick { display: inline-block; width: 26px; height: 18px; margin-right: 6px; background-color: #3a3a40; border: 1px solid var(--ink-3); }
.p-dither { background-image: var(--pat-dither); }
.p-dots { background-image: var(--pat-dots); }
.p-diag { background-image: var(--pat-diag); }
.p-bricks { background-image: var(--pat-bricks); }
.journal { display: flex; flex-direction: column; height: 100%; padding: 8px 8px 10px; gap: 8px; }
.journal .sunken { flex: 1; min-height: 0; overflow: auto; }
.journal-sum { font: 16px var(--retro); }
.about { padding: 16px 18px; line-height: 1.5; }
.about h2 { margin: 0 0 6px; font: 30px/1 var(--retro); }
.about kbd { display: inline-block; min-width: 20px; padding: 0 6px; text-align: center; border: 1px solid var(--ink-2); border-radius: 4px; background: var(--paper-2); font: 13px/1.5 var(--retro); }
.about ul { margin: 6px 0; padding-left: 18px; }
.about b { font-size: 16px; }
.about p { margin: 0 0 12px; font-size: 16px; line-height: 1.6; }
.about .sign { margin: 18px 0 0; text-align: right; font-size: 18px; color: var(--accent); text-shadow: 0 0 6px var(--glow); }

/* ============================================================
   PETITS ÉCRANS
   ============================================================ */
@media (max-width: 860px) {
  .docked .deck-ctrl { width: 196px; }
  .docked .spin .field { width: 44px; font-size: 20px; padding-left: 3px; }
  .docked .lbl { display: none; }
}
@media (max-width: 560px) {
  :root { --deck-h: 224px; }
  .menubar { padding: 0 4px; }
  .mb-title { padding: 0 7px; }
  .docked .deck-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; grid-template-areas: 'screen' 'ctrl'; padding: 8px; gap: 8px; }
  .docked .deck-ctrl { width: 100%; flex-direction: row; align-items: center; gap: 6px; }
  .docked .setup { flex-direction: row; }
  .docked .deck-btns { display: flex; flex: 1; gap: 6px; }
  .docked .deck-btns .btn { flex: 1; padding: 3px 4px; font-size: 13px; }
  .docked .deck-btns .default { margin: 4px; }
  .docked .deck-toggle { width: auto; padding: 3px 8px; font-size: 13px; }
  .full .deck-body { padding: 10px; }
  .graph-main, .trig, .conv, .help, .stats { flex-direction: column; }
  .graph-side, .trig-side, .conv .listbox, .help .listbox { width: auto; max-height: 132px; }
  .keys { gap: 4px; }
  .key { min-height: 28px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .deck, .boot { transition: none; }
  .st-status::before, .digits { animation: none !important; }
}
