:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel2: #1e2740;
  --line: #2a3550;
  --text: #e7ecf5;
  --muted: #93a1bd;
  --accent: #2563eb;
  --accent2: #38bdf8;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --tab-h: 58px;
  --top-h: 50px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: radial-gradient(900px 500px at 15% -10%, #1b2a4a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent2); text-decoration: none; }
button { font-family: inherit; }

#topbar { position: sticky; top: 0; z-index: 20; background: rgba(15,20,32,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-inner { height: var(--top-h); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; }
.logo { font-size: 18px; font-weight: 700; }
.logo-sub { font-size: 12px; color: var(--muted); margin-left: 6px; font-weight: 400; }
.chip { font-size: 12px; color: var(--text); background: var(--panel2); border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }

#page { max-width: 520px; margin: 0 auto; padding: 16px 14px 24px; }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: rgba(20,27,44,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.tab-ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--accent2); }
.tab.active .tab-ico { transform: translateY(-1px); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 15px; color: var(--accent2); margin-bottom: 10px; }
.hero { padding: 22px 18px; margin-bottom: 16px; border-radius: 16px; background: linear-gradient(135deg, #1e3a8a 0%, #172554 55%, #0f172a 100%); border: 1px solid rgba(56,189,248,.25); }
.hero h1 { font-size: 22px; font-weight: 700; }
.hero p { color: var(--muted); font-size: 13px; margin-top: 6px; line-height: 1.6; }
.hero .row { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.hero .balance { font-size: 20px; color: var(--warn); font-weight: 700; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--accent), #1d4ed8);
  cursor: pointer; transition: opacity .15s ease;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: .45; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--panel2); border: 1px solid var(--line); color: var(--text); }
.btn.sm { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.ok { background: linear-gradient(135deg, #059669, #047857); }

.grid { display: grid; gap: 10px; }
.grid.tools { grid-template-columns: repeat(3, 1fr); }
.tool-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 8px; text-align: center; color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.tool-card .ico { font-size: 26px; }
.tool-card .name { font-size: 12px; }
.tool-card .desc { font-size: 10px; color: var(--muted); line-height: 1.35; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 12px 14px; font-size: 15px; outline: none;
}
.input:focus { border-color: var(--accent2); }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-opt {
  padding: 9px 14px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); font-size: 13px; cursor: pointer;
}
.chip-opt.active { border-color: var(--accent2); color: var(--accent2); background: rgba(56,189,248,.12); }
.swatch { width: 16px; height: 16px; border-radius: 50%; display: inline-block; vertical-align: -3px; margin-right: 6px; border: 1px solid rgba(255,255,255,.2); }

.drop {
  border: 1.5px dashed #3b4b6d; border-radius: 14px; padding: 30px 16px; text-align: center;
  color: var(--muted); font-size: 13px; cursor: pointer; background: var(--panel2);
}
.drop .big { font-size: 40px; display: block; margin-bottom: 8px; }
.preview { width: 100%; border-radius: 12px; display: block; background: #0b1020; }
.preview-wrap { position: relative; }
.result-img { width: 100%; border-radius: 12px; display: block; }
.photo-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.photo-item { background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.photo-item img { width: 100%; border-radius: 8px; display: block; }
.photo-item .pname { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }

.notice { font-size: 12px; color: var(--muted); background: rgba(251,191,36,.06); border: 1px solid rgba(251,191,36,.25); border-radius: 12px; padding: 12px; line-height: 1.6; }
.notice b { color: var(--warn); }

.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; padding: 9px 0; border-radius: 9px; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }

.list-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-item:last-child { border-bottom: 0; }
.list-item .lk { color: var(--muted); font-size: 12px; }

.state-msg { font-size: 13px; color: var(--muted); text-align: center; padding: 8px; }
.state-msg.err { color: var(--err); }
.state-msg.ok { color: var(--ok); }
.terms { font-size: 12px; color: var(--muted); line-height: 1.6; }
.terms input { margin-right: 6px; }
.link-line { text-align: center; font-size: 13px; margin-top: 10px; }

.avatar { width: 54px; height: 54px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent2)); display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #fff; }
.user-head { display: flex; align-items: center; gap: 14px; }
.user-head .name { font-size: 17px; font-weight: 700; }
.user-head .phone { font-size: 12px; color: var(--muted); margin-top: 3px; }

#toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  background: rgba(15,20,32,.95); border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 12px; font-size: 13px; z-index: 99;
  opacity: 0; pointer-events: none; transition: opacity .2s ease; max-width: 80vw; text-align: center;
}
#toast.show { opacity: 1; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
