/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a1a2e;
  color: #e2e8f0;
  height: 100vh;
  overflow: hidden;
}

/* ════════════════════════════════════════════════
   GATE SCREEN
════════════════════════════════════════════════ */

#gate {
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.gate-card {
  background: #13132a;
  border: 1px solid #2a2a50;
  border-radius: 14px;
  padding: 2rem 2.2rem 2.2rem;
  width: 100%;
  max-width: 430px;
  box-shadow: 0 24px 64px rgba(0,0,0,.7), 0 0 0 1px rgba(232,63,63,.12);
}

.gate-logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: #F28C7D;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.gate-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 0.2rem;
  letter-spacing: -0.02em;
}

.gate-sub {
  font-size: 0.88rem;
  color: #E83F3F;
  font-weight: 500;
  min-height: 1.2em;
  margin-bottom: 1.4rem;
}

/* Form fields */
.field-group {
  margin-bottom: 1.1rem;
}

.field-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #7c83a3;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.4rem;
}

.field-group input[type="text"],
.field-group input[type="email"],
.field-group input[type="password"],
.field-group input[type="url"] {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: #0e0e22;
  border: 1px solid #2a2a50;
  border-radius: 7px;
  color: #e2e8f0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  font-family: inherit;
}
.field-group input:focus {
  border-color: #E83F3F;
  box-shadow: 0 0 0 3px rgba(232,63,63,.15);
}
.field-group input::placeholder { color: #3d3d6b; }

.field-hint {
  font-size: 0.73rem;
  color: #3d3d6b;
  margin-top: 0.3rem;
}

.req      { color: #f87171; margin-left: 1px; }
.optional { font-weight: 400; color: #3d3d6b; text-transform: none; letter-spacing: 0; }

/* Role selector */
.role-options {
  display: flex;
  gap: 0.6rem;
}

.role-opt {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: #0e0e22;
  border: 1px solid #2a2a50;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
  color: #64748b;
  font-size: 0.88rem;
  user-select: none;
}
.role-opt input { display: none; }
.role-opt.active {
  border-color: #E83F3F;
  background: #2a1818;
  color: #e2e8f0;
}
.role-icon { font-size: 1rem; }

/* Gate error */
.gate-error {
  color: #f87171;
  font-size: 0.83rem;
  min-height: 1.2em;
  margin-bottom: 0.6rem;
  padding: 0.45rem 0.75rem;
  background: rgba(248,113,113,.08);
  border-radius: 6px;
  display: none;
}
.gate-error.visible { display: block; }

/* Primary button */
.btn-primary {
  width: 100%;
  padding: 0.78rem 1rem;
  background: #E83F3F;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-primary:hover:not(:disabled) { background: #c92e2e; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-danger {
  width: 100%;
  margin-top: 0.6rem;
  padding: 0.78rem 1rem;
  background: transparent;
  color: #f87171;
  border: 2px solid #f87171;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.btn-danger:hover:not(:disabled) { background: #f87171; color: #fff; }
.btn-danger:active:not(:disabled) { transform: scale(0.98); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-arrow { font-size: 1.1rem; }

/* ════════════════════════════════════════════════
   APP LAYOUT
════════════════════════════════════════════════ */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Toolbar ─────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  height: 52px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  z-index: 50;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.company-logo {
  height: 26px;
  max-width: 120px;
  object-fit: contain;
  flex-shrink: 0;
  background: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.toolbar-logo { font-size: 1.1rem; flex-shrink: 0; }

.board-topic {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.note-count-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: #888888;
  white-space: nowrap;
  padding: 0.25rem 0.6rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 0.2rem 0.4rem;
}

.zoom-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 700;
  color: #555555;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.zoom-btn:hover { background: #e9eaec; color: #1a1a1a; }
.zoom-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.zoom-level {
  font-size: 0.75rem;
  font-weight: 600;
  color: #555555;
  min-width: 36px;
  text-align: center;
  user-select: none;
}

.color-picker {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 0.3rem 0.6rem;
}

.cp-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--c);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  outline: none;
}
.cp-btn:hover  { transform: scale(1.2); }
.cp-btn.active { border-color: #1a1a1a; transform: scale(1.15); }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-tool {
  padding: 0.38rem 0.75rem;
  background: #f3f4f6;
  color: #555555;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-tool:hover { background: #e9eaec; color: #1a1a1a; }

.btn-add {
  padding: 0.38rem 0.9rem;
  background: #E83F3F;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s;
  font-family: inherit;
}
.btn-add:hover { background: #c92e2e; }

.user-chip {
  padding: 0.3rem 0.65rem;
  background: #fff1f0;
  border: 1px solid #fecaca;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #E83F3F;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-leave {
  padding: 0.35rem 0.65rem;
  background: transparent;
  color: #888888;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
  font-family: inherit;
}
.btn-leave:hover { color: #E83F3F; border-color: #E83F3F; }

/* ── Board & infinite canvas ─────────────────── */
.board {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #f0ece8;
  background-image: radial-gradient(circle, #d9d4cf 1px, transparent 1px);
  background-size: 26px 26px;
  cursor: grab;
}
.board.panning { cursor: grabbing; }

.canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  /* transform: translate(panX, panY) set by JS */
}

/* ════════════════════════════════════════════════
   NOTE CARDS
════════════════════════════════════════════════ */

.note {
  position: absolute;
  width: 230px;
  border-radius: 5px;
  box-shadow: 3px 5px 18px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  user-select: none;
  transition: box-shadow 0.15s;
}
.note:hover   { box-shadow: 4px 7px 24px rgba(0,0,0,.26); }
.note.dragging {
  box-shadow: 8px 12px 32px rgba(0,0,0,.32);
  opacity: 0.93;
}

/* Colour themes */
.note[data-color="yellow"] { background: #fef9c3; }
.note[data-color="pink"]   { background: #ffe4e6; }
.note[data-color="blue"]   { background: #dbeafe; }
.note[data-color="green"]  { background: #dcfce7; }
.note[data-color="mint"]   { background: #ccfbf1; }

/* Note header strip (slightly darker) */
.note[data-color="yellow"] .note-header { background: #fde047; }
.note[data-color="pink"]   .note-header { background: #fda4af; }
.note[data-color="blue"]   .note-header { background: #93c5fd; }
.note[data-color="green"]  .note-header { background: #86efac; }
.note[data-color="mint"]   .note-header { background: #5eead4; }

.note-header {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  border-radius: 5px 5px 0 0;
  border-bottom: 1px solid rgba(0,0,0,.12);
}

.note-drag-handle {
  cursor: grab;
  font-size: 1rem;
  color: rgba(0,0,0,.4);
  flex-shrink: 0;
  line-height: 1;
  padding: 0 2px;
}
.note-drag-handle:active { cursor: grabbing; }

.note-author {
  flex: 1;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(0,0,0,.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-controls {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

/* Vote button */
.btn-vote {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,.2);
  background: rgba(255,255,255,.45);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(0,0,0,.55);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  line-height: 1.4;
}
.btn-vote:hover:not(:disabled):not(.vote-own) {
  background: #E83F3F;
  color: #fff;
  border-color: #E83F3F;
}
.btn-vote.voted {
  background: #E83F3F;
  color: #fff;
  border-color: #E83F3F;
}
.btn-vote.voted:hover {
  background: #c92e2e;
}
.btn-vote.vote-own {
  opacity: 0.35;
  cursor: not-allowed;
}
.vote-count { min-width: 10px; text-align: center; }

/* Delete button */
.btn-delete {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: rgba(0,0,0,.35);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  font-family: inherit;
}
.btn-delete:hover {
  background: rgba(232,63,63,.15);
  color: #E83F3F;
}

/* Note textarea */
.note-body {
  flex: 1;
  min-height: 110px;
  padding: 0.6rem 0.7rem;
  border: none;
  background: transparent;
  resize: none;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #1e1b4b;
  outline: none;
  border-radius: 0 0 5px 5px;
}
.note-body::placeholder { color: rgba(0,0,0,.3); }
.note-body[readonly]    { cursor: default; }

/* ════════════════════════════════════════════════
   MODALS
════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(2px);
}

.modal {
  background: #13132a;
  border: 1px solid #2a2a50;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  box-shadow: 0 24px 64px rgba(0,0,0,.8);
  width: 100%;
}

.modal-wide { max-width: 760px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid #1e1e40;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e2e8f0;
}

.modal-x {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 1.3rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.modal-x:hover { background: #1e1e40; color: #e2e8f0; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.85rem 1.2rem;
  border-top: 1px solid #1e1e40;
  flex-shrink: 0;
}

.btn-copy {
  padding: 0.45rem 1rem;
  background: #1a1a3a;
  color: #F28C7D;
  border: 1px solid #2a2a50;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  font-family: inherit;
}
.btn-copy:hover    { background: #E83F3F; color: #fff; border-color: #E83F3F; }
.btn-copy.copied   { background: #16a34a; color: #fff; border-color: #16a34a; }

.btn-secondary {
  padding: 0.45rem 1rem;
  background: transparent;
  color: #64748b;
  border: 1px solid #2a2a50;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
  font-family: inherit;
}
.btn-secondary:hover { color: #e2e8f0; border-color: #64748b; }

.export-topic {
  font-size: 0.88rem;
  color: #F28C7D;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

/* ── Data tables (participants & export) ─────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #475569;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid #1e1e40;
  white-space: nowrap;
}

.data-table td {
  padding: 0.55rem 0.6rem;
  color: #cbd5e1;
  border-bottom: 1px solid #1a1a35;
  vertical-align: top;
}

.data-table tbody tr:hover td { background: #16162e; }

.data-table .num { text-align: right; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: #F28C7D; font-weight: 600; }

/* Vote badge in export */
.vote-badge {
  display: inline-block;
  padding: 1px 8px;
  background: #E83F3F;
  color: #fff;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* Scrollbar styling for modal body */
.modal-body::-webkit-scrollbar        { width: 6px; }
.modal-body::-webkit-scrollbar-track  { background: transparent; }
.modal-body::-webkit-scrollbar-thumb  { background: #2a2a50; border-radius: 3px; }

/* ════════════════════════════════════════════════
   EMBED MODAL
════════════════════════════════════════════════ */

.modal-embed { max-width: 560px; }

.embed-options {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-bottom: 1.1rem;
}

.embed-option-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.embed-option-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #7c83a3;
  width: 48px;
  flex-shrink: 0;
}

.embed-option-btns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.embed-opt-btn {
  padding: 0.3rem 0.75rem;
  background: #0e0e22;
  color: #94a3b8;
  border: 1px solid #2a2a50;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}
.embed-opt-btn:hover  { background: #1a1a3a; color: #e2e8f0; }
.embed-opt-btn.active { background: #E83F3F; color: #fff; border-color: #E83F3F; }

.embed-code {
  background: #0e0e22;
  border: 1px solid #2a2a50;
  border-radius: 8px;
  padding: 1rem 1.1rem;
  font-family: 'Consolas', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.65;
  color: #a5b4fc;
  white-space: pre;
  overflow-x: auto;
  user-select: all;
}
