:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #151920;
  --panel-2: #101319;
  --line: #27303a;
  --muted: #8f99a6;
  --text: #f4f7fb;
  --accent: #f0b84f;
  --accent-2: #46c2a5;
  --danger: #f26d6d;
  --blue: #6da8ff;
  --marker: #f04d5e;
  --marker-set: #2ed573;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
.file-button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #202632;
  color: var(--text);
  padding: 0 11px;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: #3c4755;
  background: #27303d;
}

.app {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 340px;
  width: 100vw;
  height: 100vh;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border-color: var(--line);
  overflow-y: auto;
}

.left-panel {
  border-right: 1px solid var(--line);
}

.right-panel {
  border-left: 1px solid var(--line);
  padding: 14px;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.brand h1 {
  margin: 2px 0 0;
  font-size: 21px;
  letter-spacing: 0;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.counter {
  min-width: 54px;
  padding: 4px 8px;
  border: 1px solid rgba(46, 213, 115, .35);
  border-radius: 7px;
  background: rgba(46, 213, 115, .1);
  color: #9df2bf;
  text-align: center;
  font-weight: 700;
}

.control-group {
  display: grid;
  gap: 7px;
  padding: 12px 14px 0;
}

.right-panel .control-group {
  padding: 12px 0 0;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0c1016;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 86px;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(109, 168, 255, .12);
}

.photo-list {
  display: grid;
  gap: 8px;
  padding: 12px 10px 16px;
}

.photo-item {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 7px;
  color: var(--text);
  text-align: left;
}

.photo-item.active {
  border-color: var(--accent);
  background: #252111;
}

.photo-item.bound {
  border-color: rgba(46, 213, 115, .42);
}

.photo-item img {
  width: 58px;
  height: 58px;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}

.photo-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.photo-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: #030405;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #11161d;
}

.toolbar strong {
  display: block;
  margin-top: 2px;
  font-size: 15px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.plan-shell {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px),
    #050607;
  background-size: 42px 42px;
  cursor: crosshair;
}

.plan-shell.grabbing {
  cursor: grabbing;
}

.plan-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}

#planImage {
  display: block;
  width: 913px;
  height: 1231px;
  user-select: none;
  -webkit-user-drag: none;
  background: #fff;
}

.marker-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: 28px;
  height: 34px;
  border: 0;
  background: transparent;
  padding: 0;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .5));
}

.marker::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 0;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50% 50% 50% 0;
  background: var(--marker-set);
  transform: rotate(-45deg);
}

.marker::after {
  content: attr(data-index);
  position: absolute;
  left: 50%;
  top: -19px;
  min-width: 20px;
  transform: translateX(-50%);
  border-radius: 5px;
  background: rgba(5, 6, 7, .9);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

.marker.active::before {
  background: var(--accent);
}

.selected-card {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  overflow: hidden;
}

.selected-card img {
  display: block;
  width: 100%;
  max-height: 270px;
  object-fit: contain;
  background: #000;
}

.selected-info {
  padding: 11px;
}

.selected-info h2 {
  margin: 0 0 6px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.selected-info p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  min-height: 210px;
  place-items: center;
  color: var(--muted);
}

.binding-editor {
  margin-top: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.danger {
  border-color: rgba(242, 109, 109, .45);
  color: #ffd2d2;
}

.danger:hover {
  background: #371b20;
}

.map-summary {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

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

.summary-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  padding: 9px;
  color: #c9d2de;
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 50;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 17, 23, .95);
  color: var(--text);
  padding: 10px 14px;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    max-height: none;
    overflow: visible;
  }

  .workspace {
    height: 70vh;
    min-height: 520px;
  }

  .left-panel,
  .right-panel {
    border: 0;
  }
}
