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

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #0d0d12;
}

button,
input,
select { font: inherit; }

.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  padding: 0.75rem;
}

.app-header {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  min-height: 2.4rem;
  padding: 0 0.25rem 0.65rem;
}

h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.app-header p {
  margin: 0;
  color: #95909f;
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 0;
  padding: 0.9rem;
  overflow: auto;
  border: 1px solid #34313b;
  border-radius: 0.55rem;
  background: #17161c;
}

.control-group {
  display: grid;
  gap: 0.35rem;
}

label,
.label-row {
  color: #cbc7d1;
  font-size: 0.74rem;
  font-weight: 650;
}

.label-row {
  display: flex;
  justify-content: space-between;
}

output {
  color: #92ded7;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

input[type="number"],
select {
  width: 100%;
  min-height: 2.35rem;
  padding: 0 0.6rem;
  border: 1px solid #494550;
  border-radius: 0.35rem;
  outline: none;
  background: #0f0e13;
  color: #fff;
}

input[type="number"]:focus,
select:focus,
button:focus-visible {
  border-color: #92ded7;
  box-shadow: 0 0 0 2px rgba(146, 222, 215, 0.18);
}

input[aria-invalid="true"] { border-color: #ff8174; }

.input-warning {
  margin: 0;
  color: #d69b55;
  font-size: 0.68rem;
  line-height: 1.35;
}

input[type="range"] {
  width: 100%;
  accent-color: #92ded7;
}

button {
  min-height: 2.35rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #4a4652;
  border-radius: 0.35rem;
  background: #25222c;
  color: #f4f2f7;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #777180;
  background: #2d2935;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button.primary {
  border-color: #92ded7;
  background: #92ded7;
  color: #0a1616;
  font-weight: 750;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 0.5rem;
}

.display-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.canvas-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #34313b;
  border-radius: 0.55rem;
  background: #202020;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: crosshair;
}

.view-metadata {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  max-width: calc(100% - 1.1rem);
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0.3rem;
  background: rgba(10, 10, 14, 0.76);
  color: #dedbe3;
  font: 0.68rem/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
  pointer-events: none;
}

.selection {
  position: absolute;
  display: none;
  pointer-events: none;
  border: 1.5px solid #66b3ff;
  background: rgba(64, 160, 255, 0.22);
}

.selection.is-visible { display: block; }

.status {
  flex: 0 0 4.7rem;
  height: 4.7rem;
  margin: 0;
  padding: 0.55rem 0.2rem 0;
  overflow: auto;
  color: #aaa5b1;
  font: 0.72rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 760px) {
  html,
  body { overflow: auto; }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .app-header p { display: none; }

  .workspace {
    display: flex;
    flex-direction: column;
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: none;
    overflow: visible;
  }

  .controls > .primary,
  .controls > .button-row {
    align-self: end;
  }

  .display-column { min-height: 65vh; }
  .canvas-shell { min-height: 55vh; }
}

@media (max-width: 470px) {
  .controls { grid-template-columns: 1fr; }
  .display-column { min-height: 60vh; }
}
