@font-face {
  font-family: "Poppins";
  font-weight: 400;
  src: url("/fonts/Poppins-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins";
  font-weight: 500;
  src: url("/fonts/Poppins-Medium.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins";
  font-weight: 600;
  src: url("/fonts/Poppins-SemiBold.ttf") format("truetype");
}
@font-face {
  font-family: "Poppins";
  font-weight: 800;
  src: url("/fonts/Poppins-ExtraBold.ttf") format("truetype");
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 400;
  src: url("/fonts/BeVietnamPro-Regular.ttf") format("truetype");
}
@font-face {
  font-family: "Be Vietnam Pro";
  font-weight: 600;
  src: url("/fonts/BeVietnamPro-SemiBold.ttf") format("truetype");
}

:root {
  --bg: #0c0c0c;
  --rail: #111111;
  --panel: #171717;
  --line: #2b2b2b;
  --ink: #f3f3f3;
  --muted: #8d8d8d;
  --red: #d02915;
  --red-press: #a81f10;
  --paper: #e8e8e8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Poppins", "Be Vietnam Pro", sans-serif;
  overflow: hidden;
}

.app {
  height: 100%;
  max-height: 100dvh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  overflow: hidden;
}

.top {
  grid-column: 1 / -1;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #0a0a0a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand span:last-child {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.mark {
  width: 22px;
  height: 22px;
  background: var(--red);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 62% 100%, 0 100%);
}

.size {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding: 20px 18px 28px;
  overflow: auto;
  min-height: 0;
}

.lookup label,
.block h2 {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.row { display: flex; gap: 8px; }

#query, #batch {
  width: 100%;
  background: #0c0c0c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
  font: 500 13px/1.4 "Poppins", "Be Vietnam Pro", sans-serif;
}

#query:focus, #batch:focus {
  outline: none;
  border-color: var(--red);
}

.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #1c1c1c;
  color: var(--ink);
  font: 600 13px/1 "Poppins", "Be Vietnam Pro", sans-serif;
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { border-color: #4a4a4a; }
.btn:active { transform: scale(0.98); }

.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.btn.primary:hover { background: var(--red-press); border-color: var(--red-press); }

.btn.ghost {
  background: transparent;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 16px 0 22px;
}

.chips button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font: 500 12px/1 "Poppins", "Be Vietnam Pro", sans-serif;
  padding: 7px 10px;
  border-radius: 2px;
  cursor: pointer;
}

.chips button:hover { border-color: var(--red); color: #fff; }

.block { margin-top: 22px; }

.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list li { color: var(--muted); font-size: 13px; }

.list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--ink);
  padding: 9px 8px;
  border-radius: 2px;
  cursor: pointer;
  font: 500 13px/1.35 "Poppins", "Be Vietnam Pro", sans-serif;
}

.list button:hover { background: #1c1c1c; }

.list button small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

#batch { resize: vertical; min-height: 96px; margin-bottom: 8px; }

.main {
  display: grid;
  grid-template-rows: 1fr;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.main.has-meta {
  grid-template-rows: minmax(0, 1fr) 8px minmax(0, 36vh);
}

.main.has-meta.is-split {
  grid-template-rows: var(--stage-h, 58%) 8px minmax(0, 1fr);
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    #101010;
  background-size: 24px 24px;
}

.canvas-bar {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgb(18 18 18 / 0.92);
  border: 1px solid var(--line);
}

.canvas-bar button {
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-radius: 5px;
  cursor: pointer;
}

.canvas-bar button:hover { background: #2a2a2a; }

#zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.canvas-space {
  flex: 1;
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.canvas-space.hidden { display: none; }

.canvas-space.panning { cursor: grabbing; }

.canvas-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.split {
  background: var(--line);
  cursor: ns-resize;
}

.split[hidden] { display: none; }

.split:hover,
.split.dragging { background: #4a4a4a; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  z-index: 1;
}

.empty[hidden] { display: none; }

.empty p:first-child {
  color: var(--ink);
  font-weight: 600;
  margin-bottom: 6px;
}

.sheet-wrap {
  width: 397px;
  height: 560px;
  background: #fff;
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.45);
  overflow: hidden;
  pointer-events: none;
}

#preview {
  display: block;
  border: 0;
  background: #fff;
  width: 397px;
  height: 560px;
}

.meta {
  border-top: 0;
  background: var(--panel);
  padding: 18px 22px 22px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.meta-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.meta h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.25;
  max-width: 62ch;
}

.meta-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 14px;
}

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

.look-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 12px 0 2px;
}

.layout-pick {
  display: flex;
  gap: 6px;
  margin: 0;
}

.layout-pick button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.layout-pick button.active {
  background: #fff;
  color: #111;
  border-color: #fff;
}

.editor {
  margin-top: 14px;
  display: grid;
  gap: 14px;
}

.editor fieldset {
  border: 1px solid var(--line);
  padding: 12px;
  min-width: 0;
}

.editor legend {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
}

.editor label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

.editor input {
  width: 100%;
  margin-top: 4px;
  background: #0c0c0c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px 10px;
  font: 500 13px/1.35 "Poppins", "Be Vietnam Pro", sans-serif;
}

.editor input:focus,
.editor select:focus {
  outline: none;
  border-color: var(--red);
}

.editor select {
  width: 100%;
  margin-top: 4px;
  background: #0c0c0c;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px 8px;
  font: 500 12px/1.3 "Poppins", "Be Vietnam Pro", sans-serif;
}

.type-grid {
  display: grid;
  gap: 6px;
}

.type-head,
.type-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.type-head {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
}

.type-row span {
  font-size: 12px;
  color: var(--ink);
}

.type-row select { margin-top: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pair-list { display: grid; gap: 8px; }

.pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  align-items: end;
}

.pair-row .rm {
  min-height: 36px;
  padding: 0;
}

.status-err { color: #ff8a7a; }
#edit-status { color: #b7b7b7; }

@media (max-width: 980px) {
  html, body, .app {
    height: auto;
    max-height: none;
    overflow: auto;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 64px auto auto;
  }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
  }
  .main, .main.has-meta, .main.has-meta.is-split {
    grid-template-rows: minmax(280px, 50vh) 8px auto;
  }
  .meta { overflow: visible; }
  .meta-head { display: block; }
  .actions { margin-top: 12px; }
  .grid-2, .pair-row { grid-template-columns: 1fr; }
}
