/* UI web MedNote — componentes sobre los tokens de la extensión.
   Paleta: mednote-theme.css (GENERADO desde src/theme-tokens.js, npm run build:theme).
   Acá NO van colores: test/web-no-hex.test.js falla si aparece un hex o rgb(). */
@import url("mednote-theme.css");

:root {
  /* Tipografía: la misma pila que el panel (src/overlay.js). Sin webfonts. */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius-lg: 12px; --radius-md: 8px; --radius-sm: 6px;
  --page-max: 760px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  /* Alias históricos de páginas ya migradas. */
  --pos: var(--tok-add);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body:has(.foot) { padding-bottom: 88px; }
a { color: var(--chip-text); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.hd {
  background: var(--header-grad);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 20;
}
.hd::after { content: ""; display: block; height: 2px; background: var(--header-bar); }
.hd-inner, .toolbar, main, .banner, .foot-inner {
  width: min(var(--page-max), calc(100% - 32px));
  margin-left: auto; margin-right: auto;
}
.hd-inner { display: flex; align-items: center; gap: 12px; padding: 14px 0 16px; flex-wrap: wrap; }
.hd-icon { width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; object-fit: cover; display: block; }
.hd-title { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.hd-title strong { font-size: 16px; font-weight: 650; }
.hd-sub { font-size: 11px; font-weight: 600; color: var(--text-faint); letter-spacing: .32px; text-transform: uppercase; }
.hd-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hd-actions a, .hd-actions span {
  color: var(--text-dim); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px;
}
.hd-actions a:hover { background: var(--fill-hover); color: var(--text); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 16px 0 0;
}
.seg {
  display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 2px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-raised);
}
.seg button {
  background: transparent; border: 0; color: var(--text-dim); cursor: pointer;
  padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 550;
  min-height: 36px;
}
.seg button.is-on { background: var(--fill-seg-on); color: var(--accent); }
.seg button:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring-focus); }

.banner {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--surface-raised); border: 1px solid var(--border-soft);
  color: var(--text-dim); font-size: 13px;
}
.banner.err { color: var(--danger); border-color: var(--tok-del-bg); background: var(--tok-del-bg); }
.banner.ok { color: var(--pos); border-color: var(--tok-add-bg); background: var(--tok-add-bg); }

main { padding: 16px 0 56px; display: flex; flex-direction: column; gap: 16px; }
h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
h2 { margin: 0 0 8px; font-size: 17px; font-weight: 650; }
.lede { margin: 0; color: var(--text-dim); font-size: 14.5px; }

.panel {
  background: var(--surface-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px; box-shadow: var(--shadow-chrome);
}
.panel-head {
  padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.pitch { font-size: 16px; line-height: 1.55; margin: 0 0 14px; }
.pitch:last-child { margin-bottom: 0; }
.does, .doesnt { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.does li, .doesnt li {
  padding-left: 28px; position: relative; color: var(--text-dim); font-size: 14.5px;
}
.does li::before, .doesnt li::before {
  position: absolute; left: 0; top: 0; font-weight: 700; font-size: 14px;
}
.does li::before { content: "✓"; color: var(--pos); }
.doesnt li::before { content: "×"; color: var(--danger); }
.split { display: grid; gap: 16px; }
@media (min-width: 640px) {
  .split { grid-template-columns: 1fr 1fr; }
  .hd-inner, .toolbar, main, .banner, .foot-inner { width: min(var(--page-max), calc(100% - 48px)); }
}

.cta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-top: 4px;
}
.btn {
  font: inherit; font-size: 14px; font-weight: 650; color: var(--text-on-accent);
  background: var(--accent); border: 0; border-radius: var(--radius-sm);
  padding: 12px 20px; min-height: 44px; cursor: pointer; display: inline-flex;
  align-items: center; justify-content: center; text-decoration: none;
}
.btn:hover { background: var(--accent-hover); color: var(--text-on-accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-ring-soft); }
.btn.sec {
  background: var(--surface-raised); color: var(--text); border: 1px solid var(--border);
}
.btn.sec:hover { background: var(--fill-hover); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--rec-hover); color: var(--text-on-accent); }
.btn.sec.danger {
  background: var(--surface-raised);
  color: var(--danger);
  border-color: var(--tok-del-bg);
}
.btn.sec.danger:hover {
  background: var(--tok-del-bg);
  color: var(--danger);
}
.btn.tiny { padding: 6px 12px; min-height: 34px; font-size: 13px; font-weight: 600; }

label.lbl { display: grid; gap: 6px; font-size: 14px; font-weight: 650; color: var(--text); }
label.lbl span.hint { font-weight: 500; color: var(--text-faint); font-size: 12.5px; }
.req { color: var(--accent); font-weight: 700; }
.fields { display: grid; gap: 18px; }
input[type="text"], input[type="password"], select, textarea {
  width: 100%; font: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 42px;
}
select {
  font-weight: 550;
  background: var(--surface) var(--select-chevron) no-repeat right 12px center;
  padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
}
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring-soft);
}
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  padding: 8px 12px; min-height: 40px; cursor: pointer; font-size: 13.5px; font-weight: 500;
}
.opt:has(:checked) {
  border-color: var(--accent); background: var(--fill-seg-on); color: var(--accent);
}
.opt input { accent-color: var(--accent); margin: 0; }
.opt:focus-within { box-shadow: 0 0 0 3px var(--accent-ring-soft); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset legend { padding: 0; margin-bottom: 10px; font-size: 14px; font-weight: 650; }

ol.pasos { counter-reset: paso; list-style: none; padding: 0; margin: 0; }
ol.pasos > li {
  counter-increment: paso; position: relative; padding: 0 0 22px 52px;
}
ol.pasos > li:last-child { padding-bottom: 0; }
ol.pasos > li::before {
  content: counter(paso); position: absolute; left: 0; top: 0;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--fill-seg-on); border: 1px solid var(--accent-ring-soft);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--accent);
}
ol.pasos h3 { margin: 4px 0 6px; font-size: 15.5px; }
ol.pasos p { margin: 0 0 6px; color: var(--text-dim); font-size: 14px; }
code, kbd {
  background: var(--surface-sunken); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 1px 7px; font-size: 13px;
  font-family: var(--font-mono); color: var(--text);
}
.nota {
  background: var(--tok-corr-bg); border: 1px solid var(--confirm-border);
  border-radius: var(--radius-md); padding: 14px 16px; font-size: 13.5px; color: var(--tok-corr);
}
.nota strong { color: var(--text); }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--text-dim); font-size: 13.5px; font-weight: 550; }
details p { font-size: 13.5px; color: var(--text-dim); margin: 8px 0 0; }

.q + .q { margin-top: 20px; }
.count { display: block; text-align: right; font-size: 12px; color: var(--text-faint); margin-top: 4px; }
input:disabled, textarea:disabled, select:disabled { opacity: .9; cursor: default; color: var(--text); }
.opt:has(:disabled) { cursor: default; }
.seg button:disabled { cursor: default; }

.page-wide { --page-max: 960px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.data, .table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data th, .table th {
  text-align: left; font-size: 11.5px; font-weight: 650; color: var(--text-faint);
  letter-spacing: .32px; text-transform: uppercase;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.data td, .table td { padding: 12px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr:hover td, .table tbody tr:hover td { background: var(--fill-hover); }
.data .muted { color: var(--text-faint); font-weight: 500; }
.chip {
  display: inline-flex; align-items: center;
  background: var(--chip-bg); color: var(--chip-text); box-shadow: inset 0 0 0 1px var(--chip-ring);
  border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.empty-row { color: var(--text-dim); font-size: 14px; padding: 18px 10px; }

.modal-bg {
  position: fixed; inset: 0; z-index: 40;
  /* Scrim: claro en día, oscuro en noche. */
  background: color-mix(in srgb, var(--surface-sunken) 72%, transparent);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px 24px; overflow: auto;
}
.modal-bg[hidden] { display: none; }
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 64px);
  overflow: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-chrome);
  padding: 20px 22px;
}
.modal-hd {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding-bottom: 14px; margin-bottom: 16px; border-bottom: 1px solid var(--border-soft);
}
.modal-hd h2 { margin: 0; font-size: 18px; }
.modal-ft { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.foot {
  position: sticky; bottom: 0; z-index: 30;
  background: var(--surface-raised); border-top: 1px solid var(--border-soft);
  box-shadow: var(--shadow-header);
}
.foot-inner {
  padding: 12px 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.foot .meta { flex: 1; min-width: 140px; font-size: 13px; color: var(--text-dim); }

@media (max-width: 639px) {
  .seg { width: 100%; }
  .seg button { flex: 1; }
  .opt { width: 100%; }
  .cta .btn, .foot .btn { width: 100%; }
  .foot-inner { flex-direction: column; align-items: stretch; }
}

/* --- Componentes calcados del panel (src/overlay.js) --- */
.btn.ghost { background: transparent; border: 1px solid transparent; color: var(--text-dim); }
.btn.ghost:hover { background: var(--fill-hover); color: var(--text); }

.field { width: 100%; }

/* Diff de correcciones: los mismos 4 colores que la leyenda del panel
   (agregado / eliminado / corrección de dictado / sugerencia). */
.tok-add { color: var(--tok-add); background: var(--tok-add-bg); border-radius: 3px; padding: 0 2px; }
.tok-del { color: var(--tok-del); background: var(--tok-del-bg); border-radius: 3px; padding: 0 2px; text-decoration: line-through; }
.tok-corr { color: var(--tok-corr); background: var(--tok-corr-bg); border-radius: 3px; padding: 0 2px; }
.tok-sug { color: var(--chip-text); background: var(--chip-bg); border-radius: 3px; padding: 0 2px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; }
.dot.add { background: var(--tok-add-dot); }
.dot.del { background: var(--tok-del-dot); }
.dot.corr { background: var(--tok-corr-dot); }
.dot.sug { background: var(--brand-cyan); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-soft); background: transparent;
  color: var(--text-dim); cursor: pointer; font: inherit; font-size: 15px; line-height: 1; padding: 0;
}
.theme-toggle:hover { background: var(--fill-hover); color: var(--text); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring-focus); }

/* --- Login / registro (login.html) --- */
body.page-center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; padding: 24px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth-brand img { border-radius: 10px; display: block; }
.auth-brand > div { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.auth-brand strong { font-size: 18px; font-weight: 650; }
.auth-form { display: grid; gap: 12px; }
.auth-form .lbl { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.btn.wide { width: 100%; margin-top: 6px; }
.auth-alt { text-align: center; font-size: 13px; margin: 14px 0 0; color: var(--text-dim); }
.err {
  color: var(--danger); font-size: 13px; margin: 0 0 12px; padding: 8px 10px;
  border-radius: var(--radius-md); background: var(--tok-del-bg);
}
