:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --ink: #171717;
  --muted: #78716c;
  --line: #e7e0d3;
  --accent: #0f766e;
  --accent-2: #f59e0b;
  --bubble: #f0eee8;
  --shadow: 0 20px 60px rgba(28, 25, 23, .12);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-serif, Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(245, 158, 11, .20), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(15, 118, 110, .16), transparent 36rem),
    var(--bg);
}
.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,.58);
  backdrop-filter: blur(18px);
}
.brand { font-size: 26px; font-weight: 900; letter-spacing: -.04em; margin-bottom: 22px; }
.new-chat {
  width: 100%; border: 0; border-radius: 18px; padding: 14px 16px;
  background: var(--ink); color: white; cursor: pointer; font-weight: 800; font-size: 15px;
  box-shadow: var(--shadow);
}
.side-card { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.75); }
.label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.queue-card small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.55; }
.side-note { margin-top: 18px; color: var(--muted); line-height: 1.7; font-size: 14px; }
.chat { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 22px 28px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
p { margin: 6px 0 0; color: var(--muted); }
.status { padding: 8px 12px; border-radius: 999px; background: rgba(15,118,110,.10); color: var(--accent); font-size: 13px; font-weight: 800; }
.messages { padding: 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.message { display: flex; gap: 12px; max-width: 860px; animation: rise .22s ease both; }
.message.user { margin-left: auto; flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; color: white; font-weight: 900; background: var(--accent); flex: 0 0 auto; }
.user .avatar { background: var(--accent-2); color: #231f16; }
.bubble { padding: 14px 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(28,25,23,.06); white-space: pre-wrap; line-height: 1.7; }
.user .bubble { background: var(--bubble); }
.bubble.status-text { color: var(--muted); }
.bubble.error { color: #b91c1c; border-color: #fecaca; background: #fff1f2; }
.image-card { overflow: hidden; padding: 0; }
.image-card img { display: block; width: min(420px, 72vw); max-width: 100%; height: auto; cursor: zoom-in; }
.image-actions { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
.image-actions a, .image-actions button { border: 1px solid var(--line); background: white; color: var(--ink); border-radius: 12px; padding: 8px 11px; text-decoration: none; cursor: pointer; }
.composer { display: flex; gap: 12px; padding: 20px 28px 28px; border-top: 1px solid var(--line); background: rgba(245,243,238,.8); }
textarea {
  flex: 1; resize: none; min-height: 54px; max-height: 180px; border: 1px solid var(--line); border-radius: 22px;
  padding: 16px 18px; font: 16px/1.5 ui-serif, Georgia, "Songti SC", serif; outline: none; background: rgba(255,255,255,.86);
}
textarea:focus { border-color: rgba(15,118,110,.55); box-shadow: 0 0 0 4px rgba(15,118,110,.08); }
.composer button { width: 96px; border: 0; border-radius: 20px; background: var(--accent); color: white; font-weight: 900; cursor: pointer; }
.composer button:disabled { opacity: .45; cursor: not-allowed; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.82); display: grid; place-items: center; z-index: 10; padding: 30px; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 18px; box-shadow: var(--shadow); }
.lightbox button { position: fixed; top: 20px; right: 20px; border: 0; border-radius: 999px; padding: 10px 14px; cursor: pointer; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 780px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .chat-header { padding: 18px; }
  .messages { padding: 18px; }
  .composer { padding: 14px; }
  .image-card img { max-width: 82vw; }
}

.lightbox[hidden] {
  display: none !important;
}
