/* AIchats — calm, readable, mobile-first. */
:root {
  --bg: #f6f4ef; --panel: #fffdf9; --line: #e4dfd5; --text: #2b2a27; --muted: #7a756b;
  --accent: #3b7a6b; --accent-ink: #fff; --me: #dcefe8; --bot: #ffffff; --err: #b3412e;
  --radius: 14px;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
[hidden] { display: none !important; }

.screen { height: 100dvh; }
.center { display: grid; place-items: center; padding: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem 1.5rem; width: min(380px, 100%); display: flex; flex-direction: column; gap: .8rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.04); text-align: center;
}
.card h1 { margin: 0; font-size: 1.6rem; }
.muted { color: var(--muted); }
.error { color: var(--err); margin: 0; font-size: .95rem; }
input[type=password], select, textarea {
  font: inherit; color: inherit; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: .6rem .75rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn { font: inherit; border: 0; border-radius: 10px; padding: .6rem 1rem; cursor: pointer; background: #ece8df; color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:disabled { opacity: .5; cursor: default; }
.btn.link { background: none; color: var(--muted); padding: .4rem .5rem; }
.btn.link:hover { color: var(--text); }
.btn.block { width: 100%; }
.btn.icon { display: none; background: none; font-size: 1.3rem; padding: .3rem .6rem; }

/* App layout */
.app { display: grid; grid-template-columns: 260px 1fr; }
#sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 1rem; overflow-y: auto; }
#chat-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
#chat-list li { display: flex; align-items: center; border-radius: 10px; }
#chat-list li.active, #chat-list li:hover { background: #efebe3; }
.chat-title { flex: 1; text-align: left; background: none; border: 0; font: inherit; color: inherit; padding: .55rem .6rem; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-del { background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: .3rem .6rem; cursor: pointer; visibility: hidden; }
#chat-list li:hover .chat-del, #chat-list li.active .chat-del { visibility: visible; }

#main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
#topbar { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--panel); }
#who { margin-left: auto; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#messages { flex: 1; overflow-y: auto; padding: 1.2rem 1rem; display: flex; flex-direction: column; gap: .6rem; }
.empty { margin: auto; }
.bubble { max-width: min(720px, 85%); padding: .65rem .9rem; border-radius: var(--radius); white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); }
.bubble.me { align-self: flex-end; background: var(--me); border-color: transparent; border-bottom-right-radius: 4px; }
.bubble.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }

#composer { display: flex; gap: .5rem; padding: .7rem 1rem; border-top: 1px solid var(--line); background: var(--panel); }
#input { flex: 1; resize: none; max-height: 200px; }
.status { margin: 0; padding: 0 1rem .4rem; font-size: .85rem; min-height: 1em; background: var(--panel); }

/* Mobile: sidebar slides over */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .btn.icon { display: inline-block; }
  #sidebar { position: fixed; inset: 0 30% 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 20px rgba(0,0,0,.08); }
  body.sidebar-open #sidebar { transform: none; }
  .chat-del { visibility: visible; }
  .bubble { max-width: 92%; }
  #who { font-size: .8rem; }
}
