:root {
  --bg: #f6f4ef; --panel: #fff; --ink: #24272b; --muted: #6b7078; --line: #e4e0d8;
  --accent: #2f6f6a; --accent-2: #e08a3c; --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, select, input { font: inherit; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 18px;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 500; color: var(--muted); font-size: .7rem; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: linear-gradient(135deg, var(--accent) 50%, #f6d365 50%); display: inline-block; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: #fff; padding: 7px 12px; border-radius: 9px; cursor: pointer; }
.btn:hover { border-color: #c9c3b6; background: #fbfaf7; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: #285f5b; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.small { padding: 3px 8px; font-size: .85rem; }

.layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; padding: 16px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .catalog { order: 2; max-height: none; } }

.catalog { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  max-height: calc(100vh - 90px); overflow: auto; position: sticky; top: 72px; }
.catalog h2 { margin: 0 0 10px; font-size: 1.05rem; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tabs button { border: none; background: #f1eee8; padding: 5px 10px; border-radius: 20px; cursor: pointer; font-size: .85rem; }
.tabs button.active { background: var(--ink); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; }
.chip { border: 1px solid var(--line); background: #fff; padding: 3px 9px; border-radius: 20px; cursor: pointer; font-size: .8rem; text-transform: capitalize; }
.chip.active { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.hint { font-size: .8rem; color: var(--muted); margin: 6px 0 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; cursor: grab; background: #fff; position: relative; transition: box-shadow .15s, transform .15s; }
.card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); transform: translateY(-1px); }
.card .thumb { height: 92px; display: flex; align-items: center; justify-content: center; background: #f7f5f0; border-radius: 7px; margin-bottom: 6px; }
.card .thumb img { max-width: 85%; max-height: 82px; pointer-events: none; }
.card .name { font-size: .84rem; font-weight: 600; line-height: 1.2; }
.card .styles { font-size: .7rem; color: var(--muted); text-transform: capitalize; margin: 2px 0 4px; }
.card .badge { position: absolute; top: 6px; left: 6px; background: rgba(36,39,43,.75); color: #fff; font-size: .62rem; padding: 1px 6px; border-radius: 10px; letter-spacing: .03em; }
.card .shop { font-size: .74rem; color: var(--accent); text-decoration: none; font-weight: 600; }
.card .shop:hover { text-decoration: underline; }
.empty { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; padding: 20px 0; text-align: center; }
.disclaimer { font-size: .72rem; color: var(--muted); margin-top: 12px; }

.workspace { min-width: 0; }
.roomtabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.roomtabs button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; cursor: pointer; }
.roomtabs button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); font-weight: 600; }

.stage-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.stage { position: relative; width: 100%; aspect-ratio: 1000 / 625; overflow: hidden; border-radius: 8px; user-select: none; touch-action: none; background: #ddd; }
.stage.drop-over { outline: 3px dashed var(--accent-2); outline-offset: -3px; }
.wall { position: absolute; left: 0; top: 0; width: 100%; height: 68.8%; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.layer.floor { z-index: 1; }
.layer.furniture { z-index: 3; }
.empty-hint { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 4; color: rgba(0,0,0,.45); font-size: .95rem;
  background: rgba(255,255,255,.6); padding: 6px 12px; border-radius: 20px; pointer-events: none; white-space: nowrap; }
.empty-hint.hidden { display: none; }

.placed { position: absolute; cursor: move; }
.placed img { width: 100%; display: block; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(0,0,0,.18)); }
.placed.rug img { filter: none; }
.placed.selected { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.placed .h { display: none; position: absolute; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--accent-2);
  font-size: 13px; line-height: 17px; text-align: center; padding: 0; cursor: pointer; color: var(--accent-2); font-weight: 700; }
.placed.selected .h { display: block; }
.placed .del { top: -12px; right: -12px; }
.placed .rs { bottom: -12px; right: -12px; cursor: nwse-resize; }

.panel-row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 12px; margin-top: 12px; }
@media (max-width: 1100px) { .panel-row { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.panel h3 { margin: 0 0 8px; font-size: .9rem; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--accent); }
.inline { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.inline input[type=color] { width: 36px; height: 26px; border: none; background: none; padding: 0; cursor: pointer; }
select { width: 100%; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.muted { color: var(--muted); font-size: .85rem; }
.sel-row { display: flex; gap: 12px; align-items: flex-start; }
.sel-row img { width: 64px; max-height: 80px; object-fit: contain; background: #f7f5f0; border-radius: 6px; padding: 4px; }
.sel-row .meta { font-size: .85rem; }
.sel-row .meta b { display: block; font-size: .95rem; }
.sel-row .btns { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.shop-btn { display: inline-block; background: var(--accent-2); color: #fff; text-decoration: none; padding: 4px 10px; border-radius: 8px; font-size: .82rem; font-weight: 600; }

dialog { border: none; border-radius: 14px; padding: 0; width: min(520px, 92vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,20,20,.35); }
.dlg { padding: 18px; }
.dlg h3 { margin: 0 0 10px; }
.dlg input { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.dlg menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 14px 0 0; }
.save-row { display: flex; gap: 8px; }
.save-row input { flex: 1; }
.design-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 300px; overflow: auto; }
.design-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.design-list li small { color: var(--muted); display: block; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff;
  padding: 9px 16px; border-radius: 10px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 100; font-size: .9rem; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
