:root {
  --bg: #f4f5f7; --surface: #fff; --text: #14171c; --muted: #5d6573; --line: #dde0e6;
  --accent: #2557d6; --on-accent: #fff; --warn: #8a5200; --warn-bg: #fff0d6; --bad: #a4161a; --bad-bg: #fde4e4;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --surface: #181b22; --text: #eceef2; --muted: #9aa2b1; --line: #2b303a;
    --accent: #6b93ff; --on-accent: #08102a; --warn: #ffc46b; --warn-bg: #3a2a0c; --bad: #ff9c9c; --bad-bg: #3d1517;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, sans-serif; }
header { display: flex; justify-content: space-between; align-items: center; max-width: 1100px; margin: 0 auto; padding: 8px 16px; }
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 190px; }
h1 { font-size: 1.35rem; margin: 0 0 8px; }
h2 { font-size: 1.05rem; }
ul { list-style: none; padding: 0; margin: 0; }
p { margin: 6px 0; }

.screen { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.narrow { width: min(360px, 100%); display: grid; gap: 10px; }
label { display: block; }
label[for] { font-size: .9rem; color: var(--muted); margin: 8px 0 4px; }

/* 16px en los campos: evita que iOS haga zoom al enfocarlos */
input:not([type=checkbox]), textarea, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { resize: vertical; font-size: 16px; }
input[type=checkbox] { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin: 0; }
button, .button {
  font: inherit; font-weight: 600; min-height: 44px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; touch-action: manipulation;
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ghost { background: transparent; font-weight: 500; }
.danger { color: var(--bad); }
.wide { width: 100%; }
button:disabled { opacity: .55; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.brand { border: 0; background: none; padding: 0; font-size: 1.1rem; font-weight: 700; }

.url-row { display: grid; gap: 8px; }
summary { cursor: pointer; min-height: 36px; display: list-item; padding-top: 6px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.compact { min-height: 36px; }
.inline { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin: 6px 0; }
.inline input, .inline select { width: 13rem; max-width: 60%; }
.inline input { width: 7rem; }
.sub.inline select { flex: 1; width: auto; max-width: none; min-width: 0; padding-inline: 8px; }
.sub { margin-left: 32px; }
.hint, .muted { color: var(--muted); }
.hint, .small { font-size: .82rem; }
.error { color: var(--bad); }
.error:empty { display: none; }
.center { text-align: center; padding: 24px 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.history-item { display: block; width: 100%; text-align: left; margin-bottom: 8px; background: var(--surface); }
.history-item span { display: block; }
.history-item small { color: var(--muted); font-weight: 400; }

.bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 8px 0; }
.bar i { display: block; height: 100%; width: 35%; background: var(--accent); animation: slide 1.3s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .bar i { animation: none; width: 100%; } }
#warnings ul { font-size: .88rem; list-style: disc; padding-left: 18px; overflow-wrap: anywhere; }

.toolbar { margin: 12px 0 10px; }
.grid { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.video { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; content-visibility: auto; contain-intrinsic-size: auto 340px; }
.hidden-item { opacity: .65; border-style: dashed; }
.media { position: relative; }
.thumb { aspect-ratio: 16 / 9; background: var(--line) url("icon.svg") center / 48px no-repeat; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick { position: absolute; top: 10px; left: 10px; width: 28px !important; height: 28px !important; }
.info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.title { font-weight: 600; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; }
.badges span { font-size: .76rem; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; }
.badges .warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badges .bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.badges .dim { color: var(--muted); }
.reason { color: var(--warn); font-size: .84rem; margin: 0; }
.actions { margin-top: 6px; }
#more { margin-top: 14px; }

#dock { position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); z-index: 2; }
#dock > * { max-width: 1068px; margin-inline: auto; }
.dock-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.dock-options label { font-size: .78rem; color: var(--muted); }

dialog { width: min(560px, calc(100% - 24px)); max-height: 90dvh; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); padding: 14px; }
dialog::backdrop { background: rgb(0 0 0 / .65); }
dialog video { width: 100%; max-height: 68dvh; background: #000; }
.parts li { margin-bottom: 8px; }
#dialog-close { margin-top: 10px; }

@media (min-width: 640px) {
  .url-row { grid-template-columns: 1fr auto; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  main { padding-bottom: 170px; }
}
