* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Verdana, Helvetica, sans-serif;
  color: #000;
  background: #fff;
  line-height: 1.6;
}
a { color: #05728f; text-decoration: none; }

/* top bar */
.topbar {
  background: #1f1f1f;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 18px;
  height: 54px;
}
.brand { color: #fff; font-size: 22px; font-weight: 700; }
.brand b { font-weight: 400; }
.topbar nav a { color: #fff; font-size: 14px; padding: 6px; }
.topbar nav a:hover { background: #333; }
.topbar .spacer { flex: 1; }
.signup { background: #04AA6D; color: #fff !important; padding: 8px 14px; border-radius: 4px; font-size: 14px; white-space: nowrap; }

.subbar { background: #04AA6D; color: #fff; padding: 10px 18px; font-size: 15px; font-weight: 600; cursor: default; user-select: none; }

/* layout */
.layout { display: flex; max-width: 1100px; margin: 0 auto; }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #f1f1f1;
  padding: 16px 0;
  min-height: 80vh;
}
.sidebar h3 { margin: 0; padding: 8px 18px; font-size: 15px; }
.sidebar a { display: block; padding: 7px 18px; color: #000; font-size: 14px; }
.sidebar a:hover { background: #ddd; }
.sidebar a.active { background: #04AA6D; color: #fff; }

.content { flex: 1; padding: 24px 34px; min-width: 0; }
.content h1 { font-size: 40px; margin: 0 0 8px; }
.content h2 { font-size: 26px; margin-top: 30px; }
.content p { margin: 12px 0; }

/* example box */
.example {
  background: #E7E9EB;
  border-left: 6px solid #04AA6D;
  padding: 14px 16px;
  margin: 18px 0;
}
.example h4 { margin: 0 0 8px; }
.example .code {
  background: #fff;
  padding: 12px;
  font-family: Consolas, monospace;
  font-size: 15px;
  white-space: pre;
  overflow-x: auto;
}
.tryit {
  margin-top: 12px;
  background: #04AA6D;
  color: #fff;
  border: 0;
  padding: 9px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.navbtns { display: flex; justify-content: space-between; margin: 40px 0 10px; }
.navbtns a {
  background: #04AA6D;
  color: #fff;
  padding: 10px 18px;
  border-radius: 4px;
  font-size: 15px;
}

.foot { background: #1f1f1f; color: #bbb; text-align: center; padding: 26px; font-size: 13px; margin-top: 40px; }

/* ---------- the hidden bits ---------- */
.modal-wrap {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-wrap.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 8px;
  padding: 22px;
  width: 300px;
}
.modal h3 { margin: 0 0 14px; }
.modal input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px; /* >=16px stops iOS Safari auto-zoom on focus */
}
.modal button {
  width: 100%;
  background: #04AA6D;
  color: #fff;
  border: 0;
  padding: 11px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
}
.modal .err { color: #d9534f; font-size: 13px; min-height: 18px; margin-bottom: 6px; }

/* stop the page behind the chat from scrolling on mobile */
body.chat-open { overflow: hidden; }

/* chat panel */
#chatPanel {
  display: none;
  position: fixed;
  /* top/right/bottom pin to the real viewport and follow the mobile toolbar,
     so no 100vh guesswork and the input bar can't fall off-screen */
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: #fff;
  box-shadow: -3px 0 16px rgba(0,0,0,.2);
  z-index: 90;
  flex-direction: column;
  overscroll-behavior: none;
}
#chatPanel.show { display: flex; }
.chat-top {
  flex: 0 0 auto;
  background: #04AA6D;
  color: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.chat-top .who { flex: 1 1 100%; font-size: 14px; }
.chat-top .dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #cfe9dd;
  margin-right: 6px;
}
.chat-top .dot.on { background: #baffcf; box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.chat-top button {
  background: rgba(255,255,255,.2);
  color: #fff;
  border: 0;
  padding: 6px 9px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
.chat-top .kick { margin-left: auto; }
.chat-msgs {
  flex: 1 1 auto;
  min-height: 0; /* lets this pane shrink instead of shoving the form off-screen */
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  background: #f7f7f7;
}
.bubble {
  max-width: 78%;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 10px;
  clear: both;
  font-size: 14px;
  word-wrap: break-word;
}
.bubble.me { background: #04AA6D; color: #fff; float: right; }
.bubble.them { background: #e4e4e4; color: #000; float: left; }
.bubble .t { display: block; font-size: 10px; opacity: .7; margin-top: 3px; }
.img-wrap { position: relative; display: inline-block; margin-top: 4px; }
.chat-img {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  cursor: pointer;
}
.img-del,
.img-dl {
  position: absolute;
  top: 5px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 13px;
  line-height: 24px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.img-del { right: 5px; }
.img-dl { right: 34px; }
.img-del:hover,
.img-dl:hover { background: rgba(0,0,0,.8); }

/* upload progress bar */
#upWrap { flex: 0 0 auto; display: none; height: 4px; background: #e6e6e6; overflow: hidden; }
#upWrap.show { display: block; }
#upFill { height: 100%; width: 0; background: #04AA6D; transition: width .15s linear; }
#upWrap.indeterminate #upFill { width: 35%; animation: upslide 1s ease-in-out infinite; }
@keyframes upslide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

.chat-err { flex: 0 0 auto; color: #d9534f; font-size: 12px; padding: 0 10px; }
.chat-err:not(:empty) { padding: 6px 10px; }

.chat-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eee;
  background: #fff;
}
#chatInput {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 16px; /* >=16px stops iOS Safari auto-zoom on focus */
}
.send-btn {
  flex-shrink: 0;
  height: 38px;
  background: #04AA6D;
  color: #fff;
  border: 0;
  padding: 0 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.attach-btn {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  font-size: 18px;
  user-select: none;
}
.attach-btn input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.attach-btn:hover { background: #f0f0f0; }

@media (max-width: 800px) {
  .topbar {
    height: auto;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 10px 14px;
    justify-content: space-between;
  }
  .topbar nav { display: none; }
  .topbar .spacer { display: none; }
  .brand { font-size: 20px; }
  .subbar { padding: 9px 14px; font-size: 14px; }
  .sidebar { display: none; }
  .content { padding: 18px; }
  .content h1 { font-size: 28px; }
  .content h2 { font-size: 22px; }
}

@media (max-width: 480px) {
  #chatPanel { width: 100vw; }
}
