:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e8edf2;
  background: #0d1115;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-rows: auto 1fr;
}

button,
.button,
select,
input {
  font: inherit;
}

button,
.button,
select {
  color: #dce5ec;
  border: 1px solid #394651;
  border-radius: 6px;
  background: #202a32;
}

button,
.button {
  min-height: 34px;
  padding: 7px 11px;
  cursor: pointer;
}

button:hover:not(:disabled),
.button:hover {
  border-color: #6d8293;
  background: #293640;
}

button:disabled {
  cursor: default;
  opacity: .45;
}

.primary {
  color: white;
  border-color: #2887b8;
  background: #0878b2;
}

.primary:hover:not(:disabled) {
  background: #0b8acb;
}

.secondary {
  display: inline-flex;
  align-items: center;
}

.topbar {
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 11px 16px;
  border-bottom: 1px solid #2c353d;
  background: #151c22;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.topbar p {
  margin: 3px 0 0;
  color: #8997a3;
  font-size: 12px;
}

.file-actions {
  display: flex;
  gap: 8px;
}

#directory-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.workspace {
  display: grid;
  grid-template-columns: 250px minmax(300px, 1fr) 280px;
  min-height: 0;
}

.sidebar {
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  background: #151c22;
}

.left-sidebar {
  border-right: 1px solid #2c353d;
}

.right-sidebar {
  border-left: 1px solid #2c353d;
}

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

h2 {
  margin: 0 0 10px;
  color: #b9c5ce;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 10px 0 6px;
  color: #aebbc5;
  font-size: 12px;
}

output {
  float: right;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 36px;
  padding: 6px 8px;
}

.floor-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  gap: 6px;
}

.floor-controls button {
  min-width: 36px;
  padding: 0;
}

.stats {
  margin: 0;
  font-size: 12px;
}

.stats div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #232c33;
}

.stats dt {
  color: #7e8d98;
}

.stats dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #e6edf2;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.tool.active {
  border-color: #40a9df;
  background: #075f8d;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  margin-top: 8px;
}

.swatches button {
  min-width: 0;
  min-height: 21px;
  padding: 0;
  border-radius: 3px;
}

.swatches button.active {
  border-color: #40a9df;
  box-shadow: 0 0 0 2px #40a9df;
}

.quick-values {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.quick-values button {
  min-width: 0;
  min-height: 28px;
  padding: 3px;
  font-size: 11px;
}

.check-row {
  display: flex;
  gap: 7px;
  align-items: center;
}

.check-row input {
  margin: 0;
}

.canvas-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: #11161b;
  background-image:
    linear-gradient(45deg, #151b20 25%, transparent 25%),
    linear-gradient(-45deg, #151b20 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151b20 75%),
    linear-gradient(-45deg, transparent 75%, #151b20 75%);
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
}

#map-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}

#map-canvas[data-tool="pan"] {
  cursor: grab;
}

#map-canvas[data-tool="paint"] {
  cursor: crosshair;
}

#empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  padding: 26px 34px;
  border: 1px dashed #45545f;
  border-radius: 10px;
  color: #8d9ca7;
  background: rgba(17, 22, 27, .9);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#empty-state strong {
  color: #d9e2e9;
}

#empty-state span {
  font-size: 12px;
}

.canvas-controls,
#coordinates {
  position: absolute;
  bottom: 12px;
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid #34414a;
  border-radius: 7px;
  background: rgba(21, 28, 34, .93);
  box-shadow: 0 3px 14px rgba(0, 0, 0, .3);
}

.canvas-controls {
  left: 12px;
  padding: 3px;
}

.canvas-controls button {
  min-width: 32px;
  min-height: 28px;
  padding: 2px 8px;
  border: 0;
  background: transparent;
}

#zoom-label {
  min-width: 55px;
  color: #acbbc5;
  font-size: 11px;
  text-align: center;
}

#coordinates {
  right: 12px;
  padding: 0 11px;
  color: #b6c2ca;
  font: 12px ui-monospace, SFMono-Regular, Consolas, monospace;
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
}

.section-heading button {
  min-height: 25px;
  padding: 3px 7px;
  font-size: 10px;
}

.hint {
  margin: 5px 0 10px;
  color: #788792;
  font-size: 11px;
  line-height: 1.45;
}

.marker-list {
  display: grid;
  gap: 5px;
}

.marker-row {
  display: grid;
  grid-template-columns: 1fr 28px;
  gap: 4px;
}

.marker-jump {
  display: grid;
  grid-template-columns: 12px 1fr;
  column-gap: 7px;
  min-width: 0;
  text-align: left;
}

.marker-jump span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marker-jump small {
  grid-column: 2;
  color: #82909a;
  font-size: 9px;
}

.marker-sprite {
  display: inline-block;
  width: 11px;
  height: 11px;
  background-image: url("icons.png");
  background-repeat: no-repeat;
  image-rendering: pixelated;
}

.marker-jump .marker-sprite {
  margin-top: 2px;
}

.marker-icons {
  display: grid;
  grid-template-columns: repeat(7, 32px);
  gap: 5px;
}

.marker-icons button {
  display: grid;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
}

.marker-icons button.active {
  border-color: #40a9df;
  background: #075f8d;
  box-shadow: 0 0 0 1px #40a9df inset;
}

.marker-delete {
  min-width: 28px;
  padding: 0;
  color: #c69494;
}

.log {
  display: grid;
  gap: 6px;
  color: #8fa0ab;
  font-size: 11px;
  line-height: 1.35;
}

.log .error {
  color: #e59b9b;
}

dialog {
  width: min(380px, calc(100vw - 30px));
  color: #e8edf2;
  border: 1px solid #46545f;
  border-radius: 9px;
  background: #182027;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .65);
}

dialog::backdrop {
  background: rgba(4, 7, 9, .7);
}

dialog form {
  display: grid;
  gap: 5px;
}

dialog input:not([type="color"]) {
  width: 100%;
  padding: 8px;
  color: white;
  border: 1px solid #3d4b55;
  border-radius: 5px;
  background: #0f151a;
}

.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 7px;
  margin-top: 15px;
}

.loader {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 7, 9, .78);
  backdrop-filter: blur(2px);
}

.loader[hidden] {
  display: none;
}

.loader-card {
  display: grid;
  width: min(360px, calc(100vw - 30px));
  gap: 12px;
  justify-items: center;
  padding: 24px;
  border: 1px solid #46545f;
  border-radius: 10px;
  background: #182027;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .65);
}

.loader-card strong {
  font-size: 15px;
}

.loader-card span {
  color: #9dacb7;
  font-size: 12px;
}

.loader-card progress {
  width: 100%;
  height: 8px;
  accent-color: #1595d1;
}

.loader-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #344550;
  border-top-color: #40a9df;
  border-radius: 50%;
  animation: loader-spin .8s linear infinite;
}

@keyframes loader-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 210px 1fr;
  }

  .right-sidebar {
    display: none;
  }

  .topbar p {
    display: none;
  }
}
