@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

/* ─── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  /* Whiteboard surface */
  --board:      #f0f2f8;
  --board-alt:  #e8ebf4;

  /* UI surfaces */
  --surface:    #ffffff;
  --surface-2:  #f7f8fc;

  /* Text */
  --ink:        #1a1b2e;
  --muted:      #64748b;

  /* Borders */
  --border:     rgba(30, 40, 80, 0.10);
  --border-med: rgba(30, 40, 80, 0.16);

  /* Brand green */
  --green:       #2d7a50;
  --green-dark:  #1b5c38;
  --green-light: rgba(45, 122, 80, 0.10);

  /* Sticky palette */
  --yellow: #fef08a;
  --pink:   #fbcfe8;
  --mint:   #bbf7d0;
  --sky:    #bfdbfe;
  --peach:  #fed7aa;
  --lilac:  #e9d5ff;
  --sage:   #d1fae5;

  /* Typography */
  --hand: 'Caveat', cursive;
  --ui:   Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;

  color-scheme: light;
}

/* ─── Reset ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; background: none; }

/* ─── Whiteboard background ──────────────────────────────────────────────── */

body {
  margin: 0;
  font-family: var(--ui);
  font-size: 15px;
  color: var(--ink);
  min-height: 100vh;
  background-color: var(--board);
  /* dot grid — whiteboard marker-grid feel */
  background-image: radial-gradient(circle, rgba(90, 100, 160, 0.18) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ─── Home ───────────────────────────────────────────────────────────────── */

.home {
  min-height: 100vh;
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 28px 80px;
}

.home-header {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 40px;
}

.home-logo {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
}

.home-logo img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.home-header h1 {
  margin: 0;
  font-family: var(--ui);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.home-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* create card */
.create-card {
  background: var(--surface);
  border: 1px solid var(--border-med);
  border-radius: 12px;
  padding: 30px 32px 26px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07), 0 12px 32px rgba(0,0,0,0.06);
  margin-bottom: 44px;
}

.create-card h2 {
  margin: 0 0 20px;
  font-family: var(--ui);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field input,
.field textarea {
  width: 100%;
  border: 1.5px solid var(--border-med);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px 13px;
  color: var(--ink);
  outline: 0;
  transition: border-color 120ms, box-shadow 120ms;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-light);
  background: var(--surface);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.slug-preview {
  margin: -2px 0 16px;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  border: 1.5px dashed var(--border-med);
  font-family: ui-monospace, monospace;
  word-break: break-all;
  line-height: 1.5;
}

.slug-preview strong { color: var(--green-dark); }

/* rooms grid */
.home-rooms h2 {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 14px;
}

.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
}

.room-card {
  position: relative;
  padding: 18px 14px 14px;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 3px 5px 0 rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.08);
  transition: transform 140ms, box-shadow 140ms;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.room-card:hover {
  transform: translateY(-3px) rotate(0.3deg);
  box-shadow: 4px 10px 0 rgba(0,0,0,0.13), 0 2px 4px rgba(0,0,0,0.08);
}

/* pushpin */
.room-card::before {
  content: '';
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%);
  width: 14px; height: 14px;
  background: radial-gradient(circle at 38% 35%, #f87171, #b91c1c);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  z-index: 2;
}

.room-card strong {
  font-family: var(--ui);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: block;
}

.room-card .room-count {
  font-size: 12px;
  font-weight: 600;
  color: rgba(26,27,46,0.5);
}

.room-card .room-slug {
  font-size: 11px;
  font-family: ui-monospace, monospace;
  color: rgba(26,27,46,0.38);
  margin-top: auto;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  width: 100%;
  padding: 0 20px;
  background: var(--green);
  color: white;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(45, 122, 80, 0.32);
  transition: background 100ms, box-shadow 100ms, transform 80ms;
  white-space: nowrap;
  border: none;
}

.btn-primary:hover  { background: var(--green-dark); box-shadow: 0 4px 14px rgba(45,122,80,0.38); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 4px rgba(45,122,80,0.3); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--border-med);
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: border-color 100ms, background 100ms;
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: rgba(30,40,80,0.26);
}

/* ─── Admin shell ────────────────────────────────────────────────────────── */

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

/* Sidebar — white panel over the board */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border-med);
  box-shadow: 2px 0 16px rgba(0,0,0,0.06);
  padding: 20px 18px;
  overflow-y: auto;
}

.sidebar-inner { position: relative; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: grid;
  place-items: center;
}

.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-family: var(--ui);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.1;
}

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

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* rooms list */
.room-list { display: grid; gap: 4px; }

.room-row {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: background 100ms, border-color 100ms;
  cursor: pointer;
}

.room-row:hover        { background: var(--board-alt); }
.room-row.active       { background: var(--green-light); border-color: var(--green); }
.room-row strong       { display: block; font-size: 13px; font-weight: 700; }
.room-row span         { color: var(--muted); font-size: 11px; }

/* room row with delete */
.room-row-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.room-row-wrap .room-row { flex: 1; }

.room-delete-btn {
  flex-shrink: 0;
  padding: 6px 7px;
  border-radius: 7px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  opacity: 0.45;
  transition: opacity 100ms, background 100ms;
  border: none;
  background: none;
  cursor: pointer;
}

.room-delete-btn:hover {
  opacity: 1;
  background: #fee2e2;
  color: #b91c1c;
}

/* qr */
.qr-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.qr {
  width: 88px; height: 88px;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--border-med);
  padding: 5px;
  object-fit: contain;
  cursor: zoom-in;
  transition: box-shadow 120ms;
}

.qr:hover {
  box-shadow: 0 0 0 3px var(--green-light), 0 2px 8px rgba(0,0,0,0.10);
}

/* QR modal */
.qr-modal-backdrop {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(15, 20, 40, 0.55);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  animation: qr-fade-in 150ms ease;
}

@keyframes qr-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.qr-modal {
  background: white;
  border-radius: 16px;
  padding: 28px 28px 22px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 90vw;
  animation: qr-pop-in 180ms cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes qr-pop-in {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.qr-modal img,
.qr-modal canvas {
  width: 260px; height: 260px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.qr-modal-name {
  font-size: 16px; font-weight: 700;
  color: var(--ink);
}

.qr-modal-url {
  font-size: 12px; color: var(--muted);
  font-family: ui-monospace, monospace;
  word-break: break-all;
  max-width: 280px;
}

.qr-modal-close {
  margin-top: 4px;
  padding: 8px 22px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border-med);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background 100ms;
}
.qr-modal-close:hover { background: var(--board-alt); }

.qr-fallback { display: none; }

.microcopy {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-all;
}

/* ─── Wall area ──────────────────────────────────────────────────────────── */

.wall-area {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* Topbar — white strip above the board */
.topbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-med);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  flex-wrap: wrap;
  position: relative;
  z-index: 10;
}

.room-title h2 {
  margin: 0;
  font-family: var(--ui);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.room-title p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

/* ─── Wall ───────────────────────────────────────────────────────────────── */

.wall {
  position: relative;
  overflow: hidden;
  min-height: 680px;
}

.wall-only {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.wall-only .wall { min-height: unset; height: 100%; }

/* ─── Cluster labels ─────────────────────────────────────────────────────── */

.cluster-label {
  position: absolute;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 6px;
  background: rgba(255,255,255,0.72);
  border: 1.5px dashed var(--border-med);
  color: var(--muted);
  font-family: var(--ui);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

/* ─── Group labels ───────────────────────────────────────────────────────── */

.group-label {
  position: absolute;
  z-index: 3;
  left: var(--x); top: var(--y);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 4px;
  font-family: var(--hand);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  user-select: none;
  opacity: 0.92;
}

.group-draggable         { cursor: grab; }
.group-draggable:hover   { opacity: 1; }
.group-draggable.dragging {
  cursor: grabbing; z-index: 20; opacity: 1;
  box-shadow: 0 8px 24px rgba(0,0,0,0.20);
}

.group-title[contenteditable] {
  outline: none; cursor: text; min-width: 36px;
}
.group-title[contenteditable]:focus {
  border-bottom: 2px solid var(--green);
}

.group-delete-btn {
  color: rgba(26,27,46,0.3);
  font-size: 16px; line-height: 1;
  padding: 0 2px; cursor: pointer; border: none; background: none;
}
.group-delete-btn:hover { color: #b91c1c; }

/* ─── Stickies ───────────────────────────────────────────────────────────── */

.sticky {
  position: absolute;
  z-index: 2;
  left: var(--x); top: var(--y);
  width: clamp(148px, 15vw, 210px);
  min-height: 118px;
  padding: 16px 13px 11px;
  border-radius: 2px;
  color: #1e1c17;
  box-shadow: 3px 5px 0 rgba(0,0,0,0.10), 0 1px 3px rgba(0,0,0,0.07),
              inset 0 -2px 6px rgba(0,0,0,0.04);
  transform: rotate(var(--r));
  transition: transform 650ms cubic-bezier(0.22,1,0.36,1), box-shadow 150ms;
}

/* pushpin */
.sticky::before {
  content: '';
  position: absolute;
  top: -9px; left: 50%;
  transform: translateX(-50%);
  width: 13px; height: 13px;
  background: radial-gradient(circle at 38% 35%, #f87171, #b91c1c);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.35);
  z-index: 3;
}

/* glue strip */
.sticky::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 8px;
  background: rgba(0,0,0,0.05);
  border-radius: 2px 2px 0 0;
}

.sticky:hover {
  box-shadow: 4px 10px 0 rgba(0,0,0,0.14), 0 2px 4px rgba(0,0,0,0.09);
}

.wall.editable .sticky { cursor: grab; }

.wall.editable .sticky.dragging {
  cursor: grabbing; z-index: 10;
  transform: rotate(0deg) scale(1.05);
  box-shadow: 6px 16px 0 rgba(0,0,0,0.17), 0 4px 8px rgba(0,0,0,0.10);
  transition: transform 80ms, box-shadow 80ms;
}

.sticky strong {
  display: block;
  font-family: var(--hand);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.sticky footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: rgba(30,28,23,0.50);
  font-family: var(--hand);
  font-size: 12px;
  font-weight: 600;
}

/* ─── Group picker (dropdown on sticky) ──────────────────────────────────── */

.tag-wrap {
  position: relative;
}

.tag {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-btn {
  max-width: 108px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(0,0,0,0.10);
  border: none;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(30,28,23,0.65);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.tag-btn:hover { background: rgba(0,0,0,0.17); }

.tag-btn-arrow {
  font-size: 9px;
  opacity: 0.7;
  margin-left: 1px;
}

.group-picker {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-med);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.08);
  min-width: 170px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
}

.group-picker[hidden] { display: none; }

.picker-section {
  padding: 6px 0 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 10px;
}

.picker-opt {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 0;
  transition: background 80ms;
}

.picker-opt:hover  { background: var(--surface-2); }
.picker-opt.active { color: var(--green); background: var(--green-light); }

.picker-dot {
  flex-shrink: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.12);
}

/* ─── Empty wall ─────────────────────────────────────────────────────────── */

.empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center; color: var(--muted); padding: 24px;
}

.empty strong {
  display: block;
  font-family: var(--ui);
  font-size: 26px; font-weight: 700;
  color: var(--ink); margin-bottom: 8px;
}

.empty span { font-size: 14px; }

/* ─── Participant ────────────────────────────────────────────────────────── */

.participant {
  min-height: 100vh;
  display: grid; place-items: center; padding: 20px;
}

.submit-card {
  width: min(100%, 530px);
  background: var(--surface);
  border: 1px solid var(--border-med);
  border-radius: 12px;
  padding: 26px 26px 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.09), 0 1px 3px rgba(0,0,0,0.06);
}

.submit-card h1 {
  margin: 0 0 4px;
  font-family: var(--ui);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.prompts {
  margin: 14px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.prompt {
  border-left: 3px solid var(--green);
  background: var(--surface-2);
  border-radius: 0 6px 6px 0;
  padding: 8px 10px;
  font-family: var(--ui);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.3;
}

.frequency {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-bottom: 13px;
}

.frequency input { position: absolute; opacity: 0; pointer-events: none; }

.frequency span {
  display: grid; place-items: center;
  min-height: 40px;
  border: 1.5px solid var(--border-med);
  border-radius: 8px;
  background: var(--surface-2);
  font-weight: 700; font-size: 13px;
  cursor: pointer;
  transition: border-color 100ms, background 100ms;
}

.frequency input:checked + span {
  border-color: var(--green);
  color: var(--green-dark);
  background: var(--green-light);
}

/* ─── Notice ─────────────────────────────────────────────────────────────── */

.notice {
  margin-top: 11px; padding: 10px 12px;
  border-radius: 8px;
  background: var(--mint);
  color: #064e2a;
  font-size: 13px; font-weight: 700;
  border: 1px solid rgba(0,0,0,0.07);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border-med); box-shadow: none; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; }
  .actions > * { flex: 1; }
  .wall { min-height: 540px; }
  .sticky { width: 140px; }
  .prompts { grid-template-columns: 1fr; }
  .home { padding: 32px 16px 56px; }
  .rooms-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
}
