:root {
  --bg: #ffffff; --surface: #f6f6f8; --border: rgba(0,0,0,.10); --text: #0d0d0d; --muted: #5d5d5d;
  --accent: #7c5cff; --accent-soft: rgba(124,92,255,.12);
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Inter, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #16161c; --surface: #202028; --border: rgba(255,255,255,.10); --text: #ececec; --muted: #a8a8b3; --accent-soft: rgba(124,92,255,.22); }
}
:root[data-theme="dark"] { --bg: #16161c; --surface: #202028; --border: rgba(255,255,255,.10); --text: #ececec; --muted: #a8a8b3; --accent-soft: rgba(124,92,255,.22); }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); min-height: 100vh; }
.hidden { display: none !important; }

.cv-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding: 16px 20px 6px; }
.cv-top h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.cv-sub { color: var(--muted); font-size: 13px; }
.cv-back { color: var(--muted); text-decoration: none; font-size: 14px; border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; }
.cv-back:hover { color: var(--text); border-color: var(--accent); }

.cv-main { max-width: 860px; margin: 0 auto; padding: 10px 16px 40px; display: flex; flex-direction: column; gap: 18px; }

.cv-drop { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 26px 16px 22px; border: 2px dashed var(--border); border-radius: 22px; background: var(--surface); cursor: pointer; text-align: center; transition: border-color .2s, background .2s; }
.cv-drop:hover, .cv-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.cv-drop strong { font-size: 18px; }
.cv-drop span { color: var(--muted); font-size: 13px; }
.cv-cloud { width: 150px; height: 112px; margin-bottom: -26px; position: relative; z-index: 1; }
.cv-sack { width: 120px; height: 90px; }

.cv-files { display: flex; flex-wrap: wrap; gap: 8px; }
.cv-file { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; font-size: 14px; max-width: 100%; }
.cv-file b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.cv-image-size { flex: 1 0 100%; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.cv-image-size select { min-height: 36px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.cv-file small { color: var(--muted); }
.cv-file button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; }

.cv-targets h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 6px 0 8px; }
.cv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 10px; }
.cv-opt { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s; }
.cv-opt:hover { border-color: var(--accent); }
.cv-opt b { font-size: 15px; }
.cv-opt small { color: var(--muted); font-size: 12px; }
.cv-opt .cv-tag { font-size: 11px; color: var(--accent); font-weight: 700; }
.cv-ai { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 4px; }

.cv-status { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; }
.cv-bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.cv-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7c3aed, #3b82f6); transition: width .3s; }
.cv-status p { margin: 10px 0 0; }
#cv-result { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cv-dl { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 10px; background: var(--accent-primary, #7c5cff); color: #fff; text-decoration: none; font-weight: 600; box-shadow: none; }
.cv-err { color: #e5484d; font-weight: 600; padding: 10px 14px; border-radius: 10px; background: rgba(229, 72, 77, .12); border: 1px solid rgba(229, 72, 77, .35); }

@media (max-width: 480px) { .cv-top h1 { font-size: 19px; } .cv-grid { grid-template-columns: repeat(2, 1fr); } }

.cv-catalog h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 10px; }
#cv-cat { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.cv-cat-group { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 12px 14px; animation: cv-in .35s ease both; }
.cv-cat-group h3 { margin: 0 0 8px; font-size: 15px; }
.cv-cat-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-chip { border: 1px solid var(--border); background: var(--bg); color: var(--text); border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; transition: border-color .15s, background .15s; }
.cv-chip:hover { border-color: var(--accent); background: var(--accent-soft); }
@keyframes cv-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .cv-cat-group { animation: none; } }

/* Barras de desplazamiento finas y discretas */
* { scrollbar-width: thin; scrollbar-color: rgba(127,127,127,.35) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(127,127,127,.32); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }

/* Casilla «Mejorar con la IA» con el estilo de la marca */
.cv-ai { display: flex; align-items: center; gap: 10px; }
.cv-ai input[type="checkbox"] { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; flex: none; margin: 0; border-radius: 6px; border: 1.5px solid rgba(255,255,255,.28); background: rgba(255,255,255,.05); display: inline-grid; place-items: center; cursor: pointer; }
.cv-ai input[type="checkbox"]:checked { background: linear-gradient(135deg, #7c3aed, #3b82f6); border-color: transparent; }
.cv-ai input[type="checkbox"]:checked::after { content: ""; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }

/* Traducir documento: idioma de destino + botón */
.cv-tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.cv-tr > .ns, .cv-tr > .cv-tr-field { flex: 4 1 130px; min-width: 0; }
.cv-tr .ns .ns-btn { width: 100%; }
.cv-tr-field { height: 42px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; max-width: 100%; }
.cv-tr-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cv-tr-go { flex: 1 0 auto; height: 42px; padding: 0 20px; border: 0; border-radius: 12px; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.cv-tr-go:disabled, .cv-opt:disabled { opacity: .55; cursor: default; }
.cv-tr small { flex: 1 1 100%; color: var(--muted); font-size: 12px; }
.cv-ai { align-items: flex-start; }
.cv-file b { min-width: 0; } .cv-file small { flex: none; white-space: nowrap; }
.cv-status p { overflow-wrap: anywhere; }
.cv-dl { max-width: 100%; overflow-wrap: anywhere; }
/* Casilla visible también en tema claro */
:root[data-theme="light"] .cv-ai input[type="checkbox"]:not(:checked) { border-color: rgba(0,0,0,.35); background: rgba(0,0,0,.04); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .cv-ai input[type="checkbox"]:not(:checked) { border-color: rgba(0,0,0,.35); background: rgba(0,0,0,.04); } }
/* Panel estrecho (≈270 px) */
@media (max-width: 340px) {
  .cv-top { padding: 12px 12px 4px; } .cv-main { padding: 8px 10px 32px; }
  .cv-grid { gap: 8px; } .cv-opt { padding: 10px; min-width: 0; } .cv-opt b, .cv-opt small { overflow-wrap: anywhere; }
  #cv-cat { grid-template-columns: 1fr; }
  .cv-tr-go { flex: 1 1 100%; }
}
/* Tema claro: los estilos comunes pintan campos y bordes pensados para fondo oscuro */
html[data-theme="light"] body .cv-tr .cv-tr-field { background: var(--surface) !important; border-color: rgba(0,0,0,.16) !important; color: var(--text) !important; }
html[data-theme="light"] body .cv-opt, html[data-theme="light"] body .cv-file, html[data-theme="light"] body .cv-status { border-color: rgba(0,0,0,.12) !important; }
