/* RULO3D-skinned styles for the Mountain Maker (relief maker).
 * Monochrome: ink black + paper white + a soft gray ramp. Structure comes
 * from hairline borders first, soft shadows second. All colours reference
 * the RULO3D design tokens (var(--rulo-* / --*)). Dark mode inverts the ramp. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --hover-fill: var(--rulo-ink-50);
  --track: var(--rulo-ink-100);
  --danger-text: var(--rulo-danger);
  --danger-hover: #f7ecec;
  --scrim: rgba(20, 20, 20, 0.55);
}
[data-theme="dark"] {
  --text-strong: #f4f4f4;
  --text-body: #e2e2e2;
  --text-muted: #adadad;
  --text-subtle: #808080;
  --text-inverse: #141414;
  --surface-page: #141414;
  --surface-wash: #1f1f1f;
  --surface-card: #1c1c1c;
  --surface-sunken: #0e0e0e;
  --surface-inverse: #f4f4f4;
  --border-subtle: #2b2b2b;
  --border-default: #3d3d3d;
  --border-strong: #6f6f6f;
  --accent: #f4f4f4;
  --accent-hover: #d4d4d4;
  --accent-press: #b0b0b0;
  --accent-contrast: #141414;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.45);
  --shadow-focus: 0 0 0 3px rgba(244, 244, 244, 0.28);
  --hover-fill: #2b2b2b;
  --track: #2b2b2b;
  --danger-text: #e0857f;
  --danger-hover: #35211f;
  --scrim: rgba(0, 0, 0, 0.72);
}

html, body { background: var(--surface-page); }
body, .brandbar, .card, main, input, select, textarea, button, .badge, #map, #viewer {
  transition: background-color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out), color var(--duration-base) var(--ease-out);
}

body {
  margin: 0;
  font-family: "Montserrat", system-ui, sans-serif;
  background: var(--surface-page);
  color: var(--text-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--text-strong); text-decoration: none; }
a:hover { color: var(--text-muted); text-decoration: underline; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ---------------- Brand bar ---------------- */
.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 32px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-page);
  position: sticky;
  top: 0;
  z-index: 500;
  backdrop-filter: saturate(1.1) blur(6px);
}
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-lockup img { width: 34px; height: 34px; display: block; }
[data-theme="dark"] .brand-lockup img,
[data-theme="dark"] .foot-credit img { filter: invert(1); }
.brand-word {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.02em;
  color: var(--text-strong);
  line-height: 1;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin-top: 3px;
}
.header-controls { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px;
  padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  background: var(--surface-page);
  color: var(--text-strong);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--hover-fill); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .icon-sun { display: none; }
[data-theme="dark"] .icon-btn .icon-sun { display: block; }
[data-theme="dark"] .icon-btn .icon-moon { display: none; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-pill);
  padding: 2px;
  gap: 2px;
  background: var(--surface-page);
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.segmented button:hover { color: var(--text-strong); }
.segmented button.lang-active {
  background: var(--accent);
  color: var(--accent-contrast);
}

/* ---------------- Title + steps ---------------- */
.intro {
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 28px 32px 6px;
}
.intro h1 {
  margin: 8px 0 6px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-strong);
  line-height: 1.1;
}
.tagline {
  margin: 0;
  color: var(--text-muted);
  max-width: 820px;
  font-size: 15px;
  text-wrap: pretty;
}
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-default);
  color: var(--text-body);
  background: var(--surface-page);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
}
.badge svg { width: 15px; height: 15px; stroke-width: 2; flex: none; }

.steps {
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 18px 32px 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.steps-lead { grid-column: 1 / -1; margin: 0 0 -4px; }
.step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-wash);
}
.step-num {
  flex: none;
  width: 30px; height: 30px;
  border-radius: var(--radius-pill);
  border: var(--border-thick) solid var(--text-strong);
  color: var(--text-strong);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
}
.step-t { font-weight: 700; color: var(--text-strong); font-size: 14px; }
.step-d { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; text-wrap: pretty; }
@media (max-width: 820px) { .steps { grid-template-columns: 1fr; } }

/* ---------------- Layout ---------------- */
main {
  max-width: var(--container-xl);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 28px;
  align-items: start;
}
@media (max-width: 980px) { main { grid-template-columns: 1fr; } }
#settings-col, #work-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px 20px;
  box-shadow: var(--shadow-sm);
}
.card > h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-strong);
}
.card .step-num { width: 26px; height: 26px; font-size: 13px; border-width: var(--border-thin); }

/* ---------------- Search ---------------- */
.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input { flex: 1; }
.searchbar button { flex: none; }

/* ---------------- Fields / rows ---------------- */
.control-row {
  display: grid;
  grid-template-columns: 150px 1fr 62px;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
}
.control-row > label:first-child { color: var(--text-muted); font-weight: 600; }
.control-row .value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-body); font-weight: 600; }
.track-row { grid-template-columns: 150px 1fr; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-muted); font-weight: 600; }

input[type="number"], input[type="text"], input[type="search"], select, textarea {
  background: var(--surface-page);
  border: 1px solid var(--border-default);
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
textarea { font-family: "SFMono-Regular", Consolas, monospace; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text-strong);
  box-shadow: var(--shadow-focus);
}
input[type="range"] { accent-color: var(--accent); width: 100%; padding: 0; border: none; background: none; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="file"] { border: none; background: none; padding: 0; color: var(--text-muted); font-size: 12px; }
input[type="file"]::file-selector-button {
  font-family: inherit; font-weight: 600; font-size: 12px;
  border: 1px solid var(--border-default); background: var(--surface-page);
  color: var(--text-strong); border-radius: var(--radius-pill);
  padding: 5px 12px; margin-right: 10px; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--hover-fill); }
input[type="color"] {
  width: 46px; height: 30px; padding: 2px;
  border: 1px solid var(--border-default); border-radius: var(--radius-sm);
  background: var(--surface-page); cursor: pointer; justify-self: start;
}

.coords { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; margin-top: 10px; }
.status { color: var(--text-muted); font-size: 12.5px; min-height: 18px; margin-top: 6px; text-wrap: pretty; }
.stats { color: var(--text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-wrap: pretty; }
.hint { color: var(--text-muted); font-size: 12.5px; margin: 10px 0 0; text-wrap: pretty; }
.dim { color: var(--text-muted); }
.hidden { display: none !important; }

.check { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: 13px; color: var(--text-body); font-weight: 500; }

.dims-row { grid-template-columns: 150px 1fr 42px; }
.dims-pair { display: flex; align-items: center; gap: 6px; color: var(--text-subtle); font-size: 13px; }
.dims-pair input { width: 100%; min-width: 0; }

.row { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }

/* ---------------- Buttons (pills) ---------------- */
button {
  background: var(--surface-page);
  color: var(--text-strong);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}
button:hover:not(:disabled) { background: var(--hover-fill); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.primary:active:not(:disabled) { background: var(--accent-press); }
button.secondary { background: var(--surface-page); color: var(--text-strong); }
button.mini { padding: 5px 10px; font-size: 13px; color: var(--text-muted); flex: none; border-radius: var(--radius-sm); }
.block-full { width: 100%; }

/* Scene picker + render CTA (in the model card) */
.mockup-bar { display: flex; align-items: flex-end; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.scene-picker { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.scene-picker > label { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
.scene-picker .scene-row { display: flex; gap: 8px; align-items: center; }
.scene-picker select { flex: 1; }
.mockup-bar > button { flex: none; }

/* ---------------- Map ---------------- */
#map {
  height: 300px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  z-index: 0;
}
.leaflet-container { font-family: "Montserrat", system-ui, sans-serif; background: var(--surface-sunken); }
.leaflet-bar, .leaflet-bar a, .leaflet-control-layers {
  border-color: var(--border-default) !important;
}
.leaflet-bar a {
  background: var(--surface-page) !important;
  color: var(--text-strong) !important;
}
.leaflet-bar a:hover { background: var(--hover-fill) !important; }
.leaflet-control-layers, .leaflet-control-attribution {
  background: var(--surface-page) !important;
  color: var(--text-muted) !important;
  border-radius: var(--radius-sm);
}
.leaflet-control-attribution a { color: var(--text-muted) !important; }

/* ---------------- 3D viewer ---------------- */
#viewer {
  position: relative;
  height: 340px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
  overflow: hidden;
}
#viewer canvas { display: block; border-radius: var(--radius-md); }
#viewer-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-subtle); font-size: 14px; pointer-events: none;
}
.preview-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px; flex-wrap: wrap;
}

/* ---------------- Disclosure ---------------- */
details.disclose { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--surface-card); box-shadow: var(--shadow-sm); }
details.disclose > summary {
  cursor: pointer;
  list-style: none;
  color: var(--text-strong);
  font-weight: 700;
  font-size: 14px;
  padding: 16px 20px;
  display: flex; align-items: center; gap: 10px;
}
details.disclose > summary::-webkit-details-marker { display: none; }
details.disclose > summary::after {
  content: "";
  margin-left: auto;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--duration-fast) var(--ease-out);
}
details.disclose[open] > summary::after { transform: rotate(-135deg); }
details.disclose > .disclose-body { padding: 0 20px 20px; }
.foot-disclose { border: none; box-shadow: none; background: none; }
.foot-disclose > summary { padding: 6px 0; font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.foot-disclose > .disclose-body { padding: 6px 0 0; }

/* ---------------- Footer ---------------- */
footer {
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 4px 32px 40px;
  color: var(--text-muted);
  font-size: 12.5px;
}
footer .foot-tech { max-width: 900px; text-wrap: pretty; }
footer .foot-credit {
  display: flex; align-items: center; gap: 10px;
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-subtle);
  font-size: 12px;
}
footer .foot-credit img { width: 20px; height: 20px; }

/* ---------------- Aligner + poster modals ---------------- */
#aligner-modal, #poster-modal {
  position: fixed; inset: 0;
  background: var(--scrim);
  display: flex; align-items: center; justify-content: center;
  z-index: 2100;
  backdrop-filter: blur(3px);
}
#aligner-modal[hidden], #poster-modal[hidden] { display: none; }
.aligner-box, .poster-box {
  position: relative;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 96vw; max-height: 96vh;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
/* Always-there dismiss, pinned to the corner so it can't get lost in the
   wrapping toolbar the way the text "Close" button does. */
.modal-dismiss {
  position: absolute; top: 8px; right: 8px; z-index: 1;
  width: 30px; height: 30px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.modal-dismiss:hover { background: var(--hover-fill); color: var(--text-strong); }
.aligner-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aligner-box > .aligner-toolbar:first-of-type { padding-right: 34px; }
.aligner-toolbar input[type="file"] { max-width: 220px; }
.aligner-toolbar input[type="text"] { width: 170px; }
.aligner-lights { gap: 16px; }
.aligner-lights label, .filelbl, .aligner-opacity {
  display: flex; align-items: center; gap: 6px;
  color: var(--text-muted); font-size: 12.5px; white-space: nowrap; font-weight: 600;
}
.aligner-lights input[type="range"] { width: 128px; }
.aligner-opacity input { width: 110px; }
.numin {
  width: 62px;
  background: var(--surface-page);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-strong);
  padding: 4px 6px; font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
#aligner-tx-x, #aligner-tx-y { width: 70px; }
.aligner-hint { color: var(--text-subtle); font-size: 12px; font-style: italic; }
#aligner-stage { overflow: auto; display: flex; justify-content: center; }
#aligner-canvas { cursor: crosshair; border-radius: var(--radius-sm); touch-action: none; }
#aligner-json {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px; padding: 8px; resize: none;
}
.poster-box { max-height: 94vh; }
#poster-preview canvas {
  height: min(82vh, 1200px);
  width: auto; display: block;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.poster-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
