/* Limitless Society DM demo
   Dark, restrained, phone-first. Not an official Instagram surface. */

:root {
  --bg: #0b0b0c;
  --bg-2: #141416;
  --paper: #1a1a1d;
  --ink: #f3efe6;
  --muted: #b6b0a4;
  --faint: #8a857c;
  --line: #2a2a2e;
  --accent: #c4a574;
  --accent-2: #8d1c2d;
  --good: #8fbf9f;
  --warn: #d4a017;
  --bad: #d4534a;
  --incoming: #2a2a2e;
  --outgoing: #3b5bfd;
  --radius: 18px;
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  --font: "DM Sans", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  line-height: 1.45;
}
button, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.skip {
  position: absolute; left: 12px; top: -40px; background: var(--accent); color: #111; padding: 6px 10px;
}
.skip:focus { top: 12px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 20px 8px;
  max-width: 1180px;
  margin: 0 auto;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #16080b; color: var(--accent);
  border: 1px solid #3a2a1d;
  font-weight: 700; letter-spacing: 0.04em;
}
.eyebrow {
  margin: 0; text-transform: uppercase; letter-spacing: 0.12em;
  font-size: 11px; color: var(--accent); font-weight: 600;
}
h1 { margin: 0; font-family: var(--serif); font-size: 28px; font-weight: 400; letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; }
.top-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; color: var(--muted);
}
.live-pill i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 4px rgba(143,191,159,0.15);
}
.text-btn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; padding: 6px 0;
}
.text-btn:hover { color: var(--ink); }

.disclaimer {
  max-width: 1180px; margin: 8px auto 0; padding: 12px 20px;
  color: var(--muted); font-size: 13px;
}
.disclaimer strong { color: var(--ink); font-weight: 600; }

.walkthrough {
  max-width: 1180px; margin: 8px auto 18px; padding: 16px 20px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.walkthrough h2 { margin: 0 0 8px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.walkthrough ol {
  margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px;
  display: grid; gap: 4px;
}
.walkthrough em { color: var(--ink); font-style: normal; font-weight: 600; }

.layout {
  max-width: 1180px;
  margin: 0 auto 40px;
  padding: 0 16px 80px;
  display: grid;
  gap: 24px;
}
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(320px, 420px) 1fr; align-items: start; padding-bottom: 40px; }
  .mobile-nav { display: none !important; }
}

.presets {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.chip {
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  border-radius: 999px; padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.phone {
  background: #000;
  border: 1px solid #2c2c30;
  border-radius: 32px;
  overflow: hidden;
  display: flex; flex-direction: column;
  height: min(740px, calc(100dvh - 220px));
  min-height: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}
.phone-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 20px 0; font-size: 12px; color: #ddd; position: relative;
}
.notch {
  width: 90px; height: 8px; background: #1a1a1a; border-radius: 8px;
  position: absolute; left: 50%; transform: translateX(-50%);
}
.ig-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 10px 14px; border-bottom: 1px solid #1f1f22;
}
.who { display: flex; gap: 10px; align-items: center; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, #6b3a22, #1a0b0e 70%);
  border: 1px solid #5a3a22; font-size: 11px; font-weight: 700; color: var(--accent);
  flex: 0 0 auto;
}
.who strong { display: block; font-size: 14px; }
.who span, .ig-meta { font-size: 11px; color: var(--faint); }
.ig-meta { white-space: nowrap; }

.chat-log {
  flex: 1; overflow-y: auto; padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 8px;
  background: #000;
}
.day-tag {
  align-self: center; font-size: 11px; color: #7a7a7a; margin: 6px 0 8px;
}
.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.bubble.in {
  align-self: flex-start;
  background: var(--incoming);
  color: #f2f2f2;
  border-bottom-left-radius: 6px;
}
.bubble.out {
  align-self: flex-end;
  background: var(--outgoing);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.bubble.human {
  background: #3a2f1c;
  border: 1px solid #6a542e;
}
.bubble.system {
  align-self: center;
  max-width: 92%;
  background: #161616;
  color: #c8c2b6;
  font-size: 12px;
  border-radius: 12px;
  text-align: center;
}
.meta-line {
  font-size: 11px; color: #8a8a8a; padding: 0 4px;
}
.meta-line.out { align-self: flex-end; }
.typing {
  align-self: flex-start;
  color: #9a9a9a; font-size: 13px; padding: 4px 8px;
}
.typing span { animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2 } 40% { opacity: 1 } }

.composer {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 10px var(--safe-bottom);
  border-top: 1px solid #1f1f22; background: #000;
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px;
  background: #161616; border: 1px solid #2a2a2e;
  border-radius: 20px; padding: 10px 14px;
  outline: none; line-height: 1.3;
}
.composer textarea:focus { border-color: #555; }
.send {
  background: var(--outgoing); border: 0; color: #fff;
  border-radius: 16px; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: 14px;
}
.send:disabled { opacity: 0.4; cursor: default; }

.desk {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 22px;
  min-height: 560px;
}
.desk-head h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 26px; }
.desk-head p { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.desk-controls {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  align-items: center; margin-bottom: 14px;
}
.switch { display: flex; gap: 8px; align-items: center; font-size: 14px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.counts { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.counts b { color: var(--ink); font-weight: 600; }

.thread-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.thread {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  width: 100%; text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; color: inherit;
}
.thread.on { border-color: var(--accent); }
.thread .t-name { font-weight: 600; font-size: 14px; }
.thread .t-preview { color: var(--faint); font-size: 12px; grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  padding: 2px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.ok { color: var(--good); border-color: #2a4a34; }
.pill.warn { color: var(--warn); border-color: #5a4a12; }
.pill.bad { color: var(--bad); border-color: #5a2220; }
.pill.accent { color: var(--accent); border-color: #4a3a22; }

.lead-card, .booked {
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px;
}
.lead-card h3, .booked h3 {
  margin: 0 0 10px; font-size: 13px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint); font-weight: 600;
}
.facts { display: grid; gap: 8px; font-size: 14px; }
.facts div { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
.facts dt, .k { color: var(--faint); }
.facts dd, .v { margin: 0; overflow-wrap: anywhere; }
.score-row { display: flex; align-items: center; gap: 10px; margin: 10px 0 12px; }
.bar { flex: 1; height: 6px; background: #2a2a2e; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0%; }
.takeover-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; }
.reason { margin: 8px 0 0; color: var(--warn); font-size: 13px; }

#booked-list { display: grid; gap: 8px; }
.booked-item {
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px;
}
.booked-item span { display: block; color: var(--faint); font-size: 12px; }
.empty { color: var(--faint); font-size: 14px; }

.mobile-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: #0e0e10; border-top: 1px solid var(--line);
  padding: 8px 12px var(--safe-bottom); z-index: 20; gap: 8px;
}
.mobile-nav button {
  flex: 1; background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 12px; padding: 10px; cursor: pointer; font-weight: 600;
}
.mobile-nav button.on { color: var(--ink); border-color: var(--accent); }

.mobile-hint { display: none; }

@media (max-width: 959px) {
  .desk { display: none; }
  body.show-desk .disclaimer,
  body.show-desk .walkthrough { display: block; }
  body.show-desk .desk { display: block; }
  body.show-desk .phone-col { display: none; }
  body.show-desk .layout { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }

  body:not(.show-desk) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }
  body:not(.show-desk) .disclaimer,
  body:not(.show-desk) .walkthrough { display: none; }
  body:not(.show-desk) .mobile-hint {
    display: block; margin: 0 0 8px; color: var(--faint); font-size: 12px;
  }
  body:not(.show-desk) .sub { display: none; }
  body:not(.show-desk) .topbar { padding-top: 12px; padding-bottom: 4px; flex-shrink: 0; }
  body:not(.show-desk) .layout {
    flex: 1;
    min-height: 0;
    margin: 0 auto;
    padding-bottom: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
  }
  body:not(.show-desk) .phone-col {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  body:not(.show-desk) .presets { flex-shrink: 0; }
  body:not(.show-desk) .phone {
    flex: 1;
    height: auto;
    min-height: 0;
  }
  body:not(.show-desk) .mobile-nav {
    position: static;
    flex-shrink: 0;
  }
}

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,0.62);
  display: grid; place-items: center; z-index: 40; padding: 16px;
}
@media (max-width: 959px) {
  .sheet { place-items: end center; }
}
.sheet[hidden] { display: none; }
.sheet-card {
  width: min(440px, 100%);
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 20px 20px 12px 12px;
  padding: 18px 16px 16px;
}
.sheet-card h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 24px; font-weight: 400; }
.sheet-note, .sheet-offer { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.slots { display: grid; gap: 8px; margin-bottom: 10px; }
.slot {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; color: inherit; font-weight: 500;
}
.slot:hover { border-color: var(--accent); }

@media (max-width: 390px) {
  h1 { font-size: 24px; }
  .topbar, .disclaimer, .walkthrough { padding-left: 14px; padding-right: 14px; }
  .layout { padding-left: 10px; padding-right: 10px; }
  .phone { border-radius: 24px; min-height: 520px; }
  .bubble { max-width: 88%; font-size: 14px; }
  .facts div { grid-template-columns: 1fr; gap: 2px; }
}
