:root {
  color-scheme: light;
  --paper: #f5f3ed;
  --paper-deep: #ebe8df;
  --card: #fffefb;
  --ink: #20231f;
  --muted: #747971;
  --line: #dcd9cf;
  --green: #286b57;
  --green-dark: #1e5545;
  --green-soft: #e2eee8;
  --terracotta: #b9684d;
  --danger: #a84a46;
  --shadow: 0 24px 70px rgba(39, 45, 38, .13);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none; }
.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .18em;
}

.app-shell { height: 100%; display: flex; overflow: hidden; }
.sidebar {
  width: 278px;
  flex: 0 0 278px;
  display: flex;
  flex-direction: column;
  padding: 24px 14px 16px;
  background: var(--paper-deep);
  border-right: 1px solid var(--line);
}
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; }
.brand-mark, .login-brand span {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--green);
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(40, 107, 87, .22);
}
.brand-copy { min-width: 0; }
.brand-copy strong, .brand-copy span { display: block; }
.brand-copy strong { font-family: Georgia, "Noto Serif SC", serif; font-size: 17px; }
.brand-copy span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.new-chat-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid #d3d0c6;
  border-radius: 12px;
  background: rgba(255, 255, 255, .64);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: .18s ease;
}
.new-chat-button:hover { background: var(--card); transform: translateY(-1px); }
.new-chat-button span { font-size: 19px; font-weight: 400; }
.sidebar-label { padding: 25px 10px 9px; color: #8b8f87; font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.conversation-list { flex: 1; overflow-y: auto; }
.conversation-item {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 2px;
  padding: 10px 36px 10px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #525750;
  cursor: pointer;
  text-align: left;
}
.conversation-item:hover, .conversation-item.active { background: rgba(255, 255, 255, .68); color: var(--ink); }
.conversation-item.active { box-shadow: inset 2px 0 var(--green); }
.conversation-item .bubble { color: #8a8e86; }
.conversation-item .item-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.delete-conversation {
  opacity: 0;
  position: absolute;
  right: 6px;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 8px;
  color: #888d85;
  background: transparent;
  cursor: pointer;
}
.conversation-item:hover .delete-conversation { opacity: 1; }
.delete-conversation:hover { color: var(--danger); background: #f5dfdc; }
.sidebar-footer { padding-top: 11px; border-top: 1px solid var(--line); }
.settings-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.settings-button:hover { background: rgba(255, 255, 255, .6); }
.settings-icon { font-size: 17px; }
.settings-button strong, .settings-button small { display: block; }
.settings-button strong { font-size: 12px; }
.settings-button small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.sidebar-scrim { display: none; }

.main-panel { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.topbar {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 26px;
  border-bottom: 1px solid rgba(220, 217, 207, .8);
  background: rgba(245, 243, 237, .88);
  backdrop-filter: blur(14px);
  z-index: 3;
}
.conversation-heading { min-width: 0; flex: 1; }
.conversation-heading input {
  width: min(380px, 100%);
  display: block;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 13px;
  font-weight: 750;
}
.conversation-heading input:focus { border-color: var(--line); background: white; }
.conversation-heading span { display: block; padding-left: 6px; margin-top: 2px; color: var(--muted); font-size: 9px; }
select {
  max-width: 230px;
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  color: #4f554e;
  background: white;
  font-size: 11px;
}
select:focus { border-color: #91b3a7; box-shadow: 0 0 0 3px rgba(40, 107, 87, .08); }
.icon-button {
  width: 35px;
  height: 35px;
  border: 0;
  border-radius: 10px;
  color: #656a63;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
}
.icon-button:hover { background: rgba(0, 0, 0, .05); }

.chat-stage { flex: 1; min-height: 0; overflow-y: auto; scroll-behavior: smooth; }
.welcome {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 38px 24px 95px;
}
.welcome-orb {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  border-radius: 19px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 24px;
}
.welcome h1 {
  margin: 9px 0 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: clamp(30px, 4vw, 46px);
  font-weight: 500;
  letter-spacing: -.04em;
}
.welcome-copy { margin: 13px 0 30px; color: var(--muted); font-size: 13px; }
.suggestions { width: min(530px, 100%); display: grid; gap: 8px; }
.suggestions button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #555b53;
  background: rgba(255, 255, 255, .58);
  cursor: pointer;
  text-align: left;
  font-size: 12px;
  transition: .16s;
}
.suggestions button:hover { border-color: #c3c7bc; background: white; transform: translateX(2px); }
.suggestions button span { color: #989d95; }
.messages { width: min(860px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 135px; }
.message { display: flex; gap: 14px; margin-bottom: 29px; animation: enter .22s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.message.user { flex-direction: row-reverse; }
.avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 850;
}
.message.user .avatar { color: #635d50; background: #e6e0d4; }
.message-body { min-width: 0; max-width: min(700px, calc(100% - 50px)); }
.message-meta { margin: 2px 0 7px; color: #8d918a; font-size: 9px; }
.message.user .message-meta { text-align: right; }
.message-content { line-height: 1.72; overflow-wrap: anywhere; font-size: 14px; }
.message-content p { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content h1, .message-content h2, .message-content h3 { margin: 20px 0 8px; font-family: Georgia, "Noto Serif SC", serif; }
.message-content h1 { font-size: 22px; } .message-content h2 { font-size: 18px; } .message-content h3 { font-size: 16px; }
.message-content ul, .message-content ol { margin: 8px 0; padding-left: 22px; }
.message-content pre { max-width: 100%; overflow-x: auto; padding: 14px; border-radius: 11px; color: #e7eee9; background: #26302b; font-size: 12px; }
.message-content code { padding: 2px 5px; border-radius: 5px; background: #e9e7e0; font-family: "Cascadia Code", Consolas, monospace; font-size: .88em; }
.message-content pre code { padding: 0; background: transparent; }
.message.user .message-content { padding: 10px 14px; border-radius: 16px 4px 16px 16px; background: #e8e4da; white-space: pre-wrap; }
.message.error .message-content { color: var(--danger); }
.message-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; margin-bottom: 8px; }
.attachment-link, .message-photo {
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #50564f;
  background: rgba(255, 255, 255, .72);
  text-decoration: none;
  font-size: 10px;
}
.message-photo { display: block; max-width: 180px; padding: 0; overflow: hidden; }
.message-photo img { width: 100%; max-height: 140px; display: block; object-fit: cover; }
.generated-image { display: block; max-width: min(560px, 100%); border-radius: 16px; box-shadow: var(--shadow); }
.image-actions { margin-top: 9px; }
.image-actions a { color: var(--green); text-decoration: none; font-size: 11px; }
.typing { display: flex; gap: 5px; padding: 9px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #969c94; animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.composer-wrap { position: relative; z-index: 4; width: min(790px, calc(100% - 34px)); margin: -105px auto 0; padding-bottom: 10px; }
.composer-wrap::before { content: ""; position: absolute; inset: -38px -70px 0; z-index: -1; pointer-events: none; background: linear-gradient(transparent, var(--paper) 34%); }
.mode-switch { display: inline-flex; margin: 0 0 7px 8px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #e7e4dc; }
.mode-switch button { padding: 5px 14px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; font-size: 10px; font-weight: 750; }
.mode-switch button.active { color: var(--green); background: white; box-shadow: 0 2px 8px rgba(0, 0, 0, .07); }
.composer { padding: 12px 12px 9px 15px; border: 1px solid #d4d1c8; border-radius: 18px; background: white; box-shadow: 0 11px 36px rgba(42, 47, 40, .1); }
.composer:focus-within { border-color: #96b9ad; box-shadow: 0 11px 38px rgba(40, 107, 87, .1), 0 0 0 3px rgba(40, 107, 87, .05); }
.composer textarea { width: 100%; max-height: 160px; display: block; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; line-height: 1.55; font-size: 14px; }
.composer textarea::placeholder { color: #a0a49e; }
.composer-bottom { min-height: 32px; display: flex; align-items: center; margin-top: 7px; }
.attach-button { flex: 0 0 29px; width: 29px; height: 29px; margin-right: 8px; border: 1px solid var(--line); border-radius: 9px; color: #6f746d; background: #fafafa; cursor: pointer; font-size: 18px; }
.attach-button:hover { color: var(--green); border-color: #9ebdb2; background: var(--green-soft); }
.attach-button:disabled { opacity: .5; cursor: wait; }
.mode-hint { flex: 1; color: #9ca09a; font-size: 9px; }
.image-size { display: flex; align-items: center; gap: 5px; margin-right: 8px; color: var(--muted); font-size: 9px; }
.image-size select { padding: 4px 22px 4px 7px; font-size: 9px; }
.send-button { width: 33px; height: 33px; border: 0; border-radius: 10px; color: white; background: var(--green); cursor: pointer; font-size: 18px; transition: .15s; }
.send-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.send-button:disabled { opacity: .45; cursor: wait; transform: none; }
.attachment-tray { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; }
.attachment-chip { position: relative; flex: 0 0 auto; max-width: 130px; padding: 8px 24px 8px 9px; border: 1px solid var(--line); border-radius: 10px; color: #596058; background: #fafaf7; font-size: 9px; }
.attachment-chip strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attachment-chip small { color: var(--muted); }
.remove-attachment { position: absolute; top: 4px; right: 4px; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 50%; color: white; background: #70766e; cursor: pointer; line-height: 15px; }
.disclaimer { margin: 7px 0 0; color: #9b9f98; text-align: center; font-size: 8px; }

.lock-screen { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: minmax(360px, 1.08fr) minmax(420px, .92fr); background: var(--paper); }
.lock-screen.unlocked { display: none; }
.lock-visual { position: relative; overflow: hidden; background:
  radial-gradient(circle at 72% 22%, rgba(235, 197, 163, .78), transparent 27%),
  radial-gradient(circle at 22% 78%, rgba(84, 125, 106, .9), transparent 31%),
  linear-gradient(145deg, #233d34 0%, #486f5d 40%, #c58769 100%); }
.lock-visual::before, .lock-visual::after { content: ""; position: absolute; border-radius: 50%; filter: blur(1px); }
.lock-visual::before { width: 72vw; height: 72vw; left: -45vw; top: -22vw; border: 1px solid rgba(255, 255, 255, .2); box-shadow: 0 0 0 90px rgba(255,255,255,.025), 0 0 0 180px rgba(255,255,255,.02); }
.lock-visual::after { width: 440px; height: 440px; right: -180px; bottom: -190px; background: rgba(246, 213, 181, .22); }
.grain { position: absolute; inset: 0; opacity: .12; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E"); }
.lock-quote { position: absolute; left: 9%; bottom: 11%; color: rgba(255, 255, 255, .9); }
.lock-quote span { font-size: 24px; }
.lock-quote p { margin: 16px 0 0; font-family: Georgia, serif; font-size: clamp(22px, 3vw, 38px); line-height: 1.18; letter-spacing: -.025em; }
.login-panel { display: grid; place-items: center; padding: 45px; }
.login-card { width: min(410px, 100%); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 70px; }
.login-brand span { width: 42px; height: 42px; }
.login-brand strong { font-family: Georgia, serif; font-size: 20px; }
.login-card h1 { margin: 10px 0 0; font-family: Georgia, "Noto Serif SC", serif; font-size: 42px; font-weight: 500; letter-spacing: -.035em; }
.login-copy { margin: 12px 0 32px; color: var(--muted); font-size: 13px; }
.login-card label { display: block; margin-bottom: 8px; color: #555b54; font-size: 11px; font-weight: 700; }
.password-field { display: flex; border-bottom: 1px solid #bfc2ba; }
.password-field:focus-within { border-color: var(--green); }
.password-field input { flex: 1; min-width: 0; padding: 12px 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 18px; letter-spacing: .18em; }
.password-field button { border: 0; color: var(--green); background: transparent; cursor: pointer; font-size: 10px; }
.login-error { min-height: 19px; margin: 8px 0 4px; color: var(--danger); font-size: 10px; }
.login-button { width: 100%; display: flex; justify-content: space-between; padding: 13px 16px; border: 0; border-radius: 11px; color: white; background: var(--green); cursor: pointer; font-size: 12px; font-weight: 750; }
.login-button:hover { background: var(--green-dark); }
.login-button:disabled { opacity: .55; cursor: wait; }
.privacy-note { margin: 28px 0 0; color: #888d86; text-align: center; font-size: 9px; }
.privacy-note span { color: var(--green); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(30, 35, 30, .42); backdrop-filter: blur(5px); }
.modal { width: min(480px, 100%); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 5px 0 0; font-family: Georgia, serif; font-weight: 500; }
.settings-content { display: grid; gap: 10px; padding: 22px 24px 25px; }
.connection-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f5; }
.connection-card div { display: flex; align-items: center; gap: 8px; }
.connection-card strong { font-size: 12px; }
.connection-card p { margin: 7px 0 0 17px; color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #3d9b73; box-shadow: 0 0 0 3px #dff0e8; }
.secondary-button, .danger-button { padding: 10px 13px; border-radius: 10px; cursor: pointer; font-size: 11px; font-weight: 700; }
.secondary-button { border: 1px solid var(--line); background: white; }
.danger-button { border: 1px solid #e3c4c1; color: var(--danger); background: #fff8f7; }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 120; padding: 9px 14px; border-radius: 9px; color: white; background: #30342f; opacity: 0; transform: translate(-50%, 14px); pointer-events: none; transition: .2s; font-size: 11px; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 820px) {
  .lock-screen { grid-template-columns: 1fr; }
  .lock-visual { display: none; }
  .login-panel { padding: 28px; }
  .login-brand { margin-bottom: 55px; }
}

@media (max-width: 760px) {
  .mobile-only { display: grid; place-items: center; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; transform: translateX(-100%); transition: .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 19; background: rgba(28, 33, 28, .28); }
  .brand-row .icon-button { margin-left: auto; }
  .topbar { padding: 9px 12px; }
  .conversation-heading span { display: none; }
  .topbar select { max-width: 135px; }
  .welcome { padding-inline: 18px; }
  .welcome h1 { text-align: center; }
  .welcome-copy { text-align: center; }
  .messages { width: calc(100% - 22px); }
  .composer-wrap { width: calc(100% - 20px); }
  .message { gap: 8px; }
  .avatar { flex-basis: 29px; width: 29px; height: 29px; }
  .message-body { max-width: calc(100% - 38px); }
  .mode-hint { display: none; }
  .lock-screen { min-height: 100dvh; }
  .login-panel { place-items: center stretch; }
}
