:root {
  --brand: #04508f;
  --brand-ink: #033a68;
  --brand-soft: #e6eff7;
  --accent: #f08a24;
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1d2733;
  --muted: #667383;
  --line: #dfe4ea;
  --ok: #1e8e5a;
  --warn: #c77700;
  --edit: #2f6fd6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
code { background: var(--brand-soft); color: var(--brand-ink); padding: 1px 5px; border-radius: 4px; font-size: .92em; }
.muted { color: var(--muted); margin: 2px 0 0; }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: #c5ced8; background: #fafbfc; }
.btn:focus-visible, .tool:focus-visible, .seg button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(4, 80, 143, .07); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13.5px; }
.btn.block { width: 100%; margin-top: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn em, .tag { font-style: normal; font-size: 11px; font-weight: 600; text-transform: uppercase; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 99px; }
.icon-btn { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #fff; font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink); }
.icon-btn:hover { background: #f2f4f7; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: #fff; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 34px; max-width: 150px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12.5px; color: var(--muted); }
.patient { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.patient label { font-size: 13px; color: var(--muted); }
.patient .btn { white-space: nowrap; }
.patient input.need { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }
.patient input { height: 36px; width: 240px; }
.actions { display: flex; gap: 4px; }

input:not([type]), input[type=text], select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; height: 36px; width: 100%;
}
textarea { height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(4, 80, 143, .25); border-color: var(--brand); }
input[type=color] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: #fff; }
input[type=range] { accent-color: var(--brand); width: 100%; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.check input { accent-color: var(--brand); width: 16px; height: 16px; }

main { padding: 28px 24px 60px; max-width: 1400px; margin: 0 auto; }

/* ---------- Paso 1 ---------- */
.drop-view { max-width: 820px; margin: 4vh auto 0; }
.dropzone {
  background: #fff; border: 2px dashed #c4d3e2; border-radius: 18px;
  padding: 48px 32px; text-align: center; transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.drop-icon svg { fill: none; stroke: var(--brand); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.dropzone h1 { font-size: 24px; margin: 10px 0 8px; }
.dropzone p { color: var(--muted); margin: 0 auto; max-width: 520px; }
.drop-buttons { display: flex; gap: 10px; justify-content: center; margin: 22px 0 18px; flex-wrap: wrap; }
.privacy { font-size: 13px; }
.level-choice { max-width: 520px; margin: 0 auto 16px; padding: 14px 16px; border-radius: 12px; background: #f6f8fb; border: 1px solid var(--line); }
.level-choice > span { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 8px; }
.level-choice .seg button { height: 36px; font-size: 13.5px; }
.level-choice .hint { margin-top: 8px; }
#edDirty { color: var(--warn); font-weight: 600; }
.fill-switch { margin-top: 12px; }
.fill-warn { color: var(--warn); font-weight: 600; margin-top: 4px; }
.fill-warn.off { visibility: hidden; } /* conserva su espacio: el panel no salta */
.range-row.adj-row { grid-template-columns: 82px 1fr 50px; margin-top: 8px; }
.seg.blur-mode { margin-top: 10px; }
.ed-label b { color: var(--brand); text-transform: none; letter-spacing: 0; }
.guide-tools { margin: 10px 0 0 46px; }
.guide-tools .switch { font-size: 13.5px; }
.guide-tools .switch + .hint { margin-left: 0; }
.guide-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.guide-btns .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.steps { list-style: none; padding: 0; margin: 28px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: #fff; border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); font-size: 14px; }
.steps b { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }

/* ---------- Pasos 2 y 3 ---------- */
.gridbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.gridbar h2 { font-size: 22px; }
.gridbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.warnings { background: #fff7e8; border: 1px solid #f3d9a4; color: #7a4c00; border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.warnings ul { margin: 4px 0 0; padding-left: 18px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.card {
  position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; border: 2px solid transparent; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: #c9d7e6; }
.card.excluded .thumb { opacity: .35; }
.thumb { display: block; width: 100%; aspect-ratio: 4 / 5; background: #e9edf1; cursor: zoom-in; }
.card-body { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.card-title { flex: 1; min-width: 0; }
.card-title b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; margin-top: 3px; }
.chip.ok { background: #e3f4ec; color: var(--ok); }
.chip.revisar { background: #fff1db; color: var(--warn); }
.chip.editada { background: #e5eefc; color: var(--edit); }
.chip.incompleta { background: #f1f2f4; color: var(--muted); }
.chip.pendiente { background: #f1f2f4; color: var(--muted); }
.card-actions { display: flex; gap: 4px; }
.card-actions button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 15px; }
.card-actions button:hover { background: #f2f4f7; }
.card .pick { position: absolute; top: 10px; left: 10px; width: 22px; height: 22px; accent-color: var(--brand); cursor: pointer; }
.card-note { font-size: 12px; color: var(--warn); padding: 0 12px 10px; margin-top: -4px; }

/* ---------- Progreso y avisos ---------- */
.progress { position: fixed; inset: 0; background: rgba(244, 246, 249, .75); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; }
.progress-card { background: #fff; padding: 22px 26px; border-radius: 14px; box-shadow: var(--shadow); width: min(420px, 90vw); }
.progress-card p { margin: 0 0 12px; font-weight: 500; }
.bar { height: 8px; border-radius: 99px; background: #e8edf2; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: #1d2733; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Editor ---------- */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(15, 22, 32, .55); }
/* El editor ocupa la pantalla con medidas fijas: abrir o cerrar opciones nunca
   cambia el tamaño de la ventana ni mueve las fotos. Solo el panel de
   opciones se desplaza por dentro. */
.editor[open] { width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0; display: flex; background: #20262e; overflow: hidden; }
.editor-stage { flex: 1; display: grid; place-items: center; padding: 20px; min-width: 0; min-height: 0; overflow: hidden; }
.editor-stage canvas { box-shadow: 0 10px 40px rgba(0, 0, 0, .45); cursor: grab; touch-action: none; border-radius: 4px; }
.editor-stage canvas.dragging { cursor: grabbing; }
.ed-canvas-wrap { position: relative; line-height: 0; }
.lock-btn {
  position: absolute; width: 34px; height: 34px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; cursor: pointer; color: #33404d;
  background: rgba(255, 255, 255, .92); border: 1px solid rgba(0, 0, 0, .15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25); transition: background .15s, color .15s;
}
.lock-btn:hover { background: #fff; }
.lock-btn.locked { background: var(--brand); color: #fff; border-color: var(--brand); }
.lock-btn:focus-visible { outline: 2px solid #3d8bff; outline-offset: 2px; }
.lock-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
#edLockHint { color: var(--brand); font-weight: 600; }
/* Cambiar foto: mismo estilo que el candado; con punto naranja si ya fue reemplazada */
.swap-btn.replaced::after { content: ""; position: absolute; top: 1px; right: 1px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; }
.swap-badge {
  position: absolute; padding: 3px 9px; border-radius: 99px; font: 600 11.5px/1.3 "Segoe UI", system-ui, sans-serif;
  background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); pointer-events: auto; cursor: help; white-space: nowrap;
  transform: translateX(-100%);
}
.chip.replaced { background: #fdeedd; color: #b4580c; }
.card-menu {
  position: absolute; right: 10px; bottom: 52px; z-index: 5; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 220px;
}
.card-menu button { text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 7px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.card-menu button:hover { background: #f2f4f7; }
.card-menu small { display: block; color: var(--muted); font-size: 12px; }
.swap-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.swap-row .btn { flex: 1; height: 32px; font-size: 13px; padding: 0 10px; }
.tool:disabled, input[type=range]:disabled { opacity: .4; cursor: not-allowed; }
.editor-side { width: 330px; flex: none; height: 100%; background: #fff; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 16px; border-bottom: 1px solid var(--line); }
.ed-nav { display: flex; gap: 6px; flex: none; }
.ed-name { flex: 1; min-width: 0; text-align: right; }
.ed-head small { color: var(--muted); font-size: 12px; }
.ed-head h2 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ed-block { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ed-label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 8px; }
/* Secciones desplegables del panel lateral */
summary.ed-label {
  display: flex; align-items: center; gap: 4px; list-style: none; cursor: pointer; user-select: none;
  margin: -14px -16px 0; padding: 14px 16px 10px; border-radius: 6px;
}
summary.ed-label::-webkit-details-marker { display: none; }
summary.ed-label::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .15s;
}
details.ed-block:not([open]) > summary.ed-label { padding-bottom: 14px; margin-bottom: -14px; }
details.ed-block:not([open]) > summary.ed-label::after { transform: rotate(-45deg); }
summary.ed-label:hover { color: var(--ink); background: #f6f8fb; }
summary.ed-label:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.seg { display: flex; background: #eef1f4; border-radius: 9px; padding: 3px; gap: 3px; }
.seg + .seg { margin-top: 8px; }
.seg button { flex: 1; height: 32px; border: 0; border-radius: 7px; background: transparent; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.seg button.on { background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); font-weight: 600; color: var(--brand); }
.seg.small button { height: 28px; font-size: 13px; }
.seg.disabled { opacity: .45; pointer-events: none; }
.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tool { height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 16px; cursor: pointer; color: var(--ink); }
.tool:hover { background: #f2f4f7; }
.range-row { display: grid; grid-template-columns: auto 1fr 46px; align-items: center; gap: 10px; margin-top: 12px; font-size: 14px; }
.range-row output { font-variant-numeric: tabular-nums; text-align: right; color: var(--muted); font-size: 13px; }
/* position: relative contiene la casilla invisible dentro del interruptor; sin
   esto, al tocarlo el navegador desplazaba todo el editor para mostrarla. */
.switch { position: relative; display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; margin-top: 10px; }
.switch:first-child { margin-top: 0; }
.switch input { position: absolute; opacity: 0; left: 0; top: 50%; width: 1px; height: 1px; margin: 0; }
.switch span { flex: none; width: 36px; height: 20px; border-radius: 99px; background: #cfd6de; position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch + .hint { margin: 2px 0 6px 46px; }
/* Pie fijo: Guardar y Cancelar siempre visibles aunque el panel se desplace. */
.ed-foot { margin-top: auto; padding: 12px 16px 14px; position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -6px 14px rgba(16, 24, 40, .06); }
.ed-foot-btns { display: flex; gap: 8px; margin-top: 10px; }
.ed-undo-row { display: flex; gap: 8px; margin-top: 8px; }
.ed-undo-row .btn { flex: 1; }
.ed-foot-btns .btn { flex: 1; }

/* ---------- Modales ---------- */
.modal[open] { width: min(860px, 94vw); max-height: 92vh; border-radius: 16px; display: flex; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.update-banner {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 8px 16px; background: #fff6df; border-bottom: 1px solid #f0d69a; color: #6b4a00; font-size: 14px; flex-wrap: wrap;
}
.app-version { font-size: 12px; font-weight: 500; color: var(--muted); background: #eef1f4; padding: 2px 8px; border-radius: 99px; }
.modal.confirm[open] { width: min(460px, 92vw); }
.modal.confirm .modal-scroll { padding-top: 14px; }
.modal.confirm p { margin: 0; line-height: 1.5; }
.modal-body { display: flex; flex-direction: column; width: 100%; max-height: 92vh; margin: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 19px; display: flex; align-items: center; gap: 8px; }
.modal-scroll { overflow-y: auto; padding: 8px 22px 18px; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
fieldset { border: 0; padding: 0; margin: 16px 0 6px; }
legend { font-weight: 600; font-size: 15px; margin-bottom: 10px; padding: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.form-grid label.check { flex-direction: row; color: var(--ink); align-self: end; }
.asset-row { display: grid; grid-template-columns: 200px 1fr; gap: 16px; align-items: center; padding: 10px 0; }
.asset-row + .asset-row { border-top: 1px solid var(--line); }
.asset-row .btn { margin: 8px 10px 0 0; }
.asset-preview { height: 90px; border-radius: 10px; display: grid; place-items: center; padding: 10px;
  background: repeating-conic-gradient(#eef1f4 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); }
.asset-preview img { max-width: 100%; max-height: 70px; }
.pref-list { display: grid; gap: 8px; margin-top: 10px; }
.pref-list.cols { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.pref-list .sub { margin-left: 26px; }
.pref-list .pref-explain { margin-top: -4px; margin-bottom: 6px; line-height: 1.45; }
.pref-select { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.pref-select select { width: auto; height: 32px; padding: 4px 8px; }
.pref-group { font-size: 14px; margin-top: 4px; }
.pref-range input[type=range] { width: 180px; flex: none; }
.pref-range output { min-width: 28px; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.pref-subtitle { display: block; margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.seq-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.seq-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 6px; }
.seq-table td { padding: 3px 6px; }
.seq-table td:first-child { width: 32px; color: var(--muted); text-align: center; }
.seq-table select, .seq-table input { height: 32px; padding: 4px 8px; }
.seq-table .zoom-in { width: 72px; font: inherit; border: 1px solid var(--line); border-radius: 8px; }
.seq-table .label-pos { min-width: 150px; }
.seq-table .wm-pos { min-width: 96px; }
.seq-table .label-pos:disabled { color: var(--muted); background: #f4f6f9; }

.video-grid { display: grid; grid-template-columns: 1fr 300px; gap: 22px; padding-top: 16px; }
.video-grid output { font-size: 12px; }
.video-preview { background: #111; border-radius: 12px; display: grid; place-items: center; min-height: 375px; overflow: hidden; }
.video-preview video, .video-preview canvas { width: 100%; height: auto; display: block; }
.video-empty { color: #8a96a3; font-size: 13px; padding: 20px; text-align: center; }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .patient { margin-left: 0; order: 3; width: 100%; }
  .patient input { width: auto; flex: 1; min-width: 0; }
  main { padding: 20px 16px 48px; }
  .steps { grid-template-columns: 1fr; }
  .editor[open] { flex-direction: column; }
  .editor-side { width: 100%; height: 45vh; height: 45dvh; max-height: none; }
  .video-grid { grid-template-columns: 1fr; }
  .asset-row { grid-template-columns: 1fr; }
}

/* ---- Pacientes ---- */
.lib-view, .pt-view { max-width: 1100px; margin: 0 auto; }
.lib-setup { background: var(--card, #fff); border: 1px solid var(--line); border-radius: 14px; padding: 24px 28px; max-width: 720px; }
.lib-setup h3 { margin: 0 0 8px; font-size: 18px; }
.lib-setup ol { margin: 12px 0 18px; padding-left: 20px; line-height: 1.6; }
.lib-setup .btn + .btn { margin-left: 8px; }
.lib-setup .hint { margin-top: 14px; }
.lib-tools { display: flex; gap: 12px; align-items: center; flex-wrap: nowrap; margin: 16px 0 12px; }
.lib-tools input[type=search] { flex: 1 1 auto; min-width: 0; max-width: 420px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.lib-tools .seg { flex: none; }
.lib-tools .seg button { white-space: nowrap; }
.lib-list { display: grid; gap: 8px; }
.lib-row { display: grid; grid-template-columns: minmax(180px, 1.2fr) 2fr auto auto; gap: 16px; align-items: center; text-align: left; width: 100%;
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; font: inherit; color: inherit; cursor: pointer; }
.lib-row:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(4, 80, 143, 0.08); }
.lib-name { display: flex; flex-direction: column; min-width: 0; }
.lib-name small, .lib-dates { color: var(--muted); font-size: 13px; }
.lib-treat { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-dates { white-space: nowrap; }
.lib-tags em { font-style: normal; font-size: 12px; background: #e8f1fa; color: var(--brand); border-radius: 999px; padding: 3px 10px; }
.lib-empty { color: var(--muted); padding: 24px 0; }
.pt-head { display: flex; align-items: center; gap: 14px; margin: 14px 0 10px; }
.pt-head h2 { margin: 0; font-size: 24px; }
.pt-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 24px; background: var(--card, #fff); border: 1px solid var(--line); border-radius: 14px; padding: 16px 20px; }
.pt-info div { display: flex; flex-direction: column; gap: 2px; }
.pt-info .wide { grid-column: 1 / -1; }
.pt-info span { font-size: 12px; color: var(--muted); }
.pt-info b { font-weight: 600; white-space: pre-wrap; }
.pt-blocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.pt-block { background: var(--card, #fff); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.pt-block h3 { margin: 0; font-size: 16px; }
.pt-block p { margin: 0; color: var(--muted); }
.pt-block.soon { opacity: 0.7; }
.soon-tag { align-self: flex-start; font-size: 12px; background: #f1f3f6; color: var(--muted); border-radius: 999px; padding: 3px 10px; }
.pd-grid { grid-template-columns: 1fr 1fr; }
.pd-grid .wide { grid-column: 1 / -1; }
.pd-grid textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; }
#pdNombre.need { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18); }
@media (max-width: 900px) {
  .lib-row { grid-template-columns: 1fr; gap: 4px; }
  .pt-info, .pt-blocks { grid-template-columns: 1fr; }
}
.pt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Recordatorio de guardar en la ficha del paciente */
.save-reminder { display: flex; align-items: center; gap: 14px; margin: 0 0 14px; padding: 12px 16px; border-radius: 12px;
  background: #fff6e6; border: 1px solid #f0c27a; color: #7a4a00; font-weight: 600; }
.save-reminder[hidden] { display: none; }
.save-reminder span { flex: 1; }
.btn.attention { box-shadow: 0 0 0 3px rgba(240, 160, 40, 0.55); animation: attention 1.6s ease-in-out infinite; }
@keyframes attention { 50% { box-shadow: 0 0 0 7px rgba(240, 160, 40, 0.15); } }
/* Fotos individuales en el editor */
#editor [hidden] { display: none !important; }
.ed-type { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.ed-type select { height: 34px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; font: inherit; color: var(--fg, inherit); }
.ed-sub { display: block; margin: 10px 0 6px; font-size: 12px; color: var(--muted); }
/* Citas de control y comparaciones */
.pt-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pt-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.pt-sub { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.ctl-date { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.ctl-date input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; max-width: 220px; }
.lib-warn { margin-top: 4px; color: var(--warn); }
