@import url("/static/fonts/fonts.css");

/* ==========================================================================
   Maria Paulina de Villarreal, Psicologa — sistema de interfaz
   Derivado del manual de marca. Ver DESIGN.md para las decisiones.
   Los colores de marca van en hex porque el manual es la fuente de verdad;
   las derivadas se calculan con color-mix sobre esos mismos hex.
   ========================================================================== */

:root {
  /* --- Marca (manual, intocables) --------------------------------------- */
  --brand-beige:  #C6A285;  /* Estabilidad · Pantone 7521 C */
  --brand-cream:  #F8DFCD;  /* Humanidad   · Pantone 475 C  */
  --brand-blue:   #9AC7DF;  /* Equilibrio  · Pantone 551 C  */

  /* --- Superficies ------------------------------------------------------ */
  --bg:            #FBF8F5;
  --surface:       #FFFFFF;
  --surface-brand: #F3E4D6;
  --surface-sunk:  #F6F0E9;

  /* --- Tinta (verificada AA sobre --surface) ---------------------------- */
  --ink:    #2E241D;  /* 15.2:1 */
  --ink-2:  #5C4B3E;  /*  8.3:1 */
  --ink-3:  #6B5647;  /*  6.9:1 — el minimo que sigue siendo AA */

  --line:        #E9DED3;
  --line-strong: #DCCBBA;

  /* --- Accion y estados ------------------------------------------------- */
  --action:       #7B4F3F;  /* 6.9:1 */
  --action-hover: #653F32;
  --ok:     #4E6B52;
  --info:   #37687F;
  --warn:   #8A6A2B;
  --danger: #9B3B2E;

  --tint-ok:     #EDF3EE;
  --tint-info:   #E8F2F8;
  --tint-warn:   #FBF2DF;
  --tint-danger: #FBEDEA;

  /* --- Tipografia ------------------------------------------------------- */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Mulish", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --t-xs:  0.75rem;
  --t-sm:  0.8125rem;
  --t-ui:  0.875rem;
  --t-md:  0.9375rem;
  --t-base: 1rem;
  --t-lg:  1.125rem;
  --t-xl:  1.375rem;
  --t-2xl: 1.75rem;

  --measure: 68ch;

  /* --- Espacio (escala de 4) -------------------------------------------- */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;

  --r-1: 6px; --r-2: 10px; --r-3: 16px; --r-full: 999px;

  --shadow-1: 0 1px 2px rgb(46 36 29 / 0.05);
  --shadow-2: 0 4px 16px -4px rgb(46 36 29 / 0.10);
  --shadow-3: 0 12px 32px -8px rgb(46 36 29 / 0.16);

  /* --- Movimiento ------------------------------------------------------- */
  --ease: cubic-bezier(0.25, 1, 0.5, 1);       /* ease-out-quart */
  --fast: 150ms; --mid: 220ms;

  /* --- z-index semantico ------------------------------------------------ */
  --z-sticky: 100; --z-overlay: 200; --z-modal: 300; --z-toast: 400;

  --sidebar-w: 232px;
}

/* ==========================================================================
   Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* Los componentes con display explicito (botones, banners) ganan al display:none
   que el navegador da a [hidden]. Toda la app oculta pasos y acciones con hidden,
   asi que esta regla no es cosmetica: sin ella se muestran controles invalidos. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: "SOFT" 30, "WONK" 1;
  color: var(--ink);
  line-height: 1.2;
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: var(--t-2xl); letter-spacing: -0.015em; }
h2 { font-size: var(--t-xl); letter-spacing: -0.01em; }
h3 { font-size: var(--t-lg); }

p { margin: 0 0 var(--s-3); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-hover); }

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

::selection { background: var(--brand-cream); color: var(--ink); }

.muted { color: var(--ink-3); font-size: var(--t-ui); }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: var(--s-4); }
.prose { max-width: var(--measure); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ==========================================================================
   Shell: barra lateral + area de trabajo
   ========================================================================== */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface-brand);
  border-right: 1px solid var(--line-strong);
  padding: var(--s-5) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: var(--z-sticky);
}

.sidebar .brand { display: block; color: inherit; text-decoration: none; width: 106px; margin: 0 auto; }
.sidebar .brand svg { display: block; width: 100%; height: auto; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-2);
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--t-ui);
  font-weight: 600;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-link:hover { background: rgb(255 255 255 / 0.55); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.75; }
.nav-link[aria-current="page"] svg { opacity: 1; }

.sidebar .spacer { flex: 1; }
.sidebar footer { border-top: 1px solid var(--line-strong); padding-top: var(--s-4); }

.content { flex: 1; min-width: 0; padding: var(--s-6) var(--s-6) var(--s-8); }
.content > * { max-width: 1080px; }

.page-head {
  display: flex; align-items: flex-start; gap: var(--s-4);
  flex-wrap: wrap; margin-bottom: var(--s-5);
}
.page-head .grow { min-width: 240px; }
.page-head p { color: var(--ink-3); margin: var(--s-1) 0 0; max-width: var(--measure); }

.back-link {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: var(--t-ui); color: var(--ink-3); text-decoration: none;
  margin-bottom: var(--s-2);
}
.back-link:hover { color: var(--action); }

/* ==========================================================================
   Superficies
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-5);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: var(--s-4); }
.card > h2:first-child, .card > h3:first-child { margin-bottom: var(--s-3); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.panel > table { border-radius: 0; }

/* ==========================================================================
   Botones
   ========================================================================== */

.btn, button {
  font: inherit;
  font-family: var(--sans);
  font-size: var(--t-ui);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 40px;
  padding: 0 var(--s-4);
  border-radius: var(--r-2);
  border: 1px solid transparent;
  background: var(--action);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease),
              color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover, button:hover { background: var(--action-hover); color: #fff; }
.btn:active, button:active { transform: translateY(1px); }

.btn.secondary, button.secondary {
  background: var(--surface);
  color: var(--action);
  border-color: var(--line-strong);
}
.btn.secondary:hover, button.secondary:hover {
  background: var(--surface-sunk); color: var(--action-hover); border-color: var(--brand-beige);
}

.btn.ghost, button.ghost {
  background: transparent; color: var(--ink-2); border-color: transparent;
}
.btn.ghost:hover, button.ghost:hover { background: var(--surface-sunk); color: var(--ink); }

.btn.danger, button.danger { background: var(--danger); border-color: var(--danger); }
.btn.danger:hover, button.danger:hover { background: #82301F; }

.btn.big, button.big { min-height: 52px; font-size: var(--t-base); padding: 0 var(--s-6); border-radius: var(--r-3); }
.btn.small, button.small { min-height: 32px; font-size: var(--t-sm); padding: 0 var(--s-3); }

button:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45; cursor: not-allowed; transform: none;
}
button[data-loading] { color: transparent; position: relative; pointer-events: none; }
button[data-loading]::after {
  content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid rgb(255 255 255 / 0.35); border-top-color: #fff;
  border-radius: 50%; animation: spin 700ms linear infinite;
}
button.secondary[data-loading]::after { border-color: rgb(123 79 63 / 0.3); border-top-color: var(--action); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Formularios
   ========================================================================== */

label {
  display: block;
  margin-bottom: var(--s-1);
  font-size: var(--t-sm);
  font-weight: 700;
  color: var(--ink-2);
}
.field + .field { margin-top: var(--s-4); }
.field .hint { font-size: var(--t-xs); color: var(--ink-3); margin: var(--s-1) 0 0; font-weight: 400; }

input, select, textarea {
  font: inherit;
  font-family: var(--sans);
  font-size: var(--t-md);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  padding: 10px var(--s-3);
  width: 100%;
  min-height: 40px;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
input:hover, select:hover, textarea:hover { border-color: var(--brand-beige); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--action);
  box-shadow: 0 0 0 3px rgb(123 79 63 / 0.12);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-sunk); color: var(--ink-3); cursor: not-allowed; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%236B5647' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-3) center;
  background-size: 11px;
  padding-right: var(--s-6);
}
select.auto { width: auto; min-width: 170px; }

textarea {
  min-height: 320px;
  font-family: var(--mono);
  font-size: var(--t-sm);
  line-height: 1.7;
  resize: vertical;
}

/* Casillas y radios */
.choice {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-2);
  cursor: pointer;
  font-size: var(--t-ui);
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 0;
  transition: border-color var(--fast) var(--ease), background var(--fast) var(--ease);
}
.choice:hover { border-color: var(--brand-beige); background: var(--surface-sunk); }
.choice:has(input:checked) { border-color: var(--action); background: var(--tint-warn); color: var(--ink); }
.choice input { width: auto; min-height: 0; margin: 3px 0 0; accent-color: var(--action); flex-shrink: 0; }
.choice .t { display: block; }
.choice .d { display: block; font-weight: 400; font-size: var(--t-sm); color: var(--ink-3); margin-top: 2px; }
.choice-row { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.choice-row .choice { flex: 1; min-width: 240px; }

/* ==========================================================================
   Tablas
   ========================================================================== */

table { width: 100%; border-collapse: collapse; font-size: var(--t-ui); }
thead th {
  text-align: left;
  font-size: var(--t-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-sunk);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody td .name { font-weight: 700; color: var(--ink); }
tr.clickable { cursor: pointer; transition: background var(--fast) var(--ease); }
tr.clickable:hover td { background: var(--surface-sunk); }
tr.clickable:focus-visible { outline: 2px solid var(--action); outline-offset: -2px; }
td.num { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   Pills de estado — color + texto, nunca color solo
   ========================================================================== */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--t-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--surface-sunk);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.pill::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex-shrink: 0;
}
.pill.ready, .pill.approved { background: var(--tint-ok); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.pill.uploaded, .pill.transcribing, .pill.transcribed, .pill.generating {
  background: var(--tint-info); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent);
}
.pill.transcribing::before, .pill.generating::before, .pill.uploaded::before { animation: breathe 1.8s ease-in-out infinite; }
.pill.draft { background: var(--tint-warn); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.pill.error, .pill.interrupted { background: var(--tint-danger); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.pill.recording { background: var(--tint-danger); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.pill.recording::before { animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.tag {
  display: inline-block;
  font-size: var(--t-xs);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  padding: 2px 9px;
  color: var(--ink-2);
  margin: 0 var(--s-1) var(--s-1) 0;
}

/* ==========================================================================
   Avisos
   ========================================================================== */

.banner {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-2);
  border: 1px solid var(--line-strong);
  background: var(--surface-sunk);
  font-size: var(--t-ui);
  color: var(--ink-2);
  margin-bottom: var(--s-4);
}
.banner strong { color: var(--ink); }
.banner .grow { min-width: 0; }
.banner.info   { background: var(--tint-info);   border-color: color-mix(in srgb, var(--info) 25%, transparent); color: var(--info); }
.banner.warn   { background: var(--tint-warn);   border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.banner.error  { background: var(--tint-danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.banner.ok     { background: var(--tint-ok);     border-color: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.banner.info strong, .banner.warn strong, .banner.error strong, .banner.ok strong { color: inherit; }
.banner button { flex-shrink: 0; }

/* ==========================================================================
   Estados vacios — ensenan la siguiente accion
   ========================================================================== */

.empty {
  text-align: center;
  padding: var(--s-8) var(--s-5);
  color: var(--ink-3);
}
.empty .sparkle { color: var(--brand-beige); margin-bottom: var(--s-3); }
.empty h3 { color: var(--ink-2); margin-bottom: var(--s-2); }
.empty p { max-width: 44ch; margin-inline: auto; margin-bottom: var(--s-4); font-size: var(--t-ui); }
td .empty { padding: var(--s-7) var(--s-4); }

.sparkle { display: inline-block; color: var(--brand-blue); }
.sparkle svg { display: block; }

/* ==========================================================================
   Grabacion
   ========================================================================== */

.rec-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  padding: var(--s-6);
  box-shadow: var(--shadow-1);
}
.rec-stage.live { border-color: color-mix(in srgb, var(--danger) 35%, transparent); box-shadow: var(--shadow-2); }

.rec-timer {
  font-family: var(--display);
  font-variation-settings: "SOFT" 30, "WONK" 0;
  font-size: 3.5rem;
  font-weight: 500;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.rec-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--danger); flex-shrink: 0;
  animation: pulse 1.4s var(--ease) infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgb(155 59 46 / 0.35); }
  50%      { opacity: 0.65; box-shadow: 0 0 0 7px rgb(155 59 46 / 0); }
}

.meters { display: grid; gap: var(--s-3); min-width: 240px; }
.meter label { margin-bottom: var(--s-1); font-size: var(--t-xs); }
.vu {
  height: 8px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
}
.vu > div {
  height: 100%; width: 100%;
  background: var(--ok);
  transform: scaleX(0); transform-origin: left;
  transition: transform 80ms linear, background var(--mid) var(--ease);
}
.vu.dead > div { background: var(--danger); }

.steps { display: flex; gap: var(--s-2); align-items: center; margin-bottom: var(--s-5); font-size: var(--t-sm); color: var(--ink-3); }
.steps .step { display: flex; align-items: center; gap: var(--s-2); font-weight: 700; }
.steps .step .n {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line-strong);
  font-size: var(--t-xs); color: var(--ink-3);
}
.steps .step[data-on] { color: var(--ink); }
.steps .step[data-on] .n { background: var(--action); border-color: var(--action); color: #fff; }
.steps .sep { flex: 1; height: 1px; background: var(--line-strong); max-width: 32px; }

/* ==========================================================================
   Transcripcion
   ========================================================================== */

.transcript { max-width: var(--measure); }
.utt { display: grid; grid-template-columns: 42px 1fr; gap: var(--s-3); padding: var(--s-2) 0; }
.utt + .utt { border-top: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.utt .t { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; padding-top: 3px; }
.utt .who { font-weight: 800; font-size: var(--t-sm); display: block; }
.utt.psi .who { color: var(--action); }
.utt.pac .who { color: var(--info); }
.utt .text { color: var(--ink-2); }

/* ==========================================================================
   Documentos
   ========================================================================== */

.doc-tabs {
  display: flex; gap: var(--s-1); flex-wrap: wrap;
  margin-bottom: calc(var(--s-4) * -1 + var(--s-4));
  padding-bottom: var(--s-4);
}
.doc-tabs button {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  min-height: 34px;
  padding: 0 var(--s-3);
  font-size: var(--t-sm);
  font-weight: 700;
}
.doc-tabs button:hover { background: var(--surface); color: var(--ink); border-color: var(--brand-beige); }
.doc-tabs button[aria-selected="true"] {
  background: var(--action); color: #fff; border-color: var(--action);
}
.doc-tabs button .check { opacity: 0.85; }

.doc-toolbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  padding-bottom: var(--s-4); margin-bottom: var(--s-4);
  border-bottom: 1px solid var(--line);
}
/* Cuerpo del documento: es lectura larga con criterio clinico encima, asi que
   manda la comodidad de lectura — medida corta, interlinea amplia, jerarquia
   clara entre secciones. El markdown se renderiza (ver mdToHtml en app.js). */
.doc-body {
  max-width: var(--measure);
  font-size: var(--t-base);
  line-height: 1.75;
  color: var(--ink-2);
}
.doc-body:empty::after { content: "Este documento está vacío."; color: var(--ink-3); font-style: italic; }
.doc-body > :first-child { margin-top: 0; }
.doc-body h2, .doc-body h3, .doc-body h4 {
  font-family: var(--display);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}
.doc-body h2 { font-size: var(--t-xl); margin: var(--s-6) 0 var(--s-3); }
.doc-body h3 {
  font-size: var(--t-base);
  font-family: var(--sans); font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--action);
  margin: var(--s-6) 0 var(--s-2);
}
.doc-body h4 { font-size: var(--t-lg); margin: var(--s-5) 0 var(--s-1); }
.doc-body p { margin: 0 0 var(--s-3); }
.doc-body ul { margin: 0 0 var(--s-3); padding-left: var(--s-5); }
.doc-body li { margin-bottom: var(--s-2); }
.doc-body li::marker { color: var(--brand-beige); }
.doc-body ul.task { list-style: none; padding-left: 0; }
.doc-body ul.task li { display: flex; gap: var(--s-3); align-items: flex-start; }
.doc-body ul.task li::before {
  content: ""; flex-shrink: 0;
  width: 15px; height: 15px; margin-top: 5px;
  border: 1.5px solid var(--brand-beige); border-radius: 4px;
}
.doc-body ul.task li.done::before {
  background: var(--ok); border-color: var(--ok);
}
.doc-body strong { color: var(--ink); font-weight: 700; }
.doc-body em { color: var(--action); }
.doc-body hr { border: none; border-top: 1px solid var(--line); margin: var(--s-5) 0; }

.history-entry { padding: var(--s-4) 0; border-bottom: 1px solid var(--line); }
.history-entry:last-child { border-bottom: none; }
.history-entry .when { font-size: var(--t-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: var(--s-2); }

/* ==========================================================================
   Carga manual de sesiones y perfil de paciente
   ========================================================================== */

/* Prosa que ella escribe (notas, antecedentes): la mono del textarea es para
   editar el markdown de un documento; aquí escribe como en una libreta. */
textarea.prose-input {
  font-family: var(--sans);
  font-size: var(--t-md);
  line-height: 1.65;
  min-height: 280px;
}
textarea.prose-input.short { min-height: 120px; }

input[type="file"] { padding: var(--s-2); cursor: pointer; }
input[type="file"]::file-selector-button {
  font: inherit; font-size: var(--t-ui); font-weight: 700;
  min-height: 32px; margin-right: var(--s-3); padding: 0 var(--s-3);
  border: 1px solid var(--line-strong); border-radius: var(--r-1);
  background: var(--surface-sunk); color: var(--action); cursor: pointer;
}

.btn svg, button svg { width: 16px; height: 16px; flex-shrink: 0; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-4); }
.field + .field-row, .field-row + .field, .field-row + .field-row { margin-top: var(--s-4); }
.field-row > .field + .field { margin-top: 0; }

.choice-row.tres .choice { min-width: 190px; }

.material-text { white-space: pre-wrap; color: var(--ink-2); line-height: 1.75; }

.profile-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-4) var(--s-5); margin: 0;
}
.profile-grid .wide { grid-column: 1 / -1; }
.profile-grid dt {
  font-size: var(--t-xs); font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-3); margin-bottom: var(--s-1);
}
.profile-grid dd { margin: 0; color: var(--ink); }
.profile-grid .material-text { display: block; max-width: var(--measure); }

@media (max-width: 520px) {
  .choice-row.tres .choice { min-width: 100%; }
}

/* ==========================================================================
   Insights
   ========================================================================== */

.insight-grid { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.insight { display: flex; flex-direction: column; gap: var(--s-3); }
.insight .pain { font-family: var(--display); font-size: var(--t-lg); font-weight: 600; line-height: 1.3; color: var(--ink); }
.insight blockquote {
  margin: 0; padding-left: var(--s-4);
  border-left: 1px solid var(--brand-beige);
  color: var(--ink-2); font-style: italic;
}
.insight .foot {
  display: flex; align-items: flex-end; gap: var(--s-3); flex-wrap: wrap;
  margin-top: auto; padding-top: var(--s-2);
}
.insight .foot .tags { margin-bottom: calc(var(--s-1) * -1); }
.insight .foot .when { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; }

/* ==========================================================================
   Login — superficie de marca (Committed)
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-5);
  background: var(--brand-cream);
  position: relative;
  overflow: hidden;
}
.login-page .stars { position: absolute; inset: 0; pointer-events: none; color: var(--brand-beige); opacity: 0.5; }
.login-card {
  position: relative;
  width: min(400px, 100%);
  background: var(--surface);
  border-radius: var(--r-3);
  padding: var(--s-7) var(--s-6) var(--s-6);
  box-shadow: var(--shadow-3);
}
.login-card .brand { display: block; margin: 0 auto var(--s-6); width: 200px; }
.login-card .brand svg { display: block; width: 100%; height: auto; }
.login-card button { width: 100%; margin-top: var(--s-5); }
.login-foot { text-align: center; margin-top: var(--s-5); font-size: var(--t-xs); color: var(--ink-3); }

/* ==========================================================================
   Responsive — estructural
   ========================================================================== */

@media (max-width: 899px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0;
    flex-direction: row; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-right: none; border-bottom: 1px solid var(--line-strong);
    overflow-x: auto;
  }
  .sidebar .brand { width: 116px; flex-shrink: 0; }
  .sidebar nav { flex-direction: row; gap: var(--s-1); }
  .nav-link { padding: var(--s-2); }
  .nav-link .label { display: none; }
  .nav-link svg { width: 20px; height: 20px; }
  .sidebar footer { border-top: none; padding-top: 0; }
  .sidebar .spacer { flex: 1; }

  .content { padding: var(--s-5) var(--s-4) var(--s-8); }
  h1 { font-size: var(--t-xl); }

  /* Tablas -> fichas apiladas, sin JS. La tabla y el tbody tienen que dejar de
     ser display:table o el layout de tabla mantiene el ancho minimo y desborda. */
  table.responsive, table.responsive tbody { display: block; width: 100%; }
  table.responsive thead { display: none; }
  table.responsive tbody tr {
    display: grid; gap: var(--s-1);
    padding: var(--s-4);
    border-bottom: 1px solid var(--line);
  }
  table.responsive tbody td { display: flex; justify-content: space-between; gap: var(--s-4); padding: 0; border: none; }
  table.responsive tbody td::before {
    content: attr(data-label);
    font-size: var(--t-xs); font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--ink-3); flex-shrink: 0;
  }
  table.responsive tbody td[colspan]::before { content: none; }
  table.responsive tbody td .name { font-size: var(--t-md); }

  .rec-timer { font-size: 2.75rem; }
  .rec-stage { padding: var(--s-5) var(--s-4); }
  button, .btn { min-height: 44px; }
}

@media (max-width: 520px) {
  .choice-row .choice { min-width: 100%; }
  .doc-toolbar { gap: var(--s-1); }
  .doc-toolbar button { flex: 1; }
}

/* ==========================================================================
   Movimiento reducido — el punto de grabar deja de pulsar pero sigue estando,
   y su etiqueta de texto nunca dependio del movimiento.
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .rec-dot { animation: none; opacity: 1; }
  .vu > div { transition: none; }
  button[data-loading]::after { animation: none; border-top-color: transparent; }
}

@media print {
  .sidebar, .doc-toolbar, .doc-tabs, .banner { display: none !important; }
  .content { padding: 0; }
  .card, .panel { border: none; box-shadow: none; }
}
