:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --border: #e5e2da;
  --text: #26241f;
  --muted: #7a7568;
  --accent: #b5651d;
  --accent-dark: #954f16;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); }

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: #201d18;
  color: #f4efe6;
}
.site-header .logo { font-weight: 700; font-size: 17px; letter-spacing: 0.02em; }
.site-header .logo span { color: #e4a95c; }
.site-header a.admin-link { color: #cfc8b8; font-size: 13px; }

.container { max-width: 1180px; margin: 0 auto; padding: 32px 20px 60px; }

/* ---------- Room selection screen ---------- */
.hero { text-align: center; margin-bottom: 32px; }
.hero h1 { font-size: 26px; margin-bottom: 8px; }
.hero p { color: var(--muted); font-size: 15px; }

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
}
.room-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.room-card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(0,0,0,0.08); }
.room-card .emoji { font-size: 44px; margin-bottom: 12px; }
.room-card h3 { margin: 0 0 6px; font-size: 17px; }
.room-card p { margin: 0; color: var(--muted); font-size: 13px; }

/* ---------- Workspace screen ---------- */
.workspace { display: none; gap: 24px; align-items: flex-start; }
.workspace.active { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.room-select-screen.hidden { display: none; }

.workspace-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  grid-column: 1 / -1;
}
.workspace-top h2 { margin: 0; font-size: 20px; }
.back-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.back-btn:hover { background: #efece5; }

.canvas-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.canvas-wrap { position: relative; width: 100%; aspect-ratio: 900 / 600; }
.canvas-wrap canvas {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  display: block;
  background: #ddd;
  touch-action: none; /* let OrbitControls handle one-finger drag / pinch on touch */
}
.canvas-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  background: rgba(20, 18, 14, 0.55);
  color: #fdfaf3;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.fullscreen-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: rgba(20, 18, 14, 0.55);
  color: #fdfaf3;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(2px);
}
.fullscreen-btn:hover { background: rgba(20, 18, 14, 0.75); }
.fullscreen-info {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  right: 56px;
  background: rgba(20, 18, 14, 0.55);
  color: #fdfaf3;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 10px;
  backdrop-filter: blur(2px);
  pointer-events: none;
}
.fullscreen-info-row strong { color: #fff; }
.fullscreen-info-row .muted { color: #cfc8b8; }
.canvas-wrap.is-fullscreen,
.canvas-wrap:fullscreen,
.canvas-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  background: #000;
}
.canvas-wrap.is-fullscreen canvas,
.canvas-wrap:fullscreen canvas,
.canvas-wrap:-webkit-full-screen canvas {
  border-radius: 0;
}
.canvas-wrap.is-fullscreen .fullscreen-info { display: block; }
.applied-info {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.applied-row {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
}
.applied-row strong { color: var(--text); }
.applied-row .muted { color: var(--muted); }

.tile-menu {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  max-height: 640px;
  overflow-y: auto;
}
.surface-toggle {
  display: flex;
  gap: 6px;
  background: #f1efe8;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 14px;
}
.surface-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.surface-tab.active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.grout-picker {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.grout-picker-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.grout-swatches {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.grout-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  padding: 0;
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.6);
}
.grout-swatch:hover { transform: scale(1.08); }
.grout-swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}
.grout-swatch-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  overflow: hidden;
}
.grout-swatch-custom input[type="color"] {
  width: 34px;
  height: 34px;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: none;
  opacity: 0;
}

.pattern-picker {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.pattern-picker-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.pattern-select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: var(--panel);
  color: var(--text);
}
.pattern-select:disabled { opacity: 0.55; cursor: not-allowed; }

.wall-mix-panel {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.wall-mix-panel.hidden { display: none; }
.wall-mix-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.wall-mix-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.wall-mix-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12.5px;
  background: #f6f3ec;
  border-radius: 8px;
  padding: 6px 8px;
}
.wall-mix-item strong { color: var(--text); }
.wall-mix-remove-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  flex-shrink: 0;
}
.wall-mix-remove-btn:hover { color: var(--accent); }
.wall-mix-empty { font-size: 12px; color: var(--muted); }
.wall-mix-add {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 6px;
}
.wall-mix-row-input,
.wall-mix-product-select {
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 12.5px;
  width: 100%;
  min-width: 0;
}
.wall-mix-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}
.wall-mix-add-btn:hover { background: var(--accent-dark); }
.wall-mix-add-btn:disabled,
.wall-mix-row-input:disabled,
.wall-mix-product-select:disabled { opacity: 0.5; cursor: not-allowed; }
.wall-mix-note { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

.surface-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.surface-toolbar h3 { margin: 0; font-size: 15px; }
.clear-surface-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}
.clear-surface-btn:hover { text-decoration: underline; }
.tile-filter {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
  font-size: 13px;
}
.tile-item {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  margin-bottom: 6px;
}
.tile-item:hover { background: #f6f3ec; }
.tile-item.selected { border-color: var(--accent); background: #fbf1e4; }
.tile-item img {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.tile-item .info { min-width: 0; }
.tile-item .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-item .meta { font-size: 11px; color: var(--muted); }
.tile-empty { color: var(--muted); font-size: 13px; padding: 12px 0; }

@media (max-width: 820px) {
  .workspace.active { grid-template-columns: 1fr; }
  .tile-menu { max-height: none; }
}
