/* ============================================================
   RocketHub — minimalist aerospace theme
   ============================================================ */
:root {
  --ink:        #0e1116;
  --ink-soft:   #404a57;
  --ink-faint:  #8a93a0;
  --line:       #e6e9ee;
  --surface:    #ffffff;
  --bg:         #ffffff;
  --hand:       'Caveat', 'Segoe Script', cursive;
  --accent:     #2b5cff;
  --accent-ink: #1d44cc;
  --danger:     #e5484d;
  --radius:     14px;
  --radius-sm:  9px;
  --shadow:     0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-sm:  0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg:  0 12px 40px rgba(16, 24, 40, .18);
}

* { box-sizing: border-box; }
/* The HTML `hidden` attribute must always win, even over .btn's display. */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  height: 60px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.brand__mark { color: var(--ink); width: 1.25em; height: 1.25em; display: inline-block; vertical-align: -0.22em; }
.brand__name { letter-spacing: -.02em; }
.topbar__nav { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); font-weight: 500; }
.topbar__sep { color: var(--line); }
.topbar__crumb--active { color: var(--ink); }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.save-state { font-size: 12.5px; color: var(--ink-faint); font-weight: 500; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--ink-soft);
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px;
}

/* Setups list */
.setups-list, .versions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.setups-list__empty { color: var(--ink-faint); font-size: 13px; padding: 6px 2px; }
.setup-row {
  display: flex; align-items: center; gap: 12px; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  transition: border-color .12s, background .12s;
}
.setup-row:hover { border-color: var(--accent); background: var(--bg); }
.setup-row__thumb { flex: none; width: 64px; height: 48px; border-radius: 8px; object-fit: cover; background: #0e1116; }
.setup-row__thumb--empty { display: grid; place-items: center; color: var(--ink-faint); font-size: 18px; }
.setup-row__body { min-width: 0; }
.setup-row__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-row__meta { color: var(--ink-faint); font-size: 12px; }
.setup-row__del {
  margin-left: auto; border: none; background: transparent; color: var(--ink-faint);
  cursor: pointer; width: 30px; height: 30px; border-radius: 8px; font-size: 14px;
}
.setup-row__del:hover { background: #fdecec; color: var(--danger); }

/* Versions list */
.versions-hint { color: var(--ink-faint); font-size: 12.5px; margin: 0 0 12px; }
.version-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.version-row:hover { border-color: var(--accent); background: var(--bg); }
.version-row__no { font-weight: 700; }
.version-row__date { margin-left: auto; color: var(--ink-faint); font-size: 12px; }

/* Category picker (item modal) */
.cat-picker { display: flex; gap: 8px; }
.cat-picker select { flex: 1; cursor: pointer; }
.cat-new { display: flex; gap: 8px; margin-top: 8px; }
.cat-new input { flex: 1; }

/* Profile: avatar + chips */
.profile-avatar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.profile-avatar__img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--line); background: var(--bg);
}
.profile-avatar__img--empty { display: grid; place-items: center; font-size: 26px; color: var(--ink-faint); }
.profile-avatar__hint { margin: 5px 0 0; font-size: 12px; color: var(--ink-faint); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #eef2ff; color: var(--accent-ink);
  font-size: 12.5px; font-weight: 600;
  padding: 4px 6px 4px 11px; border-radius: 999px;
}
.chip__x { border: none; background: none; cursor: pointer; color: var(--accent-ink); font-size: 13px; line-height: 1; padding: 0 2px; }
.chip__x:hover { color: var(--danger); }

.user-chip { cursor: pointer; }
.user-chip:hover { border-color: var(--ink-faint); }

.google-btn { display: inline-flex; align-items: center; }
.google-btn[hidden] { display: none; }

/* Login gate */
.auth-gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.auth-gate[hidden] { display: none; }
.auth-gate__card {
  text-align: center; max-width: 400px; width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; box-shadow: var(--shadow); padding: 40px 32px;
}
.auth-gate__brand { font-size: 26px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; justify-content: center; gap: 10px; }
.auth-gate__brand .brand__mark { color: var(--ink); width: 1.15em; height: 1.15em; }
.auth-gate__tag { color: var(--ink-soft); margin: 10px 0 0; }
.auth-gate__cta { color: var(--ink-faint); font-size: 13px; margin: 22px 0 18px; }
.auth-gate__google { display: flex; justify-content: center; min-height: 44px; }
.auth-gate__card .btn { margin-top: 10px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 15px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s, border-color .15s, opacity .15s, transform .05s;
  color: var(--ink); background: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--accent-ink); }
.btn--ghost { background: var(--surface); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink-faint); }
.btn--block { width: 100%; justify-content: center; }
.btn--danger-ghost { color: var(--danger); padding: 6px 10px; }
.btn--danger-ghost:hover { background: #fdecec; }
.btn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* ---------- Editor layout ---------- */
.editor { max-width: 1180px; margin: 0 auto; padding: 24px; }

/* ---------- Stage ---------- */
.stage__head { margin-bottom: 14px; }
.title-input {
  font: inherit; font-size: 22px; font-weight: 700; letter-spacing: -.02em;
  border: none; background: transparent; width: 100%; padding: 4px 0; color: var(--ink);
}
.title-input:focus { outline: none; }
.title-input::placeholder { color: var(--ink-faint); }
.stage__hint { margin: 2px 0 0; color: var(--ink-faint); }

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  background: var(--surface); min-height: 360px;
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--accent); background: #f3f6ff; }
.dropzone__inner { text-align: center; color: var(--ink-soft); }
.dropzone__icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  display: grid; place-items: center; font-size: 26px; color: var(--accent);
  background: #eef2ff; border-radius: 50%;
}
.dropzone__title { font-weight: 600; margin: 0 0 4px; color: var(--ink); }
.dropzone__sub { margin: 0; color: var(--ink-faint); font-size: 13px; }

/* ---------- Tagged area: image + name labels + legend ---------- */
.tagged {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.canvas {
  position: relative; border-radius: 10px; overflow: hidden;
  background: #0e1116; line-height: 0; align-self: start;
}
.canvas { cursor: crosshair; }   /* clicking empty image area adds an item */
.canvas__img { width: 100%; height: auto; display: block; max-height: 66vh; object-fit: contain; }
.label-layer { position: absolute; inset: 0; }
.label-layer--hidden { display: none; }

/* Connector line: from the fixed anchor point to its (movable) label */
.connectors { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
.connector { stroke: #ffffff; stroke-width: 1.6; opacity: .85; }
.connector.is-active { stroke: var(--accent); opacity: 1; }

/* Fixed anchor dot where the user clicked */
.anchor {
  position: absolute; transform: translate(-50%, -50%);
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 1px 5px rgba(16,24,40,.45);
  z-index: 2; cursor: pointer;
}
.anchor.is-active { background: var(--ink); }

/* On-image movable name label — plain white text, no box */
.label {
  position: absolute;
  transform: translate(-50%, -50%);
  max-width: 240px;
  padding: 2px 6px;            /* keeps a comfortable click/drag target */
  background: none; border: none; box-shadow: none;
  font-family: var(--label-font, var(--hand));
  font-size: var(--label-size, 22px); font-weight: 600; line-height: 1.2;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0,0,0,.65), 0 0 2px rgba(0,0,0,.4);
  cursor: grab; z-index: 3;
  transition: color .12s;
  white-space: nowrap;
}
.label.is-active { color: #9cc0ff; }
.label.is-dragging { cursor: grabbing; z-index: 6; }
.label__text { overflow: hidden; text-overflow: ellipsis; display: block; }
.label__text--empty { opacity: .75; font-weight: 500; }

/* Font picker in the toolbar */
.font-picker { display: inline-flex; align-items: center; gap: 7px; }
.font-picker__label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.font-select {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); cursor: pointer;
}
.font-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,92,255,.12); }

/* Font size stepper */
.size-stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper-btn {
  width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 16px; font-weight: 700;
  cursor: pointer; display: grid; place-items: center; line-height: 1;
}
.stepper-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.stepper-btn:disabled { opacity: .4; cursor: not-allowed; }
.stepper-readout { min-width: 24px; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink-soft); }

/* Legend list beside the image */
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; align-self: start; z-index: 2; }
.legend__empty { color: var(--ink-faint); font-size: 13px; padding: 4px 2px; }
.legend-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.legend-row:hover, .legend-row.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,92,255,.1); }
.legend-row__bullet {
  flex: none; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 3px rgba(43,92,255,.15);
}
.legend-row__name { font-family: var(--hand); font-size: 18px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row__name--empty { color: var(--ink-faint); font-style: italic; }
.legend-row__meta { margin-left: auto; color: var(--ink-faint); font-size: 12px; white-space: nowrap; }

@media (max-width: 860px) {
  .tagged { grid-template-columns: 1fr; gap: 16px; }
}

/* Toolbar */
.stage__toolbar { display: flex; align-items: center; gap: 12px; margin-top: 14px; }
.stage__help { color: var(--accent-ink); font-weight: 500; font-size: 13px; }

/* Thumbnails */
.thumbs { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.thumb {
  position: relative; width: 84px; height: 64px;
  border-radius: 9px; overflow: hidden; border: 2px solid transparent;
  cursor: pointer; background: #0e1116;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.is-active { border-color: var(--accent); }
.thumb__count {
  position: absolute; right: 4px; bottom: 4px;
  background: rgba(14,17,22,.8); color: #fff; font-size: 11px; font-weight: 600;
  padding: 1px 6px; border-radius: 20px;
}
.thumb-add {
  width: 84px; height: 64px;
  border: 1.5px dashed var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink-faint);
  font-size: 22px; cursor: pointer; display: grid; place-items: center;
}
.thumb-add:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Fields ---------- */
.field { display: block; margin-bottom: 12px; }
.field__label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field__input {
  width: 100%; font: inherit; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(43,92,255,.12); }
.field__input--area { resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.detail-grid:empty { display: none; }
.detail-thumb { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #0e1116; }
.detail-thumb img { width: 100%; height: 100%; object-fit: cover; }
.detail-thumb__x {
  position: absolute; top: 3px; right: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(14,17,22,.75); color: #fff;
  border: none; cursor: pointer; font-size: 12px; line-height: 1;
  display: grid; place-items: center;
}

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(14,17,22,.45); backdrop-filter: blur(2px); animation: fade .15s ease; }
.modal__card {
  position: relative; width: min(520px, 100%);
  max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: pop .16s cubic-bezier(.2,.8,.3,1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.modal__title { font-size: 15px; font-weight: 600; margin: 0; }
.dot-chip {
  background: var(--accent); color: #fff;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; display: inline-grid; place-items: center; vertical-align: middle;
}
.modal__head-actions { display: flex; align-items: center; gap: 6px; }
.modal__x {
  border: none; background: transparent; cursor: pointer;
  width: 30px; height: 30px; border-radius: 8px; color: var(--ink-faint); font-size: 15px;
}
.modal__x:hover { background: var(--bg); color: var(--ink); }
.modal__body { padding: 18px; overflow-y: auto; }
.modal__foot { padding: 14px 18px; border-top: 1px solid var(--line); }
