:root {
  --orange: #f6821f;
  --orange-dark: #d4660a;
  --ink: #1d1f20;
  --muted: #6b7075;
  --line: #e7e3df;
  --bg: #fbfaf8;
  --card: #ffffff;
  --bot: #ffffff;
  --user: #1d1f20;
  --danger: #b42318;
  --radius: 16px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--orange-dark); }

/* Header */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: rgba(251, 250, 248, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--orange); color: #fff; font-size: 18px;
}
h1 { margin: 0; font-size: 17px; line-height: 1.2; }
.sub { margin: 0; font-size: 13px; color: var(--muted); }
.pill {
  font-size: 12px; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); background: #fff;
}

/* Chat */
.chat {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}
.welcome { text-align: center; padding: 8vh 4px 16px; }
.welcome h2 { margin: 0 0 6px; font-size: 24px; }
.welcome p { margin: 0 0 20px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
.chip:hover { border-color: var(--orange); }

.msg { display: flex; flex-direction: column; margin: 12px 0; }
.msg.user { align-items: flex-end; }
.msg.bot { align-items: flex-start; }
.bubble {
  max-width: min(88%, 620px);
  padding: 10px 14px;
  border-radius: var(--radius);
  word-wrap: break-word;
}
.msg.user .bubble { background: var(--user); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--bot); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble p { margin: 0 0 8px; }
.bubble p:last-child, .bubble ul:last-child { margin-bottom: 0; }
.bubble ul { margin: 0 0 8px; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.ref { font-weight: 600; text-decoration: none; border-bottom: 1px solid currentColor; }

.blocked {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #fff1e6;
  color: var(--orange-dark);
  font-weight: 600;
  font-size: 14px;
}

.pending { display: flex; gap: 5px; padding: 14px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #c9c4bf; animation: blink 1.2s infinite; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* Session cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  width: min(100%, 620px);
  margin-top: 8px;
}
.card {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--orange);
  color: inherit;
  text-decoration: none;
}
.card:hover { border-color: var(--orange); }
.card-when { font-size: 12px; font-weight: 600; color: var(--orange-dark); }
.card-title { font-weight: 600; margin: 2px 0; line-height: 1.3; }
.card-meta, .card-speakers { font-size: 13px; color: var(--muted); }
.card-speakers { margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-demo { margin-top: 6px; font-size: 12px; color: var(--danger); font-weight: 600; }

/* Composer */
.composer {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, rgba(251, 250, 248, 0));
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.turnstile { display: flex; justify-content: center; }
#form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 760px;
  margin: 0 auto;
  padding: 6px 6px 6px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
}
#form:focus-within { border-color: var(--orange); }
textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: 0;
  font: inherit;
  padding: 8px 0;
  max-height: 140px;
  background: transparent;
}
#send {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--orange);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
#send:disabled { background: #d9d5d1; cursor: not-allowed; }
.fine { max-width: 760px; margin: 8px auto 0; font-size: 12px; color: var(--muted); text-align: center; }

/* Admin */
.admin { max-width: 860px; margin: 0 auto; padding: 16px; width: 100%; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 18px; }
.toggle { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.toggle:first-of-type { border-top: 0; }
.toggle strong { display: block; }
.toggle small { color: var(--muted); }
.switch { flex: none; position: relative; width: 52px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #d9d5d1; border-radius: 30px; transition: 0.2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--orange); }
.switch input:checked + .slider::before { transform: translateX(22px); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.stat { background: var(--bg); border-radius: 12px; padding: 10px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.btn { font: inherit; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.muted { color: var(--muted); }

@media (max-width: 520px) {
  .sub { display: none; }
  .welcome { padding-top: 4vh; }
  .welcome h2 { font-size: 21px; }
}
