/* =========================================================
   投递 · LAN-Share  —  极简传输流
   浅色主题 · 手机优先自适应 · 单屏收发流
   ========================================================= */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #141a26;
  --ink-2: #4a5367;
  --ink-3: #97a0b3;
  --line: #e6eaf2;
  --brand: #0f5ef7;
  --brand-dk: #0a48c4;
  --brand-soft: #eaf1ff;
  --green: #12a150;
  --green-soft: #e5f7ec;
  --red: #e03e3e;
  --red-soft: #fdeaea;
  --amber: #e08a00;
  --amber-soft: #fdf1dc;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(18,26,45,.05);
  --shadow-md: 0 4px 16px rgba(18,26,45,.07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font); color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, code { font-family: inherit; }
svg { display: block; flex: none; }

.app {
  display: flex; flex-direction: column;
  height: 100dvh; max-width: 720px; margin: 0 auto;
  padding-top: var(--safe-t);
}

/* ================= 顶栏 ================= */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 16px 8px;
}
.bar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { display: flex; }
.logo svg { filter: drop-shadow(0 3px 8px rgba(15,94,247,.28)); }
.bar-title h1 { font-size: 18px; font-weight: 750; letter-spacing: .2px; line-height: 1.1; }
.tagline { font-size: 10px; color: var(--ink-3); letter-spacing: 2px; font-weight: 600; text-transform: uppercase; }
.bar-right { display: flex; align-items: center; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); white-space: nowrap; max-width: 46vw; overflow: hidden;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-gray { background: #c3cad8; }
.dot-green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot-red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 11px; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
  transition: transform .12s ease, background .15s ease;
}
.iconbtn:active { transform: scale(.94); }
.iconbtn:hover { background: #fff; color: var(--ink); }

/* ================= 主体(传输流) ================= */
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 16px; overflow: hidden; }
.feed-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 8px; }
.send-hint { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-3); }
.send-hint[hidden] { display: none; }
.send-hint b { color: var(--brand); font-weight: 650; }
.hint-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.peer-count { font-size: 12px; color: var(--ink-3); }

/* 多设备切换胶囊 */
.device-strip { display: flex; gap: 8px; padding: 2px 0 8px; overflow-x: auto; scrollbar-width: none; }
.device-strip::-webkit-scrollbar { display: none; }
.dev-chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  padding: 7px 13px; border-radius: 20px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: all .15s ease;
}
.dev-chip .cavatar { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; color: #fff; }
.dev-chip .cavatar.pc { background: linear-gradient(135deg,#34b8ee,#1677d8); }
.dev-chip .cavatar.phone { background: linear-gradient(135deg,#f5a03c,#ef7d1b); }
.dev-chip .cavatar.tablet { background: linear-gradient(135deg,#8b5cf6,#6d3ef0); }
.dev-chip .st { font-size: 10px; color: var(--ink-3); font-weight: 600; }
.dev-chip.on { background: var(--green-soft); border-color: transparent; color: var(--green); }
.dev-chip.on .st { color: var(--green); }
.dev-chip.connecting { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.dev-chip.connecting .st { color: var(--amber); }
.dev-chip.current { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }

/* 传输流列表 */
.feed { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 2px 12px; display: flex; flex-direction: column; gap: 9px; scrollbar-width: thin; }
.feed::-webkit-scrollbar { width: 6px; }
.feed::-webkit-scrollbar-thumb { background: #d3d9e5; border-radius: 6px; }

.feed-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; flex: 1; color: var(--ink-3); min-height: 180px; padding: 16px 0; }
.feed-empty[hidden] { display: none; }
.empty-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-mark svg { filter: drop-shadow(0 12px 26px rgba(15,94,247,.24)); }
.empty-hero h2 { font-size: 19px; font-weight: 750; color: var(--ink); letter-spacing: .3px; }
.empty-hero p { font-size: 13px; color: var(--ink-3); line-height: 1.65; max-width: 320px; }
.empty-hero p b { color: var(--brand); font-weight: 650; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.empty-actions .btn { width: auto; padding: 11px 24px; font-size: 14px; }
.empty-hint { font-size: 11.5px; color: #b9c0cf; letter-spacing: .3px; }

/* 时间线分割 */
.daysep { font-size: 10.5px; color: var(--ink-3); text-align: center; padding: 6px 0 2px; letter-spacing: 1px; }

/* 卡片项 */
.item { display: flex; gap: 12px; padding: 12px 13px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px);} to { opacity: 1; transform: none;} }
.item.is-new { animation: popnew .6s ease; border-color: var(--brand-soft); }
@keyframes popnew { 0% { box-shadow: 0 0 0 3px var(--brand-soft);} 100% { box-shadow: var(--shadow-sm);} }

.t-icon { width: 42px; height: 42px; border-radius: 11px; flex: none; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 12px; }
.t-icon.file { background: linear-gradient(135deg,#35aee8,#1477d6); }
.t-icon.img { background: linear-gradient(135deg,#3bc77c,#12a150); }
.t-icon.zip { background: linear-gradient(135deg,#f4a13c,#e07a08); }
.t-icon.doc { background: linear-gradient(135deg,#6d6bf6,#4b43e0); }
.t-icon.code { background: linear-gradient(135deg,#6c7da3,#4d5c80); }
.t-icon.text { background: linear-gradient(135deg,#a06bf5,#8338e0); }
.t-icon.video { background: linear-gradient(135deg,#f06b6b,#d22b2b); }
.t-icon.folder { background: linear-gradient(135deg,#3bc7d0,#0f9aa5); }

/* 媒体缩略图(左侧, 替换文字图标) */
.item { align-items: center; }
.t-thumbwrap { position: relative; width: 52px; height: 52px; border-radius: 12px; overflow: hidden; flex: none; background: var(--bg); border: 1px solid var(--line); cursor: zoom-in; }
.t-thumbwrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.playbadge { position: absolute; inset: 0; margin: auto; width: 24px; height: 24px; border-radius: 50%; background: rgba(12,18,32,.55); display: flex; align-items: center; justify-content: center; pointer-events: none; backdrop-filter: blur(1px); }
.playbadge svg { width: 10px; height: 10px; fill: #fff; margin-left: 2px; }

.t-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.t-title { font-size: 14px; font-weight: 650; word-break: break-all; line-height: 1.3; }
.t-title.fname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.t-meta .dir { display: inline-flex; align-items: center; gap: 4px; }
.t-meta .dir em { font-style: normal; color: var(--ink-2); font-weight: 600; }

.progress { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 2px 0 1px; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg,var(--brand),#5b8bff); transition: width .15s linear; }
.progress.send > i { background: linear-gradient(90deg,#35aee8,#0f5ef7); }
.progress.recv > i { background: linear-gradient(90deg,#3bc77c,#12a150); }

.t-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.t-status { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.t-status.ok { color: var(--green); }
.t-status.pending { color: var(--amber); }
.t-status.err { color: var(--red); }
.t-status .spin { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line); border-top-color: currentColor; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg);} }

.t-act { display: inline-flex; gap: 6px; }
.btn-mini {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 9px;
  font-size: 12px; font-weight: 650; transition: transform .12s ease, background .15s ease;
}
.btn-mini:active { transform: scale(.95); }
.btn-mini.primary { background: var(--brand); color: #fff; }
.btn-mini.primary:hover { background: var(--brand-dk); }
.btn-mini.soft { background: var(--brand-soft); color: var(--brand); }
.btn-mini.green { background: var(--green); color: #fff; }
.btn-mini.ghost { background: var(--bg); color: var(--ink-2); border: 1px solid var(--line); }

/* ================= 底部输入坞 ================= */
.dock { padding: 8px 16px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(245,247,251,.92); backdrop-filter: blur(8px); }
.dropzone {
  display: flex; align-items: center; gap: 6px; padding: 4px;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-md); transition: border-color .15s ease, box-shadow .2s ease;
}
.dropzone:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow-md); }
.dropzone.dragover { border-color: var(--brand); border-style: dashed; box-shadow: 0 0 0 3px var(--brand-soft); }
.text-input {
  flex: 1; min-width: 0; display: block;
  border: none; outline: none; background: transparent;
  padding: 11px 10px; font-size: 15px; color: var(--ink);
  font-family: inherit; line-height: 1.4;
  height: 42px; max-height: 132px;             /* 约 4 行, 超出内部滚动 */
  resize: none; overflow-y: auto; box-sizing: border-box;
  vertical-align: middle;
}
.text-input::placeholder { color: var(--ink-3); }
.text-input::-webkit-scrollbar { width: 4px; }
.text-input::-webkit-scrollbar-thumb { background: var(--ink-3); border-radius: 2px; }

/* 发送按钮: 输入框有文字时在右侧展开显现, 为空则收起 */
.send-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  flex: none; height: 42px; border-radius: 12px;
  color: #fff; background: var(--brand);
  box-shadow: 0 4px 12px rgba(15,94,247,.3);
  font-size: 14px; font-weight: 650; white-space: nowrap;
  max-width: 0; padding: 0; opacity: 0; overflow: hidden;
  transform: scale(.7); pointer-events: none;
  transition: max-width .2s ease, padding .2s ease, opacity .16s ease, transform .2s ease, background .15s ease;
}
.send-btn:active { background: var(--brand-dk); }
.dropzone.has-text .send-btn { max-width: 120px; padding: 0 16px; opacity: 1; transform: scale(1); pointer-events: auto; }
.dz-right { display: flex; gap: 5px; flex: none; padding-right: 2px; }
.dz-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; color: var(--ink-2);
  background: var(--bg); transition: transform .12s ease, background .15s ease;
}
.dz-btn:active { transform: scale(.92); }
.dz-btn-accent { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(15,94,247,.3); }
.dz-btn-accent:active { background: var(--brand-dk); }
.dock-status { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 4px 0; }
#dock-hint { font-size: 11.5px; color: var(--ink-3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qr-link { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); padding: 3px 6px; border-radius: 7px; }
.qr-link:hover { background: var(--brand-soft); color: var(--brand); }

/* 自动保存横幅 */
.autosave { margin: 0 16px; display: flex; align-items: center; gap: 8px; padding: 9px 12px; background: var(--green-soft); color: var(--green); border-radius: 11px; font-size: 12.5px; font-weight: 600; }
.autosave button { margin-left: auto; color: var(--green); font-size: 18px; line-height: 1; opacity: .7; }
.autosave[hidden] { display: none; }

/* ================= 弹窗 ================= */
.overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(15,20,35,.42); backdrop-filter: blur(2px); animation: fade .18s ease; }
.overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0;} to { opacity: 1;} }
.sheet { width: 100%; max-width: 420px; background: var(--card); border-radius: 20px 20px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); animation: rise-sheet .22s cubic-bezier(.2,.9,.3,1); box-shadow: 0 -6px 30px rgba(18,26,45,.14); }
@media (min-width: 480px) { .overlay { align-items: center; padding: 20px; } .sheet { border-radius: 18px; } }
@keyframes rise-sheet { from { transform: translateY(40px); opacity: .6;} to { transform: none; opacity: 1;} }
.sheet-center { text-align: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h3 { font-size: 16px; font-weight: 700; }
.sheet-close { font-size: 24px; color: var(--ink-3); line-height: 1; padding: 0 4px; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; }
.sheet-close:hover { background: var(--bg); color: var(--ink); }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; text-align: left; }
.field label { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.field input { border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; font-size: 15px; outline: none; background: var(--bg); }
.field input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft); }

.setgroup { border-top: 1px solid var(--line); padding: 12px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-t { font-size: 14px; font-weight: 600; color: var(--ink); }
.row-static code { font-size: 13px; color: var(--brand); background: var(--brand-soft); padding: 4px 9px; border-radius: 8px; word-break: break-all; text-align: right; }
.row-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.55; }

.switch { position: relative; flex: none; }
.switch input { display: none; }
.switch i { display: block; width: 44px; height: 26px; border-radius: 20px; background: var(--line); position: relative; transition: background .18s ease; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .18s ease; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { left: 21px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 12px; border-radius: 12px; font-size: 14.5px; font-weight: 650; width: 100%; transition: transform .12s ease; }
.btn:active { transform: scale(.99); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dk); }
.btn-ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line); }

.qr-box { width: 224px; height: 224px; margin: 4px auto 12px; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.qr-box canvas, .qr-box img { width: 100%; height: 100%; display: block; }
.qr-url { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 16px; word-break: break-all; }
.qr-actions { display: flex; gap: 10px; }
.qr-actions .btn { flex: 1; padding: 11px; font-size: 13.5px; }

/* 媒体预览灯箱 */
.overlay-media { background: rgba(8,12,22,.88); align-items: center; padding: 16px; flex-direction: column; backdrop-filter: blur(6px); }
.overlay-media[hidden] { display: none; }
.preview-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 900px; margin-bottom: 10px; color: #fff; }
.preview-name { font-size: 13.5px; color: rgba(255,255,255,.88); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; flex: 1; }
.preview-close { font-size: 26px; line-height: 1; width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: #fff; background: rgba(255,255,255,.08); }
.preview-close:hover { background: rgba(255,255,255,.18); }
.preview-stage { width: 100%; max-width: 900px; min-height: 120px; display: flex; align-items: center; justify-content: center; background: #05070c; border-radius: 16px; overflow: hidden; }
.preview-stage img, .preview-stage video { max-width: 100%; max-height: 66vh; display: block; object-fit: contain; }
.preview-bar { margin-top: 12px; width: 100%; max-width: 900px; display: flex; align-items: center; }
.preview-bar .btn-mini.primary { margin-left: auto; }
.preview-bar .btn-mini.ghost-light { background: rgba(255,255,255,.1); color: #fff; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%); z-index: 90; background: #1a2130; color: #fff; padding: 9px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.22); max-width: 84vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: rise .2s ease; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
