* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f2f3f5; color: #1f2329;
}
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* 登录 */
.login { height: 100dvh; display: flex; align-items: center; justify-content: center; }
.login form { width: min(320px, 90vw); display: flex; flex-direction: column; gap: 12px; }
.login h1 { text-align: center; font-size: 24px; margin: 0 0 8px; }
#pw { font-size: 16px; padding: 12px; border: 1px solid #d0d3d6; border-radius: 10px; }
.login button { padding: 12px; border: 0; border-radius: 10px; background: #3370ff; color: #fff; font-size: 16px; }
.show-pw { font-size: 14px; color: #646a73; display: flex; align-items: center; gap: 6px; cursor: pointer; }
.err { color: #d83931; min-height: 1.5em; margin: 0; text-align: center; }

/* 主界面 */
.app { height: 100dvh; display: flex; flex-direction: column; max-width: 900px; margin: 0 auto; position: relative; }
header {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: #f2f3f5; border-bottom: 1px solid #e3e5e8; position: relative;
}
.title { font-weight: 600; font-size: 17px; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: #c0c4cc; }
.conn.on { background: #34c759; }
header .icon { margin-left: auto; }
.icon { border: 0; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; border-radius: 8px; color: #555; }
.icon:hover { background: #e3e5e8; }
.menu {
  position: absolute; right: 12px; top: 100%; z-index: 20; background: #fff; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.15); overflow: hidden; display: flex; flex-direction: column;
}
.menu button { border: 0; background: none; padding: 12px 20px; text-align: left; }
.menu button:hover { background: #f2f3f5; }
#clearBtn { color: #d83931; }

.list { flex: 1; overflow-y: auto; padding: 12px 14px 16px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.empty { color: #8f959e; text-align: center; margin-top: 30vh; font-size: 14px; }
.day { text-align: center; color: #8f959e; font-size: 12px; margin: 14px 0 6px; }

.msg { display: flex; flex-direction: column; align-items: flex-start; margin: 8px 0; }
.msg.mine { align-items: flex-end; }
.meta { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #8f959e; margin: 0 2px 3px; }
.mine .meta { flex-direction: row-reverse; }
.meta .copy {
  border: 1px solid #d0d3d6; background: #fff; color: #3370ff; font-size: 12px; line-height: 1.4;
  padding: 1px 10px; border-radius: 999px;
}
.meta .copy:hover { border-color: #3370ff; }
.meta .copy.done { color: #34a853; border-color: #34a853; }
.bubble {
  max-width: min(78%, 620px); background: #fff; border-radius: 12px; padding: 9px 12px;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
}
.mine .bubble { background: #d6e4ff; }
.bubble a { color: #245bdb; }
.bubble.media { padding: 4px; background: #fff; }
.bubble img, .bubble video { display: block; max-width: 100%; max-height: 360px; border-radius: 8px; cursor: zoom-in; }
.bubble video { cursor: auto; }
.file { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.file .ext {
  width: 40px; height: 40px; border-radius: 8px; background: #3370ff; color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; text-transform: uppercase;
}
.file .info { min-width: 0; }
.file .name { word-break: break-all; }
.file .size { font-size: 12px; color: #8f959e; }
.actions { display: flex; gap: 2px; }
.actions a, .actions button {
  border: 0; background: none; color: #646a73; font-size: 12px; padding: 2px 6px; border-radius: 6px; text-decoration: none;
}
.actions a:hover, .actions button:hover { background: #e3e5e8; color: #1f2329; }
.progress { height: 4px; background: #e3e5e8; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: #3370ff; transition: width .2s; }
.failed .bubble { outline: 1px solid #d83931; }

/* 新内容按钮 */
.to-bottom {
  position: absolute; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 10;
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: #fff; color: #3370ff;
  box-shadow: 0 2px 12px rgba(0,0,0,.18); font-size: 20px; display: flex; align-items: center; justify-content: center;
}
.to-bottom.has-new { background: #3370ff; color: #fff; animation: bob 1.2s ease-in-out infinite; }
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #f54a45; color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
@keyframes bob { 50% { transform: translateY(3px); } }

/* 输入区 */
footer {
  display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #f7f8fa; border-top: 1px solid #e3e5e8;
}
.attach { font-size: 26px; padding: 4px 8px 6px; cursor: pointer; }
footer textarea {
  flex: 1; resize: none; font: inherit; font-size: 16px; line-height: 1.4; padding: 9px 12px;
  border: 1px solid #d0d3d6; border-radius: 10px; background: #fff; max-height: 40vh; outline: none;
}
footer textarea:focus { border-color: #3370ff; }
.send { border: 0; background: #3370ff; color: #fff; border-radius: 10px; padding: 9px 16px; font-size: 15px; }
.send:disabled { background: #a8c0ff; cursor: default; }

/* 拖放、看大图、提示 */
.drop {
  position: absolute; inset: 0; z-index: 30; background: rgba(51,112,255,.12); border: 3px dashed #3370ff;
  display: flex; align-items: center; justify-content: center; pointer-events: none;
}
.drop div { background: #3370ff; color: #fff; padding: 12px 24px; border-radius: 10px; font-size: 18px; }
.viewer {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.88);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.viewer img { max-width: 96vw; max-height: 96vh; }
.toast {
  position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); z-index: 50;
  background: rgba(0,0,0,.78); color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 14px;
}

@media (prefers-color-scheme: dark) {
  body, header { background: #17181a; color: #e8e9eb; }
  header { border-color: #2b2d31; }
  .bubble, .bubble.media, .menu { background: #2b2d31; }
  .mine .bubble { background: #1f3a75; }
  .bubble a { color: #7aa2ff; }
  footer { background: #1d1e21; border-color: #2b2d31; }
  footer textarea, #pw { background: #2b2d31; color: #e8e9eb; border-color: #3b3e44; }
  .icon, .actions a, .actions button { color: #a6abb3; }
  .icon:hover, .actions a:hover, .actions button:hover, .menu button:hover { background: #3b3e44; color: #fff; }
  .menu button { color: #e8e9eb; }
  .meta .copy { background: #2b2d31; border-color: #3b3e44; color: #7aa2ff; }
  .to-bottom { background: #2b2d31; }
}
