:root {
  --bg: #17141a; --panel: #231f27; --text: #f2edf5; --muted: #a79eb0;
  --accent: #e0577b; --warn: #e8b04a; --radius: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #faf6f8; --panel: #fff; --text: #2a2230; --muted: #6f6677; color-scheme: light; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, sans-serif; }
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 1.4rem; }

#login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
#login-form { background: var(--panel); padding: 28px; border-radius: var(--radius); width: min(360px, 100%); display: grid; gap: 12px; }
input { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--muted); background: var(--bg); color: var(--text); font: inherit; }
button { padding: 10px 14px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; cursor: pointer; }
button:hover { filter: brightness(1.1); }
#logout { background: transparent; border: 1px solid var(--muted); color: var(--muted); margin-left: auto; }
#login-error { color: var(--warn); margin: 0; min-height: 1.4em; }

header { display: flex; align-items: center; gap: 16px; padding: 14px 16px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
#count { color: var(--muted); }
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; padding: 8px 16px 32px; }
.tile { background: var(--panel); border-radius: var(--radius); padding: 8px; display: grid; gap: 6px; align-content: start; }
.tile img { width: 100%; aspect-ratio: 1500 / 2100; border-radius: 6px; background: var(--bg); object-fit: cover; }
.tile .name { font-size: .9rem; font-weight: 600; }
.tile .meta { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: .72rem; padding: 2px 7px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.badge.commander { background: var(--accent); color: #fff; }
.badge.warn { color: var(--warn); border: 1px solid var(--warn); }

a.button, button.ghost, .button { text-decoration: none; display: inline-block; }
button.ghost, a.button.ghost { background: transparent; border: 1px solid var(--muted); color: var(--muted); padding: 9px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile { cursor: pointer; color: inherit; text-decoration: none; }
.tile:hover { outline: 2px solid var(--accent); }

#editor header h1 { font-size: 1.15rem; flex: 1; }
#editor nav { display: flex; gap: 8px; }
.editor-body { display: grid; grid-template-columns: minmax(260px, 460px) minmax(260px, 420px); gap: 32px; padding: 8px 16px 40px; justify-content: center; align-items: start; }
@media (max-width: 760px) { .editor-body { grid-template-columns: 1fr; } }
#stage { position: relative; width: 100%; aspect-ratio: 1500 / 2100; border-radius: 4.5%; overflow: hidden; background: var(--panel); touch-action: none; user-select: none; }
#stage > img#render { position: absolute; inset: 0; width: 100%; height: 100%; }
#art { position: absolute; overflow: hidden; cursor: grab; }
#art.dragging { cursor: grabbing; }
#art img { position: absolute; max-width: none; pointer-events: none; }
/* Marco con el hueco del dibujo transparente: va por encima de la foto, como en la carta final (así la placa del nombre original nunca queda tapada). */
#stage > img#frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#stage.drag-over { outline: 3px dashed var(--accent); outline-offset: -3px; }
#drop-hint { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: #fff; font-weight: 600; }
#controls { display: grid; gap: 16px; }
fieldset { border: 1px solid var(--muted); border-radius: var(--radius); padding: 14px; display: grid; gap: 10px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.help { color: var(--muted); font-size: .85rem; margin: 0; }
#status { min-height: 1.4em; margin: 0; color: var(--muted); }
#status.error { color: var(--warn); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

#loading { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.loading-box { background: var(--panel); padding: 28px; border-radius: var(--radius); max-width: 420px; display: grid; gap: 12px; }
#downloads { position: relative; }
#downloads summary { list-style: none; cursor: pointer; padding: 9px 14px; border-radius: 8px; background: var(--accent); color: #fff; }
#downloads summary::-webkit-details-marker { display: none; }
#downloads .menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 2; background: var(--panel); border: 1px solid var(--muted); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; width: min(320px, 90vw); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.check { display: flex; gap: 8px; align-items: center; font-size: .9rem; }
#deck-status { margin: 0; padding: 0 16px; min-height: 1.4em; color: var(--muted); }
#deck-status.error { color: var(--warn); }
@media (max-width: 760px) { #editor header { flex-wrap: wrap; } }
