:root {
  color-scheme: dark;
  --green: #087965;
  --green-hover: #09836d;
  --mint: #244b39;
  --ink: #e3ede7;
  --muted: #a0b2a8;
  --line: #34443c;
  --surface: #1b2420;
  --surface-raised: #222d27;
  --bg: #111815;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", sans-serif;
  color: var(--ink);
  font-size: 15px;
}

* { box-sizing: border-box; }
body { margin: 0; background: #111815; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid #48c6a0;
  outline-offset: 3px;
}
.hidden { display: none !important; }
.workspace {
  display: flex;
  height: 100dvh;
  max-width: 1680px;
  margin: auto;
  background: var(--surface);
  overflow: hidden;
}
.sidebar {
  width: 360px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: #19221e;
  border-right: 1px solid var(--line);
}
.brand-row { height: 94px; display: flex; align-items: center; gap: 12px; padding: 20px; }
.brand-row h1 { font-size: 20px; letter-spacing: -.8px; margin: 0 0 4px; }
.brand-small {
  width: 43px; height: 43px; border-radius: 13px; background: var(--green); color: white;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 29px;
  letter-spacing: -4px; padding-right: 5px;
}
.brand-small span { color: #a9e2b8; font-size: 23px; align-self: flex-end; margin-bottom: 3px; }
.brand-row .icon-button { margin-left: auto; }
.connection { color: var(--muted); font-size: 12px; margin: 0; }
.connection.online { color: #65d3a0; }
.sidebar-controls { padding: 5px 18px 0; }
.field-label { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); margin-bottom: 6px; font-weight: 700; }
select {
  width: 100%; border: 1px solid var(--line); background: #202a25; border-radius: 10px;
  padding: 11px; color: var(--ink); font-weight: 600;
}
.search-wrap {
  display: flex; align-items: center; gap: 9px; background: #222d27; border-radius: 9px;
  margin: 14px 0; padding: 0 12px; color: var(--muted);
}
.search-wrap span { font-size: 27px; }
.search-wrap input { width: 100%; border: 0; padding: 11px 0; background: transparent; outline: 0; color: var(--ink); min-width: 0; }
.search-wrap input::placeholder, textarea::placeholder, input::placeholder { color: #87998f; opacity: 1; }
.list-tabs { display: flex; align-items: center; gap: 7px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 7px 13px; border-radius: 20px; font-size: 13px; font-weight: 600; }
.tab.active { background: #214534; color: #a6e4bf; }
#thread-count { margin-left: auto; color: #93a69b; font-size: 12px; }
.thread-list { overflow: auto; flex: 1; padding: 5px 8px; }
.thread-row { border: 0; text-align: left; background: transparent; display: flex; gap: 12px; width: 100%; padding: 15px 10px; border-radius: 9px; align-items: center; color: var(--ink); }
.thread-row:hover { background: #222d27; }
.thread-row.selected { background: #263c30; }
.thread-avatar, .chat-avatar { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #2a3c32; color: #a4d2b4; font-weight: 600; flex-shrink: 0; width: 43px; height: 43px; font-size: 18px; }
.thread-copy { min-width: 0; flex: 1; }
.thread-title { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.thread-preview { display: block; font-size: 12px; color: var(--muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.thread-date { font-size: 10px; color: #93a69b; align-self: flex-start; padding-top: 3px; }
.sidebar-footer { padding: 14px 20px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.tiny-dot { display: inline-block; width: 6px; height: 6px; background: #76c99a; border-radius: 50%; margin-right: 5px; }
.conversation { flex: 1; min-width: 0; position: relative; background: #151e1a; }
.welcome { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 32px; }
.welcome-orbit { width: 180px; height: 180px; border: 1px solid #344b3d; display: grid; place-items: center; border-radius: 50%; margin-bottom: 40px; background: radial-gradient(circle, #293d30 0%, #151e1a 70%); }
.brand-mark { width: 83px; height: 83px; border-radius: 25px; display: flex; align-items: center; justify-content: center; background: var(--green); color: white; font-size: 58px; font-weight: 800; letter-spacing: -8px; padding-right: 9px; box-shadow: 0 14px 30px #0005; }
.brand-mark span { color: #b5e9bf; font-size: 40px; align-self: flex-end; margin-bottom: 5px; }
.eyebrow { font-size: 10px; letter-spacing: 2.5px; font-weight: 700; color: #9cb9a5; }
.welcome h2 { font-size: 34px; line-height: 1.5; letter-spacing: -1px; font-weight: 600; margin: 14px 0; }
.welcome > p:not(.eyebrow) { font-size: 14px; color: var(--muted); line-height: 1.9; }
.welcome-note { margin-top: 50px; color: #91a499; font-size: 11px; }
.chat { height: 100%; display: flex; flex-direction: column; }
.chat-header { display: flex; align-items: center; gap: 12px; background: #1b2420; padding: 15px 24px; border-bottom: 1px solid var(--line); min-height: 80px; }
.chat-heading { min-width: 0; flex: 1; }
.chat-heading h2 { font-size: 16px; margin: 0 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-heading p { color: var(--muted); font-size: 12px; margin: 0; }
.icon-button { border: 0; background: transparent; border-radius: 50%; width: 38px; height: 38px; font-size: 24px; color: #b0c2b7; flex-shrink: 0; }
.icon-button:hover { background: #2a3930; }
.back-button { display: none; font-size: 36px; }
.notice { background: #493a1e; color: #f0d89c; font-size: 12px; padding: 10px 24px; line-height: 1.6; }
.message-scroll { flex: 1; min-height: 0; overflow: auto; background-color: #151e1a; background-image: radial-gradient(#8ea39720 .7px, transparent .7px); background-size: 18px 18px; padding: 16px clamp(16px, 4vw, 66px) 24px; }
.history-top { text-align: center; margin: 4px 0 23px; }
.text-button { background: #29352e; border: 1px solid #43564a; border-radius: 20px; color: #bdd0c3; font-size: 11px; padding: 8px 16px; }
.text-button:hover { background: #34443a; }
.messages { display: flex; flex-direction: column; gap: 13px; }
.bubble { align-self: flex-start; background: #25302a; padding: 12px 15px 8px; border-radius: 2px 12px 12px; max-width: min(88%, 780px); box-shadow: 0 1px 1px #0004; min-width: 100px; }
.bubble.user { align-self: flex-end; background: #244b39; border-radius: 12px 2px 12px 12px; }
.bubble.pending { opacity: .8; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.75; tab-size: 2; }
.bubble-meta { display: flex; justify-content: flex-end; gap: 6px; font-size: 10px; color: #a1b2a7; margin-top: 7px; }
.bubble-meta .receipt { color: #8ed7af; }
.day-divider { text-align: center; align-self: center; padding: 6px 12px; font-size: 10px; color: #b6c8ba; background: #29352ecc; border-radius: 7px; margin: 10px 0; }
.compose-status { font-size: 11px; color: #a5b8aa; min-height: 24px; padding: 5px 22px; background: #1d2822; }
.composer { background: #1d2822; display: flex; gap: 12px; align-items: flex-end; padding: 4px 20px max(16px, env(safe-area-inset-bottom)); }
.composer textarea { resize: none; min-height: 47px; max-height: 150px; border: 1px solid #405146; background: #222d27; border-radius: 12px; padding: 13px 15px; color: var(--ink); flex: 1; min-width: 0; line-height: 1.5; }
.send-button { border: 0; border-radius: 50%; background: var(--green); color: #fff; width: 47px; height: 47px; display: grid; place-items: center; flex-shrink: 0; }
.send-button:hover { background: var(--green-hover); }
.send-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.list-placeholder { text-align: center; padding: 35px 14px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #30483b; color: #f2f8f4; padding: 13px 20px; border-radius: 10px; z-index: 20; max-width: 90%; font-size: 13px; box-shadow: 0 6px 30px #0008; }
.login-body { min-height: 100dvh; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 20%, #263b2e, #111815 70%); padding: 24px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand-mark { margin-bottom: 40px; width: 64px; height: 64px; font-size: 44px; border-radius: 19px; letter-spacing: -6px; }
.login-card .brand-mark span { font-size: 30px; }
.login-card h1 { font-size: 38px; letter-spacing: -1.8px; margin: 14px 0; }
.login-intro { font-size: 14px; color: var(--muted); margin: 0 0 36px; line-height: 1.8; }
.login-card label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 10px; }
.login-card input { width: 100%; border: 1px solid #405146; border-radius: 10px; background: #1d2822; padding: 15px; min-height: 52px; color: var(--ink); }
.primary { width: 100%; display: flex; justify-content: space-between; background: var(--green); color: white; border: 0; padding: 16px 19px; border-radius: 10px; margin-top: 15px; font-weight: 600; }
.primary:hover { background: var(--green-hover); }
.login-foot { font-size: 11px; color: #9aada1; margin-top: 40px; }
#login-error { font-size: 13px; color: #ff9388; min-height: 20px; }

@media (min-width: 1400px) {
  body { padding: 22px; }
  .workspace { height: calc(100dvh - 44px); border-radius: 14px; box-shadow: 0 10px 60px #0005; }
}

@media (max-width: 700px) {
  body { background: #111815; }
  .workspace { height: 100dvh; }
  .sidebar { width: 100%; min-width: 0; border: 0; }
  .brand-row { height: 86px; }
  .conversation { display: none; }
  .in-chat .sidebar { display: none; }
  .in-chat .conversation { display: block; width: 100%; }
  .back-button { display: block; font-size: 36px; }
  .chat-header { padding: 12px 10px; gap: 7px; min-height: 72px; }
  .chat-avatar { width: 36px; height: 36px; font-size: 15px; }
  .chat-heading h2 { font-size: 14px; }
  .chat-heading p { font-size: 11px; }
  .message-scroll { padding: 10px 12px 20px; }
  .bubble { max-width: 91%; padding: 10px 12px 7px; }
  .bubble-text { font-size: 14px; }
  .composer { padding: 4px 10px max(12px, env(safe-area-inset-bottom)); gap: 8px; }
  .compose-status { padding-left: 14px; }
  .notice { padding: 9px 14px; }
  .sidebar-controls { padding-top: 0; }
}

.new-dialog { width: min(480px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 26px; color: var(--ink); box-shadow: 0 20px 80px #0009; background: #1b2420; }
.new-dialog::backdrop { background: #050b08b8; backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.dialog-heading h2 { margin: 8px 0 0; font-size: 24px; letter-spacing: -.6px; }
.dialog-heading .eyebrow { margin-top: 0; }
.new-dialog label { display: block; font-size: 12px; font-weight: 600; margin: 16px 0 8px; }
.new-dialog input, .new-dialog textarea { width: 100%; border: 1px solid #405146; padding: 12px; border-radius: 9px; background: #222d27; color: var(--ink); resize: vertical; line-height: 1.6; }
.new-dialog textarea { max-height: 35dvh; min-height: 110px; }
.optional { font-weight: 400; color: var(--muted); }
.new-status { font-size: 12px; line-height: 1.7; color: var(--muted); margin-bottom: 0; }
.brand-row #new-chat { margin-left: auto; }
.brand-row #logout { margin-left: 0; }
@media (max-width: 700px) { .new-dialog { padding: 22px; } }
