@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&family=Poppins:wght@400;600&display=swap");

:root {
  color-scheme: light;
  --ink: #1a2925;
  --ink-soft: #0f172a;
  --paper: #f5f5f0;
  --wash: #ffffff;
  --accent: #dee82a;
  --accent-dark: #1a2925;
  --accent-muted: #ffffff;
  --panel: #ffffff;
  --panel-border: rgba(34, 34, 34, 0.12);
  --grid-line: rgba(26, 41, 37, 0.2);
  --grid-strong: rgba(26, 41, 37, 0.45);
  --shadow: 0 18px 36px rgba(13, 6, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--paper) 0%, var(--wash) 100%);
  min-height: 100vh;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px clamp(18px, 4vw, 48px) 2px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.2;
}

.app-logo {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  overflow: hidden;
  color: #1a2925;
  background: transparent;
}

.app-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

body.ar-active {
  background: transparent;
}

body.ar-active .app-shell {
  opacity: 0;
  pointer-events: none;
}

.ar-exit {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 9999;
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: rgba(10, 12, 14, 0.6);
  color: #fff;
  padding: 10px 14px;
  border-radius: 999px;
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  display: none;
  cursor: pointer;
}

body.ar-active .ar-exit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

h1,
.panel h2 {
  margin: 0;
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  font-weight: 300;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 3.6rem);
  letter-spacing: 0.02em;
}

.panel h2 {
  font-size: 1.35rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) minmax(420px, 2fr);
  gap: 20px;
  padding: 20px clamp(18px, 4vw, 48px);
  align-items: stretch;
  min-height: 100vh;
}

.mobile-tabs {
  display: none;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  align-items: flex-start;
}

.panel-controls,
.panel-editor {
  justify-content: flex-start;
}

.profile-toggle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 10px;
}

.profile-label {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 0.8rem;
  color: var(--ink);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(26, 41, 37, 0.2);
  border: 1px solid var(--panel-border);
  transition: 0.2s ease;
  border-radius: 999px;
}

.slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 2px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  transition: 0.2s ease;
  border-radius: 50%;
}

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

.switch input:checked + .slider::before {
  transform: translateX(20px);
}

.panel-viewport {
  position: relative;
  align-items: stretch;
  gap: 18px;
}

.viewport-loading {
  position: absolute;
  inset: 18px;
  border-radius: 18px;
  background: linear-gradient(140deg, rgba(245, 245, 240, 0.92), rgba(255, 255, 255, 0.94));
  border: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  z-index: 4;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.viewport-loading.is-hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(26, 41, 37, 0.15);
  border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.caption {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.control label {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.value-pill {
  min-width: 60px;
  text-align: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 0.8rem;
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
  position: relative;
}

.value-pill::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--accent);
}

.range-stack {
  display: grid;
  gap: 2px;
  position: relative;
  padding-top: 30px;
  width: 100%;
}

.range-stack .value-pill {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
}

.range-track {
  position: relative;
  padding: 0;
  background: transparent;
}

.range-track input[type="range"] {
  width: 100%;
  margin: 0;
  background: transparent;
  accent-color: var(--accent);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-top: -2px;
}

.control-info {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  padding-top: 8px;
  border-top: 1px dashed var(--panel-border);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
  width: 100%;
}

.debug-sliders {
  display: grid;
  gap: 10px;
  width: 100%;
}

.debug-slider {
  display: grid;
  gap: 6px;
}

.debug-slider label {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.debug-slider-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--ink-soft);
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
}

.debug-value {
  font-weight: 700;
  color: var(--ink);
}

.debug-slider input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.grid-wrap {
  background: transparent;
  border-radius: 0;
  padding: 0;
  border: none;
  flex: 1;
  min-height: 360px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.panel-editor .grid-wrap {
  flex: 0 0 auto;
}

.export-buttons {
  display: grid;
  gap: 10px;
  width: 100%;
}

.mobile-exports {
  display: none;
  margin-top: 14px;
  width: 100%;
}

.preset-row {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: center;
  width: 100%;
}

.preset {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--wash);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: grid;
  place-items: center;
}

.preset:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(34, 24, 10, 0.12);
}

.preset svg {
  width: 36px;
  height: 36px;
  stroke: var(--ink);
  stroke-width: 4;
  fill: none;
  stroke-linecap: round;
}

#viewport canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#gridCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 12px;
  cursor: crosshair;
  max-width: 380px;
}

#viewport {
  flex: 0 0 80%;
  height: 80%;
  margin-top: 10px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  background: radial-gradient(circle at top, rgba(60, 60, 60, 0.05) 0%, #efeeea 60%, #f7f7f5 100%);
  cursor: grab;
  flex: 1;
}

#viewport.grabbing {
  cursor: grabbing;
}

.price-tag {
  border: 1px solid var(--panel-border);
  background: var(--accent);
  padding: 8px 12px;
  border-radius: 10px;
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--accent-dark);
}

.viewport-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.viewport-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-button {
  border: 1px solid var(--panel-border);
  background: var(--accent);
  color: var(--accent-dark);
  padding: 8px 14px;
  border-radius: 5px;
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.toggle-button:hover {
  background: var(--accent-dark);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(34, 24, 10, 0.12);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.icon-button:hover {
  background: var(--accent);
  color: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(34, 24, 10, 0.12);
}

.icon-button svg {
  width: 28px;
  height: 28px;
}

#lightToggle svg {
  width: 32px;
  height: 32px;
}

.icon-button.is-active {
  background: var(--accent);
  color: var(--accent-dark);
  border-color: rgba(26, 41, 37, 0.28);
}

.icon-button.light-toggle.is-on {
  background: var(--accent);
  color: var(--accent-dark);
  border-color: rgba(26, 41, 37, 0.28);
}

.icon-button.light-toggle.is-on:hover {
  background: var(--accent);
  color: var(--accent-dark);
}

.icon-button.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.select-control {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--wash);
}

.text-input {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: "Lato", "Helvetica Neue", "Segoe UI", sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--wash);
  width: 100%;
}

.ar-button span {
  font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}



.panel-controls {
  animation: slideIn 0.8s ease forwards;
}

.panel-editor {
  animation: slideIn 0.8s ease 0.1s forwards;
}

.panel-viewport {
  animation: slideIn 0.8s ease 0.2s forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .panel {
    height: auto;
  }

  .panel-head {
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  body {
    font-size: 16px;
  }

  .panel {
    font-size: 0.98rem;
  }

  .range-scale {
    font-size: 0.8rem;
  }

  .app-header {
    padding: 10px clamp(18px, 4vw, 48px) 2px;
  }

  .app-header h1 {
    font-size: 1.05rem;
  }

  .app-logo {
    width: 54px;
    height: 54px;
  }

  .mobile-tabs {
    display: flex;
    gap: 8px;
    padding: 6px clamp(18px, 4vw, 48px) 8px;
  }

  .mobile-tab {
    flex: 1;
    border: 1px solid var(--panel-border);
    background: var(--panel);
    color: var(--ink);
    border-radius: 999px;
    padding: 10px 12px;
    font-size: 0.85rem;
    font-family: "Poppins", "Helvetica Neue", "Segoe UI", sans-serif;
  }

  .mobile-tab.is-active {
    background: var(--accent);
    color: var(--accent-dark);
    border-color: rgba(26, 41, 37, 0.28);
  }

  .app-shell {
    padding: 10px clamp(18px, 4vw, 48px) 28px;
  }

  .panel-viewport {
    order: 1;
    min-height: 48vh;
  }

  #viewport {
    min-height: 42vh;
    touch-action: none;
  }

  #gridCanvas {
    touch-action: none;
  }

  .panel-controls,
  .panel-editor {
    display: none;
  }

  body.mobile-show-controls .panel-controls {
    display: flex;
  }

  body.mobile-show-editor .panel-editor {
    display: flex;
  }

  .range-track input[type="range"] {
    height: 36px;
  }

  .range-track input[type="range"]::-webkit-slider-thumb {
    width: 26px;
    height: 26px;
  }

  .range-track input[type="range"]::-moz-range-thumb {
    width: 26px;
    height: 26px;
  }

  .mobile-exports {
    display: block;
  }
}

