:root {
  --navy: #071821;
  --ink: #132b35;
  --muted: #667a83;
  --line: #d8e2e3;
  --accent: #0f6f95;
  --copper: #d78a52;
  --paper: #f6faf9;
  --panel: rgba(255, 255, 255, .9);
  --shadow: 0 22px 58px rgba(4, 22, 29, .14);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(15, 111, 149, .10), transparent 28%),
    linear-gradient(135deg, #e9ece7 0%, #f6f7f5 48%, #e8ece8 100%);
  font-family: "DM Sans", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 clamp(18px, 3vw, 42px);
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(15, 111, 149, .12);
  backdrop-filter: blur(14px);
}

body.is-embedded .app-header {
  display: none;
}

body.is-embedded .planner-app {
  min-height: 100vh;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--navy);
  text-decoration: none;
}

.brand-logo {
  width: 52px;
  height: 44px;
  flex: 0 0 52px;
}

.brand span {
  display: grid;
}

.brand strong {
  font: 800 1.16rem/1 "Manrope", sans-serif;
  letter-spacing: .12em;
}

.brand small {
  margin-top: 5px;
  color: #71858d;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

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

.header-actions a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #526b75;
  background: white;
  border: 1px solid rgba(15, 111, 149, .14);
  border-radius: 999px;
  font-size: .86rem;
  font-weight: 800;
  text-decoration: none;
}

.header-actions .call-link {
  color: white;
  background: var(--accent);
}

.planner-app {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
}

.tool-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  overflow: auto;
  border-right: 1px solid rgba(15, 111, 149, .12);
}

.panel-section {
  padding: 18px;
  background: var(--panel);
  border: 1px solid rgba(15, 111, 149, .13);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(4, 22, 29, .06);
}

.eyebrow {
  margin: 0 0 9px;
  color: #9f6036;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 18px;
  color: var(--navy);
  font: 800 clamp(1.8rem, 4vw, 2.45rem)/1.02 "Manrope", sans-serif;
}

.dimension-grid,
.measure-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.dimension-grid label,
.measure-grid label,
.select-label,
.range-stack label {
  display: grid;
  gap: 8px;
  color: #526a76;
  font-size: .74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.dimension-grid span,
.measure-grid span,
.measure-grid select {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.dimension-grid input,
.measure-grid input {
  width: 100%;
  min-width: 0;
  color: var(--navy);
  background: transparent;
  border: 0;
  outline: 0;
  font-weight: 800;
}

.measure-grid select {
  width: 100%;
  color: var(--navy);
  font-weight: 800;
}

.subsection-title {
  margin: 16px 0 10px;
  color: #526a76;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.measure-grid {
  grid-template-columns: repeat(2, 1fr);
}

.color-grid {
  display: grid;
  gap: 10px;
}

.color-grid {
  grid-template-columns: repeat(3, 1fr);
}

.color-grid label {
  display: grid;
  gap: 8px;
  color: #526a76;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.color-grid input {
  width: 100%;
  height: 48px;
  padding: 5px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}

.ceramic-color-picker {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.color-targets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 4px;
  background: #eef4f4;
  border-radius: 8px;
}

.color-targets button {
  min-height: 38px;
  padding: 7px 8px;
  color: #526a76;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: 800 .68rem "DM Sans", sans-serif;
  transition: color .15s, background .15s, box-shadow .15s;
}

.color-targets button:hover,
.color-targets button.is-active {
  color: white;
  background: var(--accent);
  box-shadow: 0 7px 16px rgba(15,111,149,.18);
}

.color-targets button:focus-visible {
  outline: 3px solid rgba(15,111,149,.28);
  outline-offset: 3px;
}

.custom-color-control {
  display: grid;
  gap: 12px;
  padding: 11px 12px 13px;
  color: #27434e;
  background: #f5f8f7;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.custom-color-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.custom-color-trigger > span {
  display: grid;
  gap: 2px;
}

.custom-color-trigger strong,
.color-adjustments strong {
  font: 800 .74rem "DM Sans", sans-serif;
}

.custom-color-trigger small {
  color: #6b8089;
  font-size: .64rem;
  line-height: 1.35;
}

.custom-color-trigger input[type="color"] {
  flex: 0 0 62px;
  width: 62px;
  height: 42px;
  padding: 3px;
  background: white;
  border: 1px solid #b8c9ce;
  border-radius: 8px;
  cursor: pointer;
}

.custom-color-trigger input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-trigger input[type="color"]::-webkit-color-swatch {
  border: 0;
  border-radius: 5px;
}

.custom-color-trigger input[type="color"]:focus-visible {
  outline: 3px solid rgba(15,111,149,.28);
  outline-offset: 2px;
}

.color-adjustments {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #d8e3e5;
}

.color-adjustments label {
  display: grid;
  gap: 6px;
}

.color-adjustments label > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.color-adjustments output {
  color: #627983;
  font: 700 .66rem "DM Sans", sans-serif;
}

.color-range {
  width: 100%;
  height: 10px;
  margin: 0;
  appearance: none;
  background: var(--range-gradient, linear-gradient(90deg, #777, #fff));
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.hue-range {
  background: linear-gradient(90deg, #f33 0%, #ff0 17%, #3d3 33%, #0ff 50%, #36f 67%, #c3f 83%, #f33 100%);
}

.color-range::-webkit-slider-thumb {
  width: 20px;
  height: 20px;
  appearance: none;
  background: white;
  border: 2px solid #173e4a;
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(15,47,58,.26);
}

.color-range::-moz-range-thumb {
  width: 17px;
  height: 17px;
  background: white;
  border: 2px solid #173e4a;
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(15,47,58,.26);
}

.color-range:focus-visible {
  outline: 3px solid rgba(15,111,149,.28);
  outline-offset: 4px;
}

.color-picker-help {
  margin: 0;
  color: #667a83;
  font-size: .68rem;
  line-height: 1.45;
}

.grout-grid {
  grid-template-columns: repeat(2, 1fr);
}

.fixture-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.fixture-list label {
  min-height: 43px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .84rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

.fixture-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.fixture-symbol {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  color: #60737b;
  background: #eef4f4;
  border: 1px solid rgba(15, 111, 149, .14);
  border-radius: 50%;
  font: 800 1rem "Manrope", sans-serif;
}

.fixture-toggle b {
  font-size: .84rem;
}

.fixture-toggle:has(input:checked) {
  background: #f4fbfc;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 111, 149, .1);
}

.fixture-toggle:has(input:checked) .fixture-symbol {
  color: white;
  background: var(--accent);
}

#bathroom-stage.is-dragging {
  cursor: move;
}

.select-label select {
  min-height: 46px;
  padding: 0 12px;
  color: var(--navy);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 800;
}

.range-stack {
  display: grid;
  gap: 13px;
  margin-top: 14px;
}

.range-stack input {
  width: 100%;
  accent-color: var(--accent);
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.panel-actions button {
  min-height: 46px;
  color: var(--navy);
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: .84rem;
  font-weight: 800;
}

.panel-actions .primary-action {
  color: white;
  background: #ff7d55;
  border-color: #ff7d55;
}

.stage-wrap {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  padding: 18px;
}

@media (min-width: 981px) {
  .stage-wrap {
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: start;
  }

  #bathroom-stage {
    min-height: 0;
    height: calc(100vh - 104px);
  }
}

.stage-toolbar {
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(390px, 560px);
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  background: rgba(7, 24, 33, .88);
  color: white;
  border-radius: 8px 8px 0 0;
}

.stage-toolbar strong {
  display: block;
  font: 800 1.12rem "Manrope", sans-serif;
}

.stage-toolbar span {
  color: #c6d6dc;
  font-size: .82rem;
}

.stage-actions {
  justify-self: end;
  width: min(560px, 100%);
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stage-actions button {
  min-height: 34px;
  border-color: rgba(255, 255, 255, .18);
}

.stage-actions .primary-action {
  grid-column: span 3;
}
.stage-actions .inquiry-action {
  grid-column: span 3;
  color: white;
  background: #0f6f95;
  border-color: #0f6f95;
  box-shadow: 0 9px 20px rgba(15,111,149,.2);
}
.stage-actions .inquiry-action:hover {
  color: white;
  background: #0b5877;
  border-color: #0b5877;
}

#bathroom-stage {
  position: relative;
  min-height: 620px;
  height: calc(100vh - 182px);
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 255, 255, .2), transparent 24%),
    linear-gradient(180deg, #b6bbb3 0%, #d4d7d2 100%);
  border: 1px solid rgba(15, 111, 149, .15);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  cursor: grab;
}

#bathroom-stage:active {
  cursor: grabbing;
}

#bathroom-stage canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.stage-error {
  max-width: 520px;
  margin: 80px auto;
  padding: 18px;
  color: #7a2618;
  background: #fff2ec;
  border: 1px solid #ffb39c;
  border-radius: 8px;
  font-weight: 800;
  line-height: 1.45;
}

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

  .tool-panel {
    max-height: none;
    border-right: 0;
  }

  .stage-wrap {
    order: -1;
  }

  #bathroom-stage {
    min-height: 540px;
    height: 64vh;
  }
}

@media (max-width: 620px) {
  .app-header {
    height: auto;
    min-height: 72px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions a {
    flex: 1;
  }

  .planner-app {
    min-height: calc(100vh - 126px);
  }

  .tool-panel,
  .stage-wrap {
    padding: 12px;
  }

  .dimension-grid,
  .measure-grid,
  .color-grid,
  .fixture-list,
  .panel-actions {
    grid-template-columns: 1fr;
  }

  .stage-toolbar {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .stage-actions {
    justify-self: stretch;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage-actions .primary-action {
    grid-column: span 2;
  }

  .stage-actions .inquiry-action {
    grid-column: span 2;
  }

  .color-targets {
    grid-template-columns: 1fr;
  }
}
