:root {
  --bg: #0f1419;
  --panel: #161d27;
  --panel-2: #1c2533;
  --border: #2a3544;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --accent: #0d9488;
  --accent-2: #14b8a6;
  --user: #1e3a5f;
  --bot: #1a2433;
  --danger: #f87171;
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(13, 148, 136, 0.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(30, 64, 175, 0.16), transparent 50%),
    var(--bg);
}

.hidden { display: none !important; }

.gate {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  text-align: center;
}
.gate-card h1 { margin: 0 0 10px; font-size: 1.35rem; }
.gate-card p { color: var(--muted); margin: 0 0 18px; line-height: 1.5; }

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: rgba(22, 29, 39, 0.92);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}
.brand { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.brand-title { font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; }

.session-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.session-item {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
}
.session-item:hover { background: var(--panel-2); }
.session-item.active { border-color: var(--accent); background: rgba(13, 148, 136, 0.12); }
.session-item small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.lang-switch {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 12px;
}

.main {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-width: 0;
  height: 100%;
}
.topbar {
  padding: 16px 20px 8px;
  border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: 1.1rem; }
.hint { margin: 4px 0 0; color: var(--muted); font-size: 12px; }

.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 12px 20px 0;
}
.chip {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.messages {
  overflow: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg {
  max-width: min(720px, 92%);
  padding: 12px 14px;
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.msg.user { align-self: flex-end; background: var(--user); }
.msg.assistant { align-self: flex-start; background: var(--bot); border: 1px solid var(--border); }
.msg .img {
  display: block;
  max-width: 280px;
  border-radius: 8px;
  margin-bottom: 8px;
}
.msg.err { color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.msg.thinking { color: var(--muted); font-style: italic; }

.composer {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
  background: rgba(22, 29, 39, 0.85);
}
.preview {
  position: relative;
  display: inline-block;
  margin-bottom: 8px;
}
.preview img {
  max-height: 96px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.preview button {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff; cursor: pointer;
}
.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
}
textarea {
  width: 100%;
  resize: none;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  outline: none;
}
textarea:focus { border-color: var(--accent); }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  cursor: pointer;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--accent), #0f766e);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }

@media (max-width: 800px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
