:root {
  --bg: #faf9f5;
  --side: #f5f4ef;
  --panel: #ffffff;
  --line: #e8e6dc;
  --line-soft: #eeede4;
  --ink: #1f1e1b;
  --muted: #77756c;
  --faint: #96948a;
  --user: #ecebe4;
  --accent: #d97757;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100%; }

/* -------------------------------------------------------------- sidebar */

.sidebar {
  width: 268px;
  flex: none;
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 10px 10px;
}

.side-top { padding: 0 6px 12px; }

.brand-row { display: flex; align-items: center; gap: 9px; margin-bottom: 14px; }

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #d97757, #e9a08a, #d97757);
}

.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 15px; }

.new-btn {
  display: block;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 500;
}

.new-btn:hover { background: #fbfaf7; }

.side-nav { padding: 4px 6px 8px; }

.side-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 6px 6px;
}

.side-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: #45443e;
  padding: 6px;
}

.dotstat { width: 7px; height: 7px; border-radius: 50%; }
.dotstat.on { background: #4f9d69; }
.dotstat.off { background: #c9c7bd; }

.side-action { margin: 0; }

.side-item {
  width: 100%;
  text-align: left;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 8px 6px;
  cursor: pointer;
}

.side-item:hover { background: #ecebe3; }
.side-item strong { font-weight: 600; }
.side-accent { color: var(--accent); font-weight: 550; }
.side-quiet { color: var(--muted); }

.side-scroll { flex: 1; overflow-y: auto; padding: 0 6px; min-height: 0; }

.side-scroll::-webkit-scrollbar { width: 8px; }
.side-scroll::-webkit-scrollbar-thumb { background: #ded9c9; border-radius: 99px; }
.side-scroll::-webkit-scrollbar-track { background: transparent; }

.side-job {
  display: flex;
  flex-direction: column;
  padding: 7px 6px;
  border-radius: 9px;
  cursor: default;
}

.side-job:hover { background: #ecebe3; }

.side-job-title {
  font-size: 13px;
  color: #35342f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-job-meta { font-size: 11.5px; color: var(--faint); }

.side-empty { font-size: 12.5px; color: var(--faint); padding: 2px 6px; line-height: 1.5; }

.side-foot { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #ded9c9; color: #4a483f;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex: none;
}

.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-size: 13px; font-weight: 550; }
.user-sub { font-size: 11.5px; color: var(--faint); }

/* ------------------------------------------------------------ workspace */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  min-height: 48px;
  z-index: 30;
}

.topbar-title { font-size: 14px; color: var(--muted); font-weight: 500; display: none; }

/* ------------------------------------------------------------------ menu */

.menu { position: relative; }

.menu-btn {
  list-style: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--muted);
  user-select: none;
}

.menu-btn::-webkit-details-marker { display: none; }
.menu-btn:hover { background: #eceef3; }

.menu-panel {
  position: absolute;
  right: 0;
  top: 42px;
  width: 250px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(15, 18, 30, 0.13);
  padding: 8px;
  z-index: 40;
}

.menu-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 6px 8px 4px;
}

.menu-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  font-size: 13px;
}

.menu-line .ok { color: #186b3a; }
.menu-line .off { color: #a33; }

.menu-action { margin: 0; }

.menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 9px 8px;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}

.menu-item:hover { background: #f1f2f6; }
.menu-danger { color: #a33; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }

/* -------------------------------------------------------------- messages */

.convo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.convo.is-empty { justify-content: center; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  scroll-behavior: smooth;
  min-height: 0;
}

.convo.is-empty .messages { flex: 0 0 auto; overflow: visible; }

.messages::-webkit-scrollbar { width: 9px; }
.messages::-webkit-scrollbar-thumb { background: #d6d7de; border-radius: 99px; }
.messages::-webkit-scrollbar-track { background: transparent; }

.row { display: flex; margin: 0 auto 18px; max-width: 660px; width: 100%; }
.row-user { justify-content: flex-end; }
.row-agent { justify-content: flex-start; }

.wrap { display: flex; flex-direction: column; max-width: 82%; }
.wrap-user { align-items: flex-end; }
.wrap-agent { align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.bubble-user {
  background: var(--user);
  color: #26251f;
  border-radius: 18px;
}

.bubble-agent {
  background: transparent;
  border: 0;
  padding: 2px 0 0;
  color: #26251f;
}

.bubble code {
  background: rgba(128, 128, 140, 0.14);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.88em;
}

.bubble ul { margin: 6px 0; padding-left: 18px; }

.stamp {
  font-size: 10.5px;
  color: var(--faint);
  margin-top: 4px;
  padding: 0 4px;
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  width: min(560px, 100%);
  box-shadow: 0 1px 2px rgba(60, 55, 40, 0.05);
}

.card-job { border-left: 3px solid var(--accent); }
.card-draft { border-left: 3px solid #c99a3f; }
.card-status { border-left: 3px solid #4f9d69; }
.card-connect { border-left: 3px solid #c0655f; }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-weight: 640; letter-spacing: -0.01em; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-body { margin: 9px 0 0; font-size: 13.5px; color: #33333d; }

.pill {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eceef3;
  color: var(--muted);
  white-space: nowrap;
}

.pill-amber { background: #fdf3dd; color: #8a6208; }
.pill-rose { background: #fdeaee; color: #99253c; }

.draft-block { margin-top: 10px; }
.draft-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.draft-text {
  margin: 4px 0 0;
  font-family: inherit;
  font-size: 13.5px;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: #fafafb;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
}

.status-row { display: flex; align-items: flex-start; gap: 10px; }
.status-row .card-body { margin: 0; }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3a9e63;
  margin-top: 7px;
  flex: none;
}

.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }

.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 7px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.06s ease, background 0.12s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #33333d; }

.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #f3f4f7; }

/* ------------------------------------------------------------ empty state */

.notice {
  max-width: 660px;
  margin: 0 auto 16px;
  background: #fdf3dd;
  border: 1px solid #f0dfb2;
  color: #6d4d06;
  padding: 10px 13px;
  border-radius: 12px;
  font-size: 13px;
}

.empty { max-width: 520px; margin: 8vh auto 0; text-align: center; color: var(--muted); }

.hero { max-width: 620px; margin: 0 auto; text-align: center; padding: 0 8px; }

.hero-mark {
  width: 34px;
  height: 34px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #d97757, #e9a08a, #d97757);
  opacity: 0.9;
}

.hero-title {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: #1f1e1b;
  margin: 0 0 26px;
}

.hero-sub {
  color: #77756c;
  font-size: 14px;
  max-width: 480px;
  margin: 0 auto 20px;
}

.suggests { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* Terms / privacy pages */
.legal { max-width: 620px; margin: 8vh auto; padding: 0 20px; color: #3a3934; font-size: 15px; line-height: 1.65; }
.legal h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: 28px; color: #1f1e1b; margin: 0 0 20px; }
.legal p { margin: 0 0 16px; }
.legal a { color: var(--accent); }
.legal-back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 22px; }
.legal-foot { color: var(--faint); font-size: 12.5px; }

.suggest {
  font-family: inherit;
  font-size: 12.5px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  color: #4a483f;
  text-align: center;
}

.suggest:hover { background: #f1efe7; }

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

.composer {
  flex: none;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}

.composer-inner {
  max-width: 660px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 10px 10px 10px 12px;
  box-shadow: 0 2px 10px rgba(60, 55, 40, 0.06);
}

.composer-input {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 180px;
  padding: 6px 0;
  background: transparent;
  color: var(--ink);
}

.send {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 0;
  background: #d97757;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.send:hover { background: #c96744; }
.send:disabled { opacity: 0.4; cursor: default; }

.composer-hint {
  max-width: 660px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--faint);
}

/* --------------------------------------------------------------- typing */

.typing { display: flex; gap: 4px; padding: 13px 15px; }
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b5b3a8;
  animation: blink 1.2s infinite ease-in-out;
}

.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.htmx-request .send { opacity: 0.55; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar-title { display: block; }
}

@media (max-width: 560px) {
  .wrap { max-width: 92%; }
  .messages { padding: 14px 12px 6px; }
  .composer { padding-left: 12px; padding-right: 12px; }
}
