:root {
  --bg: #0b1215;
  --panel: #121d21;
  --panel-2: #17262b;
  --line: rgba(151, 214, 205, .16);
  --text: #e7f1ee;
  --muted: #8fa5a2;
  --accent: #8bd6c9;
  --accent-2: #d8b56a;
  --user: #1d3a3a;
  --assistant: #142125;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 0%, rgba(139, 214, 201, .09), transparent 38%),
    radial-gradient(circle at 100% 100%, rgba(216, 181, 106, .06), transparent 42%),
    var(--bg);
}
button, textarea, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.offline {
  position: fixed; z-index: 20; top: 0; left: 0; right: 0;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: #4b2c26; color: #ffd9c9; text-align: center; font-size: 12px;
}

.gate {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px calc(24px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  text-align: center;
}
.gate-icon { width: 86px; height: 86px; border-radius: 24px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
.gate h1 { margin: 18px 0 4px; font-size: 26px; letter-spacing: .08em; font-weight: 600; }
.gate p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.gate form { width: min(320px, 100%); display: flex; gap: 8px; }
.gate input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 12px; padding: 12px 13px; outline: none;
}
.gate input:focus { border-color: var(--accent); }
.gate button { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--accent); color: #08201c; font-weight: 700; }
.error { color: #ff9c8a !important; min-height: 18px; margin-top: 10px !important; }
.fine { color: #617774 !important; font-size: 11px !important; margin-top: 18px !important; }

.app { height: 100%; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px 10px; border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 21, .72); backdrop-filter: blur(14px);
}
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who img { width: 38px; height: 38px; border-radius: 12px; }
.who div { display: flex; flex-direction: column; min-width: 0; }
.who strong { font-size: 16px; letter-spacing: .06em; }
.who span { color: var(--muted); font-size: 11px; }
.top-actions { display: flex; gap: 6px; }
.ghost { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 9px; padding: 6px 9px; font-size: 12px; }

.chat { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.msg { max-width: 84%; padding: 10px 12px; border-radius: 15px; line-height: 1.58; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--assistant); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.system { align-self: center; background: transparent; color: #6f8582; font-size: 11px; max-width: 92%; text-align: center; }
.msg .image { display: block; max-width: 100%; border-radius: 10px; margin-bottom: 7px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 12px; padding: 3px 6px; }

.composer { padding: 9px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(11,18,21,.82); backdrop-filter: blur(14px); }
.preview { display: flex; align-items: center; gap: 9px; padding: 7px 0; }
.preview img { width: 58px; height: 58px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.preview button { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 8px; padding: 5px 8px; font-size: 11px; }
.input-row { display: flex; align-items: flex-end; gap: 7px; }
.attach { flex: 0 0 38px; width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel); color: var(--accent); border-radius: 12px; font-size: 22px; line-height: 1; }
#input { flex: 1; resize: none; max-height: 120px; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; padding: 10px 11px; outline: none; line-height: 1.4; }
#input:focus { border-color: rgba(139,214,201,.55); }
.send { flex: 0 0 46px; height: 38px; border: 0; border-radius: 12px; background: var(--accent); color: #08201c; font-weight: 800; }
.send:disabled { opacity: .45; }
.hint { margin: 7px 2px 0; color: #5e7471; font-size: 10px; }
@media (min-width: 720px) {
  .app { max-width: 720px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
