:root {
  --bg: #0f1115;
  --bg-2: #161a21;
  --bg-3: #1d222b;
  --line: #262c38;
  --fg: #e6e9ef;
  --muted: #8b94a7;
  --accent: #4f8cff;
  --accent-2: #3a6fd8;
  --danger: #ff5f56;
  --ok: #34c759;
  --radius: 12px;
  --tap: 42px;
}

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  overscroll-behavior-y: none;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.err { color: var(--danger); font-size: 13px; }

/* ---------------- 登录 ---------------- */
.screen { min-height: 100dvh; }

#login {
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
}
.login-card h1 { margin: 12px 0 4px; font-size: 22px; }
.logo { font-size: 40px; color: var(--accent); line-height: 1; }
.login-card input {
  width: 100%; margin: 18px 0 12px;
  padding: 12px 14px; font-size: 16px;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: rgba(15,17,21,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.logo-sm { color: var(--accent); font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.counter { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); display: inline-block;
  transition: background .3s;
}
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(52,199,89,.6); }
/* 轮询兜底中：实时更新正常，只是走的不是 SSE（隧道不支持） */
.dot.poll { background: #f5a623; }
.dot.off { background: var(--danger); }

/* ---------------- 发送区 ---------------- */
.composer {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  position: sticky; top: calc(env(safe-area-inset-top) + 45px); z-index: 9;
}
.composer textarea {
  width: 100%; resize: vertical; min-height: 44px;
  padding: 10px 12px; font: inherit; font-size: 16px;
  background: var(--bg-3); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.row button { flex: 1 1 auto; min-height: var(--tap); }
.row button.icon { flex: 0 0 var(--tap); }

button {
  font: inherit; font-size: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--fg);
  padding: 0 14px;
  cursor: pointer;
  transition: transform .08s, background .15s, border-color .15s;
  touch-action: manipulation;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:active { background: var(--accent-2); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--bg-3); }
button.danger { color: var(--danger); border-color: rgba(255,95,86,.35); background: transparent; }
button.big { width: 100%; min-height: 46px; font-size: 16px; }
button.tiny-btn { font-size: 12px; padding: 6px 12px; min-height: 0; }

.upload-state {
  margin-top: 8px; font-size: 13px; color: var(--accent);
}

/* ---------------- 列表 ---------------- */
.list { padding: 12px 12px 24px; display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.card-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); margin-bottom: 8px;
}
.badge {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-3);
}
.badge.pc { color: #7fb2ff; border-color: rgba(79,140,255,.4); }
.badge.phone { color: #7fe0a8; border-color: rgba(52,199,89,.4); }
.time { white-space: nowrap; cursor: help; }
.spacer { flex: 1; }
.head-btn {
  font-size: 12px; padding: 4px 10px; min-height: 0;
  background: transparent;
}
.card-body { word-break: break-word; overflow-wrap: anywhere; }
.card-body pre {
  margin: 0; white-space: pre-wrap; font: inherit;
  max-height: 340px; overflow: auto;
}

.thumb {
  display: block; max-width: 100%; max-height: 320px;
  border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-3);
  cursor: zoom-in;
}
.file-row { display: flex; align-items: center; gap: 10px; }
.file-icon { font-size: 26px; }
.file-meta { flex: 1; min-width: 0; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.card-actions button { flex: 1; min-height: 36px; font-size: 13px; }

/* ---------------- 其他 ---------------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-icon { font-size: 44px; color: var(--line); margin-bottom: 12px; }

.footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px 24px;
  flex-wrap: wrap;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #2a3140; color: var(--fg);
  border: 1px solid var(--line);
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 100;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
  animation: pop .18s;
}

/* 图片放大查看 */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.94);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.lightbox img { max-width: 100%; max-height: 92dvh; object-fit: contain; }
.lightbox .close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px;
  font-size: 26px; color: #fff; background: none; border: none;
}

/* 登录二维码弹窗 */
.qr-wrap {
  background: #fff; color: #222;
  border-radius: 12px; padding: 18px 18px 12px;
  display: flex; flex-direction: column; align-items: center;
  max-width: min(86vw, 340px);
}
.qr-img { width: 100%; max-width: 260px; image-rendering: pixelated; }
.qr-tip { margin: 10px 0 4px; font-size: 13px; color: #222; }
.qr-link {
  margin: 0; max-width: 100%; word-break: break-all; text-align: center;
  color: #555; cursor: pointer;
}
