:root {
  --ground: #f3f1ee;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #69676a;
  --line: #e8e4df;
  --well: #f7f5f2;
  --action: #2a5cf0;
  --action-press: #1f4bd1;
  --action-soft: #eaf0ff;
  --danger: #c4372b;
  --danger-soft: #fdeeec;
  --ok: #1d7f47;
  --radius-lg: 32px;
  --radius-md: 24px;
  --radius-sm: 14px;
  --shadow: 0 10px 30px rgba(70, 50, 30, 0.07), 0 1px 3px rgba(70, 50, 30, 0.05);
  --shadow-lift: 0 24px 60px rgba(40, 30, 20, 0.18), 0 4px 10px rgba(40, 30, 20, 0.08);
  --spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: #cdc8c1 var(--ground); }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  caret-color: var(--action);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--action-soft); color: var(--ink); }

:focus-visible { outline: 3px solid rgba(42, 92, 240, 0.4); outline-offset: 3px; }

h1, h2, p { margin: 0; }

[hidden] { display: none !important; }

.page {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 96px) 20px 64px;
}

.intro { text-align: center; margin-bottom: 48px; }
.intro h1 { font-size: clamp(30px, 5vw, 40px); font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; text-wrap: balance; }
.intro p { margin-top: 12px; font-size: clamp(17px, 2.4vw, 20px); color: var(--muted); text-wrap: balance; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* 選項列 */
.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.option {
  border-radius: var(--radius-md);
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.option-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.option-title { font-weight: 600; }
.option-note { font-size: 15px; color: var(--muted); line-height: 1.5; text-wrap: pretty; }
.option-note.is-ok { color: var(--ok); }
.option-note.is-bad { color: var(--danger); }

.code-field {
  display: flex;
  align-items: center;
  min-width: 0;
  background: var(--well);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 14px;
  transition: border-color 0.2s, background 0.2s;
}
.code-field:focus-within { border-color: var(--action); background: var(--card); }
.code-field .prefix { color: var(--muted); white-space: nowrap; font-size: 16px; }
.code-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  padding: 12px 0;
  outline: none;
}
.code-field input::placeholder { color: #6f6c6f; font-weight: 400; }

/* 開關 */
.switch {
  flex: none;
  position: relative;
  width: 56px;
  height: 34px;
  border: 0;
  border-radius: 17px;
  background: #d9d5cf;
  cursor: pointer;
  transition: background 0.25s var(--ease-out);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  transition: transform 0.35s var(--spring);
}
.switch[aria-checked="true"] { background: var(--action); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

/* 拖曳區 */
.drop {
  position: relative;
  min-height: 340px;
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.45s var(--spring), box-shadow 0.45s var(--ease-out);
}
.drop:hover .drop-icon { transform: translateY(-3px); }
.drop:active { transform: scale(0.985); }
.drop-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--action-soft);
  color: var(--action);
  margin-bottom: 8px;
  transition: transform 0.35s var(--spring);
}
.drop-title { font-size: clamp(22px, 3.4vw, 28px); font-weight: 700; }
.drop-sub { color: var(--muted); }

/* 拖曳中：整頁變暗，拖曳區浮起 */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(35, 28, 20, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
  z-index: 10;
}
body.is-dragging .scrim { opacity: 1; }
body.is-dragging .drop {
  z-index: 11;
  transform: scale(1.03);
  box-shadow: var(--shadow-lift);
}
body.is-dragging .drop .drop-icon { transform: translateY(-6px) scale(1.08); }

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 0 28px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.25s var(--spring), background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-press); }
.btn-soft { background: var(--action-soft); color: var(--action); }
.btn-soft:hover { background: #dfe7ff; color: var(--action-press); }
.btn-plain { background: none; color: var(--muted); min-height: 44px; padding: 0 12px; }
.btn-plain:hover { color: var(--ink); }
.btn[disabled] { background: var(--well); color: #9a979a; cursor: default; transform: none; }
.btn-wide { width: 100%; min-height: 60px; font-size: 18px; border-radius: 20px; }

/* 上傳碼 */
.unlock { padding: 40px clamp(24px, 5vw, 48px); display: grid; gap: 18px; }
.unlock h2 { font-size: 22px; }
.unlock p { color: var(--muted); }
.unlock-row { display: flex; gap: 12px; flex-wrap: wrap; }
.unlock-row .code-field { flex: 1 1 220px; }

/* 進度 */
.progress { padding: 40px clamp(24px, 5vw, 48px); display: grid; gap: 24px; }
.progress-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.progress-head h2 { font-size: 22px; }
.progress-pct { font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 5px; background: var(--well); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--action); transition: width 0.2s linear; }

.files { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.file {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
}
.file + .file { border-top: 1px solid var(--line); }
.file-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--well);
  color: var(--muted);
  display: grid;
  place-items: center;
}
.file-name { font-weight: 600; overflow-wrap: anywhere; line-height: 1.4; }
.file-meta { font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.file-state { font-size: 15px; color: var(--muted); white-space: nowrap; }
.file-state.is-ok { color: var(--ok); }

/* 完成 */
.result {
  padding: clamp(32px, 5vw, 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 32px 40px;
  align-items: center;
}
.result { animation: rise 0.6s var(--ease-out); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
.result-title { display: flex; align-items: center; gap: 12px; font-size: 22px; text-wrap: balance; }
.check {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e3f4ea;
  color: var(--ok);
}
.result-host { margin-top: 24px; color: var(--muted); font-size: 17px; overflow-wrap: anywhere; }
.result-url {
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.result-actions { margin-top: 28px; display: flex; gap: 12px; flex-wrap: wrap; }
.result-facts { margin-top: 24px; display: grid; gap: 6px; color: var(--muted); font-size: 16px; }
.result-facts strong { color: var(--ink); font-weight: 600; }
.qr {
  width: 188px;
  padding: 14px;
  border-radius: var(--radius-md);
  background: var(--well);
  display: grid;
  gap: 8px;
  justify-items: center;
  font-size: 14px;
  color: var(--muted);
}
.qr svg { width: 160px; height: 160px; display: block; }
.result-again { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 20px; display: flex; justify-content: center; }

@media (max-width: 620px) {
  .result { grid-template-columns: 1fr; }
  .qr { justify-self: center; }
  .result-actions .btn { flex: 1 1 100%; }
}

/* 提示訊息 */
.notice {
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 16px;
}
.notice.is-info { background: var(--action-soft); color: #23458f; }

.compose-error { margin-top: 20px; }

.foot { margin-top: 40px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.usage { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; }
.usage-bar { width: 120px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.usage-bar span { display: block; height: 100%; border-radius: inherit; background: var(--muted); }
.usage.is-full { color: var(--danger); }
.usage.is-full .usage-bar span { background: var(--danger); }

/* 下載頁 */
.list-card { padding: 12px clamp(20px, 4vw, 36px); }
.list-card + .btn-wide { margin-top: 20px; }
.empty { padding: 56px 32px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty h2 { font-size: 24px; }
.empty p { color: var(--muted); max-width: 32ch; }
.empty .drop-icon { background: var(--well); color: var(--muted); }
.skeleton { height: 68px; border-radius: 14px; background: var(--well); margin: 12px 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

.brand { margin-top: 48px; text-align: center; font-size: 14px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}
