/* =========================
   HRZ-Creator app.css (clean)
   ========================= */

/* --- Hard reset --- */
html, body { height: 100%; margin: 0; }
* { box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
}

/* hidden must mean gone */
#setup[hidden],
#editor[hidden] {
  display: none !important;
}

/* --- Header --- */
.appHeader {
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(900px 420px at 20% 0%,
      rgba(90,169,255,0.10),
      rgba(0,0,0,0) 60%);
}
.appHeaderInner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 18px 14px 18px;
}
.appHeader h1 {
  margin: 0 0 6px 0;
  font-size: 34px;
  letter-spacing: 0.2px;
}
.appHeader p {
  margin: 0;
  color: rgba(230,230,230,0.75);
  line-height: 1.35;
  max-width: 900px;
}

/* --- Shared page width --- */
.setup,
.editor {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

/* --- Setup card --- */
.card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.035);
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.cardTitle {
  font-size: 13px;
  color: rgba(230,230,230,0.75);
  letter-spacing: 0.2px;
  margin: 0 0 10px 0;
}
.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
  opacity: 0.9;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.rowRight { justify-content: flex-end; }

.grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: end;
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; }
.fieldLabel { font-size: 12px; color: rgba(230,230,230,0.65); }

input[type="text"],
input[type="number"],
input[type="file"] {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.25);
  color: var(--fg);
  outline: none;
}
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: rgba(90,169,255,0.45);
  box-shadow: 0 0 0 3px rgba(90,169,255,0.12);
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(230,230,230,0.65);
  line-height: 1.4;
}

/* --- Buttons (gentle colors) --- */
.btn,
.btnSmall,
.btnPrimary {
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(245,248,255,0.92);
  padding: 9px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}
.btn:hover,
.btnSmall:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.20);
}
.btn:active,
.btnSmall:active,
.btnPrimary:active {
  transform: translateY(1px);
}
.btn:disabled,
.btnPrimary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btnSmall {
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.btnPrimary {
  border-color: rgba(90,169,255,0.55);
  background: rgba(90,169,255,0.14);
  color: rgba(245,248,255,0.98);
  font-weight: 700;
  box-shadow: 0 0 0 0 rgba(0,0,0,0), 0 10px 30px rgba(0,0,0,0.25);
}
.btnPrimary:hover {
  background: rgba(90,169,255,0.20);
  box-shadow: 0 0 0 4px rgba(90,169,255,0.10), 0 10px 30px rgba(0,0,0,0.25);
}

/* CLEAR button: subtle “danger” */
#btnChangePhoto {
  border-color: rgba(255,120,120,0.45);
  background: rgba(255,120,120,0.10);
  color: rgba(255,235,235,0.95);
}
#btnChangePhoto:hover {
  background: rgba(255,120,120,0.16);
}

/* --- Editor layout --- */
.editor {
  height: calc(100vh - 88px);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;

  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.topbarLeft {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.topbarRight {
  display: flex;
  gap: 10px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
}
.pillLabel { font-size: 11px; color: rgba(230,230,230,0.65); }
.pillValue {
  font-size: 13px;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

/* Use dvh so mobile address bar doesn’t mess layout */
.views{
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 12px;

  height: calc(100dvh - 260px); /* tune if needed */
  min-height: 420px;
}

.views canvas{
  width: 100%;
  height: 100%;
  display: block;
}


.debugButtons {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Debug dialogs --- */
.dbgDialog {
  width: min(980px, calc(100vw - 40px));
  height: min(720px, calc(100vh - 40px));
  padding: 0;

  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  background: rgba(15,17,21,0.98);
  color: var(--fg);
}
.dbgDialog::backdrop {
  background: rgba(0,0,0,0.65);
}

.dbgDialogHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.dbgDialogTitle { font-weight: 800; }

.dbgClose {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(245,248,255,0.92);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}
.dbgClose:hover { background: rgba(255,255,255,0.10); }

.dbgDialogBody {
  padding: 12px;
  height: calc(100% - 54px);
}
.dbgDialog .codeEditor { height: 100%; }

/* Inside dialogs: show plain readable textarea (no highlight overlay) */
.dbgDialog .codeBack { display: none !important; }

.dbgDialog textarea {
  display: block !important;
  position: static !important;
  width: 100% !important;
  height: 100% !important;
  resize: none;
  box-sizing: border-box;

  color: rgba(245,248,255,0.92) !important;
  background: rgba(0,0,0,0.25) !important;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 12px;

  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre;
  overflow: auto;
}

/* --- Responsive --- */
@media (max-width: 980px) {
  .views { grid-template-columns: 1fr; height: auto; }
  .views canvas { height: 45vh; min-height: 320px; }
}

@media (max-width: 520px) {
  .grid { grid-template-columns: 1fr; }
}


/* 2/3 (flat) + 1/3 (sphere), height comes from flat */
.views{
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  align-items: stretch;

  height: auto !important;     /* critical: stop forcing row height */
  min-height: 0 !important;    /* critical */
}

/* Frames */
.pane{
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b0d12;
  overflow: hidden;
}

/* Flat defines the row height */
.paneFlat{
  aspect-ratio: var(--flat-ar, 16 / 9);
}

/* Sphere simply stretches to that row height */
.paneSphere{
  height: 100%;
}

/* Canvases fill panes */
.pane > canvas{
  display: block;
  width: 100%;
  height: 100%;
}

/* Help/instructions ABOVE the views */
.helpBar{
  margin: 10px 0 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  color: rgba(230,230,230,0.78);
  font-size: 12px;
  line-height: 1.35;
}
.helpBar strong{ color: rgba(245,248,255,0.92); }

/* 2/3 + 1/3 layout */
.views{
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  align-items: stretch;
}

/* Pane frames */
.pane{
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0b0d12;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Flat defines height via aspect ratio (set by JS using --flat-ar) */
.paneFlat{
  aspect-ratio: var(--flat-ar, 16 / 9);
}

/* Sphere matches the row height */
.paneSphere{
  height: 100%;
}

/* Canvases fill panes */
.pane > canvas{
  width: 100%;
  height: 100%;
  display: block;
}

/* Title overlay inside each pane (does NOT affect layout) */
.viewTitle{
  position: absolute;
  top: 10px;
  left: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.35);
  color: rgba(245,248,255,0.92);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}