/*
 * Graphite tool chrome, one chromatic accent.
 *
 * The canvas holds arbitrary user imagery, so the interface deliberately keeps
 * no colour of its own — every hue on the page belongs to the user's content.
 * The single accent, a print-registration magenta, is reserved for one job:
 * marking what is selected, targeted, or focused. If it is pink, it is live.
 */

:root {
  --ink-000: #08090a;
  --ink-050: #0d0f11;
  --ink-100: #131619;
  --ink-150: #191d21;
  --ink-200: #1f2429;
  --line: #23292e;
  --line-hi: #333b42;

  --chalk-dim: #6b757d;
  --chalk: #a7b0b7;
  --chalk-hi: #e9edf0;

  --mark: #ff3d8b;
  --mark-soft: rgba(255, 61, 139, 0.13);

  /* Bahnschrift on Windows, DIN Alternate / Avenir Next Condensed on macOS:
     a condensed technical grotesk, the register of drafting and instrument
     labels rather than of marketing. */
  --font-display: "Bahnschrift", "DIN Alternate", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-ui: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-data: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, Menlo, monospace;

  --rail: 300px;
  --tap: 34px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  /* An explicit row is what pins the layout to the viewport. Left implicit, the
     row is `auto` and sizes to its content, so the stage's own `1fr` frame row
     resolves against the canvas instead of the window — and pushes the status
     bar off the bottom of the screen. */
  grid-template-rows: minmax(0, 1fr);
  background: var(--ink-000);
  color: var(--chalk);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--mark);
  outline-offset: 2px;
}

/* ── Rail ─────────────────────────────────────────────────────────────── */

.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 20px 18px 0;
  background: var(--ink-050);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.mark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 20px;
}

.mark__name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--chalk-hi);
}

.panel {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.panel--grow {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding-bottom: 0;
}

.panel__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

.panel__count {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0;
  color: var(--chalk-dim);
}

/* ── Drop zone ────────────────────────────────────────────────────────── */

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 30px 12px;
  background: var(--ink-100);
  border: 1px dashed var(--line-hi);
  border-radius: 3px;
  color: var(--chalk);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.14s var(--ease), background 0.14s var(--ease), color 0.14s var(--ease);
}

.drop:hover { border-color: var(--chalk-dim); }

.drop.is-over {
  border-color: var(--mark);
  background: var(--mark-soft);
  color: var(--chalk-hi);
}

.drop__cue { font-size: 13px; }

.drop__meta {
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--chalk-dim);
}

.note {
  margin: 8px 0 0;
  min-height: 1em;
  font-size: 11.5px;
  color: var(--chalk-dim);
}

.note.is-error { color: var(--mark); }

/* ── Fields ───────────────────────────────────────────────────────────── */

.field {
  width: 100%;
  height: var(--tap);
  padding: 0 10px;
  background: var(--ink-100);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  color: var(--chalk-hi);
  font: inherit;
  transition: border-color 0.14s var(--ease);
}

.field::placeholder { color: var(--chalk-dim); }
.field:hover { border-color: var(--chalk-dim); }
.field:focus { border-color: var(--mark); outline: none; }

.row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.row__label {
  font-size: 11.5px;
  color: var(--chalk-dim);
}

.row__value {
  min-width: 58px;
  font-family: var(--font-data);
  font-size: 11px;
  text-align: right;
  color: var(--chalk);
}

.slider {
  width: 100%;
  height: 18px;
  margin: 0;
  background: none;
  appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--line-hi);
}

.slider::-webkit-slider-thumb {
  appearance: none;
  width: 3px;
  height: 14px;
  margin-top: -6.5px;
  background: var(--chalk-hi);
  border: none;
  border-radius: 0;
}

.slider:hover::-webkit-slider-thumb,
.slider:focus::-webkit-slider-thumb { background: var(--mark); }

.slider::-moz-range-track { height: 1px; background: var(--line-hi); }
.slider::-moz-range-thumb {
  width: 3px; height: 14px; background: var(--chalk-hi);
  border: none; border-radius: 0;
}
.slider:hover::-moz-range-thumb { background: var(--mark); }

.swatch {
  width: 100%;
  height: 18px;
  padding: 0;
  background: none;
  border: 1px solid var(--line-hi);
  border-radius: 2px;
  cursor: pointer;
}

.swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.swatch::-webkit-color-swatch { border: none; border-radius: 1px; }
.swatch::-moz-color-swatch { border: none; border-radius: 1px; }

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  height: var(--tap);
  padding: 0 14px;
  background: var(--ink-200);
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  color: var(--chalk-hi);
  font-family: var(--font-ui);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease);
}

.btn:hover:not(:disabled) { border-color: var(--chalk-dim); background: #262c32; }
.btn:active:not(:disabled) { transform: translateY(0.5px); }

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--primary {
  width: 100%;
  margin-top: 12px;
  background: var(--mark);
  border-color: var(--mark);
  color: #14060c;
  font-weight: 600;
}

.btn--primary:hover:not(:disabled) { background: #ff5c9d; border-color: #ff5c9d; }

/* A dimmed magenta fill reads as "pressed" rather than "unavailable", so the
   button drops back to an outline until there is text to add. */
.btn--primary:disabled {
  background: none;
  border-color: var(--line-hi);
  color: var(--chalk-dim);
  opacity: 1;
}

.btn--ghost {
  height: 28px;
  padding: 0 10px;
  background: none;
  border-color: transparent;
  color: var(--chalk);
  font-size: 12px;
}

.btn--ghost:hover:not(:disabled) { background: var(--ink-150); border-color: var(--line-hi); color: var(--chalk-hi); }
.btn--danger:hover:not(:disabled) { color: var(--mark); border-color: var(--mark); background: var(--mark-soft); }

/* ── Asset library ────────────────────────────────────────────────────── */

.empty {
  margin: 0;
  font-size: 11.5px;
  color: var(--chalk-dim);
}

.assets {
  display: flex;
    list-style: none;
    padding: 6px;
    flex-wrap: wrap;
    gap: 8px;
    overflow: scroll;
}

.assets::-webkit-scrollbar{
  display: none;
}

.assets:empty { display: none; }

.asset {
  position: relative;
  aspect-ratio: 1;
  background: var(--ink-100);
  border: 1px solid var(--line);
  width: calc(50% - 4px);
  border-radius: 3px;
  cursor: grab;
  transition: border-color 0.14s var(--ease), transform 0.14s var(--ease);
}

.asset:hover { border-color: var(--chalk-dim); transform: translateY(-1px); }
.asset:active { cursor: grabbing; }
.asset.is-dragging { opacity: 0.4; }

.asset__img {
  width: 100%;
  height: 100%;
  padding: 6px;
  object-fit: contain;
  pointer-events: none;
}

.asset__remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  background: var(--ink-200);
  border: 1px solid var(--line-hi);
  border-radius: 50%;
  color: var(--chalk);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.14s var(--ease), color 0.14s var(--ease), border-color 0.14s var(--ease);
}

.asset:hover .asset__remove,
.asset__remove:focus-visible { opacity: 1; }
.asset__remove:hover { color: var(--mark); border-color: var(--mark); }

/* ── Stage ────────────────────────────────────────────────────────────── */

.stage {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.stage__frame {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 28px;
}

canvas {
  display: block;
  /* The board's edge is a box-shadow ring rather than a border because a border
     would sit inside the element box and desynchronise the CSS size from the
     bitmap size — which is exactly the factor pointer coordinates divide by.
     The ambient shadow makes the artboard read as a lit surface in a dark room
     instead of a hole in the page. */
  box-shadow: 0 0 0 1px var(--line-hi), 0 24px 70px -20px rgba(0, 0, 0, 0.9);
  touch-action: none;
  cursor: default;
  transition: box-shadow 0.14s var(--ease);
}

canvas.is-target {
  box-shadow: 0 0 0 1px var(--mark), 0 24px 70px -20px rgba(0, 0, 0, 0.9);
}
canvas:focus-visible { outline-offset: 4px; }

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  height: 46px;
  background: var(--ink-050);
  border-top: 1px solid var(--line);
}

.bar__status {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: var(--font-data);
  font-size: 11px;
  color: var(--chalk-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bar__group[hidden] { display: none; }

.bar__label {
  margin-right: 4px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--chalk-dim);
}

/* ── Narrow viewports ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
  /* Below this width the rail stacks on top and there is no longer a viewport's
     worth of height to divide up, so the page scrolls and every row is sized by
     its content instead. */
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 4px;
    overflow: visible;
  }

  .panel--grow { flex: none; }
  .assets { grid-template-columns: repeat(6, 1fr); padding-bottom: 12px; }

  .stage { grid-template-rows: auto auto; }

  /* The board takes its height from its width here, so it stays square rather
     than being squeezed into whatever vertical space the rail left over. */
  .stage__frame {
    aspect-ratio: 1;
    padding: 16px;
  }

  .bar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .bar__status { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
