/* Shared application shell. All modes occupy the same sidebar and drawing area. */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font:
    14px/1.45 system-ui,
    sans-serif;
  color: #18332e;
  background: #f2f4f3;
}
body {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
}
#viewer-sidebar {
  overflow: auto;
  padding: 14px;
  background: white;
  border-right: 1px solid #ccd6d1;
}
h1 {
  font-size: 20px;
  margin: 16px 0 10px;
}
h2 {
  font-size: 16px;
}
a {
  color: #17645d;
}
summary {
  cursor: pointer;
}
details {
  margin: 12px 0;
}
button,
select,
input {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #e0a53b;
  outline-offset: 2px;
}
#plan-navigation .pn-heading {
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
}
.pn-links {
  display: grid;
  gap: 6px;
}
.pn-links a {
  display: block;
  text-decoration: none;
  padding: 9px 10px;
  border: 1px solid #bfcec7;
  border-radius: 6px;
}
.pn-links a:not([aria-current='page']):hover {
  background: #edf4ef;
}
.pn-links a[aria-current='page'],
.toolbar a[aria-current='page'] {
  background: #215e4b;
  color: white;
  border-color: #215e4b;
  cursor: default;
}
.pn-reference {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #ccd6d1;
}
#workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 8px;
}
#mode-navigation,
.toolbar {
  display: flex;
  flex: none;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  min-height: 38px;
}
.toolbar button,
.toolbar a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #b7c9bf;
  border-radius: 6px;
  background: white;
  color: #18332e;
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.toolbar button:not(:disabled):hover,
.toolbar a:not([aria-current='page']):hover {
  background: #e8f2ec;
}
.toolbar button:disabled {
  opacity: 0.45;
  cursor: default;
  background: white;
}
#view {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  gap: 8px;
}
.plan-canvas,
#stage {
  min-height: 0;
  min-width: 0;
  flex: 1;
  border: 1px solid #ccd6d1;
  border-radius: 8px;
  background: white;
  overflow: hidden;
}
.plan-canvas > svg,
#stage > svg {
  display: block;
  width: 100%;
  height: 100%;
}
.plan-canvas > svg {
  touch-action: none;
  user-select: none;
  outline-offset: -4px;
}
.plan-canvas.zoomed,
.mode-kitchen #stage.zoomed:not(.adding):not(.dragging) {
  cursor: grab;
}
.plan-canvas.dragging {
  cursor: grabbing;
}
.plan-canvas {
  position: relative;
}
.cursor-coordinates {
  position: absolute;
  bottom: 10px;
  left: 10px;
  max-width: calc(100% - 20px);
  padding: 5px 9px;
  border: 1px solid #ccd6d1;
  border-radius: 5px;
  background: #fffffff0;
  color: #18332e;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.plan-canvas,
.mode-kitchen #stage {
  position: relative;
}
.toolbar button[aria-pressed='true'],
.toolbar button[aria-pressed='true']:hover {
  background: #215e4b;
  color: white;
  border-color: #215e4b;
}
.measuring,
.measuring > svg,
#stage.measuring .kitchen-unit {
  cursor: crosshair;
}
.tape-measure-line {
  stroke: #b33268;
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}
.tape-measure-label {
  position: absolute;
  padding: 5px 9px;
  border: 1px solid #b33268;
  border-radius: 5px;
  background: #fffffff5;
  color: #8d1749;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.controls label {
  display: block;
  margin: 8px 0;
}
input {
  vertical-align: middle;
}
#view-controls img {
  width: 100%;
  height: auto;
}
.help {
  font-size: 13px;
  color: #50685d;
}
.gallery {
  overflow: auto;
  padding: 12px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}
.cards article {
  padding: 14px;
  background: white;
  border: 1px solid #ccd6d1;
  border-radius: 8px;
}
.cards img {
  width: 100%;
  height: 330px;
  object-fit: contain;
}
.cards h2 {
  margin-top: 0;
}
@media (max-width: 640px) {
  body {
    grid-template-columns: 200px minmax(0, 1fr);
  }
  #viewer-sidebar {
    padding: 8px;
    font-size: 12px;
  }
  #workspace {
    padding: 3px;
  }
  .toolbar span {
    display: none;
  }
}
/* Kitchen placement controls. */
.mode-kitchen .dimensions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.mode-kitchen .dimensions label {
  font-size: 12px;
}
.mode-kitchen .dimensions input {
  width: 74px;
  max-width: 100%;
  padding: 5px;
  border: 1px solid #b7c9bf;
  border-radius: 4px;
}
.mode-kitchen button {
  min-height: 38px;
  border: 1px solid #b7c9bf;
  border-radius: 6px;
  background: white;
  color: #18332e;
  padding: 7px 10px;
}
.mode-kitchen button:not(:disabled):hover {
  background: #e8f2ec;
}
.mode-kitchen button:disabled {
  opacity: 0.45;
  cursor: default;
}
.mode-kitchen button[aria-pressed='true'] {
  background: #215e4b;
  color: white;
  border-color: #215e4b;
}
.palette {
  display: grid;
  gap: 8px;
}
.palette button {
  text-align: left;
  display: flex;
  gap: 12px;
  align-items: center;
}
.palette svg {
  width: 44px;
  height: 44px;
  flex: none;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
label.toggle {
  display: block;
  margin: 10px 0;
}
.mode-kitchen #status {
  min-height: 42px;
  margin: 10px 0;
  padding: 8px;
  background: #f1f6f3;
  border-radius: 6px;
}
.mode-kitchen .toolbar span {
  margin-left: auto;
  font-size: 12px;
  color: #50685d;
}
.mode-kitchen #stage > svg {
  touch-action: none;
  user-select: none;
  outline-offset: -4px;
}
#stage.adding {
  cursor: crosshair;
}
#stage .kitchen-unit {
  cursor: grab;
}
#stage.dragging,
#stage.dragging .kitchen-unit {
  cursor: grabbing;
}
.mode-kitchen .export {
  background: #215e4b;
  color: white;
}
.mode-kitchen .export:hover {
  background: #174b3b;
}
/* 3D inspection controls. */
.mode-3d label,
.mode-walkthrough label {
  display: block;
  margin: 12px 0;
}
.mode-3d input[type='range'],
.mode-walkthrough input[type='range'] {
  width: 100%;
}
.mode-3d #stage,
.mode-walkthrough #stage {
  position: relative;
  background: #dfe7e9;
}
.mode-3d canvas,
.mode-walkthrough canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline-offset: -4px;
}
.mode-3d #status,
.mode-walkthrough #status {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  pointer-events: none;
  font-size: 12px;
  background: #ffffffde;
  padding: 6px 10px;
  border-radius: 6px;
}
.mode-3d #status:empty,
.mode-walkthrough #status:empty {
  display: none;
}
[hidden] {
  display: none !important;
}
@media (max-width: 640px) {
  .palette button {
    gap: 6px;
  }
  .palette svg {
    width: 30px;
    height: 30px;
  }
}

#workspace-toolbar {
  overflow-x: auto;
}
#mode-navigation,
#mode-actions {
  overflow: visible;
  flex-shrink: 0;
}
#mode-actions {
  border-left: 1px solid #bfcec7;
  margin-left: 6px;
  padding-left: 12px;
}
#workspace-toolbar > a,
#mode-navigation > a {
  flex-shrink: 0;
}
.walk-north {
  position: absolute;
  bottom: 70px;
  right: 28px;
  background: #ffffffde;
  border-radius: 50%;
  padding: 12px;
  pointer-events: none;
  font-weight: bold;
}

/* A drawer keeps the drawing usable on phones and small tablets. */
#menu-toggle,
#menu-close {
  display: none;
}
@media (max-width: 800px) {
  body {
    grid-template-columns: minmax(0, 1fr);
  }
  #workspace {
    padding: 6px;
  }
  #workspace-toolbar {
    flex-wrap: wrap;
    overflow: visible;
  }
  #menu-toggle {
    display: inline-flex;
  }
  #menu-close {
    display: block;
    min-height: 44px;
    margin-bottom: 12px;
  }
  #mode-navigation {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
  }
  #mode-actions {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    overflow-x: auto;
  }
  .toolbar button,
  .toolbar a {
    min-height: 44px;
    height: 44px;
    flex-shrink: 0;
  }
  #viewer-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(340px, 88vw);
    z-index: 20;
    padding: 14px;
    font-size: 14px;
    visibility: hidden;
    transform: translateX(-100%);
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  body[data-menu-open='true'] #viewer-sidebar {
    visibility: visible;
    transform: none;
  }
  #menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    border: 0;
    background: #0006;
  }
  #view-controls input[type='number'] {
    font-size: 16px;
  }
  .walk-north {
    bottom: 150px;
    right: 16px;
  }
  .mode-walkthrough #status {
    bottom: auto;
    top: 10px;
  }
}
.walk-movement {
  display: none;
}
@media (pointer: coarse), (max-width: 800px) {
  .mode-walkthrough #view > .toolbar {
    display: none;
  }
  .walk-movement {
    position: absolute;
    left: max(14px, env(safe-area-inset-left));
    bottom: max(14px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, 48px);
    gap: 6px;
  }
  .walk-movement button {
    width: 48px;
    height: 48px;
    border: 1px solid #b7c9bf;
    border-radius: 8px;
    background: #fffffff0;
    color: #18332e;
    font-size: 24px;
    touch-action: none;
    user-select: none;
  }
  .walk-movement button:first-child {
    grid-column: 2;
  }
  .walk-movement button:nth-child(2) {
    grid-column: 1;
  }
  .walk-movement button[aria-pressed='true'] {
    background: #215e4b;
    color: white;
  }
}
