/* =====================================================================
   Solys — téléphone
   Chargée seulement sous 600 px de large (media de la balise <link>) :
   l'ordinateur et la tablette ne la lisent jamais, ils ne peuvent donc
   pas changer. Elle vient après solys.css et la surcharge.

   Une idée par écran, une action sous le pouce. Pas de cartes empilées,
   pas de dégradé, pas d'ombre décorative : des surfaces blanches, des
   filets fins, la couleur seulement pour l'action et l'état.
   ===================================================================== */

:root {
  --m-pad: 20px;                 /* marge latérale, partout la même */
  --m-bar: 56px;                 /* barre d'onglets du bas */
  --m-head: 52px;                /* barre de titre du haut */
  --m-safe-top: env(safe-area-inset-top, 0px);
  --m-safe-bottom: env(safe-area-inset-bottom, 0px);
  --m-line: #ebe9e4;
  --m-text: 16px;                /* sous 16 px, iOS zoome sur le champ touché */
  --m-small: 14px;
  --m-tiny: 12px;
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--surface); font-size: var(--m-text); -webkit-tap-highlight-color: transparent; }
button, a, input, textarea { touch-action: manipulation; }

/* Ce qui n'existe que sur le téléphone. */
.tabbar { display: flex; }
.m-state, .m-sub, .m-live { display: block; }
#pause { display: grid; }
.m-page { display: block; }
.ob-short { display: block; }

/* ----------------------------------------------------- barre d'onglets */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--m-bar) + var(--m-safe-bottom)); padding-bottom: var(--m-safe-bottom);
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--m-line);
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); text-decoration: none; font-size: 11px; font-weight: var(--fw-medium); letter-spacing: .01em;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
              stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"] svg { stroke-width: 2.2; }

/* ------------------------------------------------- l'écran de dictée */
.sidebar, .panel, .shell > .scrim, .workspace-body > .scrim { display: none !important; }
.shell { display: block; height: auto; min-height: 100dvh; }
.workspace { margin: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; min-height: 100dvh; }
.workspace-body { display: block; }
.main { overflow: visible; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--m-head) + var(--m-safe-top)); padding: var(--m-safe-top) var(--m-pad) 0;
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid transparent;
  -webkit-backdrop-filter: saturate(180%) blur(12px); backdrop-filter: saturate(180%) blur(12px);
}
body[data-phase="ready"] .topbar, body[data-phase="failed"] .topbar { border-bottom-color: var(--m-line); }
.topbar > .icon-btn, .topbar-divider, .topbar-end { display: none; }
.crumbs { font-size: 17px; }
.crumbs [aria-current] { font-weight: var(--fw-semibold); color: var(--text); }

.main-inner { padding: 0 var(--m-pad) calc(var(--m-bar) + var(--m-safe-bottom) + 24px); }
.page-head, .section-head, .section-sub, #doc:empty { display: none; }

/* L'enregistreur : tout l'écran quand il n'y a pas encore de note. */
.recorder {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center;
  grid-template-areas:
    "clock clock clock"
    "state state state"
    "live  live  live"
    ".     .     ."
    "pause rec   ."
    "sub   sub   sub"
    "alerts alerts alerts"
    "error error error"
    "fake  fake  fake";
  grid-template-rows: auto auto auto 1fr auto auto auto auto auto;
  min-height: calc(100dvh - var(--m-head) - var(--m-safe-top) - var(--m-bar) - var(--m-safe-bottom));
  margin: 0 calc(-1 * var(--m-pad)); padding: 32px var(--m-pad) 28px;
  background: none; border: 0; border-radius: 0; box-shadow: none;
}
.recorder-row, .recorder-status { display: contents; }
.recorder .consigne, #ui-rec-state { display: none; }

#clock { grid-area: clock; font-size: 56px; font-weight: 300; letter-spacing: -.03em; color: var(--text-3); line-height: 1.1; }
.m-state { grid-area: state; margin: 6px 0 0; font-size: 17px; font-weight: var(--fw-semibold); color: var(--text);
           display: flex; align-items: center; gap: 8px; }
.m-sub { grid-area: sub; margin: 20px 0 0; max-width: 30ch; text-align: center;
         font-size: var(--m-small); line-height: 1.45; color: var(--text-3); }
.m-sub strong { color: var(--text-2); font-weight: var(--fw-medium); }
.m-live { grid-area: live; width: 100%; margin: 24px 0 0; min-height: 3em; text-align: center;
          font-size: 15px; line-height: 1.5; color: var(--text-2);
          display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.m-live:empty { visibility: hidden; }
#alerts { grid-area: alerts; width: 100%; }
#error { grid-area: error; width: 100%; }
#fakebox { grid-area: fake; width: 100%; }

/* Le bouton : un rond sous le pouce. Micro au repos, carré rouge en écoute. */
#rec {
  grid-area: rec; width: 84px; height: 84px; min-width: 0; padding: 0; border-radius: 50%;
  font-size: 0; box-shadow: none; transition: background .15s ease, transform .1s ease;
}
#rec::before { width: 32px; height: 32px; }
#rec:active { transform: scale(.94); }
#rec.on { background: var(--record); color: #fff; box-shadow: 0 0 0 8px rgba(217, 59, 48, .12); }
#rec.on::before { width: 26px; height: 26px; border-radius: 6px; }
#rec:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

#pause {
  grid-area: pause; place-items: center; width: 56px; height: 56px; margin-right: 24px; justify-self: end;
  border: 1px solid var(--m-line); border-radius: 50%; background: var(--surface); color: var(--text);
  visibility: hidden;
}
#pause::before {
  content: ""; width: 18px; height: 18px;
  background: linear-gradient(90deg, currentColor 0 35%, transparent 35% 65%, currentColor 65%);
}
#pause:active { transform: scale(.94); }

/* Au repos : le bouton au centre, son nom dessous, rien d'autre. */
body[data-phase="idle"] .recorder, body[data-phase="closed"] .recorder {
  grid-template-areas: "." "rec" "state" "sub" "alerts" "error" "fake" ".";
  grid-template-columns: 1fr; grid-template-rows: 1fr auto auto auto auto auto auto 1.2fr;
}
body[data-phase="idle"] #clock, body[data-phase="idle"] #pause, body[data-phase="idle"] .m-live,
body[data-phase="closed"] #clock, body[data-phase="closed"] #pause, body[data-phase="closed"] .m-live { display: none; }
body[data-phase="idle"] .m-state, body[data-phase="closed"] .m-state { margin-top: 20px; }
body[data-phase="idle"] .m-sub, body[data-phase="closed"] .m-sub { margin-top: 8px; }

/* États : on doit toujours savoir si Solys écoute. */
.m-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; display: none; }
/* Le rouge est réservé au bouton et au point : le chrono reste à l'encre. */
.recorder:has(#rec.on) #clock { color: var(--text); }
body[data-phase="recording"] .m-state::before { display: block; background: var(--record); animation: m-rec 1.4s ease-in-out infinite; }
body[data-phase="recording"] #pause,
body[data-phase="paused"] #pause { visibility: visible; }
@keyframes m-rec { 50% { opacity: .3; } }

body[data-phase="paused"] .recorder:has(#rec.on) #clock { color: var(--text-3); }
body[data-phase="paused"] .m-state::before { display: block; background: var(--warning); }
/* En pause, l'action attendue est de reprendre : elle prend la couleur. Terminer reste rouge. */
body[data-phase="paused"] #rec { box-shadow: none; }
body[data-phase="paused"] #pause { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
body[data-phase="paused"] #pause::before {           /* lecture : reprendre */
  background: currentColor; clip-path: polygon(22% 10%, 22% 90%, 90% 50%); }

body[data-phase="processing"] #rec { background: var(--surface-3); color: var(--text-3); pointer-events: none; }
body[data-phase="processing"] #rec::before {
  -webkit-mask: none; mask: none; background: none; width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border-strong); border-top-color: var(--text); animation: m-spin .8s linear infinite;
}
@keyframes m-spin { to { transform: rotate(360deg); } }

/* Note prête : l'enregistreur se replie en une ligne, la note prend l'écran. */
body[data-phase="ready"] .recorder,
body[data-phase="failed"] .recorder {
  min-height: 0; padding: 14px var(--m-pad); column-gap: 12px;
  grid-template-columns: 1fr auto; justify-items: start;
  grid-template-areas: "state rec" "sub rec" "alerts alerts" "error error" "fake fake";
  grid-template-rows: auto auto auto auto auto;
  border-bottom: 1px solid var(--m-line);
}
body[data-phase="ready"] #clock, body[data-phase="ready"] #pause, body[data-phase="ready"] .m-live,
body[data-phase="failed"] #clock, body[data-phase="failed"] #pause, body[data-phase="failed"] .m-live { display: none; }
body[data-phase="ready"] .m-state, body[data-phase="failed"] .m-state { margin: 0; font-size: 15px; }
body[data-phase="ready"] .m-sub, body[data-phase="failed"] .m-sub { margin: 2px 0 0; text-align: left; max-width: none; }
body[data-phase="ready"] #rec, body[data-phase="failed"] #rec { width: 48px; height: 48px; }
body[data-phase="ready"] #rec::before, body[data-phase="failed"] #rec::before { width: 22px; height: 22px; }
body[data-phase="ready"] .m-state::before { display: block; background: var(--success); }

/* ------------------------------------------------------------- la note */
#doc { margin: 0 calc(-1 * var(--m-pad)); }
#doc > .alert, #doc > p.failed, #doc > p.hint { margin: 16px var(--m-pad) 0; border-radius: 10px; }

/* Les patients : une rangée qui défile au pouce, collée sous le titre. */
.patients {
  position: sticky; top: calc(var(--m-head) + var(--m-safe-top)); z-index: 10;
  flex-wrap: nowrap; overflow-x: auto; gap: 8px; margin: 0; padding: 10px var(--m-pad);
  background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--m-line);
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.patients::-webkit-scrollbar { display: none; }
.alert + .patients { margin-top: 16px; }
.onglet { flex: none; height: 36px; padding: 0 12px; border-radius: 18px; font-size: var(--m-small);
          scroll-snap-align: start; border-color: var(--m-line); }
.onglet-repere { max-width: 8ch; }

.note { padding: 0 var(--m-pad); }
/* L'onglet dit déjà qui : l'entête de la note serait un doublon. */
.note-head { display: none; }
.note-head .patient { font-size: 20px; letter-spacing: -.01em; }
.note-head .lieu { background: none; padding: 0; font-size: 20px; font-weight: var(--fw-semibold); color: var(--text-3); }
.repere { flex-basis: 100%; min-width: 0; border: 0; border-bottom: 1px solid var(--m-line); border-radius: 0;
          padding: 8px 0; font-size: var(--m-text); }
.repere::placeholder { color: var(--text-3); }
.repere:focus { outline: none; border-bottom-color: var(--text); }
.note .screen, .note .screen:first-child { margin: 24px 0 0; font-size: var(--m-tiny); }

/* Un encadré : un titre, son bouton, son texte. Pas de carte : un filet entre deux. */
.block, .block:hover, .block:focus-within, .block.is-selected {
  margin: 0; border: 0; border-radius: 0; box-shadow: none; background: none;
  border-bottom: 1px solid var(--m-line);
}
.block .head, .block.copied .head, .block.stale .head {
  padding: 14px 0 6px; background: none; border: 0; gap: 12px; min-height: 52px;
}
.block h4 { font-size: 15px; }
.block .field { padding: 0 0 16px; font-size: var(--m-text); line-height: 1.5; background: none; }
.block .small.failed { margin: 0 0 12px; }
.copy { height: 36px; padding: 0 14px; border-radius: 18px; font-size: var(--m-small); flex: none; position: relative; }
.copy::after { content: ""; position: absolute; inset: -6px -4px; }   /* cible de 48 px, bouton de 36 */
.block.copied .copy { background: none; }
.block.copied h4 { color: var(--success); }
.block.stale h4 { color: var(--warning); }
.block.request { margin-left: 0; padding-left: 14px; border-left: 2px solid var(--m-line); }
.block.request::before { display: none; }

/* Encadré vide : une ligne discrète, ouverte d'un toucher si on veut écrire. */
.block:has(.field:placeholder-shown):not(.ouvert):not(:focus-within) .field { display: none; }
.block:has(.field:placeholder-shown):not(.ouvert):not(:focus-within) h4 { color: var(--text-3); font-weight: var(--fw-medium); }
.block:has(.field:placeholder-shown):not(.ouvert):not(:focus-within) h4::after { content: " · rien de dicté"; font-weight: var(--fw-regular); }
.block:has(.field:placeholder-shown) .copy { display: none; }

.feeling { margin: 20px var(--m-pad) 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--m-line);
           border-radius: 0; background: none; flex-wrap: wrap; font-size: var(--m-small); }
.feeling button { min-height: 40px; }

.alert, #error, #doc p.failed { border-radius: 10px; font-size: var(--m-small); }

/* --------------------------------------- pages simples : connexion, code */
body:has(> .auth) { background: var(--surface); }
.auth { min-height: 100dvh; place-items: start stretch; padding: calc(var(--m-safe-top) + 24px) var(--m-pad) 32px;
        background: var(--surface); }
.auth::before { display: none; }
.auth-card { max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: none; }
.auth-card .brand { padding: 0 0 40px; }
.auth-card .brand-mark { width: 28px; height: 28px; border-radius: 8px; }
.auth-card .title-1 { font-size: 26px; letter-spacing: -.02em; }
.auth-card .lead { font-size: 15px; margin-top: 8px; }
.auth-form { margin-top: 28px; gap: 12px; }
.auth-form .input { height: 52px; font-size: 17px; border-radius: 12px; }
.auth-form .input-code { font-size: 26px; letter-spacing: .25em; }
.auth-form .btn-lg { height: 52px; border-radius: 12px; font-size: 16px; box-shadow: none; }
.auth-card .alert { border-radius: 10px; }
.auth-foot { margin-top: 32px; padding-top: 0; border: 0; font-size: 13px; }
.auth-foot .i { display: none; }
/* Page du code : le message d'envoi suffit, la consigne au-dessus le répétait. */
.auth-card:has(.input-code) .lead { display: none; }
.auth-card .alert.message { margin-top: 12px; padding: 0; border: 0; background: none;
                            font-size: 15px; line-height: 1.5; color: var(--text-2); }
.auth-card .alert.message .i { display: none; }
.auth-card .alert.message.alert-danger { color: var(--danger); }

/* ------------------------------------ Aujourd'hui et Compte : vraies pages */
body:has(.m-page) > .auth { display: none; }
.m-page { min-height: 100dvh; padding: 0 0 calc(var(--m-bar) + var(--m-safe-bottom) + 24px); }
.m-head { position: sticky; top: 0; z-index: 10; display: flex; align-items: flex-end;
          height: calc(var(--m-head) + var(--m-safe-top)); padding: var(--m-safe-top) var(--m-pad) 10px;
          background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--m-line); }
.m-head h1 { margin: 0; font-size: 17px; font-weight: var(--fw-semibold); }
.m-note { margin: 16px var(--m-pad) 0; font-size: 13px; line-height: 1.5; color: var(--text-3); }
.m-list { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--m-line); }
.m-list > li + li { border-top: 1px solid var(--m-line); }
.m-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 0 var(--m-pad);
         border: 0; background: none; font: inherit; font-size: var(--m-text); color: var(--text);
         text-decoration: none; text-align: left; cursor: pointer; }
.m-row:active { background: var(--surface-2); }
.m-row .m-chevron { margin-left: auto; width: 16px; height: 16px; color: var(--text-3); fill: none;
                    stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.m-list form { margin: 0; }

/* Aujourd'hui : une ligne par dictée. */
.m-jour { list-style: none; margin: 0; padding: 0; }
.m-jour .jour-item { display: flex; align-items: center; margin: 0; padding: 0 8px 0 0; border: 0;
                     border-bottom: 1px solid var(--m-line); border-radius: 0; background: none; }
.m-jour .jour-lien { flex: 1; display: grid; grid-template-columns: auto 1fr; column-gap: 14px; row-gap: 2px;
                     padding: 14px 0 14px var(--m-pad); border: 0; border-radius: 0; background: none;
                     color: var(--text); text-decoration: none; }
.m-jour .jour-lien:active { background: var(--surface-2); }
.m-jour .jour-heure { grid-row: span 2; align-self: center; font-size: 17px; font-weight: var(--fw-semibold);
                      font-variant-numeric: tabular-nums; }
.m-jour .jour-quoi { font-size: 15px; }
.m-jour .jour-reste { font-size: 13px; color: var(--text-3); }
.m-jour .icon-btn { width: 44px; height: 44px; color: var(--text-3); }
.m-jour .panel-empty { padding: 48px var(--m-pad); text-align: center; color: var(--text-3); font-size: 15px; }

/* Compte */
.m-ident { padding: 24px var(--m-pad) 20px; }
.m-nom { margin: 0; font-size: 22px; font-weight: var(--fw-semibold); letter-spacing: -.01em; }
.m-meta { margin: 4px 0 0; font-size: var(--m-small); color: var(--text-3); }
.m-page .m-list { border-top: 1px solid var(--m-line); }
.m-danger { margin: 32px 0 0; border-top: 1px solid var(--m-line); border-bottom: 1px solid var(--m-line); }
.m-danger summary { list-style: none; display: flex; align-items: center; min-height: 56px; padding: 0 var(--m-pad);
                    color: var(--danger); cursor: pointer; }
.m-danger summary::-webkit-details-marker { display: none; }
.m-danger-body { padding: 0 var(--m-pad) 20px; }
.m-danger-body p { margin: 0 0 12px; font-size: var(--m-small); color: var(--text-2); line-height: 1.5; }
.m-danger-body .input { height: 48px; font-size: var(--m-text); border-radius: 10px; }
.m-danger-body .btn { width: 100%; height: 48px; margin-top: 10px; border-radius: 10px;
                      background: var(--danger); color: #fff; border: 0; }

/* ---------------------------------------------------------- présentation
   Sur le téléphone : un titre, une phrase, l'image. Le reste attend l'ordinateur. */
body:has(.ob) { background: var(--surface); }
.ob { min-height: 100dvh; display: flex; flex-direction: column; gap: 0;
      padding: calc(var(--m-safe-top) + 8px) 0 calc(var(--m-safe-bottom) + 16px); }
.ob-top { padding: 0 var(--m-pad) 8px; }
.ob-top .brand-name { font-size: 16px; }
.ob-top .brand-sub { display: none; }
.ob-top .btn-ghost { height: 44px; padding: 0 4px; font-size: 15px; color: var(--text-3); }
.ob-stage { flex: 1; align-self: stretch; display: flex; flex-direction: column; gap: 0; }
.ob-card { flex: 1; border: 0; border-radius: 0; box-shadow: none; background: none; overflow: visible; }
.ob-step { display: flex; flex-direction: column; min-height: 0; }
.ob-step[hidden] { display: none; }
.ob-text { padding: 16px var(--m-pad) 0; justify-content: flex-start; }
.ob-kicker, .ob-lead, .ob-rule { display: none; }
.ob-title, .ob-step .ob-title { font-size: 26px; letter-spacing: -.02em; }
.ob-short { margin: 10px 0 0; font-size: 16px; line-height: 1.45; color: var(--text-2); }
.ob-visual { flex: 1; padding: 28px var(--m-pad) 12px; background: none; border: 0; place-items: start center; }
.ob-visual > * { max-width: none; }
.demo-rec, .demo-parse { box-shadow: none; border-color: var(--m-line); border-radius: 14px; padding: 18px; }
.demo-transcript { font-size: 15px; }
.demo-box, .demo-dmi { box-shadow: none; border-color: var(--m-line); }
.demo-lines p { font-size: 13px; }
.ob-nav { flex-direction: column-reverse; align-items: stretch; gap: 14px; padding: 8px var(--m-pad) 0; }
.ob-progress { justify-content: center; }
.ob-bar { width: 96px; height: 4px; }
.ob-buttons { display: flex; gap: 10px; margin: 0; }
.ob-buttons .btn { height: 52px; border-radius: 12px; font-size: 16px; box-shadow: none; }
.ob-buttons .btn:focus { outline: none; box-shadow: none; }
.ob-buttons [data-prev] { flex: none; padding: 0 20px; border-color: var(--m-line); }
.ob-buttons [data-prev]:disabled { display: none; }
.ob-buttons [data-next], .ob-buttons form, .ob-buttons form .btn { flex: 1; width: 100%; }
.ob-buttons [data-next][hidden], .ob-buttons form[hidden] { display: none; }
.ob-step.is-in.from-right .ob-visual > *, .ob-step.is-in.from-left .ob-visual > * { animation-duration: .3s; }
