:root {
  --bg: #0b111e;
  --surface: #121b2e;
  --surface-2: #18253d;
  --border: #263859;
  --border-strong: #37507d;
  --text: #eef2ff;
  --muted: #98a7c7;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --gold-1: #f59e0b;
  --gold-2: #fbbf24;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.08), transparent 40%), var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.back-link {
  display: inline-block;
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.back-link:hover {
  color: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: 1.28rem;
  letter-spacing: -0.015em;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.board-switcher {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px;
}

select,
input[type="text"],
textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
}

.board-switcher select {
  border: 0;
  padding: 5px 6px;
  font-weight: 600;
  max-width: 220px;
  cursor: pointer;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(56, 189, 248, 0.45);
  outline-offset: 1px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #031524;
  border-color: var(--accent);
}

.btn-primary:hover {
  filter: brightness(1.06);
  color: #031524;
}

.btn-pro {
  background: linear-gradient(135deg, var(--gold-1), var(--gold-2));
  color: #1c1002;
  border: 1px solid #fcd34d;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.28);
}

.btn-pro:hover {
  filter: brightness(1.06);
  border-color: #fde68a;
  color: #1c1002;
}

.btn-good {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(34, 197, 94, 0.55);
  color: #86efac;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-sm {
  padding: 5px 9px;
  font-size: 0.78rem;
}

.action-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.board-name-input {
  min-width: 240px;
  font-weight: 600;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 365px;
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.canvas-panel {
  padding: 12px;
}

.canvas-hint-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.79rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.canvas-hint-bar strong {
  color: var(--text);
}

.stage-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #070c17;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.stage-wrap.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

.stage-wrap img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.pins-layer {
  position: absolute;
  inset: 0;
}

.pin-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  color: #07101c;
  font-size: 0.82rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  cursor: grab;
  padding: 0;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.52);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: none;
}

.pin-marker:hover {
  transform: translate(-50%, -50%) scale(1.1);
}

.pin-marker.selected {
  transform: translate(-50%, -50%) scale(1.18);
  outline: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.35), 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 5;
}

.pin-marker.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.22);
  z-index: 10;
}

.pin-marker.priority-Bug {
  background: var(--bad);
}

.pin-marker.priority-Copy {
  background: var(--accent);
}

.pin-marker.priority-Visual {
  background: var(--warn);
}

.pin-marker.status-Approved {
  background: var(--good);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 30, 0.86);
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 20;
  pointer-events: none;
}

.stage-wrap.drag-over .drop-overlay {
  display: flex;
}

.drop-overlay-box {
  border: 2px dashed var(--accent);
  border-radius: 12px;
  padding: 24px 32px;
  color: var(--text);
  font-weight: 700;
}

.prompt-preview-box {
  margin-top: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.prompt-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.prompt-preview-head strong {
  font-size: 0.82rem;
}

.prompt-preview-box pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  color: var(--muted);
  max-height: 170px;
  overflow-y: auto;
}

.sidebar-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 0.98rem;
}

.filter-pills {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.filter-pill {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-pill.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent);
  color: var(--text);
}

.pin-editor {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

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

.pin-coords {
  font-size: 0.74rem;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.field {
  margin-bottom: 9px;
}

.field label {
  display: block;
  font-size: 0.77rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input,
.field textarea {
  width: 100%;
}

.priority-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.prio-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.prio-btn.active.prio-Bug {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--bad);
  color: #fecaca;
}

.prio-btn.active.prio-Copy {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--accent);
  color: #bae6fd;
}

.prio-btn.active.prio-Visual {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--warn);
  color: #fde68a;
}

.editor-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.editor-actions .btn {
  flex: 1;
}

.pin-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 360px;
  overflow-y: auto;
}

.pin-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 9px 10px;
  cursor: pointer;
  transition: border-color 0.12s ease;
}

.pin-card:hover {
  border-color: var(--border-strong);
}

.pin-card.selected {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.pin-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.pin-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.84rem;
  font-weight: 700;
  min-width: 0;
}

.pin-badge-mini {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #07101c;
  flex-shrink: 0;
}

.pin-badge-mini.priority-Bug {
  background: var(--bad);
}

.pin-badge-mini.priority-Copy {
  background: var(--accent);
}

.pin-badge-mini.priority-Visual {
  background: var(--warn);
}

.pin-badge-mini.status-Approved {
  background: var(--good);
}

.pin-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.pin-tag.approved {
  background: rgba(34, 197, 94, 0.16);
  color: #86efac;
}

.pin-card-note {
  margin: 5px 0 0;
  font-size: 0.77rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 16px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 9px;
}

.upsell-bar {
  margin-top: 14px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), var(--surface));
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.upsell-bar p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer {
  margin-top: 18px;
  font-size: 0.76rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 18, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 20px;
  max-height: 92vh;
  overflow-y: auto;
}

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

.modal-head h3 {
  margin: 0;
  font-size: 1.08rem;
}

.plan-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.plan-featured {
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08), var(--bg));
}

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

.plan-head h4 {
  margin: 0;
  font-size: 0.95rem;
}

.plan-desc {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.badge-pro {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  white-space: nowrap;
}

.pay-methods-note {
  margin: 8px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.unlock-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.unlock-row input {
  flex: 1;
}

.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  max-width: 380px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.84rem;
  display: none;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.toast.show {
  display: block;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .wrap {
    padding: 10px;
  }
  .topbar {
    padding: 12px;
  }
  .board-name-input {
    min-width: 0;
    width: 100%;
  }
  .board-switcher {
    width: 100%;
  }
  .board-switcher select {
    flex: 1;
    max-width: none;
  }
  .unlock-row {
    flex-direction: column;
  }
}
