:root {
  color-scheme: light;
  --ink: #172033;
  --paper: #f3f6f9;
  --panel: #ffffff;
  --panel-dark: #0d2638;
  --muted: #5c6b7a;
  --line: #d4dde7;
  --grid: rgba(91, 111, 132, 0.18);
  --grid-strong: rgba(20, 111, 184, 0.24);
  --blue: #146fb8;
  --blue-strong: #0a5fa4;
  --teal: #13837f;
  --gold: #b7791f;
  --danger: #c53b30;
}

* {
  box-sizing: border-box;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  font: 14px system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.planner-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
}

.toolbar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  color: #eef7ff;
  background: var(--panel-dark);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 12px 0 34px rgba(14, 31, 45, 0.14);
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.brand-logo-link {
  flex: 0 0 auto;
  display: block;
  padding: 0;
  border-radius: 6px;
}

.brand-bar img {
  display: block;
  width: 96px;
  height: auto;
}

.brand-bar p,
.brand-bar strong {
  display: block;
  margin: 0;
  line-height: 1.2;
}

.brand-bar p {
  color: #b9cbe0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.brand-bar strong {
  margin-top: 3px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.beta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 5px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: #fff;
  background: rgba(19, 131, 127, 0.42);
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
}

.toolbar-section,
.readouts {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.toolbar-section.compact {
  grid-template-columns: 1fr 1fr;
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.mode-group.two {
  grid-template-columns: 1fr 1fr;
}

label {
  color: #c5d4e4;
  font-weight: 700;
}

button,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font: 700 14px system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

button {
  cursor: pointer;
}

select {
  color: #102033;
  background: #fff;
}

.tool-button:hover,
.tool-button:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.tool-button.primary {
  border-color: var(--blue);
  background: var(--blue);
}

.tool-button.primary:hover,
.tool-button.primary:focus-visible {
  background: var(--blue-strong);
}

.tool-button.danger {
  border-color: rgba(197, 59, 48, 0.68);
  background: rgba(197, 59, 48, 0.24);
}

.piece-button {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 64px;
  padding: 7px;
  text-align: left;
}

.piece-button img {
  width: 58px;
  height: 46px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
}

.piece-button span,
.piece-button small {
  min-width: 0;
}

.piece-button span {
  font-weight: 800;
}

.piece-button small {
  color: #d3e3f3;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.readouts div {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.readouts span {
  color: #b9cbe0;
  font-size: 12px;
}

.readouts strong {
  color: #fff;
  font-size: 18px;
}

.drawing-panel {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 20%, rgba(20, 111, 184, 0.09), transparent 28%),
    linear-gradient(135deg, #f8fafc 0%, #e7edf3 58%, #eef5f2 100%);
}

#layoutCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.canvas-status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  pointer-events: none;
}

.canvas-status span {
  padding: 7px 9px;
  border: 1px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 8px 22px rgba(14, 31, 45, 0.08);
}

@media (max-width: 780px) {
  .planner-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 1fr);
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .toolbar-section,
  .readouts {
    grid-template-columns: 1fr;
  }

  .toolbar-section.compact {
    grid-template-columns: 1fr 1fr;
  }

  .piece-button {
    grid-template-columns: 52px 1fr auto;
  }

  .piece-button img {
    width: 52px;
  }

  .drawing-panel {
    min-height: 520px;
  }
}

@media (max-width: 460px) {
  .toolbar {
    padding: 10px;
  }

  .brand-bar {
    align-items: flex-start;
  }

  .brand-bar img {
    width: 82px;
  }

  .canvas-status {
    flex-direction: column;
    align-items: flex-start;
  }
}
