:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #17201d;
  --muted: #66736e;
  --line: #e2e8e5;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f3f1;
  --mine: #0f766e;
  --mine-ink: #ffffff;
  --theirs: #ffffff;
  --danger: #c2410c;
  --gold: #b7791f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 4px 16px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --card: #17201d;
    --text: #e6ece9;
    --muted: #8d9a95;
    --line: #26322e;
    --brand: #2bb3a3;
    --brand-ink: #062320;
    --brand-soft: #143a35;
    --mine: #1f8f83;
    --mine-ink: #ffffff;
    --theirs: #1d2724;
    --danger: #f08a5d;
    --gold: #e0b252;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* 顶栏 */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.logo {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font-size: 16px;
}
.userbox { display: flex; align-items: center; gap: 8px; min-width: 0; }
.email { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; max-width: 720px; margin: 0 auto; }
.view { padding: 20px 16px; }

/* 按钮 */
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .55; cursor: default; }
.primary {
  background: var(--brand); color: var(--brand-ink); border-radius: 10px; padding: 10px 18px; font-weight: 600;
}
.primary.block { width: 100%; padding: 12px; margin-top: 6px; }
.ghost { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; background: var(--card); }
.small { font-size: 13px; padding: 4px 10px; }
.link { color: var(--brand); font-size: 13px; font-weight: 600; text-decoration: none; padding: 0; }
.mine .link { color: var(--mine-ink); text-decoration: underline; }

/* 登录卡片 */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-top: 4vh; border: 1px solid var(--line); }
.tabs { display: flex; background: var(--bg); border-radius: 10px; padding: 4px; margin-bottom: 18px; }
.tabs button { flex: 1; padding: 8px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.tabs button.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input[type=email], input[type=password] {
  display: block; width: 100%; margin-top: 6px; padding: 11px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); outline: none;
}
input:focus, textarea:focus { border-color: var(--brand); }
.err { color: var(--danger); font-size: 13px; min-height: 1.2em; margin: 8px 0 0; }
.err.center { text-align: center; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* VIP 套餐 */
h2 { margin: 8px 0 4px; font-size: 22px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.plans { display: grid; gap: 12px; }
.plan {
  position: relative; text-align: left; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 2px;
}
.plan:active { transform: scale(.99); }
.plan.best { border-color: var(--brand); background: var(--brand-soft); }
.plan-name { font-weight: 700; font-size: 16px; }
.plan-price { grid-row: span 2; font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.cur { font-size: 16px; font-weight: 700; margin-right: 1px; vertical-align: 8px; }
.plan-desc { color: var(--muted); font-size: 13px; }
.tag {
  position: absolute; top: -9px; left: 14px; background: var(--gold); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px;
}
.perks { color: var(--muted); font-size: 13px; padding-left: 18px; margin-top: 20px; }
.perks li { margin: 4px 0; }

/* 主界面 */
.app { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 12px 16px 0; }
.status { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.devices { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa5a1; flex: none; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.meta-row { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin: 2px 0 8px 16px; }
.vip { color: var(--gold); font-weight: 600; white-space: nowrap; }

.feed {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 12px; padding: 8px 0 12px;
}
.empty { margin: auto; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; padding: 24px 12px; }
.empty-icon { font-size: 30px; color: var(--brand); margin-bottom: 6px; }

.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; }
.meta { font-size: 11px; color: var(--muted); margin: 0 4px 3px; }
.bubble {
  border-radius: var(--radius); padding: 10px 12px; box-shadow: var(--shadow);
  background: var(--theirs); border: 1px solid var(--line); min-width: 120px; max-width: 100%;
}
.mine .bubble { background: var(--mine); color: var(--mine-ink); border-color: transparent; }
.text { white-space: pre-wrap; word-break: break-word; user-select: text; -webkit-user-select: text; }
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 6px; }

.file { min-width: 220px; }
.file-head { display: flex; gap: 10px; align-items: center; }
.file-icon { font-size: 22px; }
.file-info { min-width: 0; }
.file-name { font-weight: 600; word-break: break-all; }
.file-size, .file-state { font-size: 12px; opacity: .75; }
.file-state { margin-top: 4px; }
.bar { height: 4px; border-radius: 4px; background: rgba(127, 127, 127, .25); margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: currentColor; transition: width .15s; }
.theirs .bar-fill { background: var(--brand); }
.failed .file-state { color: var(--danger); opacity: 1; }
.mine.failed .file-state { color: #ffd6c2; }
.preview { display: block; max-width: 100%; max-height: 50vh; border-radius: 10px; margin-bottom: 8px; background: #000; }

.toolbar { display: flex; justify-content: space-between; padding: 6px 0; }

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--bg);
}
.filebtn {
  flex: none; width: 42px; height: 42px; margin: 0; display: grid; place-items: center; cursor: pointer;
  border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--brand);
  font-size: 24px; font-weight: 300;
}
.composer textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 140px; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); outline: none;
}
.composer .primary { height: 42px; flex: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: rgba(20, 28, 25, .92); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 扫码登录 */
.qr-btn { display: none; }
@media (min-width: 760px) { .qr-btn { display: inline-block; } }
.qr-img { width: 200px; height: 200px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 8px; display: grid; place-items: center; color: #66736e; font-size: 13px; }
.qr-img svg { width: 100%; height: 100%; display: block; }
.qr-inline { margin-bottom: 16px; }
.qr-cap { margin-top: 8px; color: var(--text); font-weight: 600; font-size: 14px; }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { position: relative; background: var(--card); border-radius: 16px; padding: 22px 22px 16px; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal-card h3 { margin: 0 0 14px; font-size: 18px; }
.modal-card .qr-img { width: 220px; height: 220px; border: 1px solid var(--line); }
.modal-x { position: absolute; top: 8px; right: 10px; font-size: 24px; line-height: 1; color: var(--muted); padding: 4px 8px; }

/* 粘贴 / 拖拽发送 */
.clipbtn { font-size: 18px; }
.paste-tip { margin-top: 10px; color: var(--brand); font-size: 13px; }
.drop-mask {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: rgba(15, 118, 110, .12); border: 3px dashed var(--brand);
  display: grid; place-items: center;
}
.drop-mask div { background: var(--brand); color: var(--brand-ink); padding: 12px 22px; border-radius: 12px; font-weight: 600; font-size: 16px; }
