/* ============================================================
   Global Drop — iOS Liquid Glass
   折射光暈背景 + 多層磨砂玻璃 + 頂部高光邊 + 內嵌玻璃控件
   ============================================================ */

:root {
  --blue: #0A84FF;
  --blue-soft: rgba(10, 132, 255, 0.22);
  --green: #30D158;
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --bg: #0A0A0C;
  --bg-elevated: #121214;
  --line: rgba(255, 255, 255, 0.14);
  --glass: rgba(255, 255, 255, 0.09);
  --glass-fill: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.06) 42%,
    rgba(255, 255, 255, 0.03) 100%
  );
  --glass-edge: rgba(255, 255, 255, 0.28);
  --glass-edge-soft: rgba(255, 255, 255, 0.1);
  --glass-inner: rgba(255, 255, 255, 0.07);
  --glass-inner-edge: rgba(255, 255, 255, 0.16);
  --ink: rgba(255, 255, 255, 0.94);
  --ink-2: rgba(255, 255, 255, 0.58);
  --ink-3: rgba(255, 255, 255, 0.34);
  --cell-bg: rgba(255, 255, 255, 0.08);
  --track: rgba(255, 255, 255, 0.14);
  --shadow-card:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 -1px 0 rgba(0, 0, 0, 0.25) inset,
    0 24px 64px rgba(0, 0, 0, 0.45),
    0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-chip:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 6px 16px rgba(0, 0, 0, 0.18);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #F2F2F7;
    --bg-elevated: #FFFFFF;
    --line: rgba(0, 0, 0, 0.1);
    --glass: rgba(255, 255, 255, 0.48);
    --glass-fill: linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.78) 0%,
      rgba(255, 255, 255, 0.42) 48%,
      rgba(255, 255, 255, 0.28) 100%
    );
    --glass-edge: rgba(255, 255, 255, 0.92);
    --glass-edge-soft: rgba(255, 255, 255, 0.55);
    --glass-inner: rgba(255, 255, 255, 0.55);
    --glass-inner-edge: rgba(255, 255, 255, 0.8);
    --ink: rgba(10, 14, 28, 0.92);
    --ink-2: rgba(10, 14, 28, 0.52);
    --ink-3: rgba(10, 14, 28, 0.32);
    --cell-bg: rgba(255, 255, 255, 0.62);
    --track: rgba(0, 0, 0, 0.08);
    --shadow-card:
      0 1px 0 rgba(255, 255, 255, 0.95) inset,
      0 -1px 0 rgba(0, 0, 0, 0.04) inset,
      0 28px 64px rgba(40, 60, 120, 0.16),
      0 8px 24px rgba(40, 60, 120, 0.08);
    --shadow-chip:
      0 1px 0 rgba(255, 255, 255, 0.9) inset,
      0 6px 16px rgba(40, 60, 120, 0.08);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               "Helvetica Neue", "PingFang TC", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 背景：細橫線紋理 ---------- */

.surface {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--bg);
}

.surface-base {
  position: absolute;
  inset: 0;
  background: #0A0A0C;
}

@media (prefers-color-scheme: light) {
  .surface-base { background: var(--bg); }
}

.surface-lines {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 5px,
    var(--line) 5px,
    var(--line) 6px
  );
}

/* ---------- 靈動島（畫面假島） ---------- */

.island {
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 40;
  transform: translateX(-50%);
  pointer-events: none;
}

.island:not([hidden]) {
  pointer-events: auto;
}

.island-pill {
  --island-w: 168px;
  --island-h: 36px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--island-w);
  height: var(--island-h);
  padding: 0 12px;
  margin: 0;
  border: 0;
  border-radius: 999px;
  background: #0A0A0C;
  color: #fff;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 10px 28px rgba(0, 0, 0, 0.38),
    0 2px 8px rgba(0, 0, 0, 0.22);
  transition:
    width 520ms var(--spring),
    height 520ms var(--spring),
    border-radius 520ms var(--spring),
    transform 420ms var(--spring),
    background-color 320ms var(--ease-out),
    box-shadow 320ms var(--ease-out);
  transform: scale(0.72);
  opacity: 0;
  will-change: width, height, transform;
  -webkit-tap-highlight-color: transparent;
}

.island.is-visible .island-pill {
  transform: scale(1);
  opacity: 1;
}

.island.is-expanded .island-pill {
  --island-w: min(292px, calc(100vw - 36px));
  --island-h: 84px;
  padding: 12px 16px;
  align-items: flex-start;
}

.island.is-done .island-pill {
  --island-w: 118px;
  --island-h: 36px;
  background: #0B1A10;
  box-shadow:
    0 0 0 1px rgba(48, 209, 88, 0.22) inset,
    0 10px 28px rgba(0, 0, 0, 0.38),
    0 0 24px rgba(48, 209, 88, 0.18);
  cursor: default;
}

.island.is-leaving .island-pill {
  transform: scale(0.55);
  opacity: 0;
}

body.has-island .brand {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.brand {
  transition: opacity 280ms var(--ease-out), transform 280ms var(--spring);
}

.island-pill:active {
  filter: brightness(1.08);
}

.island-glow {
  position: absolute;
  inset: -40% -20%;
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(10, 132, 255, 0.28),
    transparent 62%
  );
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
  transition: opacity 300ms var(--ease-out);
}

.island.is-done .island-glow {
  background: radial-gradient(
    ellipse at 50% 0%,
    rgba(48, 209, 88, 0.32),
    transparent 62%
  );
}

.island-view {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.island-view-xfer {
  grid-template-areas:
    "lead mid trail"
    "expand expand expand";
}

.island-leading { grid-area: lead; display: grid; place-items: center; }
.island-mid { grid-area: mid; min-width: 0; text-align: left; }
.island-trailing {
  grid-area: trail;
  display: flex;
  align-items: center;
  gap: 6px;
}
.island-expand {
  grid-area: expand;
  display: none;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  padding-top: 2px;
}

.island.is-expanded .island-view-xfer {
  grid-template-rows: auto auto;
  align-content: center;
}

.island.is-expanded .island-expand {
  display: flex;
}

.island-glyph { color: #0A84FF; display: block; }
.island-glyph[hidden] { display: none !important; }

.island-title {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.island-sub {
  display: none;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.48);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.island.is-expanded .island-sub {
  display: block;
}

.island.is-expanded .island-title {
  font-size: 13.5px;
}

.island.is-expanded .island-pct { display: none; }

.island-pct {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: -0.01em;
}

.island-ring {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.island-ring svg {
  display: block;
  transform: rotate(-90deg);
}

.island-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 2.4;
}

.island-ring-bar {
  fill: none;
  stroke: #0A84FF;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 69.115;
  stroke-dashoffset: 69.115;
  transition: stroke-dashoffset 200ms linear;
}

.island-bar-track {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.island-bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0A84FF, #64D2FF);
  transition: width 200ms linear;
}

.island-expand-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.48);
  font-variant-numeric: tabular-nums;
}

.island-view-done {
  display: none;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 7px;
  color: #30D158;
}

.island.is-done .island-view-xfer { display: none; }
.island.is-done .island-view-done { display: flex; align-items: center; }

.island-done-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
}

.island-check path {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
}

.island.is-done .island-check path {
  animation: island-check-draw 360ms var(--spring) 40ms forwards;
}

@keyframes island-check-draw {
  to { stroke-dashoffset: 0; }
}

/* ---------- 舞台 ---------- */

.stage {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: calc(env(safe-area-inset-top) + 20px) 18px
           calc(env(safe-area-inset-bottom) + 18px);
}

/* ---------- 品牌字標 ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  color: var(--blue);
  display: block;
  border-radius: 9px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.22) inset,
    0 6px 16px rgba(10, 132, 255, 0.28);
}

.brand-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}

/* ---------- 主玻璃卡 ---------- */

.card {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 440px;
  display: grid;
  border-radius: 36px;
  background: var(--glass-fill);
  background-color: var(--glass);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  isolation: isolate;
}

/* 頂部高光條：模擬玻璃折射，不覆蓋內容 */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  border-radius: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.7) 20%,
    rgba(255, 255, 255, 0.95) 50%,
    rgba(255, 255, 255, 0.7) 80%,
    transparent
  );
  pointer-events: none;
  z-index: 3;
}

/* 內部柔光，壓在內容下方 */
.card::after {
  content: "";
  position: absolute;
  top: -40%;
  left: 10%;
  right: 10%;
  height: 55%;
  background: radial-gradient(
    ellipse at center,
    rgba(255, 255, 255, 0.12),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.role-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 0.02em;
  min-height: 1.2em;
  margin-top: -6px;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--glass-inner-edge);
  box-shadow: var(--shadow-chip);
}

.role-tag[hidden] {
  display: none !important;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
}

.back-link {
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-inner-edge);
  border-radius: 999px;
  cursor: pointer;
  min-height: 40px;
  padding: 0 18px;
  box-shadow: var(--shadow-chip);
  transition: transform 200ms var(--spring), color 200ms var(--spring),
              background-color 200ms var(--spring);
}

.back-link:active {
  transform: scale(0.96);
  color: var(--ink);
}

/* 面板 */
.panel {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: scale(0.97);
  pointer-events: none;
}

.panel.is-active {
  display: flex;
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  animation: panel-in 320ms var(--spring) both;
}

@keyframes panel-in {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.panel[hidden] {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  animation: none !important;
}

/* ---------- 首頁：內嵌玻璃按鈕 ---------- */

.panel-home {
  gap: 12px;
  padding: 22px;
}

.role-btn {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 120px;
  border-radius: 24px;
  border: 1px solid var(--glass-inner-edge);
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--shadow-chip);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 220ms var(--spring), background-color 220ms var(--spring),
              transform 220ms var(--spring), box-shadow 220ms var(--spring);
}

.role-btn:active {
  transform: scale(0.975);
  background: rgba(255, 255, 255, 0.12);
}

@media (prefers-color-scheme: light) {
  .role-btn:active { background: rgba(255, 255, 255, 0.78); }
}

.role-send:active,
.role-send:focus-visible {
  border-color: rgba(10, 132, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 0 0 3px rgba(10, 132, 255, 0.18),
    0 8px 20px rgba(10, 132, 255, 0.15);
}

.role-recv:active,
.role-recv:focus-visible {
  border-color: var(--glass-edge);
}

.role-icon {
  width: 28px;
  height: 28px;
  color: var(--blue);
  margin-bottom: 8px;
  filter: drop-shadow(0 0 8px rgba(10, 132, 255, 0.45));
}

.role-recv .role-icon {
  color: var(--ink-2);
  filter: none;
}

.role-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.role-sub { font-size: 13px; color: var(--ink-2); }

.role-or {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-or span {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ink-3), transparent);
  opacity: 0.55;
}
.role-or em { font-style: normal; font-size: 12px; font-weight: 500; color: var(--ink-3); }

/* ---------- 選檔 / 輸入代碼 ---------- */

.join-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 10px;
}

.join-hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--ink-3);
}

.xfer-role {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 2px;
}

/* ---------- 拖放區 ---------- */

.dropzone {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 26px;
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  cursor: pointer;
  transition: border-color 220ms var(--spring), background-color 220ms var(--spring),
              transform 220ms var(--spring), box-shadow 220ms var(--spring);
}

@media (prefers-color-scheme: light) {
  .dropzone { border-color: rgba(10, 14, 28, 0.18); }
}

.file-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  border-radius: 26px;
}

.dropzone:active { transform: scale(0.985); }

.card.is-dragover .dropzone {
  border-color: var(--blue);
  border-style: solid;
  background: var(--blue-soft);
  box-shadow:
    0 0 0 4px rgba(10, 132, 255, 0.12),
    inset 0 0 40px rgba(10, 132, 255, 0.08);
}

.drop-arrow {
  width: 44px;
  height: 44px;
  color: var(--blue);
  margin-bottom: 10px;
  filter: drop-shadow(0 0 10px rgba(10, 132, 255, 0.4));
}

.card.is-dragover .drop-arrow { animation: nudge 600ms var(--spring) infinite alternate; }

@keyframes nudge {
  from { transform: translateY(0); }
  to   { transform: translateY(-6px); }
}

.drop-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.drop-sub   { font-size: 13px; color: var(--ink-2); text-align: center; max-width: 260px; line-height: 1.4; }

/* ---------- 大代碼 ---------- */

.code-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}

.big-code {
  font-family: inherit;
  font-size: clamp(52px, 15vw, 72px);
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1.1;
  padding: 8px 14px;
  border-radius: 18px;
  transition: transform 200ms var(--spring), background-color 200ms var(--spring);
}

.big-code:active {
  transform: scale(0.96);
  background: var(--glass-inner);
}

.big-code .d {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px);
  animation: pop-in 420ms var(--spring) forwards;
}

@keyframes pop-in {
  to { opacity: 1; transform: translateY(0); }
}

.copy-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  transition: color 200ms var(--spring);
  min-height: 1em;
}

.copy-hint.is-copied { color: var(--green); }

.link-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  min-height: 44px;
  padding: 0 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-inner-edge);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-chip);
  transition: transform 200ms var(--spring), background-color 200ms var(--spring),
              border-color 200ms var(--spring), color 200ms var(--spring);
}

.link-copy-btn svg { flex-shrink: 0; opacity: 0.85; }

.link-copy-btn:active {
  transform: scale(0.96);
}

.link-copy-btn.is-copied {
  color: var(--green);
  border-color: rgba(48, 209, 88, 0.45);
  background: rgba(48, 209, 88, 0.12);
}

.qr-wrap { margin-top: 14px; }

.qr {
  width: 96px;
  height: 96px;
  padding: 10px;
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 10px 28px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.2);
}

.qr svg { display: block; width: 100%; height: 100%; }

.waiting-text {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  animation: breathe 2.4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ---------- 確認 / 幽靈按鈕 ---------- */

.confirm-label { font-size: 13px; color: var(--ink-2); }

.confirm-peer {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  max-width: 90%;
  word-break: break-word;
}

.confirm-file {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 4px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  align-items: center;
}

.ghost-btn {
  min-height: 44px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 550;
  color: var(--ink-2);
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-inner-edge);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow-chip);
  transition: transform 200ms var(--spring), color 200ms var(--spring),
              background-color 200ms var(--spring);
}

.ghost-btn:active {
  transform: scale(0.96);
  color: var(--ink);
}

/* ---------- 進度環 ---------- */

.mini-code {
  font-size: 16px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.22em;
  color: var(--ink-2);
  margin-bottom: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--glass-inner);
  border: 1px solid var(--glass-inner-edge);
}

.ring-wrap {
  position: relative;
  width: 156px;
  height: 156px;
  filter: drop-shadow(0 0 18px rgba(10, 132, 255, 0.2));
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--track);
  stroke-width: 3;
}

.ring-bar {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 351.86;
  stroke-dashoffset: 351.86;
  transition: stroke-dashoffset 200ms linear;
  filter: drop-shadow(0 0 6px rgba(10, 132, 255, 0.55));
}

.ring-percent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.file-line {
  margin-top: 18px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  gap: 8px;
  align-items: baseline;
  max-width: 100%;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-inner);
  border: 1px solid var(--glass-inner-edge);
}

.file-line #t-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

.file-sep { color: var(--ink-3); }

.file-line #t-speed { font-variant-numeric: tabular-nums; }

/* ---------- 完成 ---------- */

.check-wrap { width: 150px; height: 150px; }

.check { width: 100%; height: 100%; }

.check-circle {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-dasharray: 351.86;
  stroke-dashoffset: 351.86;
  transform: rotate(-90deg);
  transform-origin: center;
  filter: drop-shadow(0 0 8px rgba(48, 209, 88, 0.45));
}

.check-mark {
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
}

.panel-done.is-active .check-circle {
  animation: draw-circle 400ms var(--spring) forwards;
}

.panel-done.is-active .check-mark {
  animation: draw-check 300ms var(--spring) 250ms forwards;
}

@keyframes draw-circle { to { stroke-dashoffset: 0; } }
@keyframes draw-check  { to { stroke-dashoffset: 0; } }

.done-text {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.done-name {
  font-size: 13px;
  color: var(--ink-3);
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recv-preview {
  max-width: 70%;
  max-height: 140px;
  border-radius: 18px;
  object-fit: contain;
  margin-bottom: 4px;
  background: rgba(0, 0, 0, 0.18);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2) inset,
    0 12px 28px rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-inner-edge);
}

.check-wrap.is-hidden { display: none; }

/* ---------- 多檔清單（玻璃列） ---------- */

.recv-list {
  width: 100%;
  max-height: 172px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding: 2px;
  -webkit-overflow-scrolling: touch;
}

.recv-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-inner-edge);
  box-shadow: var(--shadow-chip);
  flex-shrink: 0;
}

.recv-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recv-size {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.recv-ok {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  white-space: nowrap;
}

.row-save {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: 999px;
  padding: 5px 13px;
  min-height: 28px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.35);
  transition: transform 200ms var(--spring), filter 200ms var(--spring);
}

.row-save:active { transform: scale(0.94); filter: brightness(0.92); }

/* ---------- 資料夾直存 ---------- */

.dir-btn {
  margin-top: 18px;
  font-size: 12px;
  padding: 0 14px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dir-btn.is-set {
  color: var(--green);
  border-color: rgba(48, 209, 88, 0.45);
  background: rgba(48, 209, 88, 0.1);
}

.save-btn {
  margin-top: 14px;
  min-height: 46px;
  padding: 0 32px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #2B95FF 0%, var(--blue) 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 8px 24px rgba(10, 132, 255, 0.4);
  transition: transform 200ms var(--spring), filter 200ms var(--spring);
}

.save-btn:active { transform: scale(0.96); filter: brightness(0.92); }

.panel-done .ghost-btn { margin-top: 10px; }

/* ---------- 代碼輸入格 ---------- */

.code-input {
  position: relative;
  display: flex;
  gap: 8px;
  cursor: text;
}

.code-hidden {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  font-size: 16px;
  border: none;
  caret-color: transparent;
}

.code-cell {
  width: 44px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--glass-inner-edge);
  border-radius: 14px;
  background: var(--glass-inner);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-chip);
  transition: border-color 200ms var(--spring), transform 200ms var(--spring),
              box-shadow 200ms var(--spring), background-color 200ms var(--spring);
}

.code-cell.is-focus {
  border-color: rgba(10, 132, 255, 0.7);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 0 0 3px rgba(10, 132, 255, 0.2),
    0 6px 16px rgba(10, 132, 255, 0.12);
  background: rgba(10, 132, 255, 0.08);
}

.code-cell.is-filled {
  transform: scale(1.03);
  border-color: var(--glass-edge);
  color: var(--ink);
}

/* ---------- App 內建瀏覽器攔截 ---------- */

.browser-gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px calc(24px + env(safe-area-inset-bottom));
  background: rgba(6, 8, 14, 0.72);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

.browser-gate[hidden] { display: none !important; }

.browser-gate-card {
  width: min(380px, 100%);
  padding: 28px 24px 22px;
  border-radius: 28px;
  background: var(--glass-fill);
  background-color: var(--glass);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-card);
}

.browser-gate-kicker {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #FF9F0A;
  margin-bottom: 8px;
}

.browser-gate-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 10px;
}

.browser-gate-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 16px;
}

.browser-gate-steps {
  margin: 0 0 22px;
  padding: 14px 14px 14px 32px;
  border-radius: 16px;
  background: var(--glass-inner);
  border: 1px solid var(--glass-inner-edge);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
}

.browser-gate-steps li + li { margin-top: 6px; }
.browser-gate-steps strong { font-weight: 650; color: var(--ink); }

.browser-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- 接收完成：玻璃感分享提示 ---------- */

.share-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  pointer-events: none;
}

.share-sheet:not([hidden]) {
  pointer-events: auto;
}

.share-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 14, 0.42);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  opacity: 0;
  transition: opacity 320ms var(--ease-out);
}

.share-sheet.is-open .share-sheet-backdrop { opacity: 1; }

.share-sheet-card {
  position: relative;
  width: min(380px, 100%);
  padding: 28px 24px 22px;
  border-radius: 28px;
  background: var(--glass-fill);
  background-color: var(--glass);
  -webkit-backdrop-filter: blur(36px) saturate(180%);
  backdrop-filter: blur(36px) saturate(180%);
  border: 1px solid var(--glass-edge);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transform: translateY(28px) scale(0.96);
  opacity: 0;
  transition: transform 420ms var(--spring), opacity 320ms var(--ease-out);
}

.share-sheet.is-open .share-sheet-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.share-sheet-glow {
  position: absolute;
  top: -40%;
  left: 20%;
  width: 60%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(10, 132, 255, 0.28), transparent 70%);
  pointer-events: none;
}

.share-sheet-kicker {
  position: relative;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--blue);
  margin-bottom: 8px;
}

.share-sheet-title {
  position: relative;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

.share-sheet-body {
  position: relative;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.share-howto {
  position: relative;
  margin-top: 14px;
  padding-left: 1.25em;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  text-align: left;
}

.share-howto li::marker {
  color: var(--blue);
  font-weight: 700;
}

.share-sheet-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

.share-primary {
  min-height: 48px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(180deg, #2B95FF 0%, var(--blue) 100%);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28) inset,
    0 8px 24px rgba(10, 132, 255, 0.4);
  transition: transform 200ms var(--spring), filter 200ms var(--spring);
}

.share-primary:active { transform: scale(0.97); filter: brightness(0.92); }

.share-secondary {
  min-height: 44px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: color 200ms var(--spring), background-color 200ms var(--spring);
}

.share-secondary:active {
  color: var(--ink);
  background: var(--glass-inner);
}

@media (min-width: 720px) {
  .share-sheet {
    align-items: center;
    padding: 24px;
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .share-sheet-card {
    background: rgba(28, 30, 40, 0.94);
  }
  @media (prefers-color-scheme: light) {
    .share-sheet-card { background: rgba(255, 255, 255, 0.96); }
  }
}

/* ---------- 響應式 ---------- */

@media (max-width: 480px) {
  .card {
    height: min(440px, 62dvh);
    border-radius: 32px;
  }
  .code-cell { width: 40px; height: 52px; }
  .code-input { gap: 6px; }
  .stage { gap: 18px; }
}

/* ---------- Safari 無 backdrop-filter 後備 ---------- */

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card {
    background: rgba(28, 30, 40, 0.92);
  }
  @media (prefers-color-scheme: light) {
    .card { background: rgba(255, 255, 255, 0.92); }
  }
}

/* ---------- 動效偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 120ms !important;
  }
  .panel.is-active { animation: none; transform: none; }
  .waiting-text { animation: none; opacity: 0.7; }
  .island.is-done .island-check path {
    animation: none;
    stroke-dashoffset: 0;
  }
}
