:root {
  --header-h: 56px;
  --sidebar-w: 320px;
  --footer-h: calc(44px + env(safe-area-inset-bottom, 0px));
}

html,
body {
  height: 100dvh; /* mobile-friendly viewport */
  overflow: hidden; /* no page scroll */
  background: #0b1220;
  color: #e6edf3;
}

/* Header */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: #0f1628;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  justify-content: space-between;
}

/* Sidebar (overlay) */
.sidebar {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  background: #0f1628;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  z-index: 60;
  display: flex;
  flex-direction: column;
}
.sidebar.open {
  transform: translateX(0);
}
.sidebar-header {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-body {
  overflow: auto;
  flex: 1;
}
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-backdrop {
  position: fixed;
  inset: var(--header-h) 0 0 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 55;
}
.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Main area fits between header and footer; no overflow on body */
.page {
  height: calc(100dvh - var(--header-h) - var(--footer-h));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages {
  flex: 1;
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.composer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  padding: 12px 16px 16px;
  background: #0b1220;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.composer .input-group textarea {
  background: #0f1628;
  color: #e6edf3;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Bubbles */
.msg {
  margin-bottom: 14px;
}
.msg .meta {
  font-size: 12px;
  opacity: 0.7;
  margin-bottom: 6px;
}
.msg.user .bubble {
  background: rgba(13, 110, 253, 0.08);
  /* border: 1px solid rgba(13, 110, 253, 0.25); */
}
.msg.assistant .bubble {
  background: rgba(255, 193, 7, 0.06);
  /* border: 1px solid rgba(255, 193, 7, 0.25); */
}
.bubble {
  padding: 12px;
  border-radius: 12px;
}

/* Assistant formatting */
.assistant-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 6px;
  position: relative;
}
.assistant-copy {
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.assistant-text {
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
  word-wrap: break-word;
  white-space: pre-wrap;
  /* max-width: 85ch; */
}
.assistant-text p {
  margin: 0 0 10px;
}
.assistant-text a {
  color: #8ab4ff;
  text-decoration: underline;
}
.assistant-text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  padding: 0 0.25em;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}
.assistant-text .code-block {
  background: #0d1324;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
}
.assistant-text .code-block code {
  display: block;
  white-space: pre;
}

/* Inline copy toast */
.copy-toast {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 1;
}
.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Chat list */
.day-group {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.day-title {
  font-size: 12px;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 6px;
}
.chat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px;
  border-radius: 8px;
}
.chat-row:hover {
  background: rgba(255, 255, 255, 0.05);
}
.chat-item {
  flex: 1 1 auto;
  cursor: pointer;
  min-width: 0;
}
.chat-line-1 {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-line-2 {
  font-size: 12px;
  opacity: 0.7;
}
.chat-delete {
  flex: 0 0 auto;
}

.badge-soft {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Footer bar (never overlaps) */
.app-footer {
  height: var(--footer-h);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #0b1220;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.app-footer .badge {
  margin-left: auto;
}
