/* Tema oscuro compartido: lista de planes, visor y editor */
:root {
  --bg: #121317; --bg2: #181a20; --panel: #1f2128; --panel2: #262932; --line: #333744;
  --fg: #e7e9ee; --muted: #9399a6; --accent: #e0a63b; --accent2: #5aa9ff;
  --ok: #4cc38a; --warn: #e0a63b; --err: #ef5b5b; --radius: 8px;
  --font: Roboto, "Segoe UI", system-ui, Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 14px/1.4 var(--font); }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
  cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: #17130a; border-color: var(--accent); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.danger { color: var(--err); }
button.icon { padding: 4px 8px; min-width: 32px; }
button.on { border-color: var(--accent); color: var(--accent); }
input[type=text], input[type=number], input[type=password], input[type=url], select, textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent2); outline-offset: 1px; }
input[type=color] { width: 36px; height: 28px; padding: 0 2px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; }
input[type=range] { width: 100%; }
label { color: var(--muted); font-size: 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; min-height: 52px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.brand small { color: var(--muted); font-weight: 400; }

/* ---------- Lista de planes ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.page h1 { font-size: 20px; margin: 4px 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: flex; gap: 12px; align-items: flex-start; position: relative;
}
.card:hover { border-color: #4a4f60; }
.card img.boss { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: var(--bg2); flex: none; }
.card .info { flex: 1; min-width: 0; }
.card .title { font-weight: 600; font-size: 15px; display: block; color: var(--fg); overflow-wrap: anywhere; }
.card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card .actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.card .actions button, .card .actions a.btn { padding: 3px 9px; font-size: 12px; }
a.btn { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; color: var(--fg); }
a.btn:hover { border-color: var(--accent); text-decoration: none; }
.empty { color: var(--muted); padding: 40px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------- Diálogos propios ---------- */
.dlg-back {
  position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 16px;
}
.dlg {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(520px, 100%);
  max-height: 90vh; overflow: auto; box-shadow: 0 10px 40px #000a;
}
.dlg.wide { width: min(760px, 100%); }
.dlg header { padding: 14px 16px 6px; font-weight: 700; font-size: 16px; }
.dlg .body { padding: 6px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.dlg .body .field { display: flex; flex-direction: column; gap: 4px; }
.dlg footer { padding: 10px 16px 14px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dlg .err { color: var(--err); font-size: 13px; min-height: 1em; }
.mapthumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; background: var(--bg2); border: 1px solid var(--line); }

.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px; max-height: 340px; overflow-y: auto; overflow-x: hidden; }
.spec-opt {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px;
  background: var(--bg2); cursor: pointer; font-size: 12px; text-align: left;
}
.spec-opt img { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; }
.spec-opt span { color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spec-opt { min-width: 0; }
.spec-opt.sel { border-color: var(--accent); background: #2d2a20; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--panel2);
  border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; z-index: 1100; box-shadow: 0 4px 20px #0008;
}

/* ---------- Plan (visor + editor) ---------- */
body.plan { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body.plan.viewer { height: auto; min-height: 100vh; overflow: auto; }
.title-input { font-size: 16px; font-weight: 600; background: transparent; border: 1px solid transparent; min-width: 120px; width: 28ch; }
.title-input:hover { border-color: var(--line); }
.plan-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.sub { color: var(--muted); font-size: 12px; }
.status { font-size: 12px; padding: 3px 8px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.status.saved { color: var(--ok); }
.status.saving { color: var(--accent2); }
.status.dirty { color: var(--warn); }
.status.error { color: var(--err); }

.banner {
  background: #3a2f12; color: #ffe2a6; border-bottom: 1px solid #6b5420; padding: 6px 16px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}

.tabs { display: flex; gap: 4px; align-items: center; padding: 6px 12px; background: var(--bg2); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  padding: 6px 12px; border-radius: 6px 6px 0 0; border: 1px solid var(--line); border-bottom: none; background: var(--panel);
  color: var(--muted); cursor: pointer; flex: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.tab.on { color: var(--fg); background: var(--panel2); border-color: var(--accent); }
.tab input { width: 140px; padding: 2px 4px; }
.tabs .tools { margin-left: auto; display: flex; gap: 4px; flex: none; padding-left: 8px; }
.tabs .tools button { padding: 3px 8px; font-size: 12px; }

.workspace { flex: 1; display: flex; min-height: 0; }
.palette, .props {
  width: 250px; flex: none; background: var(--panel); overflow-y: auto; padding: 8px 10px 20px;
}
.palette { border-right: 1px solid var(--line); }
.props { border-left: 1px solid var(--line); width: 260px; }
.palette h3, .props h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 14px 0 6px;
  display: flex; align-items: center; gap: 6px;
}
.palette h3:first-child, .props h3:first-child { margin-top: 4px; }
.palette h3 button { margin-left: auto; padding: 1px 7px; font-size: 11px; text-transform: none; letter-spacing: 0; }
.roster { display: flex; flex-direction: column; gap: 2px; }
.roster-item {
  display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: grab; user-select: none;
  font-size: 13px; border: 1px solid transparent;
}
.roster-item:hover { background: var(--panel2); border-color: var(--line); }
.roster-item img { width: 20px; height: 20px; border-radius: 50%; border: 2px solid currentColor; flex: none; }
.roster-item.absent { opacity: .38; filter: grayscale(1); }
.roster-item .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 6px;
  background: var(--bg2); border: 1px solid var(--line); cursor: grab; user-select: none; padding: 0;
}
.chip:hover { border-color: var(--accent); }
.chip img { width: 28px; height: 28px; pointer-events: none; }
.chip.wide { width: auto; padding: 0 10px; font-size: 12px; }
.chip svg { width: 26px; height: 26px; pointer-events: none; }
.mob-item { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 5px; cursor: grab; font-size: 12px; user-select: none; }
.mob-item:hover { background: var(--panel2); }
.mob-item img { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #d7180b; background: #000; flex: none; }

.stage { flex: 1; position: relative; min-width: 0; background: #0d0e11; overflow: hidden; }
.stage .canvas-container { position: absolute !important; inset: 0; }
.stage.panning .upper-canvas { cursor: grab !important; }
.zoombar {
  position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; align-items: center; z-index: 5;
  background: #1f2128dd; border: 1px solid var(--line); border-radius: 8px; padding: 4px;
}
.zoombar span { font-size: 12px; color: var(--muted); min-width: 44px; text-align: center; }
.coords { position: absolute; left: 10px; bottom: 10px; font-size: 12px; color: var(--muted); background: #1f2128cc; padding: 2px 8px; border-radius: 6px; z-index: 5; pointer-events: none; }

.props .field { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.props .field.inline { flex-direction: row; align-items: center; gap: 8px; }
.props .field.inline label { flex: 1; }
.props input[type=text], .props input[type=number], .props select, .props textarea { width: 100%; }
.props .xy { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.props .btns { display: flex; flex-wrap: wrap; gap: 4px; }
.props .btns button { font-size: 12px; padding: 4px 8px; }
.props .hint { color: var(--muted); font-size: 12px; }
.props .spec-grid { max-height: 220px; grid-template-columns: 1fr; }
.kbd-help { font-size: 11px; color: var(--muted); line-height: 1.7; margin-top: 16px; }

.notes-panel { border-top: 1px solid var(--line); background: var(--panel); }
.notes-panel summary { padding: 6px 16px; cursor: pointer; color: var(--muted); font-size: 13px; user-select: none; }
.notes-panel .notes-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 10px; }
.notes-panel textarea { width: 100%; min-height: 80px; resize: vertical; }

/* Editor de texto flotante sobre el canvas */
.float-edit {
  position: absolute; z-index: 20; background: #000d; color: #fff; border: 1px solid var(--accent);
  border-radius: 4px; padding: 4px; resize: both; font: 14px/1.2 var(--font);
}

/* Visor */
.viewer-main { padding: 10px 16px 30px; max-width: 1400px; margin: 0 auto; width: 100%; }
.viewer-canvas-wrap { width: 100%; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #0d0e11; }
.viewer-canvas-wrap canvas { display: block; }
.viewer .tabs { padding: 8px 12px; gap: 6px; }
.viewer .tab { padding: 10px 16px; font-size: 15px; border-radius: 8px; border-bottom: 1px solid var(--line); }
.notes-view { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.notes-view .note { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-view .note h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .6px; }

@media (max-width: 720px) {
  .topbar { padding: 8px 12px; }
  .viewer-main { padding: 8px 8px 30px; }
  .viewer .tab { padding: 12px 18px; }
  .dlg footer button { flex: 1; }
  body.viewer #subtitle { display: none; }
  body.viewer .topbar { gap: 6px; }
  body.viewer .topbar button, body.viewer .topbar a.btn { padding: 6px 10px !important; }
}
