/* 區網快傳 — 亮藍色系（取自 App 圖示：藍色底、白色卡片、黃／綠點綴） */
:root {
  --bg: #EEF5FF;
  --bg-2: #E2EEFF;
  --panel: #FFFFFF;
  --card: #FFFFFF;
  --raise: #EAF2FF;
  --line: #D9E6F7;
  --line-strong: #BFD3EE;
  --text: #0F2A4A;
  --text-2: #33496A;
  --muted: #5B6E8A;
  --accent: #1677FF;
  --accent-2: #3B9BFF;
  --accent-deep: #0B5BD3;
  --accent-soft: #E3EFFF;
  --accent-ink: #FFFFFF;
  --success: #1F9D55;
  --success-soft: #E3F6EA;
  --sun: #FFC531;
  --danger: #D93A3F;
  --danger-line: #F2C4C6;
  --warn: #A86500;
  --shadow: 0 1px 2px rgba(15, 42, 74, .06), 0 4px 14px rgba(22, 119, 255, .08);
  --radius: 16px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A1A33;
    --bg-2: #0D2242;
    --panel: #12284A;
    --card: #12284A;
    --raise: #1A3560;
    --line: #22406E;
    --line-strong: #2E5288;
    --text: #EAF2FF;
    --text-2: #C2D4EE;
    --muted: #93A9C9;
    --accent: #3B9BFF;
    --accent-2: #62B0FF;
    --accent-deep: #1468E0;
    --accent-soft: #163A6B;
    --accent-ink: #FFFFFF;
    --success: #4CD68A;
    --success-soft: #133D2C;
    --danger: #FF8A8E;
    --danger-line: #6B2E35;
    --warn: #FFC531;
    --shadow: 0 1px 2px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 520px at 85% -120px, var(--bg-2), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}
button, input, label.btn { font: inherit; }
[hidden] { display: none !important; }

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(110px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- 頂部 ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 8px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; box-shadow: 0 4px 12px rgba(22, 119, 255, .28); }
.brand h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: .5px; color: var(--text); }
.status { margin: 2px 0 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--line-strong); flex-shrink: 0; }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.err { background: var(--danger); }

.icon-btn {
  width: 44px; height: 44px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--card); color: var(--accent-deep);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: var(--shadow);
}

/* ---------- 群組切換 ---------- */
.rooms { display: flex; gap: 8px; align-items: center; }
.room-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; padding: 2px; }
.room-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--card); color: var(--text-2);
  cursor: pointer; white-space: nowrap; font-weight: 500;
}
.chip[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-color: transparent; color: var(--accent-ink); font-weight: 700;
  box-shadow: 0 4px 12px rgba(22, 119, 255, .3);
}
.chip-add { color: var(--accent-deep); border-style: dashed; }

/* ---------- 區塊 ---------- */
.panel { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--text-2); }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: none; color: var(--accent-deep); cursor: pointer; padding: 8px 0; min-height: 36px; font-weight: 600; }

.peers, .files, .transfers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

/* ---------- 裝置卡片 ---------- */
.peer {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 14px; min-height: 72px; border-radius: var(--radius);
  background: var(--card); border: 1.5px solid var(--line); color: var(--text);
  text-align: left; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, background .15s;
}
.peer[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.peer .ico {
  width: 46px; height: 46px; border-radius: 14px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #FFFFFF; display: grid; place-items: center;
}
.peer .meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.peer .name { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer .sub { font-size: 12px; color: var(--muted); }
.peer .check {
  width: 26px; height: 26px; border-radius: 13px; border: 2px solid var(--line-strong);
  display: grid; place-items: center; flex-shrink: 0; color: var(--accent-ink);
}
.peer[aria-pressed="true"] .check { background: var(--accent-deep); border-color: var(--accent-deep); }

.empty {
  padding: 28px 16px; border-radius: 20px; text-align: center; color: var(--text-2);
  background: var(--card); border: 1.5px dashed var(--line-strong);
}
.empty p { margin: 0 0 4px; font-weight: 600; }
.empty .hint { font-weight: 400; }

/* ---------- 檔案列 ---------- */
.file {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.file .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file .sub { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.file .acts { display: flex; gap: 6px; flex-shrink: 0; }
.small-btn {
  min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--text-2); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; font-size: 14px; font-weight: 500;
}
.small-btn.primary { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--accent-ink); font-weight: 700; }
.files.compact .file { padding: 10px 12px; box-shadow: none; }

/* ---------- 傳輸卡片 ---------- */
.transfer {
  padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
}
.transfer .head { display: flex; align-items: center; gap: 10px; }
.transfer .title { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  padding: 2px 10px; border-radius: 999px; background: var(--raise); color: var(--text-2);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.err { background: transparent; border: 1px solid var(--danger-line); color: var(--danger); }
.bar { height: 8px; border-radius: 4px; background: var(--raise); overflow: hidden; }
.bar > i {
  display: block; height: 100%; width: 0; border-radius: 4px; transition: width .2s linear;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}
.transfer .stats { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.transfer .stats .msg { font-family: inherit; }

.keep-open {
  margin: 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--warn);
  padding: 8px 12px; border-radius: 12px; background: color-mix(in srgb, var(--sun) 22%, transparent);
}
.credit { text-align: center; font-size: 12px; color: var(--muted); padding-top: 8px; }

/* ---------- 底部按鈕 ---------- */
.actions {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 14px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 72%, transparent);
  display: flex; gap: 10px; justify-content: center;
}
.actions > * { flex: 1; max-width: 264px; }
.btn {
  height: 52px; border-radius: var(--radius); border: 1.5px solid var(--line-strong);
  background: var(--card); color: var(--accent-deep); cursor: pointer; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 16px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep)); border-color: transparent;
  color: var(--accent-ink); box-shadow: 0 6px 16px rgba(22, 119, 255, .32);
}
.btn-primary:disabled { background: var(--raise); color: var(--muted); box-shadow: none; cursor: default; }
.btn-ghost { color: var(--text-2); }
.btn-danger { border-color: var(--danger-line); color: var(--danger); }
.btn:focus-visible, .chip:focus-visible, .peer:focus-visible, .icon-btn:focus-visible, .small-btn:focus-visible, .link-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ---------- 對話框 ---------- */
dialog.sheet {
  width: min(100% - 24px, 480px); max-height: 85dvh; overflow: auto;
  border: none; border-radius: 24px; background: var(--card); color: var(--text); padding: 22px;
  box-shadow: 0 20px 60px rgba(11, 45, 100, .3);
}
dialog.sheet::backdrop { background: rgba(10, 30, 60, .45); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 8px; font-size: 19px; font-weight: 800; }
dialog .hint { margin-bottom: 14px; font-size: 13px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.field input {
  height: 48px; padding: 0 14px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--bg); color: var(--text); font-size: 16px;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.row { display: flex; gap: 10px; margin-top: 8px; }
.row > * { flex: 1; }
.col { display: flex; flex-direction: column; gap: 10px; }
.warn { color: var(--warn); font-size: 13px; margin: 10px 0 0; font-weight: 600; }
#incomingList { margin: 4px 0 0; max-height: 40dvh; overflow: auto; }

.drop-overlay {
  position: fixed; inset: 12px; border: 3px dashed var(--accent); border-radius: 24px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: var(--accent-deep); z-index: 10; pointer-events: none;
}

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: 500;
  padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); z-index: 20;
  box-shadow: 0 8px 24px rgba(11, 45, 100, .25);
}
