/* PLOT & TWIST — Funnel Canvas v2 (Simplified) */
:root {
  --bg: #0a0a0a; --surface: #141414; --elevated: #1c1c1e; --hover: #252528;
  --border: #2a2a2e; --text: #f0eee6; --text2: #9c9a94; --text3: #5c5a54;
  --gold: #d4a017; --gold-light: #e8b83a; --violet: #7c3aed;
  --font-brand: 'Instrument Serif', Georgia, serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --r: 8px; --rs: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 14px; line-height: 1.4;
  touch-action: manipulation; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
input, textarea, select, button { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; color: inherit; }

/* LOGIN */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }
#login-screen { align-items: center; justify-content: center; }
.login-center { text-align: center; }
.login-brand { font-family: var(--font-brand); font-size: min(14vw, 64px); letter-spacing: -3px; line-height: 1; }
.brand-p { color: var(--text); }
.brand-a { color: var(--text3); font-size: 0.5em; font-style: italic; vertical-align: middle; }
.brand-t { color: var(--gold); font-style: italic; }
.login-sub { color: var(--text2); font-size: min(4vw, 16px); margin-top: 8px; letter-spacing: 4px; text-transform: uppercase; }
.login-form { margin-top: 28px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#password-input { background: var(--elevated); border: 1px solid var(--border); color: var(--text); padding: 14px 20px; border-radius: var(--r); width: min(80vw, 280px); text-align: center; font-size: 16px; outline: none; }
#password-input:focus { border-color: var(--gold); }
#login-btn { background: var(--gold); color: var(--bg); padding: 12px 44px; border-radius: var(--r); font-size: 15px; font-weight: 600; }
#login-btn:active { opacity: 0.8; }
.login-error { color: #ef4444; font-size: 13px; }
.hidden { display: none !important; }

/* CANVAS SCREEN */
#canvas-screen { flex-direction: column; }

/* Top bar */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 44px; padding: 0 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0; z-index: 10;
}
.tb-left { font-family: var(--font-brand); font-size: 20px; letter-spacing: -0.5px; }
.tb-center { flex: 1; margin: 0 8px; }
#funnel-select {
  width: 100%; max-width: 280px;
  background: var(--elevated); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: var(--rs);
  font-size: 13px; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239c9a94'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.tb-right { display: flex; gap: 8px; }
.btn-ghost { color: var(--text3); font-size: 16px; padding: 4px 8px; border-radius: var(--rs); }
.btn-ghost:active { color: var(--text2); }

/* Main area */
#main-area { flex: 1; position: relative; overflow: hidden; }
#funnel-canvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* Bottom bar */
#bottombar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 6px;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
.bb-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 18px; color: var(--text2);
  transition: background 0.1s;
}
.bb-btn:active { background: var(--hover); color: var(--text); }
.bb-primary { background: var(--gold); color: var(--bg); }
.bb-primary:active { background: var(--gold-light); }
.zoom-label { font-size: 11px; color: var(--text3); min-width: 32px; text-align: center; }

/* Popups */
.popup {
  position: fixed; z-index: 20;
  background: var(--elevated); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 180px;
  animation: popIn 0.15s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } }
.popup-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.popup-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 6px; border-radius: var(--rs);
  font-size: 13px; color: var(--text2); cursor: pointer;
}
.popup-item:active { background: var(--hover); color: var(--text); }
.pdot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.popup-row { display: flex; gap: 8px; }
.popup-btn {
  flex: 1; padding: 8px 12px; border-radius: var(--rs);
  background: var(--hover); color: var(--text); font-size: 13px; font-weight: 500;
}
.popup-btn:active { background: var(--border); }
.popup-btn.danger { background: #2e0a0a; color: #fca5a5; }

/* Comment popup */
.cp-list { max-height: 150px; overflow-y: auto; margin-bottom: 8px; }
.cp-item { padding: 6px 0; border-bottom: 1px solid var(--border); }
.cp-author { font-size: 12px; font-weight: 500; color: var(--gold); }
.cp-text { font-size: 13px; color: var(--text2); margin-top: 2px; }
.cp-input-row { display: flex; gap: 4px; }
#cp-author, #cp-text {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 6px 8px; border-radius: var(--rs); font-size: 12px; flex: 1; min-width: 0;
}

/* Toast */
#toast-container {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  z-index: 30; display: flex; flex-direction: column; gap: 6px;
  align-items: center; pointer-events: none;
}
.toast {
  background: var(--elevated); border: 1px solid var(--border); color: var(--text);
  padding: 8px 18px; border-radius: 20px; font-size: 13px;
  pointer-events: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
