/* 鲸鱼娘 · 手机端样式（iOS Safari 优先） */
:root {
  --ocean-1: #0b5f9e;
  --ocean-2: #0e7fc4;
  --bubble-user: #0e7fc4;
  --bubble-ai: #ffffff;
  --bg: #eef6fc;
  --text: #12344d;
  --muted: #6b8aa5;
  --line: #d6e6f3;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: linear-gradient(180deg, #dceffb 0%, var(--bg) 30%);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* 顶栏 */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 14px 8px;
  background: linear-gradient(135deg, #0b5f9e, #0e7fc4);
  color: #fff;
  box-shadow: 0 2px 10px rgba(11, 95, 158, .35);
}
#topbar .avatar { width: 42px; height: 42px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); background: #fff; }
.title-box { flex: 1; min-width: 0; }
.title { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.subtitle { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#btn-refresh {
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer;
}
#btn-refresh:active { transform: scale(.92); }
.dot-ok { color: #a9f1c4; } .dot-bad { color: #ffd3d3; }

/* 主区 */
main { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; display: flex; flex-direction: column; }
.view.hidden { display: none; }

/* 聊天 */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 6px;
  -webkit-overflow-scrolling: touch;
}
.row { display: flex; margin-bottom: 12px; gap: 8px; }
.row.user { justify-content: flex-end; }
.row .bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 15.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 4px rgba(18, 52, 77, .10);
}
.row.user .bubble { background: var(--bubble-user); color: #fff; border-bottom-right-radius: 4px; }
.row.ai { align-items: flex-start; }
.row.ai img.whale-avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; background: #fff; border: 1px solid var(--line); }
.row.ai .bubble { background: var(--bubble-ai); border-bottom-left-radius: 4px; }
.msg-typing .dot { display: inline-block; width: 6px; height: 6px; margin: 0 1px; border-radius: 50%; background: #9db8cc; animation: blink 1.2s infinite; }
.msg-typing .dot:nth-child(2) { animation-delay: .2s; }
.msg-typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }
.chat-sys { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 14px; }

/* 输入栏 */
#inputbar {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
#chat-input {
  flex: 1;
  resize: none;
  border: 1px solid #bcd8ea;
  border-radius: 18px;
  padding: 9px 14px;
  font-size: 16px;
  font-family: inherit;
  max-height: 120px;
  outline: none;
  background: #fff;
  color: var(--text);
}
#chat-input:focus { border-color: var(--ocean-2); }
#chat-send {
  flex: none;
  background: linear-gradient(135deg, #0b5f9e, #0e7fc4);
  color: #fff;
  border: none;
  border-radius: 18px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
#chat-send:disabled { opacity: .55; }
#chat-send:active { transform: scale(.96); }

/* 记忆页 */
.mem-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: rgba(255,255,255,.8);
  border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.spacer { flex: 1; }
.mini-btn {
  border: 1px solid var(--ocean-2); color: var(--ocean-2); background: #fff;
  border-radius: 14px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.mini-btn:active { background: #e3f1fb; }
#mem-content { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.mem-hint { font-size: 12.5px; color: var(--muted); padding: 0 16px 18px; line-height: 1.6; }
.mem-section {
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(18, 52, 77, .08);
}
.mem-section h4 { margin: 0 0 8px; font-size: 14.5px; color: var(--ocean-1); }
.mem-section .item {
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
  line-height: 1.55;
}
.mem-section .item:last-child { border-bottom: none; }
.mem-section .item .k { font-weight: 700; margin-right: 4px; }
.mem-section .item .t { color: var(--muted); font-size: 12px; }
.mem-empty { color: var(--muted); font-size: 13px; }

/* 设置页 */
#view-settings { overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(18, 52, 77, .08);
}
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--ocean-1); }
.card label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.card input[type="text"] {
  width: 100%;
  border: 1px solid #bcd8ea;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 15px;
  outline: none;
}
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: #335; background: #f2f7fb; border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.btn-block {
  display: block; width: 100%;
  margin-top: 10px;
  background: linear-gradient(135deg, #0b5f9e, #0e7fc4);
  color: #fff; border: none;
  border-radius: 12px;
  padding: 11px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.btn-block:active { transform: scale(.98); }
.hint { font-size: 12.5px; color: var(--muted); line-height: 1.6; margin: 8px 0 0; }

/* 底部标签栏 */
#tabbar {
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#tabbar .tab {
  flex: 1;
  border: none;
  background: none;
  padding: 11px 0 9px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
}
#tabbar .tab.active { color: var(--ocean-1); font-weight: 700; }

/* Toast */
#toast {
  position: fixed;
  left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px);
  transform: translateX(-50%) translateY(20px);
  background: rgba(18, 52, 77, .92);
  color: #fff;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: all .25s;
  z-index: 99;
  max-width: 86%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
