/* ============================================================
 *  幸运转盘 · 手机优先 PWA 样式
 *  - 浅色 / 深色双主题（html[data-theme]）
 *  - 顶部固定栏 + 底部导航 + 安全区
 *  - 转盘 / 编辑列表 / 结果弹层
 * ============================================================ */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --field: #f8fafc;
  --chip: #f1f5f9;
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 28px rgba(16, 24, 40, .07);
  --shadow-soft: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
  --bar-bg: rgba(255, 255, 255, .88);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1020;
  --card: #151b2e;
  --text: #e8ebf2;
  --muted: #9aa3b5;
  --line: #26304a;
  --field: #101728;
  --chip: #1b2339;
  --brand: #818cf8;
  --brand-2: #a78bfa;
  --brand-soft: #1e2a52;
  --danger: #f87171;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-soft: 0 1px 2px rgba(0, 0, 0, .28), 0 4px 16px rgba(0, 0, 0, .24);
  --bar-bg: rgba(17, 23, 40, .88);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(1100px 560px at 88% -12%, rgba(99, 102, 241, .16), transparent 62%),
    radial-gradient(900px 520px at -8% 108%, rgba(236, 72, 153, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  padding-top: calc(58px + var(--safe-top));
  padding-bottom: calc(70px + var(--safe-bottom));
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
}
body.modal-open { overflow: hidden; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- 顶栏 ---------- */
.app-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(58px + var(--safe-top)); padding: var(--safe-top) 14px 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--bar-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  color: var(--brand); background: var(--brand-soft);
}
.app-bar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 700; letter-spacing: .2px; }
.icon-btn {
  width: 40px; height: 40px; border: 0; background: transparent; color: var(--text);
  font-size: 19px; border-radius: 12px; cursor: pointer; flex: none;
}
.icon-btn:active { background: var(--chip); }

/* ---------- 内容区 ---------- */
.view {
  padding: 12px; display: flex; flex-direction: column; gap: 12px;
  max-width: 760px; margin: 0 auto;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(70px + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  display: flex; background: var(--bar-bg); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.tabbar button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; cursor: pointer; font-family: inherit;
  transition: color .18s, transform .18s;
}
.tabbar button .ico { font-size: 21px; line-height: 1; transition: transform .18s; }
.tabbar button[aria-current="page"] { color: var(--brand); font-weight: 600; }
.tabbar button[aria-current="page"] .ico { transform: translateY(-2px) scale(1.08); }

/* ---------- 卡片 / 基础控件 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
  border: 1px solid rgba(255, 255, 255, .04);
}
.card h2 { font-size: 16px; margin: 0; font-weight: 700; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.mt { margin-top: 10px; }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.45; }
.btn {
  border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 700;
  background: var(--brand); color: #fff; cursor: pointer; font-family: inherit;
  font-size: 15px; transition: transform .12s, filter .18s, opacity .18s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.wide { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
input, textarea, select {
  font-family: inherit; color: var(--text);
}
input::placeholder { color: var(--muted); opacity: .7; }

/* ---------- 转盘 ---------- */
.wheel-card { padding: 8px 14px 16px; overflow: visible; }
.wheel-wrap {
  position: relative; width: min(100%, 400px); aspect-ratio: 1 / 1;
  margin: 10px auto 6px;
}
.wheel-disc {
  position: absolute; inset: 4%;
  border-radius: 50%;
  border: 6px solid var(--card);
  background: var(--card);
  box-shadow: 0 20px 44px rgba(16, 24, 40, .18), 0 2px 4px rgba(16, 24, 40, .10);
  transform-origin: 50% 50%;
  will-change: transform;
}
:root[data-theme="dark"] .wheel-disc {
  box-shadow: 0 22px 48px rgba(0, 0, 0, .55), 0 2px 4px rgba(0, 0, 0, .4);
}
.wheel-disc canvas { display: block; width: 100%; height: 100%; border-radius: 50%; }
.pointer {
  position: absolute; top: -10px; left: 50%; z-index: 5;
  width: 48px; height: 56px; transform: translateX(-50%);
  filter: drop-shadow(0 5px 7px rgba(15, 23, 42, .28));
  pointer-events: none;
}
.pointer svg { display: block; width: 100%; height: 100%; }
.hub {
  position: absolute; left: 50%; top: 50%; z-index: 4;
  width: 25%; min-width: 72px; max-width: 94px; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%; border: 5px solid var(--card);
  background: linear-gradient(145deg, #6366f1 0%, #7c3aed 58%, #9333ea 100%);
  color: #fff; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .42), inset 0 2px 4px rgba(255, 255, 255, .34);
  transition: transform .12s, box-shadow .18s;
}
.hub:active:not(:disabled) { transform: translate(-50%, -50%) scale(.94); }
.hub:disabled { cursor: default; }
.hub-main { font-size: 18px; font-weight: 800; letter-spacing: 1px; line-height: 1.1; }
.hub-sub { font-size: 8px; font-weight: 700; letter-spacing: 2px; opacity: .78; }
.hub.spinning { animation: hubPulse 1.05s ease-in-out infinite; }
@keyframes hubPulse {
  0%, 100% { box-shadow: 0 8px 20px rgba(79, 70, 229, .42), inset 0 2px 4px rgba(255, 255, 255, .34); }
  50% { box-shadow: 0 0 0 9px rgba(99, 102, 241, .14), 0 8px 26px rgba(79, 70, 229, .55), inset 0 2px 4px rgba(255, 255, 255, .34); }
}
.wheel-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 4px 10px; font-size: 13px; color: var(--muted);
}
.wheel-foot b { color: var(--text); font-weight: 700; }
.link-btn {
  border: 0; background: transparent; color: var(--brand); font-family: inherit;
  font-size: 13px; font-weight: 650; padding: 6px 4px; cursor: pointer; flex: none;
}
.btn.spin {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #9333ea 100%);
  box-shadow: 0 10px 24px rgba(79, 70, 229, .30);
  letter-spacing: 3px; font-size: 16px; padding: 15px;
}
.hint { text-align: center; color: var(--muted); font-size: 12px; padding: 0 16px; line-height: 1.5; }

.last-card { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.last-label { font-size: 12px; color: var(--muted); flex: none; }
.last-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.last-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.last-share {
  flex: none; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  color: var(--brand); background: var(--brand-soft); font-weight: 650;
}
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--c, var(--brand)); }

/* ---------- 编辑页 ---------- */
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.card-head > div { flex: 1; min-width: 0; }
.count-pill {
  flex: none; font-size: 12px; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); padding: 4px 10px; border-radius: 999px;
}
.item-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.item-row {
  background: var(--field); border: 1px solid var(--line); border-radius: 16px;
  padding: 9px 11px 10px;
}
.item-top { display: flex; align-items: center; gap: 8px; }
.color-dot {
  width: 26px; height: 26px; flex: none; border-radius: 50%; padding: 0;
  background: var(--dot, #6366f1); border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12), inset 0 1px 2px rgba(255, 255, 255, .4);
  cursor: pointer;
}
:root[data-theme="dark"] .color-dot { border-color: rgba(255, 255, 255, .35); }
.color-dot:active { transform: scale(.92); }
.item-name {
  flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 9px;
  padding: 5px 6px; font-size: 15px; font-weight: 650;
}
.item-name:focus { background: var(--card); outline: 1.5px solid var(--brand); }
.row-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 30px; height: 30px; border-radius: 9px; font-size: 15px; flex: none;
  display: grid; place-items: center; padding: 0;
}
.row-btn:active { background: var(--chip); }
.row-btn.del { font-size: 14px; }
.row-btn.del:active { color: var(--danger); background: rgba(220, 38, 38, .1); }
.row-btn:disabled { opacity: .28; cursor: default; }
.item-bottom {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 5px;
  padding-left: 2px;
}
.weight-label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.item-weight {
  width: 76px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); padding: 5px 7px; font-size: 13.5px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.item-weight:focus { border-color: var(--brand); outline: none; }
.item-weight.invalid { border-color: var(--danger); background: rgba(220, 38, 38, .06); }
.share {
  font-size: 12.5px; color: var(--brand); font-weight: 650;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.reorder { margin-left: auto; display: flex; gap: 2px; }
.reorder .row-btn { width: 28px; height: 28px; font-size: 14px; }
.btn.add {
  border: 1.5px dashed var(--line); background: transparent; color: var(--brand);
  width: 100%; padding: 12px; font-size: 14px;
}
.btn.add:active { border-color: var(--brand); }
.quick-actions { display: flex; gap: 8px; margin-top: 10px; }
.chip-btn {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 11px; padding: 9px 6px; font-size: 12.5px; font-family: inherit;
  font-weight: 600; cursor: pointer;
}
.chip-btn:active { background: var(--chip); }
.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 12px; }
.preset-btn {
  border: 1px solid var(--line); background: var(--field); border-radius: 14px;
  padding: 11px 12px; text-align: left; cursor: pointer; font-family: inherit;
  color: var(--text); display: flex; flex-direction: column; gap: 3px;
}
.preset-btn:active { border-color: var(--brand); background: var(--brand-soft); }
.preset-ico { font-size: 19px; line-height: 1.2; }
.preset-title { font-size: 13.5px; font-weight: 650; }
.preset-note { font-size: 11px; color: var(--muted); }
.switch-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0 2px;
  font-size: 14px; cursor: pointer;
}
.switch-row > span:first-child { flex: 1; }
.switch-input {
  -webkit-appearance: none; appearance: none; width: 48px; height: 28px; flex: none;
  border-radius: 999px; background: var(--line); position: relative;
  cursor: pointer; transition: background .2s; margin: 0;
}
.switch-input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .25);
}
.switch-input:checked { background: var(--brand); }
.switch-input:checked::after { transform: translateX(20px); }
.version { text-align: center; color: var(--muted); font-size: 11.5px; padding: 4px 0 0; }
.log-row { text-align: center; padding-bottom: 8px; }
.log-row .link-btn { font-size: 12px; font-weight: 600; }
.log-list { margin: 12px 0 16px; display: flex; flex-direction: column; gap: 14px; }
.log-entry { background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.log-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.log-head b { color: var(--brand); font-size: 14px; }
.log-title { font-weight: 650; font-size: 14px; margin: 4px 0 6px; }
.log-items { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.65; }

/* ---------- 弹层 / 结果 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 30; background: rgba(8, 12, 24, .58);
  display: flex; align-items: flex-end; justify-content: center;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal .sheet {
  background: var(--card); width: 100%; max-width: 480px;
  border-radius: 26px 26px 0 0; padding: 22px 20px;
  max-height: 88vh; overflow: auto;
  padding-bottom: calc(22px + var(--safe-bottom));
  box-shadow: 0 -20px 50px rgba(0, 0, 0, .30);
  animation: sheetUp .26s cubic-bezier(.2, .8, .2, 1);
}
@keyframes sheetUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet h2 { margin: 0 0 6px; font-size: 19px; }
.sheet .body { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 4px 0 18px; }
.result-sheet { text-align: center; }
.result-kicker {
  font-size: 12px; letter-spacing: 3px; color: var(--muted); font-weight: 700;
  margin-bottom: 10px;
}
.result-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  max-width: 100%; padding: 8px 16px; border-radius: 999px;
  background: var(--field); border: 1px solid var(--line); margin-bottom: 10px;
}
.result-name {
  font-size: clamp(26px, 8vw, 34px); line-height: 1.22; font-weight: 800;
  letter-spacing: .5px; margin: 2px 0 8px;
  overflow-wrap: anywhere;
}
.result-meta { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.result-meta b { color: var(--brand); }
.result-actions { display: flex; flex-direction: column; gap: 9px; }
.result-tip { font-size: 11.5px; color: var(--muted); margin-top: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-bottom));
  transform: translateX(-50%) translateY(18px);
  background: rgba(17, 24, 39, .94); color: #fff; padding: 11px 16px;
  border-radius: 13px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s; max-width: min(88vw, 460px);
  z-index: 40; text-align: center; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .30);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-action {
  border: 0; background: rgba(255, 255, 255, .16); color: #fff;
  border-radius: 8px; padding: 5px 10px; font-family: inherit; font-size: 13px;
  font-weight: 700; cursor: pointer; flex: none;
}

/* ---------- 小屏适配 ---------- */
@media (max-height: 720px) {
  .wheel-wrap { width: min(100%, 310px); }
  .wheel-card { padding-top: 4px; }
  .wheel-foot { padding-bottom: 8px; }
}
@media (min-width: 680px) {
  .view { max-width: 780px; }
  .wheel-wrap { width: min(100%, 420px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
  .wheel-disc { transition-duration: .6s !important; }
}
