/* -----------------------------------------------------------------------
   Stone Carver — interface

   Flat technical drawing: hairline 1px strokes, square corners, no fills,
   no shadows, no gradients. Everything is white on black; the only "color"
   in the interface is the artwork itself.
   -------------------------------------------------------------------- */

:root {
  --ink: #ffffff;
  --ground: #000000;
  --rule: rgba(255, 255, 255, 0.35);
  --rule-strong: #ffffff;
  --muted: rgba(255, 255, 255, 0.45);
  --sidebar-width: 302px;
  --pad: 20px;
  --type: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

/* The Invert control flips the artwork's palette; the interface follows so
   it keeps matching the thing it is editing. */
body.is-inverted {
  --ink: #000000;
  --ground: #ffffff;
  --rule: rgba(0, 0, 0, 0.35);
  --rule-strong: #000000;
  --muted: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  user-select: none;
}

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--type);
  font-size: 11px;
  font-weight: 300;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#main-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* ------------------------------------------------------------- sidebar */

#gui-section {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  border-right: 1px solid var(--rule-strong);
  overflow: hidden;
  transition: margin-left 0.25s ease;
}

#gui-section.hidden {
  display: block !important;
  margin-left: calc(var(--sidebar-width) * -1);
}

#gui-panel {
  position: relative;
  height: 100%;
  width: var(--sidebar-width);
}

.gui-content {
  height: 100%;
  overflow-y: auto;
  padding: var(--pad) var(--pad) 28px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.gui-content::-webkit-scrollbar {
  width: 6px;
}

.gui-content::-webkit-scrollbar-thumb {
  background: var(--rule);
}

.wordmark {
  margin: 0 0 18px;
  font-size: 27px;
  font-weight: 300;
  letter-spacing: 0.02em;
  line-height: 1;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}

.block {
  margin-bottom: 18px;
}

/* Stays put while the panel scrolls, so it needs its own ground to keep
   from sitting on top of a slider. */
.gui-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  width: 22px;
  height: 22px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ground);
  border: none;
  color: var(--ink);
  font-family: var(--type);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.55;
}

.gui-close-btn:hover {
  opacity: 1;
}

.gui-toggle-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 2000;
  padding: 8px 14px;
  background: var(--ground);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-family: var(--type);
  font-size: 10px;
  letter-spacing: 0.1em;
  cursor: pointer;
  display: none;
}

.gui-toggle-btn:hover {
  background: var(--ink);
  color: var(--ground);
}

/* ------------------------------------------------------------- buttons */

.btn {
  display: block;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-family: var(--type);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.1s linear,
    color 0.1s linear;
}

.btn:hover {
  background: var(--ink);
  color: var(--ground);
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* File input styled as one of the outlined buttons. */

.file-field {
  position: relative;
  display: block;
  width: 100%;
  margin-bottom: 6px;
  padding: 9px 10px;
  border: 1px solid var(--rule-strong);
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}

.file-field:hover {
  background: var(--ink);
  color: var(--ground);
}

.file-field-label {
  font-size: 10px;
  letter-spacing: 0.1em;
}

.file-field input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* ------------------------------------------------------------ sections */

.section {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--rule);
}

/* Sits directly under the action buttons, which already provide the rule. */
.section--first {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.section-header {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.14em;
  /* text-align: center; */
}

/* ------------------------------------------------------------ controls */

.control {
  margin-bottom: 14px;
}

.control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}

.control-label {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.control-value {
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Hairline track, hollow ring thumb. */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 14px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--rule-strong);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -6px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--ground);
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--ink);
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--rule-strong);
}

input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--ground);
}

input[type="range"]:focus {
  outline: none;
}

/* Numeric fields, paired with a custom stepper in place of the native one. */

input[type="number"] {
  width: 100%;
  padding: 2px 18px 2px 4px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--type);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--rule-strong);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-field {
  position: relative;
  display: block;
  flex: 1 1 0;
  min-width: 0;
}

.number-steppers {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  width: 14px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--rule);
}

.stepper {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
}

.stepper:hover {
  background: var(--ink);
}

.stepper::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}

.stepper--up::before {
  border-bottom: 4px solid var(--ink);
}

.stepper--down::before {
  border-top: 4px solid var(--ink);
}

.stepper:hover::before {
  border-bottom-color: var(--ground);
  border-top-color: var(--ground);
}

/* Width × Height, one row, no labels. */

.control--dimensions {
  margin-bottom: 14px;
}

.dims-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dims-sep {
  flex: 0 0 auto;
  font-size: 16px;
  color: var(--muted);
}

/* Subheadings inside a section (CANVAS, POSITIONING, COLORS …). */

.subgroup {
  margin: 20px 0 px;
  font-size: 11px;
  /* font-weight: 400; */
  letter-spacing: 0.16em;
  color: var(--muted);
}

.section-header + .subgroup {
  margin-top: 0;
}

/* Native select, squared off to match the outlined buttons. */

.dropdown {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  padding: 7px 24px 7px 8px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--type);
  font-size: 10px;
  letter-spacing: 0.06em;
  cursor: pointer;
  /* Chevron drawn with a background gradient so no asset is needed. */
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 13px) 50%,
    calc(100% - 9px) 50%;
  background-size:
    4px 4px,
    4px 4px;
  background-repeat: no-repeat;
}

.dropdown:focus {
  outline: none;
}

.dropdown option {
  background: var(--ground);
  color: var(--ink);
}

/* Buttons that arm a drag interaction on the canvas. Small and left-aligned,
   with the live readout at the right edge of the same row — the hint text
   moves to a native tooltip so the row stays to a single line. */

.control--mode {
  margin-bottom: 14px;
}

.mode-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--rule);
}

.mode-btn {
  flex: 0 0 auto;
  padding: 7px 12px;
  margin: 3px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-family: var(--type);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: center;
  width: 50%;
  cursor: pointer;
  transition:
    background 0.1s linear,
    color 0.1s linear;
}

.mode-btn:hover {
  background: var(--ink);
  color: var(--ground);
}

.mode-btn.is-active {
  background: var(--ink);
  color: var(--ground);
}

/* Full-width action button, e.g. Isolate Subject. */

.control--action {
  margin-bottom: 0px;
}

.action-btn.is-active {
  background: var(--ink);
  color: var(--ground);
}

.action-btn:disabled,
.mode-btn:disabled {
  opacity: 0.35;
  cursor: wait;
}

.action-btn:disabled:hover,
.mode-btn:disabled:hover {
  background: transparent;
  color: var(--ink);
}

.action-btn.is-active:disabled:hover {
  background: var(--ink);
  color: var(--ground);
}

.action-status {
  margin-top: 5px;
  min-height: 13px;
}

/* Never truncated — the readout is the only feedback these buttons give, so
   the button label yields space instead. */
.mode-value {
  flex: 1 0 auto;
  margin-left: auto;
  text-align: right;
}

.mode-btn {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-reset {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  margin: 3px 6px 3px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.mode-reset:hover {
  border-color: var(--rule-strong);
  color: var(--ink);
}

/* Segmented option groups (select replacement, canvas presets). */

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 5px;
}

.segmented--single {
  grid-template-columns: 1fr;
}

.seg {
  padding: 7px 6px;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-family: var(--type);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.1s linear,
    color 0.1s linear;
}

.seg:hover {
  background: var(--ink);
  color: var(--ground);
}

.seg.is-active {
  background: var(--ink);
  color: var(--ground);
}

/* Radio-style toggle. */

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-dot {
  position: relative;
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
}

.toggle input:checked + .toggle-dot::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--ink);
}

.toggle-text {
  font-size: 10px;
  letter-spacing: 0.08em;
}

/* On/off switch — square corners, no fill or shadow, matching the toggle
   dots and everything else in the panel. Reserved for controls with a real
   physical opposite (Invert Colors); an arbitrary flag stays a .toggle. */

.switch {
  position: relative;
  flex: 0 0 auto;
  display: block;
  width: 32px;
  height: 16px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border: 1px solid var(--rule-strong);
  transition: background 0.15s ease;
}

.switch-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  background: var(--ink);
  transition:
    transform 0.15s ease,
    background 0.15s ease;
}

.switch input:checked + .switch-slider {
  background: var(--ink);
}

.switch input:checked + .switch-slider::after {
  transform: translateX(15px);
  background: var(--ground);
}

/* -------------------------------------------------------------- credits */

.credits {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 10px;
  color: var(--muted);
}

.credits a {
  color: var(--ink);
  text-decoration: none;
}

.credits a:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------- stage */

#canvas-section {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#canvas-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 24px;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  outline: 1px solid var(--rule);
}

/* The armed drag mode is announced through the cursor. */

canvas[data-mode="position"] {
  cursor: grab;
}

canvas[data-mode="position"]:active {
  cursor: grabbing;
}

canvas[data-mode="light"] {
  cursor: crosshair;
}

.canvas-hint {
  position: absolute;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--muted);
  pointer-events: none;
}

/* Processing feedback — depth estimation, subject isolation, load errors —
   pops over the artwork instead of living in the sidebar. Centered on the
   container rather than the canvas element, since letterboxed canvases don't
   fill it; the two share the same center point either way. */
.canvas-status {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  max-width: min(85%, 420px);
  padding: 10px 18px;
  background: var(--ground);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
  font-family: var(--type);
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-align: center;
  pointer-events: none;
}

/* Errors invert, the same signal the rest of the interface uses for a state
   flip, rather than introducing a second color into an otherwise flat UI. */
.canvas-status.is-error {
  background: var(--ink);
  color: var(--ground);
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  body {
    overflow: auto;
    height: auto;
  }

  #main-container {
    flex-direction: column;
    height: auto;
  }

  #gui-section {
    width: 100%;
    flex: 0 0 auto;
    border-right: none;
    border-bottom: 1px solid var(--rule-strong);
  }

  #gui-section.hidden {
    margin-left: 0;
    display: none !important;
  }

  #gui-panel {
    width: 100%;
  }

  .gui-content {
    height: auto;
    overflow: visible;
  }

  #canvas-section {
    min-height: 70vh;
  }
}
