:root {
  color-scheme: light;
  --bg: #eaf4f2;
  --panel: #ffffff;
  --ink: #123437;
  --muted: #5f7b7d;
  --brand: #0f6b70;
  --brand-soft: #d7eeeb;
  --bubble: #ffffff;
  --line: rgba(18, 52, 55, .10);
  --shadow: 0 10px 30px rgba(15, 69, 72, .12);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(circle at 15% 0%, #cfe9e3 0, transparent 38%),
    radial-gradient(circle at 100% 15%, #f7e6d0 0, transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #b43b3b; min-height: 1.2em; font-size: 13px; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(360px, 100%);
  background: rgba(255,255,255,.88);
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 30px 24px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(16px);
}
.fish-badge {
  width: 64px; height: 64px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: var(--brand);
  color: white; font-size: 32px;
  box-shadow: 0 8px 20px rgba(15,107,112,.3);
}
h1 { margin: 0; font-size: 26px; letter-spacing: .04em; }
.login-card p { margin: 8px 0 18px; }
.login-card input {
  width: 100%; height: 48px; border-radius: 15px;
  border: 1px solid var(--line); background: #fff;
  padding: 0 14px; font-size: 16px; color: var(--ink);
  outline: none;
}
.login-card input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
button { font-family: inherit; cursor: pointer; }
.login-card button {
  width: 100%; height: 48px; margin-top: 12px;
  border: 0; border-radius: 15px; background: var(--brand); color: white;
  font-size: 16px; font-weight: 650;
}

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  max-width: 760px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 4px 10px;
}
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--brand); color: #fff; font-size: 20px;
}
.identity strong { display: block; font-size: 16px; }
.status { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.status.online::before { content: "● "; color: #2f9a78; }
.status.offline::before { content: "● "; color: #b36a4a; }
.top-actions { display: flex; gap: 6px; }
.ghost {
  border: 1px solid var(--line); background: rgba(255,255,255,.72);
  color: var(--ink); border-radius: 12px; height: 34px; padding: 0 10px;
  font-size: 13px;
}

.messages {
  overflow-y: auto;
  padding: 8px 2px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}
.msg {
  max-width: min(84%, 560px);
  padding: 10px 13px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 2px 8px rgba(15,69,72,.05);
}
.msg.bot {
  align-self: flex-start;
  background: var(--bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.msg.user {
  align-self: flex-end;
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 6px;
}
.msg.system {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  box-shadow: none;
  padding: 2px 8px;
}
.msg time { display: block; font-size: 10px; opacity: .55; margin-top: 4px; }

.typing {
  align-self: flex-start;
  display: inline-flex; gap: 4px; padding: 8px 12px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
  width: max-content;
}
.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.5 } 30% { transform: translateY(-4px); opacity:1 } }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px; margin-top: 4px;
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.composer textarea {
  flex: 1; resize: none; border: 0; outline: 0; background: transparent;
  padding: 9px 8px; font-size: 16px; line-height: 1.4; color: var(--ink);
  max-height: 120px;
}
.composer button {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 20px; line-height: 1;
}
.composer button:disabled { opacity: .4; }
.install-hint {
  padding: 8px 10px; color: var(--muted); font-size: 12px; text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(8, 30, 32, .45);
  backdrop-filter: blur(4px);
}
.modal-card {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 24px 20px 18px;
  box-shadow: 0 20px 60px rgba(8, 30, 32, .25);
}
.modal-card h2 { margin: 0 0 12px; font-size: 20px; }
.modal-close {
  position: absolute;
  right: 10px; top: 8px;
  border: 0; background: transparent;
  font-size: 26px; line-height: 1;
  color: var(--muted);
}
.install-steps {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 16px;
}
.modal-primary {
  width: 100%; height: 46px;
  border: 0; border-radius: 14px;
  background: var(--brand); color: #fff;
  font-size: 16px; font-weight: 650;
}

@media (min-width: 700px) {
  .app { padding-left: 20px; padding-right: 20px; }
  .messages { padding-top: 16px; }
}
