:root {
  --bg: #f4f5f3;
  --panel: #ffffff;
  --ink: #23282a;
  --muted: #6b7378;
  --line: #e2e5e1;
  --accent: #6f8a5e;
  --accent-ink: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  padding: 14px 24px 6px;
  flex: 0 0 auto;
}
header h1 { margin: 0 0 2px; font-size: 22px; }
.hint { color: var(--muted); margin: 0; font-size: 14px; }
.hint.small { font-size: 12px; }

main {
  display: flex;
  gap: 20px;
  align-items: stretch;
  padding: 12px 24px;
  flex: 1 1 auto;
  min-height: 0;          /* aby se vnitřek mohl smrštit a panel skrolovat */
}

.stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
}
.canvas-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
}
#house {
  max-width: 100%;
  max-height: 100%;       /* obrázek se vždy vejde celý do výšky okna */
  width: auto;
  height: auto;
  border-radius: 8px;
  cursor: default;
}

.panel {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;       /* ovládací prvky skrolují samostatně */
  padding-right: 4px;
  padding-bottom: 12px;
}

.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
}
.block h2 { margin: 0 0 10px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.photo-switch { display: flex; flex-direction: column; gap: 8px; }
.photo-btn {
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: all .12s;
}
.photo-btn:hover { border-color: var(--accent); }
.photo-btn.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.region-buttons { display: flex; gap: 8px; }
.region-btn {
  flex: 1;
  padding: 10px 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  transition: all .12s;
}
.region-btn:hover { border-color: var(--accent); }
.region-btn.is-active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 10px; cursor: pointer; }

.swatch-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fafafa;
}
#vzornik { display: block; max-width: 100%; height: auto; cursor: crosshair; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.swatch {
  width: 38px; height: 38px;
  border-radius: 8px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}
.swatch.is-active { box-shadow: 0 0 0 2px var(--accent); }

.slider { margin-bottom: 12px; }
.slider:last-child { margin-bottom: 0; }
.slider label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.slider label span { color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 14px;
  border-radius: 7px;
  background: #e3e3e3;             /* přepíše JS gradientem */
  border: 1px solid var(--line);
  outline: none;
  cursor: pointer;
}
.slider input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a4a4a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  cursor: pointer;
}
.slider input[type=range]::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a4a4a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  cursor: pointer;
}

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions button.ghost {
  padding: 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
}
.actions button.ghost:hover { border-color: var(--accent); }

.mesh-box {
  width: 100%;
  height: 84px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  margin-bottom: 8px;
}
.editor-actions { display: flex; gap: 8px; }
.editor-actions button { flex: 1; }
#house.editing { cursor: crosshair; }

.filebtn {
  display: block;
  text-align: center;
  padding: 9px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--muted);
}
.filebtn:hover { border-color: var(--accent); color: var(--ink); }

@media (max-width: 880px) {
  /* úzké okno: normální svislé skrolování celé stránky */
  body { height: auto; overflow: auto; }
  main { flex-direction: column; min-height: 0; }
  .stage { min-height: 0; }
  .canvas-wrap { max-height: 70vh; }
  .panel { flex-basis: auto; width: 100%; overflow-y: visible; }
}
