/* Estilos tomados del diseño "Editor de código triple vista" (Claude Design). */
:root {
  --blue: #1B9AC0;
  --green: #7DB928;
  --green-dark: #6ea622;
  --orange: #E8821E;
  --yellow: #E9B818;
  --ink: #24323b;
  --muted: #5f6f7a;
  --soft: #8a97a0;
  --line: #dbe3e8;
  --page: #eef2f4;
  --card: #ffffff;
  --hover: #f1f5f7;
  --gutter-ink: #a9b7c0;
  --fs: 13px;
  --fw: 400;
}
body.dark {
  --ink: #e4ebf0;
  --muted: #9aabb6;
  --line: #2a363e;
  --page: #0f1417;
  --card: #172026;
  --hover: #1e2930;
  --gutter-ink: #5f6f7a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: 'Nunito', system-ui, sans-serif; }
a { color: var(--blue); }
a:hover { color: var(--green); }
button { font-family: inherit; }
textarea:focus { outline: none; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #eef2f4; color: #24323b; }
.login-card { width: 100%; max-width: 980px; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 20px 50px rgba(36,50,59,0.12); }
.login-intro { display: flex; flex-direction: column; gap: 28px; padding: 40px; background: #f6f9fa; }
.login-intro .logo { height: 64px; align-self: flex-start; }
.login-titles { display: flex; flex-direction: column; gap: 8px; }
.login-kicker { font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; color: #1580a0; }
.login-titles h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 800; text-wrap: balance; }
.login-parts { display: flex; flex-direction: column; gap: 16px; }
.login-part { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px; align-items: center; }
.login-part div { display: flex; flex-direction: column; gap: 2px; }
.login-part strong { font-size: 16px; font-weight: 800; }
.login-part div span { font-size: 14px; color: #5f6f7a; }
.part-badge { height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 14px; color: #24323b; }
.part-html { background: #E8821E; }
.part-css { background: #1580a0; color: #fff; }
.part-js { background: #E9B818; }
.tri-bar { display: flex; height: 4px; border-radius: 999px; overflow: hidden; margin-top: auto; }
.tri-bar span { flex: 1; }
.tri-bar span:nth-child(1) { background: #E8821E; }
.tri-bar span:nth-child(2) { background: #1B9AC0; }
.tri-bar span:nth-child(3) { background: #E9B818; }
.login-form { display: flex; flex-direction: column; justify-content: center; gap: 20px; padding: 40px; }
.login-head { display: flex; flex-direction: column; gap: 6px; }
.login-head h2 { margin: 0; font-size: 26px; font-weight: 800; }
.login-head span { font-size: 15px; color: #5f6f7a; }
.login-field { display: flex; flex-direction: column; gap: 8px; font-size: 14px; font-weight: 800; }
.login-field input { width: 100%; height: 50px; padding: 0 16px; border: 2px solid #dbe3e8; border-radius: 12px; background: #fff;
  font-family: 'Nunito', sans-serif; font-size: 16px; font-weight: 600; color: #24323b; }
.login-field input:focus { border-color: #1B9AC0; outline: none; }
.pass-wrap { position: relative; display: flex; }
.pass-wrap input { padding-right: 92px; }
.pass-toggle { position: absolute; right: 8px; top: 8px; height: 34px; padding: 0 12px; border: none; border-radius: 8px;
  background: #eef2f4; color: #24323b; font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 800; cursor: pointer; }
.login-error { padding: 10px 14px; border-radius: 10px; background: #fdf1e4; color: #8a4300; font-size: 14px; font-weight: 700; }
.login-submit { height: 52px; border: none; border-radius: 12px; background: #7DB928; color: #17260a; font-family: 'Nunito', sans-serif;
  font-size: 16px; font-weight: 800; cursor: pointer; }
.login-submit:hover { background: #8cc63a; }
.login-submit:disabled { opacity: 0.6; cursor: wait; }
@media (max-width: 420px) {
  .login { padding: 12px; }
  .login-intro, .login-form { padding: 28px 22px; }
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: #5d6c76;
  letter-spacing: 0.04em; text-transform: uppercase; }
.field input { padding: 12px 14px; border: 2px solid #d7e0e5; border-radius: 10px; font-family: 'Nunito', sans-serif;
  font-size: 15px; font-weight: 400; color: #3d4a52; text-transform: none; letter-spacing: normal; }
.field input:focus { border-color: var(--blue); outline: none; }
.error { font-size: 13px; font-weight: 600; color: var(--orange); }
.ok { font-size: 13px; font-weight: 600; color: var(--green-dark); }
.btn-primary { padding: 13px 18px; border: none; border-radius: 999px; background: var(--green); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer; box-shadow: 0 3px 12px rgba(125,185,40,0.4); }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: wait; }
.logo { height: 48px; width: auto; display: block; mix-blend-mode: multiply; }
body.dark .logo { mix-blend-mode: normal; background: #fff; border-radius: 8px; padding: 4px 8px; box-sizing: content-box; height: 40px; }

/* Cabecera */
.page { min-height: 100vh; display: flex; flex-direction: column; }
header.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 20px;
  background: var(--card); border-bottom: 3px solid var(--blue); }
.top-left { flex: 1 1 200px; display: flex; align-items: center; gap: 14px; }
.top-center { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.top-right { flex: 1 1 200px; display: flex; align-items: center; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.divider { width: 1px; height: 32px; background: var(--line); }
.title { font-size: 18px; font-weight: 700; color: var(--blue); letter-spacing: -0.01em; }
.font-label { font-size: 12px; font-weight: 700; min-width: 36px; text-align: center; color: var(--soft); }
.link-btn { padding: 7px 12px; border-radius: 999px; border: 2px solid var(--line); background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }

/* Editor v2: tarjetas */
.editor-row { flex: 1; display: flex; align-items: stretch; min-height: 320px; height: 60vh; overflow: hidden; }
.gutter { padding: 14px 10px 14px 12px; text-align: right; user-select: none; font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs); font-weight: var(--fw); line-height: 1.65; color: var(--gutter-ink); background: #ffffff;
  border-right: 1px solid rgba(61,74,82,0.10); overflow: hidden; flex: 0 0 auto; min-width: 42px; }
body.dark .gutter { background: #12181c; border-right-color: #2a343a; }
.gutter div.on { color: var(--c); font-weight: 700; }
.wrap { flex: 1; position: relative; display: flex; min-width: 0; background: #ffffff; overflow: hidden; }
body.dark .wrap { background: #161c20; }
.band { position: absolute; left: 0; right: 0; pointer-events: none; border-left: 3px solid transparent; display: none; }
.band.on { display: block; border-left-color: var(--c); background: color-mix(in srgb, var(--c) 6%, transparent); }
body.dark .band.on { background: rgba(255,255,255,0.07); }
.wrap textarea { flex: 1; border: none; padding: 14px; font-family: 'JetBrains Mono', monospace; font-size: var(--fs);
  font-weight: var(--fw); line-height: 1.65; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--ink);
  background: transparent; position: relative; z-index: 1; white-space: pre; overflow: auto; width: 100%; display: block;
  resize: none; tab-size: 2; }
.wrap textarea::selection { background: rgba(27,154,192,0.28); }
.wrap textarea[readonly] { cursor: default; }
/* Relleno extra a la derecha y abajo: así su desplazamiento máximo nunca es menor que el del textarea, que pierde área con sus barras. */
.hl { position: absolute; inset: 0; margin: 0; padding: 14px 54px 54px 14px; overflow: hidden; pointer-events: none;
  font-family: 'JetBrains Mono', monospace; font-size: var(--fs); font-weight: var(--fw); line-height: 1.65;
  white-space: pre; tab-size: 2; color: var(--ink); }

/* Resaltado de sintaxis (contraste de al menos 4.5:1 sobre el fondo de cada modo) */
.tk-tag, .tk-selector { color: #b35400; }
.tk-attr { color: #8a6100; }
.tk-string, .tk-value { color: #2e7d12; }
.tk-comment { color: #647380; font-style: italic; }
.tk-keyword, .tk-prop { color: #0b6e8f; }
.tk-number { color: #8e44ad; }
.tk-punct { color: #5d6c76; }
.tk-name, .tk-text { color: #3d4a52; }
body.dark .tk-tag, body.dark .tk-selector { color: #ffa857; }
body.dark .tk-attr { color: #f0c75e; }
body.dark .tk-string, body.dark .tk-value { color: #a6d96a; }
body.dark .tk-comment { color: #8a9aa5; }
body.dark .tk-keyword, body.dark .tk-prop { color: #5cc8ec; }
body.dark .tk-number { color: #d6a2f0; }
body.dark .tk-punct { color: #a9b7c0; }
body.dark .tk-name, body.dark .tk-text { color: #e6edf2; }

/* Tarjeta que el asistente está escribiendo */
.panel.raised { flex-basis: 100%; box-shadow: 0 16px 36px rgba(61,74,82,0.28); animation: rise 0.35s ease-out; }
body.dark .panel.raised { box-shadow: 0 16px 36px rgba(0,0,0,0.6); }
@keyframes rise {
  from { transform: translateY(16px) scale(0.97); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .panel.raised { animation: none; }
}
.hidden { display: none !important; }

/* Administración */
.admin { width: 100%; max-width: 980px; margin: 0 auto; padding: 24px 20px 40px; display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--card); border-radius: 14px; padding: 22px; box-shadow: 0 2px 10px rgba(61,74,82,0.07); }
.card h2 { margin: 0 0 14px; font-size: 17px; color: var(--blue); }
.create-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.create-form .field { flex: 1 1 200px; }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line); }
.users td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users td:first-child { max-width: 220px; overflow-wrap: anywhere; }
.users .url { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.users .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.users .danger { border-color: #f1c7a3; color: var(--orange); }
.empty { color: var(--soft); font-size: 14px; margin: 0; }
.table-wrap { overflow-x: auto; }

/* Modo del taller */
.mode-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.switch { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--page); border: 1px solid var(--line); }
.switch-opt { padding: 9px 22px; border-radius: 999px; border: none; background: transparent; color: var(--muted);
  font-size: 15px; font-weight: 700; cursor: pointer; }
.switch-opt.on { background: var(--blue); color: #fff; box-shadow: 0 1px 4px rgba(27,154,192,0.4); }
.progress { font-size: 13px; font-weight: 700; color: var(--blue); }
.page { position: relative; }
.lock { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(242,245,247,0.82); }
body.dark .lock { background: rgba(17,22,26,0.82); }
.lock-card { max-width: 420px; padding: 24px 28px; border-radius: 16px; background: var(--card); border-top: 5px solid var(--yellow);
  box-shadow: 0 12px 34px rgba(61,74,82,0.2); display: flex; flex-direction: column; gap: 8px; text-align: center; }
.lock-card strong { font-size: 18px; color: var(--ink); }
.lock-card p { margin: 0; color: var(--muted); font-size: 14px; }

/* Galería */
.gallery { background: var(--page); min-height: 100vh; }
.gal-head { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 12px 20px; background: var(--card); }
.gal-brand { display: flex; flex-direction: column; gap: 2px; }
.gal-sub { font-size: 13px; font-weight: 600; color: var(--muted); }
.gal-progress { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.gal-progress-text { font-size: 13px; font-weight: 800; color: var(--muted); text-align: right; }
.gal-bar { height: 8px; border-radius: 999px; background: var(--page); border: 1px solid var(--line); overflow: hidden; }
.gal-bar-fill { height: 100%; background: var(--yellow); border-radius: 999px; transition: width .3s; }
.tri-bar.flat { border-radius: 0; margin: 0; }
.gal-main { width: 100%; max-width: 1360px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: 24px; }
.gal-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.gal-intro h1 { margin: 0 0 6px; font-size: 30px; font-weight: 800; color: var(--ink); }
.gal-intro p { margin: 0; max-width: 640px; font-size: 15px; line-height: 1.5; color: var(--muted); }
.gal-filters { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.gal-filter { height: 34px; padding: 0 14px; border-radius: 8px; border: none; background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.gal-filter.on { background: var(--ink); color: var(--card); }
.gal-notice { padding: 10px 14px; border-radius: 10px; background: #fdf1e4; color: #8a4300; font-size: 14px; font-weight: 700; }
.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 32px 24px; }
.gal-empty { grid-column: 1 / -1; padding: 40px 20px; text-align: center; border-radius: 14px; border: 1.5px dashed var(--line);
  color: var(--muted); font-size: 15px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.gal-empty p { margin: 0; }
.gal-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.thumb { position: relative; aspect-ratio: 16 / 10; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fff;
  cursor: pointer; padding: 0; transition: box-shadow .2s, transform .2s; }
.thumb:hover, .thumb:focus-visible { box-shadow: 0 10px 28px rgba(36,50,59,0.18); transform: translateY(-2px); }
.thumb iframe { position: absolute; top: 0; left: 0; width: 333.333%; height: 333.333%; transform: scale(0.3); transform-origin: 0 0;
  border: none; pointer-events: none; background: #fff; }
.thumb-play { position: absolute; right: 10px; bottom: 10px; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; background: rgba(15,20,23,0.82); color: #fff; font-size: 13px; font-weight: 800; }
.gal-meta { display: flex; gap: 12px; align-items: flex-start; }
.avatar { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 999px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; }
.gal-names { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.gal-title { font-size: 16px; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gal-author { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vote-row { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); }
.vote-row.on { border-color: var(--yellow); background: #fdf7de; }
body.dark .vote-row.on { background: #2a2619; }
.vote-row.big { border: none; background: transparent; flex: 1; }
.vote-label { flex: 1; font-size: 14px; font-weight: 800; color: var(--muted); }
.vote-row.on .vote-label { color: var(--ink); }
.stars { display: flex; gap: 2px; }
.star { width: 44px; height: 44px; padding: 0; border: none; border-radius: 10px; background: transparent; color: #cfd8de;
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
body.dark .star { color: #3a464e; }
.star.lit, body.dark .star.lit { color: var(--yellow); }
.star:hover { background: var(--page); }
.gal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(15,20,23,0.62); display: flex; align-items: center; justify-content: center; padding: 24px; }
.gal-modal { width: 100%; max-width: 1100px; height: min(86vh, 820px); display: flex; flex-direction: column; background: var(--card);
  border-radius: 16px; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
.gal-modal-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--line); }
.gal-close { width: 34px; height: 34px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.gal-modal iframe { flex: 1; width: 100%; min-height: 0; border: none; background: #fff; }
.gal-modal-foot { display: flex; align-items: center; padding: 10px 14px 10px 18px; border-top: 1px solid var(--line); background: #fdf7de; }
body.dark .gal-modal-foot { background: #2a2619; }
@media (max-width: 600px) {
  .gal-progress { min-width: 0; width: 100%; }
  .gal-progress-text { text-align: left; }
  .gal-main { padding: 20px 16px 40px; }
}

/* Resultados del admin */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.results td.num, .results th:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }

/* Editor v2: cabecera */
.editor-page { height: 100vh; }
.ed-head { display: grid; grid-template-columns: minmax(0,1fr) auto minmax(0,1fr); align-items: center; gap: 12px 20px;
  padding: 12px 20px; background: var(--card); position: relative; z-index: 5; }
.ed-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.ed-brand .logo { height: 40px; }
.ed-brand-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.caption { font-size: 12px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #1580a0; white-space: nowrap; }
body.dark .caption { color: #5cc6e6; }
.name-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.name-wrap { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border-radius: 10px; background: var(--hover);
  border: 1.5px solid var(--line); color: var(--ink); cursor: text; min-width: 0; width: 100%; max-width: 300px; }
.name-wrap svg { flex: 0 0 auto; opacity: 0.6; }
.name-wrap input { flex: 1; min-width: 0; border: none; outline: none; background: transparent; font-family: 'Nunito', sans-serif;
  font-size: 17px; font-weight: 800; color: var(--ink); padding: 0; }
.name-wrap:focus-within { border-color: var(--blue); }
.save-status { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.status-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--green); flex: 0 0 auto; }
.save-status.busy .status-dot { background: var(--yellow); }
.save-status.warn { color: #b35400; }
.save-status.warn .status-dot { background: var(--orange); }
body.dark .save-status.warn { color: #ffa857; }
.seg-main { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--page); border: 1px solid var(--line); justify-self: center; }
.seg-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 18px; border-radius: 999px; border: none;
  background: transparent; color: var(--muted); font-size: 15px; font-weight: 800; cursor: pointer; }
.seg-btn.edit.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.14); }
.seg-btn.run { background: var(--green); color: #17260a; box-shadow: 0 2px 8px rgba(125,185,40,0.35); }
.seg-btn.run.on { box-shadow: inset 0 0 0 2px rgba(23,38,10,0.2); }
.seg-btn.run:disabled { opacity: 0.5; cursor: not-allowed; }
.ed-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pill-btn { height: 40px; padding: 0 14px; display: flex; align-items: center; gap: 8px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.pill-btn.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.ia-mini { height: 22px; min-width: 22px; padding: 0 5px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; background: var(--ink); color: var(--card); }
.pill-btn.on .ia-mini { background: var(--card); color: var(--ink); }
.aa-wrap { position: relative; display: flex; }
.aa-btn { width: 40px; padding: 0; justify-content: center; font-size: 15px; font-weight: 800; }
.aa-btn.on { background: var(--card); color: var(--ink); border-color: var(--ink); }
.pop { position: absolute; top: calc(100% + 8px); right: 0; width: 280px; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.18); padding: 16px; display: flex; flex-direction: column; gap: 16px; z-index: 20; }
.pop-section { display: flex; flex-direction: column; gap: 8px; }
.pop-label { font-size: 13px; font-weight: 800; color: var(--muted); }
.seg { display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 10px; background: var(--hover); }
.seg-opt { flex: 1; height: 34px; border-radius: 8px; border: none; background: transparent; color: var(--ink); font-size: 13px; font-weight: 700; cursor: pointer; }
.seg-opt.on { background: var(--ink); color: var(--card); }
.seg-value { flex: 1; text-align: center; font-size: 13px; font-weight: 800; color: var(--ink); }
@media (max-width: 1000px) {
  .editor-page { height: auto; }
  .ed-head { grid-template-columns: minmax(0,1fr); }
  .seg-main { justify-self: start; }
  .ed-tools { justify-content: flex-start; }
}

/* Editor v2: área de trabajo, pestañas y tarjetas */
.ed-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; padding: 16px 20px 20px; background: var(--page); }
.ed-main.with-assistant { grid-template-columns: minmax(0,1fr) 360px; }
.ed-work { display: flex; flex-direction: column; gap: 12px; min-height: 0; min-width: 0; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { display: flex; align-items: center; gap: 10px; padding: 5px 16px 5px 5px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; }
.tab.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--card)); }
.tab-name { font-size: 15px; font-weight: 800; }
.badge { flex: 0 0 auto; min-width: 50px; height: 32px; padding: 0 10px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; color: #24323b; }
.badge.small { min-width: 46px; height: 28px; font-size: 12px; padding: 0 8px; }
.badge-html { background: #E8821E; }
.badge-css { background: #1580a0; color: #fff; }
.badge-js { background: #E9B818; }
.ed-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0,1fr); gap: 16px; }
.ed-grid.split { grid-template-columns: repeat(3, minmax(0,1fr)); }
.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--card); border: 2px solid color-mix(in srgb, var(--c) 55%, transparent);
  border-radius: 14px; overflow: hidden; transition: box-shadow .15s, border-color .15s; }
.panel:focus-within, .panel.flash { border-color: var(--c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c) 20%, transparent); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: color-mix(in srgb, var(--c) 12%, var(--card));
  border-bottom: 1px solid color-mix(in srgb, var(--c) 25%, transparent); }
.panel-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.panel-name { font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.panel-role { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tip-btn { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 15px; font-weight: 800; cursor: pointer; }
.panel-html .tip-btn.on { background: #E8821E; border-color: #E8821E; color: #24323b; }
.panel-css .tip-btn.on { background: #1580a0; border-color: #1580a0; color: #fff; }
.panel-js .tip-btn.on { background: #E9B818; border-color: #E9B818; color: #24323b; }
.panel-tip { padding: 10px 14px; font-size: 14px; line-height: 1.5; color: var(--ink); background: color-mix(in srgb, var(--c) 12%, var(--card));
  border-bottom: 1px solid color-mix(in srgb, var(--c) 25%, transparent); }
.editor-page .editor-row { height: auto; min-height: 320px; }
.panel.raised { box-shadow: 0 16px 36px rgba(36,50,59,0.28); }
.ed-grid.split .panel.raised { grid-column: 1 / -1; }
@media (max-width: 1000px) {
  .ed-main.with-assistant, .ed-grid.split { grid-template-columns: minmax(0,1fr); }
  .editor-page .editor-row { height: 60vh; }
}

/* Editor v2: resultado */
.result-panel { flex: 1; min-height: 480px; display: flex; flex-direction: column; background: var(--card); border: 2px solid var(--green); border-radius: 14px; overflow: hidden; }
.result-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
  background: #f1f8e6; }
body.dark .result-head { background: #1a2614; }
.result-titles { display: flex; flex-direction: column; margin-right: auto; }
.result-titles strong { font-size: 15px; color: var(--ink); }
.result-titles span { font-size: 13px; color: var(--muted); }
.result-badges { display: flex; align-items: center; gap: 6px; }
.plus-sign { font-size: 14px; font-weight: 800; color: var(--muted); }
.open-link { font-size: 14px; font-weight: 700; }
.result-panel iframe { flex: 1; width: 100%; min-height: 0; border: none; background: #fff; }

/* Editor v2: asistente */
.assistant { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.assist-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ia-badge { width: 36px; height: 36px; border-radius: 10px; background: var(--ink); color: var(--card); display: flex; align-items: center;
  justify-content: center; font-size: 13px; font-weight: 800; flex: 0 0 auto; }
.assist-titles { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.assist-titles strong { font-size: 15px; color: var(--ink); }
.assist-titles span { font-size: 13px; color: var(--muted); }
.round-btn { width: 34px; height: 34px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 auto; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px;
  font-size: var(--fs); font-weight: var(--fw); line-height: 1.5; }
.welcome { display: flex; flex-direction: column; gap: 10px; }
.welcome strong { font-size: 15px; color: var(--ink); }
.welcome p { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.welcome .test-note { font-weight: 700; color: #8a6100; }
body.dark .welcome .test-note { color: #f0c75e; }
.suggestion { text-align: left; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; }
.suggestion:hover:not(:disabled) { border-color: var(--blue); }
.suggestion:disabled { opacity: 0.5; cursor: not-allowed; }
.msg-row { display: flex; }
.msg-row.me { justify-content: flex-end; }
.msg { max-width: 88%; padding: 10px 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg p { margin: 0; }
.msg.user { border-radius: 14px 14px 4px 14px; background: var(--ink); color: var(--card); }
.msg.bot { border-radius: 14px 14px 14px 4px; background: var(--hover); color: var(--ink); white-space: normal; }
.msg.bot.fail { color: #b35400; font-weight: 700; }
body.dark .msg.bot.fail { color: #ffa857; }
.msg.thinking { color: var(--muted); font-weight: 600; }
.changes { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.changes-label { font-size: 12px; font-weight: 800; color: var(--muted); }
.chip { height: 28px; padding: 0 10px; border-radius: 999px; border: none; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 700; cursor: pointer; color: #24323b; }
.chip-html { background: #E8821E; }
.chip-css { background: #1580a0; color: #fff; }
.chip-js { background: #E9B818; }
.diffs { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.diff-block { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.diff-head { width: 100%; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: none; background: transparent; color: var(--ink); cursor: pointer; text-align: left; }
.diff-caret { display: inline-block; transition: transform .15s; color: var(--muted); }
.diff-block.open .diff-caret { transform: rotate(90deg); }
.diff-count { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; }
.diff-count .plus { color: #2e7d12; }
.diff-count .minus { color: #b3261e; }
body.dark .diff-count .plus { color: #a6d96a; }
body.dark .diff-count .minus { color: #ff8a80; }
.diff-body { border-top: 1px solid var(--line); max-height: 260px; overflow: auto; font-family: 'JetBrains Mono', monospace;
  font-size: var(--fs); font-weight: var(--fw); line-height: 1.5; background: #fff; }
body.dark .diff-body { background: #161c20; }
.diff-line { display: flex; white-space: pre; min-width: max-content; }
.diff-line code { font-family: inherit; padding-right: 10px; }
.diff-mark { width: 22px; flex: 0 0 auto; text-align: center; user-select: none; color: var(--muted); }
/* Fondos suaves: el resaltado de sintaxis mantiene un contraste de al menos 4.5:1 sobre ellos. */
.diff-line.add { background: #f2fbee; box-shadow: inset 3px 0 0 #7DB928; }
.diff-line.add .diff-mark { color: #2e7d12; font-weight: 800; }
.diff-line.del { background: #fff6f4; box-shadow: inset 3px 0 0 #e5534b; }
.diff-line.del .diff-mark { color: #b3261e; font-weight: 800; }
body.dark .diff-line.add { background: #1d3317; box-shadow: inset 3px 0 0 #7DB928; }
body.dark .diff-line.add .diff-mark { color: #a6d96a; }
body.dark .diff-line.del { background: #3a1e1c; box-shadow: inset 3px 0 0 #e5534b; }
body.dark .diff-line.del .diff-mark { color: #ff8a80; }
.composer-wrap { padding: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.composer { display: flex; align-items: flex-end; gap: 8px; border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 12px; background: var(--card); }
.composer:focus-within { border-color: var(--blue); }
.composer textarea { flex: 1; border: none; outline: none; resize: none; font-family: 'Nunito', sans-serif; font-size: 14px; line-height: 1.45;
  background: transparent; color: var(--ink); min-height: 42px; max-height: 120px; padding: 4px 0; }
.send-btn { width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; border: none; background: var(--ink); color: var(--card);
  display: flex; align-items: center; justify-content: center; cursor: pointer; }
.send-btn:disabled { background: var(--line); cursor: default; }
.composer-hint { font-size: 12px; color: var(--muted); padding-left: 4px; }
@media (max-width: 1000px) { .assistant { min-height: 480px; } }

/* Sin ligaduras: "=>" o "!=" se ven tal como se escriben (y el textarea y la capa resaltada quedan alineados). */
.wrap textarea, .hl, .gutter, .diff-body, .badge, .chip { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
