/* ============================================================
   Questions Parking Lot — bottom-right chat widget
   Matches the deck's paper/ink palette (Fraunces, Inter, Mono).
   ============================================================ */

:root {
  --qw-paper: var(--paper, #f6efe4);
  --qw-cream: var(--cream, #f1e9db);
  --qw-ink: var(--ink, #1f1d1b);
  --qw-ink-soft: var(--ink-soft, #5a5650);
  --qw-clay: var(--clay, #c66a3e);
  --qw-clay-deep: var(--clay-deep, #a0542d);
  --qw-rule: rgba(31, 29, 27, 0.1);
  --qw-rule-strong: rgba(31, 29, 27, 0.18);
  --qw-shadow-soft: 0 4px 14px rgba(31, 29, 27, 0.08);
  --qw-shadow-lift: 0 18px 44px -14px rgba(31, 29, 27, 0.28), 0 4px 12px rgba(31, 29, 27, 0.08);
}

/* ---------- Floating action button (collapsed) ---------- */
.qw-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--qw-rule-strong);
  background: var(--qw-clay);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--qw-shadow-soft);
  transition: transform 200ms ease, box-shadow 220ms ease, background 220ms ease;
  z-index: 9999;
  padding: 0;
}
.qw-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(31, 29, 27, 0.16);
  background: var(--qw-clay-deep);
}
.qw-fab svg { width: 20px; height: 20px; display: block; }
.qw-fab .qw-fab-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--qw-ink);
  color: #fff;
  font: 600 10px/18px 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.04em;
  text-align: center;
  display: none;
}
.qw-fab .qw-fab-dot.visible { display: block; }
.qw-fab[aria-expanded="true"] { display: none; }

/* ---------- Panel (expanded) ---------- */
.qw-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 480px;
  max-height: calc(100vh - 40px);
  background: var(--qw-paper);
  border: 1px solid var(--qw-rule-strong);
  border-radius: 14px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--qw-shadow-lift);
  z-index: 9999;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--qw-ink);
  transform-origin: bottom right;
  animation: qwPop 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.qw-panel.open { display: flex; }

@keyframes qwPop {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Header ---------- */
.qw-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem 0.8rem;
  border-bottom: 1px solid var(--qw-rule);
  background: linear-gradient(180deg, rgba(255,255,255,0.35), transparent);
}
.qw-header-titlewrap { flex: 1; min-width: 0; }
.qw-header-eyebrow {
  display: block;
  font: 500 0.62rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--qw-ink-soft);
  opacity: 0.75;
  margin-bottom: 0.25rem;
}
.qw-header-title {
  font: 500 1.05rem/1.15 'Fraunces', serif;
  letter-spacing: -0.01em;
  color: var(--qw-ink);
  margin: 0;
}
.qw-header-count {
  font: 500 0.7rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.08em;
  color: var(--qw-ink-soft);
  opacity: 0.8;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--qw-rule);
  border-radius: 999px;
  white-space: nowrap;
}
.qw-header-close {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--qw-ink-soft);
  cursor: pointer;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  transition: background 180ms ease, color 180ms ease;
}
.qw-header-close:hover { background: rgba(31,29,27,0.05); color: var(--qw-clay); }

/* ---------- Tabs ---------- */
.qw-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.35rem 0.6rem 0;
  border-bottom: 1px solid var(--qw-rule);
  background: transparent;
}
.qw-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font: 500 0.78rem/1 'Inter', system-ui, sans-serif;
  color: var(--qw-ink-soft);
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.qw-tab:hover { color: var(--qw-ink); background: rgba(31,29,27,0.03); }
.qw-tab.active {
  color: var(--qw-ink);
  border-bottom-color: var(--qw-clay);
}
.qw-tab-count {
  font: 500 0.68rem/1 'JetBrains Mono', ui-monospace, monospace;
  padding: 0.2rem 0.38rem;
  border-radius: 999px;
  background: rgba(31,29,27,0.06);
  color: var(--qw-ink-soft);
  letter-spacing: 0.04em;
  min-width: 1.2rem;
  text-align: center;
}
.qw-tab.active .qw-tab-count {
  background: rgba(198, 106, 62, 0.14);
  color: var(--qw-clay);
}

/* ---------- List ---------- */
.qw-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.65rem 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--qw-rule-strong) transparent;
}
.qw-list::-webkit-scrollbar { width: 7px; }
.qw-list::-webkit-scrollbar-thumb { background: var(--qw-rule-strong); border-radius: 4px; }
.qw-list::-webkit-scrollbar-track { background: transparent; }

.qw-empty {
  padding: 1.8rem 1rem;
  text-align: center;
  color: var(--qw-ink-soft);
  opacity: 0.75;
  font-size: 0.85rem;
  line-height: 1.5;
}
.qw-empty-hand {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  color: var(--qw-clay);
  margin-bottom: 0.3rem;
}

.qw-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  align-items: flex-start;
  transition: background 160ms ease;
  cursor: pointer;
}
.qw-row + .qw-row { margin-top: 0.15rem; }
.qw-row:hover { background: rgba(31,29,27,0.035); }

.qw-row-text {
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--qw-ink);
  letter-spacing: -0.005em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.qw-row.expanded .qw-row-text {
  -webkit-line-clamp: initial;
  display: block;
}
.qw-row-count {
  font: 500 0.7rem/1 'JetBrains Mono', ui-monospace, monospace;
  color: var(--qw-clay);
  background: rgba(198, 106, 62, 0.1);
  border: 1px solid rgba(198, 106, 62, 0.25);
  padding: 0.28rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
  align-self: flex-start;
  letter-spacing: 0.02em;
}
.qw-row-count.solo { display: none; }

.qw-row.pending .qw-row-text {
  color: var(--qw-ink-soft);
  opacity: 0.7;
  font-style: italic;
}
.qw-row.pending::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--qw-clay);
  opacity: 0.6;
  margin-top: 0.5rem;
  margin-right: -0.25rem;
  grid-column: 1 / -1;
  justify-self: start;
  animation: qwPulse 1200ms ease-in-out infinite;
  display: none;
}
@keyframes qwPulse { 0%,100% { opacity: 0.25; } 50% { opacity: 0.8; } }

/* ---------- Error banner ---------- */
.qw-error {
  padding: 0.55rem 1rem;
  background: rgba(198, 106, 62, 0.1);
  border-top: 1px solid rgba(198, 106, 62, 0.25);
  color: var(--qw-clay-deep);
  font-size: 0.78rem;
  line-height: 1.4;
  display: none;
}
.qw-error.visible { display: block; }

/* ---------- Confirmation ---------- */
.qw-confirm {
  padding: 0.55rem 1rem;
  background: rgba(74, 106, 60, 0.08);
  border-top: 1px solid rgba(74, 106, 60, 0.2);
  color: #3d5a31;
  font-size: 0.82rem;
  line-height: 1.4;
  display: none;
  font-family: 'Caveat', cursive;
  font-size: 1.05rem;
}
.qw-confirm.visible { display: block; animation: qwFade 260ms ease; }
@keyframes qwFade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Footer (textarea + send) ---------- */
.qw-footer {
  border-top: 1px solid var(--qw-rule);
  padding: 0.7rem 0.8rem 0.8rem;
  background: rgba(255,255,255,0.35);
}
.qw-input-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: #fff;
  border: 1px solid var(--qw-rule-strong);
  border-radius: 10px;
  padding: 0.45rem 0.5rem 0.45rem 0.7rem;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}
.qw-input-wrap:focus-within {
  border-color: var(--qw-clay);
  box-shadow: 0 0 0 3px rgba(198, 106, 62, 0.12);
}
.qw-textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font: 400 0.9rem/1.45 'Inter', system-ui, sans-serif;
  color: var(--qw-ink);
  letter-spacing: -0.005em;
  min-height: 1.45em;
  max-height: calc(1.45em * 4);
  overflow-y: auto;
  padding: 0.2rem 0;
}
.qw-textarea::placeholder { color: var(--qw-ink-soft); opacity: 0.55; }

.qw-send {
  background: var(--qw-clay);
  border: 1px solid var(--qw-clay);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 180ms ease, transform 140ms ease, opacity 180ms ease;
  flex-shrink: 0;
}
.qw-send:hover { background: var(--qw-clay-deep); border-color: var(--qw-clay-deep); }
.qw-send:active { transform: scale(0.95); }
.qw-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.qw-send svg { width: 15px; height: 15px; }

.qw-footer-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  font: 500 0.68rem/1 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 0.06em;
  color: var(--qw-ink-soft);
  opacity: 0.65;
}
.qw-footer-hint { text-transform: none; letter-spacing: 0.02em; font-family: 'Inter', sans-serif; font-size: 0.7rem; }
.qw-footer-count.near-limit { color: var(--qw-clay); opacity: 1; }
.qw-footer-count.at-limit { color: var(--qw-clay-deep); opacity: 1; }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .qw-panel {
    right: 12px; bottom: 12px;
    width: calc(100vw - 24px);
    height: calc(100vh - 90px);
  }
  .qw-fab { right: 14px; bottom: 14px; }
}
