:root {
  --bg: #f7f5f2;
  --panel: #efede8;
  --card: #ffffff;
  --ink: #252421;
  --muted: #77736c;
  --line: #dedbd4;
  --accent: #c6613f;
  --accent-dark: #a94d31;
  --shadow: 0 18px 55px rgba(56, 48, 39, .12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none; }

.login-view {
  min-height: 100%; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(circle at 18% 20%, rgba(198, 97, 63, .12), transparent 32%),
    radial-gradient(circle at 84% 75%, rgba(114, 100, 81, .11), transparent 34%), var(--bg);
}
.login-card {
  width: min(430px, 100%); padding: 44px; border: 1px solid rgba(255,255,255,.8);
  border-radius: 24px; background: rgba(255,255,255,.82); box-shadow: var(--shadow); backdrop-filter: blur(14px);
}
.brand-mark {
  width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 10px;
  background: var(--accent); color: white; font-size: 12px; font-weight: 750; letter-spacing: -.4px;
}
.brand-mark.large { width: 48px; height: 48px; border-radius: 14px; margin-bottom: 18px; font-size: 15px; }
.login-card h1 { margin: 0 0 8px; font: 500 30px/1.2 Georgia, serif; }
.login-card > p { margin: 0 0 30px; color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin: 16px 0; color: #55514b; font-size: 13px; font-weight: 600; }
.login-card input {
  width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: white;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(198,97,63,.13); }
.primary { border: 0; border-radius: 11px; background: var(--accent); color: white; padding: 13px 18px; cursor: pointer; font-weight: 650; }
.primary:hover { background: var(--accent-dark); }
.full { width: 100%; margin-top: 8px; }
.form-error { min-height: 20px; color: #a63f32; font-size: 13px; }

.app { height: 100%; display: grid; grid-template-columns: 276px 1fr; }
.sidebar { min-width: 0; display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); }
.sidebar-top { height: 64px; padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 11px; font: 600 20px/1 Georgia, serif; }
.new-chat {
  margin: 6px 12px 16px; padding: 11px 13px; display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.6); cursor: pointer; text-align: left;
}
.new-chat:hover { background: white; }
.new-chat span { font-size: 20px; line-height: 16px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 9px; }
.chat-item {
  width: 100%; display: flex; align-items: center; gap: 8px; padding: 10px 11px; margin: 2px 0;
  border: 0; border-radius: 9px; background: transparent; cursor: pointer; text-align: left; color: #55514c;
}
.chat-item:hover { background: rgba(255,255,255,.55); }
.chat-item.active { color: var(--ink); background: white; box-shadow: 0 1px 1px rgba(0,0,0,.03); }
.chat-item-title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.delete-chat { opacity: 0; border: 0; background: transparent; cursor: pointer; color: #8a847c; padding: 2px 3px; }
.chat-item:hover .delete-chat { opacity: 1; }
.sidebar-bottom { padding: 14px 17px 18px; border-top: 1px solid var(--line); }
.server-status { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #54a26b; box-shadow: 0 0 0 3px rgba(84,162,107,.12); }
.logout { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 12px 0 0; font-size: 12px; }

.main { min-width: 0; height: 100%; display: grid; grid-template-rows: 64px minmax(0,1fr) auto; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 0 24px; border-bottom: 1px solid rgba(222,219,212,.8); }
.top-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 14px; }
#modelSelect { border: 1px solid var(--line); border-radius: 9px; background: transparent; padding: 7px 9px; color: #55514b; font-size: 13px; }
.conversation { overflow-y: auto; scroll-behavior: smooth; }
.welcome { width: min(720px, calc(100% - 36px)); min-height: 100%; margin: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 0 100px; text-align: center; }
.orb { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; background: #eee8df; color: var(--accent); font-size: 26px; margin-bottom: 20px; }
.welcome h1 { margin: 0; font: 500 clamp(30px,4vw,42px)/1.2 Georgia, serif; letter-spacing: -.5px; }
.welcome > p { margin: 12px 0 28px; color: var(--muted); }
.suggestions { width: min(640px,100%); display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.suggestions button { padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.65); cursor: pointer; color: #5d5851; text-align: left; font-size: 13px; line-height: 1.4; }
.suggestions button:hover { background: white; border-color: #cec9c0; }
.messages { width: min(820px, calc(100% - 36px)); margin: 0 auto; padding: 34px 0 70px; }
.message { display: grid; grid-template-columns: 34px minmax(0,1fr); gap: 14px; margin: 0 0 30px; animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }
.avatar { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; background: #e8e3dc; color: #625d56; font-size: 12px; font-weight: 700; }
.message.user .avatar { background: #dad5cd; }
.message.assistant .avatar { background: var(--accent); color: white; }
.message-body { min-width: 0; padding-top: 4px; line-height: 1.66; font-size: 15px; }
.message-body p { margin: 0 0 12px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body h1,.message-body h2,.message-body h3 { margin: 22px 0 10px; font-family: Georgia,serif; line-height: 1.3; }
.message-body h1 { font-size: 25px; }.message-body h2 { font-size: 21px; }.message-body h3 { font-size: 17px; }
.message-body pre { position: relative; overflow-x: auto; margin: 14px 0; padding: 16px; border-radius: 11px; background: #272621; color: #ece8df; font: 13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace; }
.message-body code { padding: 2px 5px; border-radius: 5px; background: #eae6df; font: 13px ui-monospace,SFMono-Regular,Consolas,monospace; }
.message-body pre code { padding: 0; background: none; }
.message-body ul,.message-body ol { margin: 10px 0; padding-left: 24px; }
.message-body blockquote { margin: 14px 0; padding-left: 14px; border-left: 3px solid #c9c2b8; color: #625d56; }
.message-body a { color: #9c4b33; }
.message-files { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 10px; }
.file-chip { display: inline-flex; gap: 7px; align-items: center; max-width: 240px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #625d56; font-size: 12px; text-decoration: none; }
.file-chip:hover { border-color: #beb6ab; color: var(--accent-dark); }
.thinking { display: inline-flex; gap: 5px; align-items: center; color: var(--muted); }
.thinking i { width: 5px; height: 5px; background: var(--muted); border-radius: 50%; animation: pulse 1.3s infinite; }
.thinking i:nth-child(2) { animation-delay: .16s; }.thinking i:nth-child(3) { animation-delay: .32s; }
@keyframes pulse { 0%,70%,100% { opacity:.25; transform:translateY(0) } 35% { opacity:1; transform:translateY(-3px) } }

.composer-wrap { padding: 0 24px max(12px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 15%); }
.attachments { width: min(820px,100%); margin: 0 auto 7px; display: flex; gap: 7px; overflow-x: auto; }
.pending-file { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; font-size: 12px; }
.pending-file button { border: 0; background: none; cursor: pointer; color: var(--muted); }
.composer { width: min(820px,100%); min-height: 58px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; padding: 9px; border: 1px solid #d6d1c8; border-radius: 17px; background: white; box-shadow: 0 8px 32px rgba(71,61,48,.08); }
.composer:focus-within { border-color: #c4bdb2; box-shadow: 0 8px 35px rgba(71,61,48,.12); }
.composer textarea { flex: 1; max-height: 180px; resize: none; border: 0; outline: 0; padding: 9px 4px 8px; background: transparent; line-height: 1.45; }
.attach,.send,.icon { width: 39px; height: 39px; flex: 0 0 auto; display: grid; place-items: center; border: 0; border-radius: 11px; cursor: pointer; }
.attach { background: transparent; color: #726c64; font-size: 24px; }
.attach:hover { background: #f1efeb; }
.send { background: var(--accent); color: white; font-size: 21px; }
.send:hover { background: var(--accent-dark); }
.send:disabled { opacity: .4; cursor: default; }
.composer-note { margin: 7px auto 0; text-align: center; color: #99938b; font-size: 10px; }
.toast { position: fixed; left: 50%; bottom: 92px; z-index: 50; transform: translateX(-50%); max-width: calc(100% - 30px); padding: 11px 15px; border-radius: 10px; background: #302e2a; color: white; box-shadow: var(--shadow); font-size: 13px; }

@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .app { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px,86vw); z-index: 30; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .backdrop { display: block !important; position: fixed; inset: 0; z-index: 20; background: rgba(35,31,27,.28); backdrop-filter: blur(2px); }
  .backdrop.hidden { display: none !important; }
  .main { height: 100%; grid-template-rows: 56px minmax(0,1fr) auto; }
  .topbar { padding: 0 12px; }
  .icon { background: transparent; font-size: 20px; }
  .welcome { padding-bottom: 50px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestions button:nth-child(n+3) { display: none; }
  .messages { width: calc(100% - 24px); padding-top: 24px; }
  .message { grid-template-columns: 30px minmax(0,1fr); gap: 10px; }
  .avatar { width: 29px; height: 29px; }
  .composer-wrap { padding-left: 10px; padding-right: 10px; }
  .composer-note { display: none; }
  .login-card { padding: 32px 24px; }
}
