/*
 * Bubble on the web — the app itself, not the marketing pages.
 *
 * Shares the palette in style.css but is laid out as an application: a fixed
 * sidebar of chats, a scrolling transcript, a composer pinned to the bottom.
 * Below 820px the sidebar becomes a drawer, because a phone browser is a
 * realistic way to reach this.
 */

html,
body {
  height: 100%;
  overflow: hidden;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------ auth screens */

.auth {
  flex: 1;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.auth-box {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-box img.mark {
  width: 72px;
  height: 72px;
  filter: var(--mark-filter);
}

.auth-box h1 {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -1.8px;
  margin: 14px 0 0;
}

.auth-box .sub {
  color: var(--text-dim);
  margin: 12px 0 28px;
  line-height: 1.5;
}

label {
  display: block;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  margin: 0 0 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 13px 15px;
  font: inherit;
  font-size: 16px; /* below 16px iOS Safari zooms on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--text);
  background: var(--bg);
}

.field {
  margin-bottom: 14px;
  text-align: left;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 16px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger {
  background: transparent;
  color: #d93636;
  border: 1px solid var(--border);
}

.linkbtn {
  color: var(--text-dim);
  font-size: 15px;
  text-decoration: underline;
  padding: 10px;
}

/* --------------------------------------------------------- social sign-in */

#social {
  margin-bottom: 4px;
}

/* Google renders its own button — required, their branding rules are strict —
   so this only reserves the space and centres it. */
#google-btn {
  display: flex;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 10px;
  color-scheme: light;
}

.social-apple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #000;
  color: #fff;
  height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .social-apple {
    background: #fff;
    color: #000;
  }
}

.or {
  position: relative;
  text-align: center;
  margin: 20px 0 18px;
  color: var(--text-faint);
  font-size: 13px;
}

.or::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.or span {
  position: relative;
  background: var(--bg);
  padding: 0 12px;
}

.error {
  color: #d93636;
  font-size: 14px;
  margin: 12px 0 0;
  min-height: 20px;
}

.notice {
  color: var(--text-dim);
  font-size: 14px;
  margin: 10px 0 0;
}

/* -------------------------------------------------------------------- chat */

.chrome {
  flex: 1;
  display: flex;
  min-height: 0;
}

aside {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.side-head img {
  width: 28px;
  height: 28px;
  filter: var(--mark-filter);
}

.side-head .name {
  font-weight: 800;
  letter-spacing: -0.7px;
  font-size: 19px;
  flex: 1;
}

.icon-btn {
  padding: 6px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 19px;
  line-height: 1;
}

.icon-btn:hover {
  background: var(--surface);
}

.new-chat {
  margin: 12px;
  padding: 11px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}

.chats {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 16px;
}

.chat-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  margin-bottom: 2px;
}

.chat-item:hover {
  background: var(--surface);
}

.chat-item.active {
  background: var(--surface);
}

.chat-item .t {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item .p {
  color: var(--text-faint);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.side-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
  font-size: 13px;
  color: var(--text-faint);
}

.quota {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.quota b {
  display: block;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 2px;
}

/* --------------------------------------------------------------- main pane */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.transcript {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 8px;
}

.thread {
  max-width: 720px;
  margin: 0 auto;
}

.msg {
  margin-bottom: 26px;
}

.msg.user {
  display: flex;
  justify-content: flex-end;
}

.msg.user .body {
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 80%;
  white-space: pre-wrap;
}

.msg.bot .body {
  line-height: 1.7;
}

.msg.bot .body p {
  margin: 0 0 14px;
  color: var(--text);
}

.msg.bot .body p:last-child {
  margin-bottom: 0;
}

.msg.bot .body ul,
.msg.bot .body ol {
  color: var(--text);
  margin: 0 0 14px;
}

.msg.bot .body code {
  background: var(--surface);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.9em;
}

.msg.bot .body pre {
  background: var(--surface);
  padding: 14px;
  border-radius: 12px;
  overflow-x: auto;
}

.msg.bot .body pre code {
  background: none;
  padding: 0;
}

.msg.bot .body h1,
.msg.bot .body h2,
.msg.bot .body h3 {
  font-size: 17px;
  margin: 20px 0 8px;
}

.thinking {
  color: var(--text-faint);
  font-size: 15px;
}

.empty-thread {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}

.empty-thread img {
  width: 64px;
  height: 64px;
  filter: var(--mark-filter);
  opacity: 0.55;
}

.empty-thread h2 {
  font-size: 21px;
  color: var(--text);
  margin: 16px 0 6px;
}

/* -------------------------------------------------------------- composer */

.composer {
  border-top: 1px solid var(--border);
  padding: 14px 20px 20px;
}

.composer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea {
  resize: none;
  max-height: 180px;
  border-radius: 16px;
  line-height: 1.5;
}

.send {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  font-size: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send:disabled {
  opacity: 0.3;
}

/* ------------------------------------------------------------------ modal */

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  background: var(--bg);
  border-radius: 18px;
  padding: 26px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
}

.modal .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.modal .row span:first-child {
  color: var(--text-dim);
}

.modal .row span:last-child {
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.modal .stack > * {
  margin-top: 10px;
}

/* ----------------------------------------------------------------- mobile */

.backdrop {
  display: none;
}

@media (max-width: 820px) {
  aside {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.18);
  }

  body.drawer aside {
    transform: translateX(0);
  }

  body.drawer .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 39;
  }

  .topbar {
    display: flex;
  }

  .transcript {
    padding: 20px 16px 8px;
  }

  .composer {
    padding: 12px 16px 16px;
  }
}
