.editor-page {
  min-width: 320px;
  min-height: 100dvh;
  overflow: auto;
  user-select: none;
  background:
    linear-gradient(rgba(123,229,224,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123,229,224,.018) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, #283330, #090d0c 50%, #030505 100%);
  background-size: 24px 24px, 24px 24px, auto;
}

.editor-page button,
.editor-page select,
.editor-page input { font: inherit; }

.editor-shell {
  width: min(1460px, 100%);
  min-height: 100dvh;
  margin: auto;
  padding: max(13px, env(safe-area-inset-top)) max(13px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(13px, env(safe-area-inset-left));
}

.editor-masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 13px;
}

.editor-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--white);
  text-decoration: none;
}

.editor-brand > span:last-child { display: grid; gap: 4px; }
.editor-brand small { color: var(--steel); font-size: .6rem; letter-spacing: .12em; }
.editor-brand strong { color: var(--red); font-size: clamp(1.05rem, 2.4vw, 1.5rem); letter-spacing: .08em; }
.editor-brand em { margin-left: 8px; color: var(--cyan); font-size: .68em; font-style: normal; }

.editor-top-actions,
.edit-actions,
.file-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }

.editor-button,
.editor-icon-button,
.editor-field select {
  min-height: 38px;
  padding: 7px 11px;
  color: #dce3df;
  border: 1px solid #59615e;
  border-bottom-color: #202423;
  border-radius: 2px;
  background: linear-gradient(#333b38, #171d1c);
  box-shadow: inset 0 1px #747c78, 0 3px 8px rgba(0,0,0,.55);
  text-decoration: none;
}

.editor-button:hover,
.editor-icon-button:hover,
.editor-field select:hover { border-color: var(--cyan); background: linear-gradient(#414b47, #202725); }
.editor-button:active,
.editor-icon-button:active { transform: translateY(1px); }
.editor-button:disabled { cursor: default; opacity: .34; transform: none; }
.editor-button.compact { min-width: 43px; padding-inline: 9px; }
.editor-button.primary { color: #061006; border-color: #8cff88; background: linear-gradient(#62ec5e, #279524); box-shadow: inset 0 1px #c2ffbf, 0 0 12px rgba(80,227,77,.16); font-weight: 900; }
.editor-button.subtle { color: #c5ccc8; }

.editor-cabinet {
  overflow: hidden;
  border: 1px solid #68716e;
  background: linear-gradient(145deg, #3b4340, #121716 14%, #0b0f0e 86%, #303735);
  box-shadow: inset 0 0 0 3px #202624, inset 0 0 35px #000, 0 18px 48px rgba(0,0,0,.7);
}

.editor-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto minmax(170px, auto);
  align-items: end;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #505956;
  background: linear-gradient(#29302e, #141918);
}

.toolbar-intro h1 { margin: 3px 0 0; color: var(--red); font-size: clamp(1rem, 2.2vw, 1.3rem); letter-spacing: .06em; }
.editor-eyebrow { margin: 0; color: var(--green); font-size: .56rem; letter-spacing: .12em; }
.floor-picker { display: flex; align-items: end; gap: 5px; }
.editor-icon-button { width: 38px; padding-inline: 0; }
.editor-field { display: grid; gap: 4px; color: var(--steel); font-size: .58rem; letter-spacing: .08em; text-transform: uppercase; }
.editor-field select { min-width: 120px; color: var(--white); }
.editor-status { min-width: 170px; margin: 0 0 9px; color: var(--cyan); font-size: .62rem; line-height: 1.25; text-align: right; }
.editor-status[data-state="dirty"] { color: var(--yellow); }
.editor-status[data-state="error"] { color: #ff6964; }

.editor-workspace {
  display: grid;
  grid-template-columns: minmax(540px, 1.35fr) minmax(330px, .65fr);
  min-height: 510px;
}

.board-panel,
.palette-panel { min-width: 0; padding: 14px; }
.palette-panel { border-left: 1px solid #48504d; background: rgba(4,7,6,.46); }

.panel-heading {
  min-height: 52px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 9px;
}
.panel-heading h2 { margin: 0 0 4px; color: var(--red); font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; }
.panel-heading p { margin: 0; color: #87918d; font-size: .59rem; line-height: 1.35; }
.board-readout { display: grid; gap: 5px; color: #8e9894; font-size: .58rem; text-align: right; }
.board-readout output { color: var(--cyan); }

.board-frame {
  padding: 9px;
  border: 2px solid #717976;
  background: linear-gradient(135deg, #171c1b, #4d5552 48%, #171c1b 50%);
  box-shadow: inset 0 0 0 3px #080b0a, 0 10px 22px #000;
}
.board-scroll {
  overflow: auto;
  min-height: 326px;
  display: grid;
  place-items: center;
  background: #030505;
  border: 1px solid #080a09;
  overscroll-behavior: contain;
}
#editor-canvas {
  display: block;
  width: 504px;
  height: 324px;
  max-width: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
}
.board-note { margin: 10px 2px 0; color: #71817a; font-size: .56rem; line-height: 1.4; }

.tile-palette {
  max-height: 392px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 6px;
  padding: 2px 3px 3px 1px;
  overscroll-behavior: contain;
}
.tile-tool {
  min-width: 0;
  min-height: 58px;
  padding: 5px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  color: #cad1cd;
  border: 1px solid #3d4642;
  background: #111615;
  text-align: left;
}
.tile-tool:hover { border-color: #76817d; background: #1d2422; }
.tile-tool.selected { color: #fff; border-color: var(--yellow); box-shadow: inset 0 0 0 1px var(--yellow), 0 0 10px rgba(243,220,71,.12); background: #272716; }
.tile-tool canvas { width: 30px; height: 30px; image-rendering: pixelated; background: #000; }
.tile-tool span { min-width: 0; overflow: hidden; font-size: .54rem; line-height: 1.25; text-overflow: ellipsis; }
.tile-tool b { display: block; color: var(--cyan); font-size: .58rem; }

.editor-footer {
  display: grid;
  grid-template-columns: minmax(280px, .72fr) minmax(520px, 1.28fr);
  border-top: 1px solid #505956;
  background: linear-gradient(#151a19, #0a0e0d);
}
.validation-panel,
.editor-actions { padding: 14px 16px; }
.validation-panel { border-right: 1px solid #414946; }
.validation-heading { display: flex; align-items: center; justify-content: space-between; }
.validation-heading h2,
.file-actions h2 { margin: 0; color: var(--red); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }
.validation-light { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.validation-panel.has-warning .validation-light { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.validation-panel.has-error .validation-light { background: var(--red); box-shadow: 0 0 8px var(--red); }
.validation-list { margin: 9px 0 0; padding-left: 18px; color: #aab3af; font-size: .58rem; line-height: 1.5; }
.validation-list li[data-severity="error"] { color: #ff7974; }
.validation-list li[data-severity="warning"] { color: var(--yellow); }
.validation-list li[data-severity="ok"] { color: #8cff88; }

.editor-actions { display: grid; gap: 11px; }
.file-actions { padding-top: 10px; border-top: 1px solid #333b38; }
.file-actions > div { flex: 1 1 260px; }
.file-actions p { margin: 4px 0 0; color: #7f8985; font-size: .55rem; line-height: 1.35; }
.draft-note { margin: 0; color: #67716d; font-size: .54rem; }

@media (max-width: 980px) {
  .editor-toolbar { grid-template-columns: 1fr auto auto; }
  .toolbar-intro { grid-column: 1 / -1; }
  .editor-status { grid-column: 1 / -1; text-align: left; }
  .editor-workspace { grid-template-columns: 1fr; }
  .palette-panel { border: 0; border-top: 1px solid #48504d; }
  .tile-palette { max-height: 290px; }
  .editor-footer { grid-template-columns: 1fr; }
  .validation-panel { border-right: 0; border-bottom: 1px solid #414946; }
}

@media (max-width: 650px) {
  .editor-shell { padding-inline: 7px; }
  .editor-masthead { align-items: flex-start; }
  .editor-brand small { display: none; }
  .editor-brand strong { font-size: .95rem; }
  .editor-brand em { display: block; margin: 5px 0 0; }
  .editor-top-actions { justify-content: end; }
  .editor-top-actions .editor-button { min-height: 40px; padding: 7px 8px; font-size: .62rem; }
  .editor-toolbar { grid-template-columns: 1fr auto; padding: 11px; }
  .floor-picker { grid-column: 1 / -1; }
  .floor-picker .editor-field { flex: 1; }
  .floor-picker select { width: 100%; }
  .board-panel, .palette-panel { padding: 11px; }
  .panel-heading { display: block; }
  .board-readout { margin-top: 8px; grid-template-columns: 1fr 1fr; text-align: left; }
  .board-scroll { place-items: start; min-height: 326px; }
  .tile-palette { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile-tool { grid-template-columns: 29px minmax(0,1fr); padding: 4px; }
  .tile-tool canvas { width: 27px; height: 27px; }
  .editor-footer { display: block; }
  .edit-actions .editor-button { flex: 1 1 calc(50% - 7px); }
  .file-actions .editor-button { flex: 1 1 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .editor-page *, .editor-page *::before, .editor-page *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
