/* Solys — design system et shell.
   Une seule source pour les couleurs, tailles, rayons et espacements.
   Les fragments rendus par le serveur (.note, .block, .copy, .field, .transcript,
   .chunks, .failed, .hint…) sont habillés ici sans changer leurs classes. */

/* ------------------------------------------------------------------ tokens */
:root {
  /* Couleurs : neutres chauds, un seul noir pour l'action principale. */
  --bg: #f5f4f1;            /* toile de l'application, derrière le workspace */
  --surface: #ffffff;       /* workspace, cartes */
  --surface-2: #faf9f7;     /* zones secondaires : panneau, encadré enregistreur */
  --surface-3: #f1f0ec;     /* survol, sélection */
  --surface-4: #e9e7e2;     /* pressé */
  --border: #e8e6e1;
  --border-strong: #d7d4cd;
  --text: #1c1b19;
  --text-2: #55524c;
  --text-3: #8b877f;
  --primary: #1c1b19;
  --primary-hover: #33312d;
  --on-primary: #ffffff;
  --focus: #2f6fde;
  --focus-ring: 0 0 0 3px rgba(47, 111, 222, .18);

  --success: #1d7a46;  --success-bg: #eef7f1;  --success-border: #bfdfca;
  --warning: #8a5a00;  --warning-bg: #fdf6e4;  --warning-border: #ecd79f;
  --danger:  #c2362b;  --danger-bg:  #fdf1ef;  --danger-border:  #f0c8c2;
  --record:  #d93b30;

  /* Typographie : police système, aucun appel à un service de polices tiers. */
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI",
          Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px;  --fs-sm: 13px;  --fs-base: 14px;  --fs-md: 15px;
  --fs-lg: 17px;  --fs-xl: 22px;  --fs-2xl: 28px;
  --lh-tight: 1.25;  --lh: 1.5;  --lh-text: 1.6;
  --fw-regular: 400;  --fw-medium: 500;  --fw-semibold: 600;
  --tracking-label: .06em;

  /* Espacements : grille de 4. */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px;  --s-4: 16px;  --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;

  /* Rayons, bordures, ombres. */
  --r-sm: 6px;  --r-md: 8px;  --r-lg: 12px;  --r-xl: 16px;  --r-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(28, 27, 25, .05);
  --shadow-sm: 0 1px 3px rgba(28, 27, 25, .06), 0 1px 2px rgba(28, 27, 25, .04);
  --shadow-md: 0 8px 24px rgba(28, 27, 25, .08), 0 2px 6px rgba(28, 27, 25, .04);
  --shadow-lg: 0 24px 48px rgba(28, 27, 25, .14), 0 4px 12px rgba(28, 27, 25, .06);

  /* Proportions du shell. */
  --sidebar-w: 240px;
  --panel-w: 328px;
  --topbar-h: 52px;
  --content-max: 760px;
  --gutter: 8px;           /* marge entre la toile et le workspace */

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t-fast: 120ms;
  --t: 200ms;
}

/* ------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor;
        stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden;
                   clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ typographie */
.title-1 { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); line-height: var(--lh-tight);
           letter-spacing: -.015em; }
.title-2 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: var(--lh-tight);
           letter-spacing: -.005em; }
.title-3 { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.lead    { font-size: var(--fs-md); color: var(--text-2); line-height: var(--lh-text); }
.muted   { color: var(--text-2); }
.subtle  { color: var(--text-3); }
.eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-medium); text-transform: uppercase;
           letter-spacing: var(--tracking-label); color: var(--text-3); }
.tabular { font-variant-numeric: tabular-nums; }
kbd { font-family: var(--font); font-size: var(--fs-xs); color: var(--text-2); background: var(--surface);
      border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-sm);
      padding: 0 var(--s-1); min-width: 20px; display: inline-block; text-align: center; line-height: 18px; }

/* ---------------------------------------------------------------- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 36px; padding: 0 var(--s-4);
  font-size: var(--fs-base); font-weight: var(--fw-medium); line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r-md); cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn:disabled { cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong);
                 box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 30px; padding: 0 var(--s-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: 44px; padding: 0 var(--s-5); font-size: var(--fs-md); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: var(--r-md); background: transparent; color: var(--text-2); cursor: pointer;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn[aria-pressed="true"] { color: var(--text); }

/* ----------------------------------------------------------------- inputs */
.input {
  display: block; width: 100%; height: 40px; padding: 0 var(--s-3);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  font-size: var(--fs-md); box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.input::placeholder { color: var(--text-3); }
.input:hover { border-color: #c6c2ba; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
textarea.input { height: auto; min-height: 72px; padding: var(--s-2) var(--s-3); line-height: var(--lh); resize: vertical; }
.label { display: block; font-size: var(--fs-sm); font-weight: var(--fw-medium); margin-bottom: var(--s-2); }

/* ------------------------------------------------------------------ cartes */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); }
.card-muted { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-xl); }

/* ----------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--s-2);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1; white-space: nowrap;
  border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.badge.plain::before { display: none; }
.badge.success { color: var(--success); background: var(--success-bg); border-color: var(--success-border); }
.badge.success::before { background: var(--success); }
.badge.warning { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.badge.warning::before { background: #c58a12; }
.badge.danger  { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.badge.danger::before  { background: var(--danger); }
.badge.live::before { background: var(--record); animation: pulse 1.4s ease-in-out infinite; }
.badge.busy::before { background: transparent; width: 9px; height: 9px; border: 1.5px solid currentColor;
                      border-right-color: transparent; animation: spin .8s linear infinite; }

/* ----------------------------------------------------------------- alertes */
.alert {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--text-2); font-size: var(--fs-sm); line-height: var(--lh);
}
.alert .i { margin-top: 1px; width: 16px; height: 16px; }
.alert strong { color: var(--text); font-weight: var(--fw-semibold); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #6b4a07; }
.alert-warning .i { color: #b07a0c; }
.alert-danger  { background: var(--danger-bg); border-color: var(--danger-border); color: #8f2a22; }

/* =================================================================== SHELL
   Navigation gauche → contenu principal → panneau de contexte. */
/* Les deux volets sont des tiroirs, fermés à l'arrivée : on arrive sur la dictée,
   rien d'autre. Ils s'ouvrent par les deux boutons de la barre du haut. */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  height: 100vh; height: 100dvh;
}

/* ------------------------------------------------------------- sidebar */
.sidebar {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  padding: var(--s-4) var(--s-3) var(--s-3);
  background: var(--bg);
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; width: min(280px, 86vw);
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%); visibility: hidden;
  transition: transform var(--t) var(--ease), visibility 0s linear var(--t);
}
.shell[data-sidebar="open"] .sidebar {
  transform: none; visibility: visible; transition: transform var(--t) var(--ease);
}
.shell[data-sidebar="open"] > .scrim {
  display: block; position: fixed; inset: 0; z-index: 35; background: rgba(28, 27, 25, .2);
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-2) var(--s-5); min-width: 0; }
.brand-mark {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px;
  border-radius: var(--r-md); background: var(--primary); color: var(--on-primary);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { min-width: 0; line-height: 1.2; }
.brand-name { font-size: var(--fs-lg); font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.brand-sub { font-size: var(--fs-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: var(--s-4) var(--s-3) var(--s-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3); height: 36px; padding: 0 var(--s-3);
  border: 1px solid transparent; border-radius: var(--r-md); background: none; width: 100%;
  color: var(--text-2); font-size: var(--fs-base); font-weight: var(--fw-medium); text-decoration: none; text-align: left;
  cursor: pointer; white-space: nowrap;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current="page"] {
  background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-xs);
}
.nav-item .nav-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-meta { font-size: var(--fs-xs); color: var(--text-3); }

.sidebar-spacer { flex: 1; }
.sidebar-card { margin: var(--s-4) 0 var(--s-3); padding: var(--s-4); background: var(--surface);
                border: 1px solid var(--border); border-radius: var(--r-lg); }
.sidebar-card .title-3 { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-1); }
.sidebar-card .title-3 .i { width: 16px; height: 16px; color: var(--text-2); }
.sidebar-card p { font-size: var(--fs-sm); color: var(--text-2); line-height: var(--lh); }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: var(--s-3); display: flex; flex-direction: column; gap: 2px; }

.user { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-2) var(--s-1) var(--s-3); min-width: 0; }
.avatar {
  display: grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-4); color: var(--text-2); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  letter-spacing: .02em;
}
.user-text { flex: 1; min-width: 0; line-height: 1.25; }
.user-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: var(--fs-xs); color: var(--text-3); }
.user form { margin: 0; }

/* Rail : la sidebar réduite ne garde que les icônes. */

/* ----------------------------------------------------------- workspace */
.workspace {
  display: flex; flex-direction: column; min-width: 0; min-height: 0;
  margin: var(--gutter);
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.topbar {
  display: flex; align-items: center; gap: var(--s-2); flex: none;
  height: var(--topbar-h); padding: 0 var(--s-3) 0 var(--s-3);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: var(--s-2); min-width: 0; font-size: var(--fs-sm); color: var(--text-3); }
.crumbs .sep { color: var(--border-strong); }
.crumbs [aria-current] { color: var(--text); font-weight: var(--fw-medium); }
.topbar-divider { width: 1px; height: 18px; background: var(--border); margin: 0 var(--s-1); }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }

.workspace-body {
  position: relative; flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr);
}
.main { min-width: 0; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.main-inner { max-width: calc(var(--content-max) + 2 * var(--s-12)); margin: 0 auto;
              padding: var(--s-10) var(--s-12) var(--s-16); }

/* ---------------------------------------------------- panneau de contexte */
.panel {
  min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-2); border-left: 1px solid var(--border);
}
.panel-head { padding: var(--s-6) var(--s-6) var(--s-5); border-bottom: 1px solid var(--border); }
.panel-head .eyebrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.panel-head .title-2 { margin-bottom: var(--s-1); }
.panel-close { display: none; }
.panel-section { padding: var(--s-5) var(--s-6); border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: 0; }
.panel-section > .eyebrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.panel-empty { font-size: var(--fs-sm); color: var(--text-3); line-height: var(--lh); }

.stat-row { display: flex; gap: var(--s-6); margin-top: var(--s-4); }
.stat .stat-value { font-size: var(--fs-lg); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.stat .stat-label { font-size: var(--fs-xs); color: var(--text-3); }

/* Liste des encadrés : ce qui est collé, ce qui reste. */
.box-list { list-style: none; margin: 0 calc(-1 * var(--s-2)); padding: 0; display: flex; flex-direction: column; gap: 2px; }
.box-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; padding: var(--s-2);
  border: 1px solid transparent; border-radius: var(--r-md); background: none; text-align: left; cursor: pointer;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.box-item:hover { background: var(--surface-3); }
.box-item[aria-current="true"] { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-xs); }
.box-state { flex: none; width: 18px; height: 18px; border-radius: 50%; border: 1.5px dashed var(--border-strong);
             display: grid; place-items: center; }
.box-item[data-state="copied"] .box-state { border: 0; background: var(--success); }
.box-item[data-state="copied"] .box-state::after { content: ""; width: 8px; height: 4px; margin-top: -2px;
  border-left: 1.75px solid #fff; border-bottom: 1.75px solid #fff; transform: rotate(-45deg); }
.box-item[data-state="stale"] .box-state { border: 1.5px solid #c58a12; background: var(--warning-bg); }
.box-item[data-state="todo"] .box-state { border: 1.5px solid var(--border-strong); }
.box-text { flex: 1; min-width: 0; }
.box-title, .box-meta { display: block; }
.box-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.3;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box-item.sub .box-title { font-weight: var(--fw-regular); color: var(--text-2); }
.box-item.sub { padding-left: var(--s-6); }
.box-meta { font-size: var(--fs-xs); color: var(--text-3); }
.progress { height: 4px; border-radius: var(--r-pill); background: var(--surface-4); overflow: hidden; margin-bottom: var(--s-3); }
.progress > span { display: block; height: 100%; width: 0; background: var(--success); border-radius: inherit;
                   transition: width var(--t) var(--ease); }

.info-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.info-list li { display: flex; gap: var(--s-3); font-size: var(--fs-sm); color: var(--text-2); line-height: var(--lh); }
.info-list .i { width: 16px; height: 16px; margin-top: 2px; color: var(--text-3); }

.scrim { display: none; }

/* ================================================================ PAGE DICTÉE */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-6);
             padding-bottom: var(--s-6); margin-bottom: var(--s-8); border-bottom: 1px solid var(--border); }
.page-head .lead { margin-top: var(--s-2); max-width: 56ch; }

/* Enregistreur : la carte d'action principale. */
.recorder { padding: var(--s-6); }
.recorder-row { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.recorder-status { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recorder-state { font-size: var(--fs-sm); color: var(--text-3); }
#rec {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-3);
  height: 52px; min-width: 148px; padding: 0 var(--s-6) 0 var(--s-5);
  font-size: var(--fs-md); font-weight: var(--fw-semibold); letter-spacing: -.005em;
  color: var(--on-primary); background: var(--primary); border: 0; border-radius: var(--r-pill);
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
#rec::before {
  content: ""; width: 20px; height: 20px; background: currentColor;
  -webkit-mask: var(--icon-mic) center / contain no-repeat; mask: var(--icon-mic) center / contain no-repeat;
}
#rec:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
#rec:active { transform: scale(.98); }
#rec.on { background: var(--record); box-shadow: 0 0 0 6px rgba(217, 59, 48, .12); }
#rec.on:hover { background: #c5332a; }
#rec.on::before { -webkit-mask: none; mask: none; width: 12px; height: 12px; border-radius: 3px; }
#clock { font-size: var(--fs-2xl); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums;
         letter-spacing: -.01em; color: var(--text); line-height: 1; }
.recorder:has(#rec.on) #clock { color: var(--record); }
.recorder .rule { margin-top: var(--s-5); }

:root {
  --icon-mic: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z'/%3E%3Cpath d='M19 10v2a7 7 0 0 1-14 0v-2'/%3E%3Cpath d='M12 19v3'/%3E%3C/svg%3E");
  --icon-doc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4'/%3E%3Cpath d='M16 13H8'/%3E%3Cpath d='M16 17H8'/%3E%3Cpath d='M10 9H8'/%3E%3C/svg%3E");
  --icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E");
}

/* Mode développement : transcription simulée. */
.devbox { margin-top: var(--s-4); padding: var(--s-4); border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }
.devbox .hint { font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--s-2); }
#fake { display: block; width: 100%; min-height: 72px; padding: var(--s-2) var(--s-3); resize: vertical;
        background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); }
#fake:focus { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }

/* Erreurs réseau et micro : jamais silencieuses. */
#error:empty { display: none; }
#error { margin-top: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--danger-border);
         border-radius: var(--r-lg); background: var(--danger-bg); color: #8f2a22; font-size: var(--fs-sm); }
#error > div + div { margin-top: var(--s-1); }

/* ------------------------------------------------------------------ Note */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-4);
                margin: var(--s-12) 0 var(--s-2); }
.section-head .muted { font-size: var(--fs-sm); }
.section-sub { font-size: var(--fs-sm); color: var(--text-2); margin-bottom: var(--s-2); }

#doc:empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 220px; margin-top: var(--s-4); padding: var(--s-8);
  border: 1px dashed var(--border-strong); border-radius: var(--r-xl); background: var(--surface-2);
  color: var(--text-3); font-size: var(--fs-sm); text-align: center;
}
#doc:empty::before { content: ""; width: 28px; height: 28px; background: var(--text-3); opacity: .7;
  -webkit-mask: var(--icon-doc) center / contain no-repeat; mask: var(--icon-doc) center / contain no-repeat; }
#doc:empty::after { content: "La note apparaîtra ici, encadré par encadré, dans l'ordre de votre logiciel."; max-width: 36ch; }

/* Messages rendus par le serveur dans la note et le transcript. */
#doc p.failed, #live p.failed {
  margin: var(--s-4) 0 0; padding: var(--s-3) var(--s-4); border: 1px solid var(--danger-border);
  border-radius: var(--r-lg); background: var(--danger-bg); color: #8f2a22; font-size: var(--fs-sm); line-height: var(--lh);
}
#live p.failed { margin: 0 0 var(--s-3); }
#doc > p.hint, #doc > div > p.hint {
  display: flex; align-items: center; gap: var(--s-3); margin-top: var(--s-4); padding: var(--s-5) var(--s-5);
  border: 1px solid var(--border); border-radius: var(--r-xl); background: var(--surface-2);
  color: var(--text-2); font-size: var(--fs-sm);
}
#doc [hx-get] > p.hint::before {  /* « Mise en forme en cours… » */
  content: ""; flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--text); animation: spin .8s linear infinite;
}

.note .screen {
  margin: var(--s-8) 0 var(--s-3); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--text-3);
}
.note .screen:first-child { margin-top: var(--s-5); }

.block {
  position: relative; margin: 0 0 var(--s-3);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.block:hover { border-color: var(--border-strong); }
.block:focus-within, .block.is-selected { border-color: #b9c9ea; box-shadow: var(--focus-ring); }
.block .head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  min-height: 48px; padding: var(--s-2) var(--s-2) var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.block h4 { font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: var(--lh-tight); }
.block .field {
  display: block; width: 100%; min-height: 3.2rem; margin: 0; padding: var(--s-3) var(--s-4) var(--s-4);
  font-size: var(--fs-md); line-height: var(--lh-text); color: var(--text);
  background: transparent; border: 0; border-radius: 0 0 var(--r-lg) var(--r-lg);
  resize: none; overflow: hidden; field-sizing: content;
}
.block .field:focus { outline: none; }
.block .field::placeholder { color: var(--text-3); font-style: italic; }
.block .small.failed { margin: var(--s-3) var(--s-4) 0; padding: var(--s-2) var(--s-3); font-size: var(--fs-sm);
                       color: var(--warning); background: var(--warning-bg); border: 1px solid var(--warning-border);
                       border-radius: var(--r-md); }

/* Bouton Copier : un par encadré du logiciel. */
.copy {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 30px; padding: 0 var(--s-3);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
  color: var(--on-primary); background: var(--primary); border: 1px solid var(--primary); border-radius: var(--r-md);
  cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.copy::before { content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: var(--icon-copy) center / contain no-repeat; mask: var(--icon-copy) center / contain no-repeat; }
.copy:hover:not(:disabled) { background: var(--primary-hover); }
.copy:disabled { color: var(--text-3); background: var(--surface-3); border-color: var(--border); cursor: default; }

/* Déjà collé : le marqueur se voit d'un coup d'œil. */
.block.copied { border-color: var(--success-border); }
.block.copied .head { background: var(--success-bg); border-bottom-color: var(--success-border);
                      border-radius: var(--r-lg) var(--r-lg) 0 0; }
.block.copied .copy { color: var(--success); background: var(--surface); border-color: var(--success-border); }
.block.copied .copy::before { display: none; }  /* le texte « Copié ✓ » porte déjà la coche */
.block.copied .copy:hover { background: var(--success-bg); }
/* Modifié après copie : à recopier. */
.block.stale { border-color: var(--warning-border); }
.block.stale .head { background: var(--warning-bg); border-bottom-color: var(--warning-border);
                     border-radius: var(--r-lg) var(--r-lg) 0 0; }
.block.stale .copy { color: #fff; background: #a56c00; border-color: #a56c00; }
.block.stale .copy:hover { background: #8a5a00; }

/* Demande d'examen : rattachée à la stratégie qui la précède. */
.block.request { margin-left: var(--s-8); }
.block.request::before { content: ""; position: absolute; left: calc(-1 * var(--s-5)); top: -13px; width: 12px; height: 38px;
  border-left: 1.5px solid var(--border); border-bottom: 1.5px solid var(--border); border-bottom-left-radius: 8px; }
.block.request h4 { font-weight: var(--fw-medium); color: var(--text-2); }

/* Ressenti après la dernière copie. */
.feeling {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin-top: var(--s-6); padding: var(--s-3) var(--s-3) var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2);
  font-size: var(--fs-sm); color: var(--text-2);
  animation: rise var(--t) var(--ease);
}
.feeling[hidden] { display: none; }
.feeling > span:first-child { margin-right: auto; font-weight: var(--fw-medium); color: var(--text); }
.feeling button {
  height: 30px; padding: 0 var(--s-4); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  cursor: pointer; transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.feeling button:hover { background: var(--surface-3); border-color: #c6c2ba; }

/* ------------------------------------------- transcript (panneau de droite) */
#live .chunks { list-style: none; margin: 0 0 var(--s-3); padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
#live .chunks:empty { display: none; }
#live .chunks li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-2); }
#live .chunks li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
#live .chunks li.done::before { background: var(--success); }
#live .chunks li.pending::before { background: #c58a12; animation: pulse 1.4s ease-in-out infinite; }
#live .chunks li.failed { color: var(--danger); font-weight: var(--fw-medium); }
#live .chunks li.failed::before { background: var(--danger); }
#live .transcript {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); line-height: var(--lh-text); color: var(--text-2);
  padding: var(--s-3) var(--s-4); min-height: 88px; max-height: 40vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
}
#live .transcript:empty::before { content: "Le texte entendu s'affiche ici, morceau par morceau, pendant la dictée."; color: var(--text-3); }

/* ============================================================ pages d'accès */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.auth-card { width: 100%; max-width: 420px; padding: var(--s-10) var(--s-8) var(--s-8);
             background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-md); }
.auth-card .brand { padding: 0 0 var(--s-8); }
.auth-card .title-1 { font-size: var(--fs-xl); }
.auth-card .lead { margin-top: var(--s-2); font-size: var(--fs-base); }
.auth-form { margin-top: var(--s-6); display: flex; flex-direction: column; gap: var(--s-3); }
.auth-card .alert { margin-top: var(--s-5); }
.auth-card .alert[hidden] { display: none; }
.auth-foot { margin-top: var(--s-6); padding-top: var(--s-5); border-top: 1px solid var(--border);
             display: flex; gap: var(--s-2); align-items: flex-start; font-size: var(--fs-xs); color: var(--text-3); line-height: var(--lh); }
.auth-foot .i { width: 14px; height: 14px; margin-top: 2px; }

/* ============================================================== animations */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important;
                           transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ============================================================== responsive */

/* Panneau fermé à la demande sur grand écran. */
/* Le panneau de contexte : tiroir de droite, fermé tant qu'on ne l'ouvre pas. */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 20; width: min(var(--panel-w), 100%);
  box-shadow: var(--shadow-lg); transform: translateX(100%); visibility: hidden;
  transition: transform var(--t) var(--ease), visibility 0s linear var(--t);
}
.shell[data-panel="open"] .panel {
  transform: none; visibility: visible; transition: transform var(--t) var(--ease);
}
.panel-close { display: inline-grid; }
.shell[data-panel="open"] .workspace-body > .scrim {
  display: block; position: absolute; inset: 0; z-index: 15; background: rgba(28, 27, 25, .12);
}

@media (max-width: 1180px) {
  .main-inner { padding: var(--s-8) var(--s-8) var(--s-12); }
}

@media (max-width: 640px) {
  :root { --gutter: 0px; }
  .workspace { border-radius: 0; border: 0; box-shadow: none; }
  .main-inner { padding: var(--s-6) var(--s-4) var(--s-12); }
  .page-head { flex-direction: column; align-items: flex-start; margin-bottom: var(--s-6); }
  .title-1 { font-size: var(--fs-xl); }
  .recorder { padding: var(--s-5) var(--s-4); }
  #rec { flex: 1; }
  .recorder-status { flex: none; }
  .block.request { margin-left: var(--s-4); }
  .block.request::before { display: none; }
  .crumbs .crumb-root, .crumbs .sep { display: none; }
  .topbar-status { display: none; }
}

/* ------------------------------------------- une note par patient dicté */
.note + .note { margin-top: var(--s-10); padding-top: var(--s-8); border-top: 1px solid var(--border); }
.note-head {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin-bottom: var(--s-2);
}
.note-head .patient { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.note-head .muted { font-weight: var(--fw-regular); font-size: var(--fs-sm); }
/* Le repère reste dans le navigateur : il ne part jamais au serveur. */
.repere {
  flex: 1; min-width: 12rem; font: inherit; font-size: var(--fs-sm);
  padding: .35rem .6rem; border: 1px dashed var(--border-strong); border-radius: var(--r-md);
  background: transparent; color: var(--text);
}
.repere:focus { outline: 2px solid var(--primary); border-color: transparent; }
@media (max-width: 640px) { .repere { min-width: 0; } }
.consigne { margin: 0 0 var(--s-3); }
.consigne strong { color: var(--text); }

/* ------------------------------------------------- les dictées du jour */
.jour-liste { list-style: none; margin: var(--s-5) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.jour-item { display: flex; align-items: center; gap: var(--s-2); }
.jour-lien {
  flex: 1; display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md);
  text-decoration: none; color: var(--text);
}
.jour-lien:hover { border-color: var(--border-strong); background: var(--surface); }
.jour-heure { font-variant-numeric: tabular-nums; font-weight: var(--fw-semibold); }
.jour-quoi { flex: 1; }
.jour-reste { font-size: var(--fs-sm); }
/* La règle : discrète dans le volet, mais la première chose qu'on y lit. */
.rule-card { background: var(--warning-bg); border-color: var(--warning-border); }
.rule-card .title-3 .i { color: #b07a0c; }
.rule-card p { color: #6b4a07; }
