/* Cyrano — fun, fast, mobile-first. Palette: deep teal night + coral + gold. */
:root {
  --bg: #0f1a1c;
  --bg-soft: #16262a;
  --card: #1d3238;
  --card-hi: #24404a;
  --ink: #f3efe6;
  --ink-dim: #9db4b8;
  --coral: #ff6b57;
  --coral-deep: #e5533f;
  --gold: #ffc857;
  --teal: #2ec4b6;
  --danger: #ff5470;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The hidden attribute must always win, even over display:flex rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', system-ui, sans-serif;
  min-height: 100dvh;
}

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px);
  min-height: 100dvh;
}

/* ------------------------------------------------------------- home */
.home-header h1 {
  font-size: 2.2rem;
  font-weight: 900;
  margin: 8px 0 0;
  letter-spacing: -0.5px;
}
.tagline { color: var(--ink-dim); margin: 4px 0 20px; }

.cyrano-list { display: flex; flex-direction: column; gap: 14px; }

.cyrano-card {
  background: linear-gradient(145deg, var(--card), var(--bg-soft));
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform .12s ease;
}
.cyrano-card:active { transform: scale(.98); }
.cyrano-card .card-emoji { font-size: 2rem; }
.cyrano-card .card-body { flex: 1; min-width: 0; }
.cyrano-card .card-name { font-weight: 900; font-size: 1.15rem; }
.cyrano-card .card-meta {
  color: var(--ink-dim);
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-actions { display: flex; gap: 6px; }

.icon-btn {
  background: var(--card-hi);
  color: var(--ink);
  border: none;
  border-radius: 12px;
  width: 42px;
  height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:active { filter: brightness(1.2); }

.empty-state {
  text-align: center;
  color: var(--ink-dim);
  margin-top: 18vh;
  line-height: 1.7;
}
.empty-emoji { font-size: 3.5rem; margin-bottom: 12px; }

.fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--coral), var(--coral-deep));
  color: #fff;
  font-family: inherit;
  font-weight: 900;
  font-size: 1.05rem;
  border: none;
  border-radius: 999px;
  padding: 16px 28px;
  box-shadow: 0 10px 28px rgba(255, 107, 87, .4);
  cursor: pointer;
}
.fab:active { transform: translateX(-50%) scale(.96); }

/* ------------------------------------------------------------- live */
.live-top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to bottom, var(--bg) 88%, transparent);
  /* bleed over the screen's side padding so the feed slides underneath */
  margin: calc(-1 * (env(safe-area-inset-top) + 16px)) -16px 0;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 18px;
}

.live-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.live-title { flex: 1; font-weight: 900; font-size: 1.2rem; display: flex; gap: 8px; align-items: center; }
.conn-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #5b6b6e;
  transition: background .3s;
}
.conn-dot.on { background: var(--teal); box-shadow: 0 0 10px var(--teal); }
.conn-dot.err { background: var(--danger); }

.listen-zone { text-align: center; padding: 4px 0 0; }

.listen-btn {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--card-hi), var(--card));
  color: var(--ink);
  font-family: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.08);
  transition: transform .1s ease;
}
.listen-btn:active { transform: scale(.94); }
.listen-btn .listen-icon { font-size: 1.9rem; }
.listen-btn .listen-label { font-weight: 900; font-size: 1rem; letter-spacing: .5px; }

.listen-btn.on {
  background: linear-gradient(145deg, var(--coral), var(--coral-deep));
  color: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 87, .45); }
  50% { box-shadow: 0 0 0 22px rgba(255, 107, 87, 0); }
}

.live-status {
  color: var(--ink-dim);
  height: 1.4em;            /* fixed height: status changes never shift layout */
  margin: 8px 0 0;
  font-size: .95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* -------------------------------------------------------------- feed */
/* Newest Q&A is prepended, so it appears at the top — right under the
   pinned Listen button. No scrolling needed to see the latest answer. */
.feed { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.qa { display: flex; flex-direction: column; gap: 8px; }

.q-bubble {
  align-self: flex-end;
  max-width: 88%;
  background: var(--card-hi);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  color: var(--ink-dim);
  font-size: .92rem;
}
.a-bubble {
  align-self: flex-start;
  max-width: 96%;
  background: linear-gradient(160deg, #223d33, #1a2f29);
  border: 1px solid rgba(46, 196, 182, .25);
  border-radius: 16px 16px 16px 4px;
  padding: 12px 16px;
  font-size: 1.05rem;
  line-height: 1.55;
}
.a-bubble.thinking::after {
  content: "▌";
  color: var(--gold);
  animation: blink .8s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.a-bubble p { margin: 0 0 8px; }
.a-bubble p:last-child { margin-bottom: 0; }
.a-bubble ul { margin: 6px 0; padding-left: 20px; }
.a-bubble li { margin: 4px 0; }
.a-bubble strong { color: var(--gold); }
.a-bubble em { color: var(--ink-dim); }

/* ------------------------------------------------------------ modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 13, .72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
@media (min-width: 560px) { .modal-backdrop { align-items: center; } }

.modal {
  background: var(--bg-soft);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 22px 22px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px 20px calc(env(safe-area-inset-bottom) + 22px);
}
@media (min-width: 560px) { .modal { border-radius: 22px; } }
.modal.small { max-width: 380px; border-radius: 22px; text-align: center; }

.modal h2 { margin: 0 0 4px; font-size: 1.35rem; }
.modal-sub { color: var(--ink-dim); font-size: .88rem; margin: 0 0 14px; }
.modal label { display: block; font-weight: 700; margin: 14px 0 6px; font-size: .95rem; }
.modal label .optional { color: var(--ink-dim); font-weight: 400; font-size: .85rem; }

.modal input[type="text"], .modal textarea {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}
.modal input:focus, .modal textarea:focus { outline: 2px solid var(--teal); border-color: transparent; }

.emoji-row { display: flex; gap: 8px; flex-wrap: wrap; }
.emoji-opt {
  font-size: 1.5rem;
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.emoji-opt.selected { border-color: var(--gold); background: var(--card); }

.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-family: inherit;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(135deg, var(--coral), var(--coral-deep)); color: #fff; }
.btn.ghost { background: var(--card); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------------------------------------------------------- knowledge */
.doc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: .92rem;
}
.doc-row .doc-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .doc-size { color: var(--ink-dim); font-size: .8rem; }
.doc-del {
  background: none; border: none; color: var(--danger);
  font-size: 1.1rem; cursor: pointer; padding: 4px;
}

.file-drop {
  display: block;
  border: 2px dashed rgba(255, 200, 87, .4);
  border-radius: 14px;
  text-align: center;
  padding: 22px 12px;
  margin-top: 8px;
  color: var(--gold);
  cursor: pointer;
  line-height: 1.5;
}
.file-drop input { display: none; }
.file-drop small { color: var(--ink-dim); }
.file-drop.has-files { border-style: solid; background: rgba(255, 200, 87, .06); }

/* -------------------------------------------------------------- toast */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-hi);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: .92rem;
  box-shadow: var(--shadow);
  z-index: 99;
  max-width: 90vw;
  text-align: center;
}
