:root {
  --bg: #f7f2e9;
  --panel: #fffdf8;
  --ink: #221b17;
  --muted: #7d6b5f;
  --accent: #d55c34;
  --line: #d9ccbf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #ffe8cd 0, transparent 30%),
    radial-gradient(circle at 90% 90%, #fdd8ce 0, transparent 25%),
    var(--bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px;
}

.sidebar h1 {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: 0.04em;
}

.sidebar section {
  margin-top: 22px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.project-source-controls {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.project-source-controls button {
  padding: 7px 8px;
  font-size: 12px;
}

.project-source-status {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.title-actions {
  display: flex;
  gap: 6px;
}

.title-actions button {
  padding: 6px 8px;
  font-size: 12px;
}

h2 {
  margin: 0;
  font-size: 16px;
}

ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.list-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  align-items: center;
}

.group-row > button:first-child {
  font-weight: 700;
  background: #fff6ef;
  border-color: #d7b9a6;
  font-family: "Consolas", "Segoe UI", sans-serif;
}

.group-row > button:first-child::before {
  content: "GROEP ";
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.page-row > button:first-child {
  background: #fff;
  border-color: var(--line);
}

.list-row[draggable="true"] {
  cursor: grab;
}

.list-row[draggable="true"]:active {
  cursor: grabbing;
}

.row-actions {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

li button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
}

li button.active {
  border-color: var(--accent);
  background: #fff3ee;
}

.mini-btn {
  width: auto;
  padding: 8px;
  font-size: 12px;
  white-space: nowrap;
}

.icon-btn {
  min-width: 28px;
  padding: 5px 4px;
  text-align: center;
  font-size: 12px;
  line-height: 1;
}

.page-row-drag-over > button:first-child {
  border-color: var(--accent);
  background: #fff3ee;
  box-shadow: 0 0 0 2px #d55c3430;
}

.page-row-dragging > button:first-child {
  opacity: 0.5;
}

.editor-area {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: #fffcf7;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.canvas-size-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.canvas-size-controls label {
  display: flex;
  align-items: center;
  gap: 3px;
}

.canvas-size-controls input[type="number"] {
  width: 70px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  text-align: right;
}

.canvas-size-controls::before {
  content: "Canvas";
  font-weight: 600;
  color: var(--muted);
}

.grid-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

#grid-size-label {
  min-width: 52px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

#grid-size-slider {
  width: 120px;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 1px solid #2d241e;
  background: #fff;
  color: #2d241e;
  padding: 8px 11px;
  border-radius: 8px;
  cursor: pointer;
}

button:hover {
  background: #fff3ee;
}

.toolbar button.active-tool {
  border-color: var(--accent);
  background: #fff3ee;
}

#status {
  font-size: 13px;
  color: var(--muted);
}

.work-area {
  display: grid;
  grid-template-columns: 1fr 360px;
  min-height: 0;
}

.canvas-wrap {
  padding: 24px;
  overflow: auto;
}

#canvas {
  width: 1200px;
  height: 900px;
  background: #fff;
  border: 1px solid var(--line);
  position: relative;
  background-image:
    linear-gradient(to right, #00000014 1px, transparent 1px),
    linear-gradient(to bottom, #00000014 1px, transparent 1px);
  background-size: 20px 20px;
  box-shadow: 0 8px 30px #0000000f;
}

.canvas-item {
  position: absolute;
  border: 1px solid #11111133;
  border-radius: 8px;
  padding: 10px 10px 26px;
  user-select: none;
  cursor: move;
  overflow: hidden;
}

.canvas-item.selected {
  outline: 2px solid var(--accent);
}

.canvas-item.label-component {
  border-style: dashed;
  background: #ffffff80;
}

.canvas-item.icon-component {
  border-style: solid;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 26px;
  font-weight: 700;
}

.item-label {
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
}

.canvas-controls {
  position: absolute;
  left: 6px;
  bottom: 4px;
  display: flex;
  gap: 4px;
}

.canvas-controls button {
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  line-height: 1;
}

.resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 12px;
  height: 12px;
  background: var(--accent);
  border-radius: 2px;
  cursor: nwse-resize;
}

.selection-box {
  position: absolute;
  border: 1px dashed var(--accent);
  background: #d55c3420;
  pointer-events: none;
  z-index: 999;
}

.properties {
  border-left: 1px solid var(--line);
  background: var(--panel);
  padding: 14px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr auto 1fr;
  gap: 8px;
}

#property-form {
  display: grid;
  gap: 8px;
}

#property-form label {
  display: grid;
  gap: 4px;
  font-size: 12px;
}

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-family: inherit;
}

textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
}

.picker-overlay {
  position: fixed;
  inset: 0;
  background: #00000055;
  display: grid;
  place-items: center;
  z-index: 999;
}

.picker-panel {
  width: min(640px, calc(100vw - 30px));
  max-height: min(560px, calc(100vh - 30px));
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px #0000002a;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  padding: 14px;
}

.picker-panel h3 {
  margin: 0;
}

.picker-list {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  padding: 8px;
  display: grid;
  gap: 6px;
}

.picker-option {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
}

.picker-option span {
  color: var(--muted);
  font-size: 12px;
}

.picker-footer {
  display: flex;
  justify-content: flex-end;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .work-area {
    grid-template-columns: 1fr;
  }

  .properties {
    border-left: none;
    border-top: 1px solid var(--line);
  }
}
