/* The Obsidian Die — tema de la web aplicado al TaleSpire Voxelizer.
   Obsidiana (#1a1a1a) + oro (#d4af37) + Playfair Display en titulares, como
   theobsidiandie.com. Fuentes desde Google Fonts (con fallback de sistema si
   no cargan). */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=Lora:ital,wght@0,400;0,500;0,600;1,400&display=swap');

* { box-sizing: border-box; }
:root {
  --bg: #1a1a1a;           /* obsidiana exacta de theobsidiandie.com */
  --panel: #212121;
  --panel2: #2a2a2a;
  --line: rgba(255, 255, 255, 0.08);
  --line-gold: rgba(212, 175, 55, 0.28);
  --text: #e0e0e0;
  --muted: #8f8f8f;
  --accent: #d4af37;       /* oro */
  --accent-ink: #1a1a1a;   /* tinta sobre el oro */
  --accent-soft: rgba(212, 175, 55, 0.12);
  --accent2: #b8935f;      /* bronce (secundario / referencia) */
  --ok: #6fce8f; --err: #d47a7a; --warn: #cbb26b;
  --head: 'Playfair Display', Georgia, serif;
  --body: 'Lora', Georgia, serif;
}
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; height: 100vh;
  font: 14px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex; align-items: center; gap: 16px; padding: 13px 22px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  position: relative; z-index: 2;
}
.brand { display: flex; flex-direction: column; gap: 3px; }
.brand .eyebrow {
  font-family: var(--head); font-size: 10px; letter-spacing: 3.5px;
  text-transform: uppercase; color: var(--accent);
}
header h1 { font-family: var(--head); font-size: 21px; font-weight: 700; margin: 0; color: var(--text); letter-spacing: .3px; line-height: 1; }
header .sub { color: var(--muted); font-size: 12px; }
header .spacer { flex: 1; }
.backlink {
  color: var(--muted); text-decoration: none; font-size: 12px;
  letter-spacing: .5px; border-bottom: 1px dotted var(--line-gold); padding-bottom: 1px;
}
.backlink:hover { color: var(--accent); }

/* selector de idioma ES / EN */
.langsel { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.langsel button {
  border: none; border-radius: 0; background: transparent; color: var(--muted);
  font-family: var(--head); font-size: 11px; letter-spacing: 1px; font-weight: 700;
  padding: 5px 10px; cursor: pointer; transition: background .15s, color .15s;
}
.langsel button:hover { color: var(--accent); background: var(--accent-soft); }
.langsel button.active { background: var(--accent); color: var(--accent-ink); }
.langsel button + button { border-left: 1px solid var(--line); }

main { flex: 1; display: flex; min-height: 0; }
.panel {
  width: 328px; min-width: 328px; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; padding: 6px 16px 22px;
}
.block { padding: 14px 0; border-bottom: 1px solid var(--line); }
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 6px; letter-spacing: .2px; }
.lbl:first-child { margin-top: 0; }
.val { font-weight: 600; word-break: break-all; color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; line-height: 1.5; }
.tag { color: var(--accent); font-weight: 700; margin-left: 4px; font-family: var(--head); }
.warn { color: var(--warn); }

input[type="text"], input[list], input:not([type]), select {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: var(--body);
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.chk { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.chk input { accent-color: var(--accent); }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.btnrow button { flex: 1; min-width: 62px; padding: 6px 4px; font-size: 12px; }

button {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 13px; cursor: pointer; font-size: 13px; font-family: var(--body);
  transition: border-color .15s, background .15s, color .15s;
}
button:hover { border-color: var(--accent); color: var(--accent); }
/* Apagado cuando no hay nada que hacer (p. ej. "Limpiar" sin malla cargada).
   Se anula tambien el hover, si no seguia iluminandose en oro al pasar por encima
   y parecia pulsable. */
button:disabled,
button:disabled:hover {
  opacity: .38; cursor: default;
  border-color: var(--line); color: var(--muted); background: var(--panel2);
}
button.primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px;
}
button.primary:hover { background: #fff; color: var(--accent-ink); border-color: #fff; }
button.wide { width: 100%; margin-top: 14px; padding: 12px; }

.stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* overflow:hidden es parte del fix del corte de la barra de estado: three.js
   escribe una altura fija en linea en el canvas y, si el layout cambia sin que
   se dispare window.resize, el canvas queda mas alto que este contenedor y (al
   ser position:relative) PINTA POR ENCIMA de la barra .msg, tapandola. Con esto
   el canvas nunca puede sangrar; el tamano real lo re-sincroniza un
   ResizeObserver en app.js. */
#viewport { flex: 1; position: relative; min-height: 0; background: #151515; overflow: hidden; }
#viewport.drag { outline: 2px dashed var(--accent); outline-offset: -8px; }
#viewport canvas { display: block; }

/* Barra de estado bajo el visor. `flex: 0 0 auto` es lo que impide que se corte
   el texto: es un item flex dentro de .stage y, por defecto, los items pueden
   encogerse (flex-shrink:1). Como el canvas de three.js lleva una altura fija en
   linea, cuando el alto disponible se quedaba justo el que cedia era este bloque,
   y el mensaje aparecia recortado por arriba. */
.msg {
  flex: 0 0 auto;
  padding: 9px 20px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.msg.ok { color: var(--ok); } .msg.err { color: var(--err); }

/* modal de exportación */
.modal {
  position: fixed; inset: 0; z-index: 50; padding: 20px;
  background: rgba(0, 0, 0, .7); display: flex; align-items: center; justify-content: center;
}
.modal.hidden { display: none; }
.modalCard {
  background: var(--panel); border: 1px solid var(--line-gold); border-radius: 10px;
  width: min(760px, 94vw); max-height: 88vh; display: flex; flex-direction: column;
  padding: 18px 20px; box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
  border-top: 3px solid var(--accent);
}
.modalHead { display: flex; align-items: center; justify-content: space-between; }
.modalTitle { font-family: var(--head); font-size: 20px; font-weight: 700; color: var(--accent); }
.iconbtn { border: none; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 8px; }
.iconbtn:hover { color: var(--text); }
.modalSummary { color: var(--muted); font-size: 13px; margin: 8px 0 12px; line-height: 1.6; }
.modalActions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
button.ghost { background: transparent; border-color: var(--accent); color: var(--accent); }
button.ghost:hover { background: var(--accent-soft); }

.help { margin-bottom: 12px; background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; padding: 9px 13px; }
.help summary { cursor: pointer; font-size: 13px; color: var(--text); font-weight: 600; font-family: var(--head); }
.help ol { margin: 8px 0 2px; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.help b { color: var(--accent); font-weight: 600; }

.outRow.refRow { border-color: var(--accent2); background: rgba(184, 147, 95, .1); }

.pager { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pager select { flex: 1; background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.pgbtn { padding: 8px 15px; font-size: 14px; }
.pgbtn:disabled { opacity: .35; cursor: default; border-color: var(--line); color: var(--muted); }
.pagerCopy { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pagerCopy button { flex: 0 0 auto; }

.output { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-right: 4px; }
.outRow { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; }
.outLbl { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.outRow textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); color: var(--text);
  border-radius: 6px; padding: 8px 10px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5; resize: vertical; min-height: 66px;
  word-break: break-all; white-space: pre-wrap;
}
.outRow textarea:focus { outline: none; border-color: var(--accent); }
.outBtns { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* scrollbar discreta a juego */
.panel::-webkit-scrollbar, .output::-webkit-scrollbar { width: 9px; }
.panel::-webkit-scrollbar-thumb, .output::-webkit-scrollbar-thumb { background: #333; border-radius: 6px; }
.panel::-webkit-scrollbar-thumb:hover, .output::-webkit-scrollbar-thumb:hover { background: var(--accent2); }
