:root {
  --bg: #0b1a2b;
  --bg2: #0f2438;
  --line: #1d3b55;
  --text: #e6f1f7;
  --muted: #7d9bb3;
  --mine: #1d6f8c;
  --theirs: #14304a;
  --accent: #7fd4e8;
  --warn: #d98a5a;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

/*
 * hidden 是 JS 开关显隐的唯一手段，但作者样式里的 display:flex 会盖掉浏览器默认的
 * [hidden]{display:none}（同层优先级：类选择器 > 属性选择器在 UA 表里那条）。
 * 2026-11-24 真浏览器一进来就是被一块空的「水底」面板整个盖住、连登录框都看不见，
 * 根因就是这条。必须 !important 钉死。
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  overscroll-behavior: none;
}

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

/* ---- 横幅 ---- */
.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  padding: 6px 12px;
  text-align: center;
  font-size: 13px;
  background: var(--warn);
  color: #201007;
}

/* ---- 登录 ---- */
.gate {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gate form {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gate h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 6px;
  font-weight: 600;
  color: var(--accent);
}
.gate .sub { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.gate input {
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 16px;
  outline: none;
}
.gate input:focus { border-color: var(--accent); }
.gate button {
  padding: 13px;
  border: 0;
  border-radius: 12px;
  background: var(--mine);
  color: #eaf8ff;
  font-size: 16px;
  font-weight: 600;
}
.gate button:disabled { opacity: .6; }
.gate .err { margin: 0; color: #ff9c7a; font-size: 14px; }
.gate .hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.gate code { color: var(--accent); }

/* ---- 外壳 ---- */
.shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  /* 必须 relative：#menu-pop 是它的子元素、用 position:absolute 定位。
     shell 是 static 时，菜单会拿视口当参照系——宽屏上弹到窗口最右边、离 ⋯ 按钮七百多像素
     （2026-11-24 真浏览器验出来的）。 */
  position: relative;
}

.top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}
.who { display: flex; align-items: baseline; gap: 8px; }
.name { font-size: 17px; letter-spacing: 3px; }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted);
  align-self: center;
}
.dot.on { background: #4fd1a5; box-shadow: 0 0 6px #4fd1a5; }
.dot.off { background: var(--warn); }
.state { font-size: 12px; color: var(--muted); }
.icon-btn {
  border: 0; background: transparent; color: var(--muted);
  font-size: 20px; padding: 4px 6px; line-height: 1;
}

/* ---- 消息 ---- */
.list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: min(78%, 620px);
  padding: 9px 13px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15.5px;
  line-height: 1.5;
}
.msg.user {
  align-self: flex-end;
  background: var(--mine);
  border-bottom-right-radius: 4px;
}
.msg.assistant {
  align-self: flex-start;
  background: var(--theirs);
  border-bottom-left-radius: 4px;
}
.msg.system, .msg.event {
  align-self: center;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}
.msg .meta {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: .55;
  text-align: right;
}
.msg.user .meta { text-align: right; }

.msg.pending { opacity: .62; }
.msg.failed { outline: 1px solid var(--warn); }

/* ---- 打字中 ---- */
.typing {
  padding: 2px 18px 6px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

/* ---- 输入 ---- */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 132px;
  padding: 11px 13px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer button {
  height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: var(--mine);
  color: #eaf8ff;
  font-size: 15px;
  font-weight: 600;
}
.composer button:disabled { opacity: .5; }

/* 桌面宽屏：中间一条，别拉满 */
@media (min-width: 760px) {
  .shell { max-width: 780px; margin: 0 auto; width: 100%; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  /* 三个全屏面板（岸 / 水底 / 搜话）也收成同一条：不收的话宽屏上一行两千多像素，
     眼睛要横着扫，等于没法读（2026-11-24 真浏览器验出来的）。 */
  .bottom-head, .bottom-body, .shore-composer { max-width: 780px; margin-left: auto; margin-right: auto; width: 100%; }
}

/* ---- 水色 · 此刻（v2 加的）---- */
.vibe {
  margin-left: 6px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  line-height: 1.7;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vibe:active { background: var(--bg2); }
/* heavy 的心情（黏人/得意/蔫着）边框亮一点，跟一过性的分开 */
.vibe.heavy { border-color: var(--accent); }

.vibe-panel {
  padding: 10px 14px 12px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.vibe-panel .row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin: 5px 0;
  flex-wrap: wrap;
}
.vibe-panel .k { min-width: 3.4em; color: var(--muted); }
.vibe-panel .mood { color: var(--text); }
.vibe-panel .why { color: var(--muted); font-size: 12px; opacity: .8; flex-basis: 100%; padding-left: 3.4em; }
.vibe-panel .bar {
  display: inline-block;
  height: 6px;
  border-radius: 3px;
  background: var(--mine);
  vertical-align: middle;
  margin-left: 6px;
}
.vibe-panel .empty { color: var(--muted); }

/* ---- 水底：日记 ---- */
.bottom-panel {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.bottom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
}
.bottom-title { color: var(--accent); font-size: 15px; letter-spacing: 2px; }
.bottom-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px calc(16px + var(--safe-b));
  -webkit-overflow-scrolling: touch;
}
.day-item {
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.day-item:active { background: var(--bg2); }
.day-item .d { color: var(--accent); font-size: 13px; }
.day-item .x { color: var(--muted); font-size: 13px; margin-top: 3px; }
.journal-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  padding: 8px 2px 24px;
}
.back-row {
  padding: 4px 0 10px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
}

/* ---- 岸：我发东西的地方 ---- */
.shore-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px calc(8px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--bg2);
}
.shore-composer textarea {
  flex: 1;
  min-height: 38px;
  max-height: 110px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  resize: none;
  outline: none;
}
.shore-composer textarea:focus { border-color: var(--accent); }
.shore-composer button {
  padding: 9px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--mine);
  color: #eaf8ff;
  font: inherit;
  font-size: 15px;
}
.shore-item {
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.shore-item .t {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.shore-item .m {
  margin-top: 5px;
  font-size: 12px;
  color: var(--muted);
}

/* ---- 顶栏菜单 ---- */
.menu-pop {
  position: absolute;
  right: 10px;
  top: 46px;
  z-index: 35;
  min-width: 132px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg2);
  box-shadow: 0 8px 24px rgba(0,0,0,.45);
  display: flex;
  flex-direction: column;
}
.menu-pop button {
  padding: 10px 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  text-align: left;
}
.menu-pop button:active { background: var(--bg); }

/* ---- 搜话 ---- */
.search-input {
  flex: 1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
  margin-right: 8px;
}
.search-input:focus { border-color: var(--accent); }
.hit {
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.hit .h {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 3px;
}
.hit .b {
  font-size: 15px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}
