:root {
  --bg: #f4f5f7; --surface: #fff; --list: #ebecf0; --text: #172b4d; --muted: #5e6c84; --line: #dfe1e6;
  --accent: #0079bf; --accent-d: #026aa7; --danger: #c9372c; --hover: rgba(9,30,66,.08);
  --shadow: 0 1px 0 rgba(9,30,66,.25); --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #1d2125; --surface: #22272b; --list: #101204; --text: #c7d1db; --muted: #8c9bab; --line: #38414a; --hover: rgba(255,255,255,.1); --shadow: 0 1px 0 rgba(0,0,0,.6); }
  .list { background: #161a1d !important; }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); background-size: cover; background-attachment: fixed; overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
#app { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Botones */
.btn { border: 0; border-radius: 4px; padding: 6px 12px; background: var(--hover); color: var(--text); font-weight: 500; }
.btn:hover { filter: brightness(.95); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.block { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.icon-btn { border: 0; background: transparent; border-radius: 4px; padding: 4px 8px; color: var(--muted); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=url], textarea, select {
  width: 100%; padding: 7px 9px; border: 2px solid var(--line); border-radius: 4px; background: var(--surface); outline: 0;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 60px; }

/* Cabecera */
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,.38); color: #fff; backdrop-filter: blur(6px); flex: none; }
.topbar .logo { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.topbar .logo:hover, .topbar .tb-btn:hover { background: rgba(255,255,255,.2); }
.topbar .tb-btn { border: 0; background: rgba(255,255,255,.14); color: #fff; padding: 6px 10px; border-radius: 4px; }
.topbar .title { font-size: 18px; font-weight: 700; padding: 3px 8px; border-radius: 4px; cursor: pointer; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .title:hover { background: rgba(255,255,255,.2); }
.topbar input.title-edit { font-size: 18px; font-weight: 700; width: 280px; max-width: 50vw; }
.topbar .spacer { flex: 1; }
.topbar .filter { width: 180px; background: rgba(255,255,255,.2); border-color: transparent; color: #fff; padding: 5px 9px; }
.topbar .filter::placeholder { color: rgba(255,255,255,.75); }
.topbar .filter:focus { background: #fff; color: #172b4d; }
.topbar .who { font-size: 13px; opacity: .9; }

/* Inicio */
.home { flex: 1; overflow: auto; padding: 32px 5vw; background: var(--bg); }
.home h2 { margin: 0 0 14px; font-size: 16px; color: var(--muted); }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; max-width: 1100px; }
.board-tile { height: 96px; border-radius: 8px; color: #fff; font-weight: 700; font-size: 16px; padding: 10px 12px; cursor: pointer; position: relative; text-shadow: 0 1px 3px rgba(0,0,0,.4); background-size: cover; border: 0; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.board-tile:hover { filter: brightness(.9); }
.board-tile small { font-weight: 400; opacity: .9; }
.board-tile.new { background: var(--list); color: var(--text); text-shadow: none; font-weight: 500; align-items: center; justify-content: center; flex-direction: row; }

/* Tablero */
.board { flex: 1; display: flex; gap: 12px; padding: 12px; overflow-x: auto; overflow-y: hidden; align-items: flex-start; }
.board::-webkit-scrollbar, .cards::-webkit-scrollbar { height: 12px; width: 8px; }
.board::-webkit-scrollbar-thumb, .cards::-webkit-scrollbar-thumb { background: rgba(0,0,0,.25); border-radius: 6px; }
.list { flex: none; width: 284px; max-height: 100%; display: flex; flex-direction: column; background: var(--list); border-radius: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.list.dragging { opacity: .35; }
.list-ph { flex: none; width: 284px; background: rgba(0,0,0,.2); border-radius: 12px; align-self: stretch; max-height: 120px; }
.list-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 12px; cursor: grab; border-radius: 12px 12px 0 0; }
.list-head .ltitle { flex: 1; font-weight: 600; padding: 3px 4px; border-radius: 4px; word-break: break-word; cursor: pointer; }
.list-head .count { color: var(--muted); font-size: 12px; }
.list-head input { font-weight: 600; padding: 3px 6px; }
.list-bar { height: 5px; margin: 0 12px 4px; border-radius: 3px; }
.cards { overflow-y: auto; padding: 2px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); cursor: pointer; overflow: hidden; position: relative; }
.card:hover { outline: 2px solid var(--accent); }
.card.dragging { opacity: .35; }
.card.done .ctitle { text-decoration: line-through; opacity: .6; }
.ph { background: rgba(9,30,66,.18); border-radius: 8px; flex: none; }
.card .cover-img { display: block; width: 100%; max-height: 180px; object-fit: cover; background: #000; }
.card .cover-yt { position: relative; }
.card .cover-yt::after { content: "▶"; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 38px; height: 38px; line-height: 38px; text-align: center; border-radius: 50%; background: rgba(0,0,0,.65); color: #fff; font-size: 16px; padding-left: 3px; }
.card .cover-color { height: 32px; }
.card .cbody { padding: 7px 10px 8px; }
.card .ctitle { word-break: break-word; white-space: pre-wrap; }
.labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.lbl { min-width: 40px; height: 8px; border-radius: 4px; }
.lbl.full { height: auto; min-height: 24px; padding: 2px 10px; color: #fff; font-size: 12px; font-weight: 600; text-shadow: 0 1px 1px rgba(0,0,0,.35); border-radius: 4px; display: inline-flex; align-items: center; min-width: 48px; }
.badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 3px; border-radius: 3px; }
.badge.overdue { background: #ffd5d2; color: #ae2e24; }
.badge.soon { background: #f5cd47; color: #3d2e00; }
.badge.ok { background: #4bce97; color: #053d27; }
.badge.complete { background: #4bce97; color: #053d27; }
.add-card { padding: 6px 8px 8px; }
.add-card button.open { width: 100%; text-align: left; border: 0; background: transparent; color: var(--muted); padding: 7px 8px; border-radius: 8px; }
.add-card button.open:hover { background: var(--hover); color: var(--text); }
.composer textarea { min-height: 54px; margin-bottom: 6px; }
.composer .row { display: flex; gap: 6px; align-items: center; }
.add-list { flex: none; width: 284px; background: rgba(255,255,255,.28); border-radius: 12px; padding: 4px; }
.add-list > button { width: 100%; text-align: left; border: 0; background: transparent; color: #fff; padding: 9px 12px; font-weight: 500; border-radius: 10px; }
.add-list > button:hover { background: rgba(255,255,255,.2); }
.add-list .composer { background: var(--list); border-radius: 12px; padding: 8px; }

/* Overlays */
#overlay { position: fixed; inset: 0; z-index: 50; display: none; }
#overlay.on { display: flex; align-items: flex-start; justify-content: center; background: rgba(9,30,66,.6); overflow-y: auto; padding: 40px 12px; }
.modal { background: var(--bg); border-radius: 12px; width: 100%; max-width: 780px; position: relative; padding: 18px 20px 24px; box-shadow: 0 8px 40px rgba(0,0,0,.4); margin: auto 0; }
.modal.small { max-width: 440px; }
.modal h3 { margin: 0 0 12px; font-size: 18px; }
.modal .x { position: absolute; right: 10px; top: 10px; font-size: 18px; }
.cm-cover { margin: -18px -20px 14px; border-radius: 12px 12px 0 0; height: 70px; }
.cm-title { width: 100%; font-size: 20px; font-weight: 700; border: 2px solid transparent; background: transparent; padding: 4px 8px; margin: 0 0 2px -8px; border-radius: 4px; resize: none; overflow: hidden; min-height: 0; }
.cm-title:focus { background: var(--surface); border-color: var(--accent); }
.cm-sub { color: var(--muted); margin-bottom: 12px; padding-left: 0; }
.cm-grid { display: grid; grid-template-columns: 1fr 170px; gap: 20px; }
@media (max-width: 640px) { .cm-grid { grid-template-columns: 1fr; } }
.sec { margin-bottom: 18px; }
.sec h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sec h4 .sp { flex: 1; }
.sec .muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.desc-view { padding: 8px 10px; background: var(--hover); border-radius: 6px; white-space: pre-wrap; word-break: break-word; cursor: text; min-height: 40px; }
.desc-view.empty { color: var(--muted); }
.side h5 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 0 0 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 32px; height: 26px; border-radius: 4px; border: 2px solid transparent; cursor: pointer; padding: 0; }
.sw.sel { border-color: var(--text); }
.sw.big { width: 74px; height: 46px; }
.lbl-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.lbl-row .lbl-pick { flex: 1; min-height: 30px; border-radius: 4px; border: 0; color: #fff; font-weight: 600; text-align: left; padding: 4px 10px; text-shadow: 0 1px 1px rgba(0,0,0,.35); display: flex; justify-content: space-between; }
.chk { display: flex; align-items: flex-start; gap: 8px; padding: 4px 2px; border-radius: 4px; }
.chk:hover { background: var(--hover); }
.chk input { margin-top: 3px; }
.chk .t { flex: 1; word-break: break-word; }
.chk.done .t { text-decoration: line-through; color: var(--muted); }
.chk .del { visibility: hidden; }
.chk:hover .del { visibility: visible; }
.progress { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.progress .bar { flex: 1; height: 7px; background: var(--hover); border-radius: 4px; overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.progress.full .bar i { background: #1f845a; }
.att { display: flex; gap: 10px; margin-bottom: 10px; align-items: flex-start; }
.att .thumb { width: 112px; height: 76px; border-radius: 6px; background: var(--hover) center/cover no-repeat; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); overflow: hidden; position: relative; }
.att .thumb img { width: 100%; height: 100%; object-fit: cover; }
.att .info { flex: 1; min-width: 0; }
.att .info .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.att .info .m { color: var(--muted); font-size: 12px; }
.att .info .acts { margin-top: 4px; display: flex; gap: 8px; }
.att .info .acts button { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 12px; }
.pv { margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.pv .yt { position: relative; aspect-ratio: 16/9; background: #000 center/cover; cursor: pointer; }
.pv .yt::after { content: "▶"; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); width: 64px; height: 44px; line-height: 44px; text-align: center; border-radius: 12px; background: #f00; color: #fff; font-size: 20px; }
.pv .yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pv img.big { display: block; max-width: 100%; max-height: 420px; margin: 0 auto; cursor: zoom-in; }
.pv .meta { padding: 7px 10px; font-size: 13px; }
.pv .meta b { display: block; }
.pv .meta span { color: var(--muted); font-size: 12px; }
.pv.link { display: flex; }
.pv.link .pimg { width: 120px; flex: none; background: var(--hover) center/cover; }
.pv video, .pv audio { display: block; width: 100%; }
.cmt { display: flex; gap: 10px; margin-bottom: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; text-transform: uppercase; }
.cmt .body { flex: 1; min-width: 0; }
.cmt .who { font-weight: 600; } .cmt .when { color: var(--muted); font-size: 12px; margin-left: 6px; }
.cmt .txt { background: var(--surface); padding: 7px 10px; border-radius: 8px; box-shadow: var(--shadow); white-space: pre-wrap; word-break: break-word; margin-top: 3px; }
.drop-hint { border: 2px dashed var(--accent); border-radius: 12px; }
.row2 { display: flex; gap: 8px; margin-top: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.user-row span { flex: 1; }
.bg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; margin-bottom: 12px; }
.bg-grid .sw { width: auto; height: 56px; }

/* Auth */
.auth { margin: auto; width: 340px; max-width: 92vw; background: var(--surface); padding: 28px; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.auth h1 { margin: 0 0 4px; font-size: 22px; } .auth p { margin: 0 0 16px; color: var(--muted); }
.auth label { display: block; margin: 10px 0 4px; font-weight: 600; font-size: 12px; color: var(--muted); }
.auth .btn { width: 100%; margin-top: 16px; padding: 9px; }
.err { color: var(--danger); margin-top: 10px; min-height: 18px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #172b4d; color: #fff; padding: 9px 16px; border-radius: 6px; z-index: 99; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; }
#toast.on { opacity: 1; }
.card.dragging, .list.dragging { display: none; }
.pv .yt.playing::after { display: none; }
.pv .yt img.ytimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.card .cover-yt img, .card .cover-img { width: 100%; display: block; }
.card .cover-yt { position: relative; aspect-ratio: 16/9; background: #111; overflow: hidden; }
.card .cover-yt img.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; object-fit: cover; }
.lchip { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding: 6px; background: var(--hover); border-radius: 8px; }
.lc-img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; background: var(--line); }
.lc-img.round { border-radius: 50%; }
.lc-b { min-width: 0; }
.lc-t { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-s { font-size: 11px; color: var(--muted); }
.pv.link.chan .pimg { width: 84px; height: 84px; border-radius: 50%; margin: 10px; flex: none; background-size: cover; background-position: center; }

.live { width: 9px; height: 9px; border-radius: 50%; background: #f5a623; display: inline-block; flex: none; }
.live.on { background: #4bce97; }
.lchip.big { flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; gap: 0; }
.lc-img.wide { width: 100%; height: auto; max-height: 150px; border-radius: 0; }
.lchip.big .lc-b { padding: 6px 8px; }
.lchip.big .lc-img.hidden + .lc-b { padding: 8px; }

.lc-media { background: var(--line); }
.lc-media img { width: 100%; max-height: 150px; object-fit: cover; display: block; }
.lc-media.sq { display: flex; justify-content: center; padding: 12px; background: var(--hover); }
.lc-media.sq img { width: 72px; height: 72px; border-radius: 50%; }
.lc-d { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 6px; }
.lc-s { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.lc-fav { width: 14px; height: 14px; border-radius: 3px; }
