:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --line: #e4dfd4;
  --ink: #14213d;
  --text: #1d2433;
  --muted: #6b7283;
  --accent: #fca311;
  --accent-ink: #14213d;
  --primary: #14213d;
  --primary-text: #ffffff;
  --red: #d9480f;
  --green: #2b8a3e;
  --hot: #e8590c;
  --warm: #f59f00;
  --cold: #4c6ef5;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 16px rgba(20, 33, 61, .06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --surface: #171e2e;
    --surface-2: #1f2739;
    --line: #2a3349;
    --ink: #f2efe8;
    --text: #e6e3dc;
    --muted: #949bab;
    --primary: #fca311;
    --primary-text: #14213d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 "Noto Sans TC", -apple-system, "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.3; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Menlo, monospace; letter-spacing: 1px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 12px; }
.red { color: var(--red) !important; }
.boot { min-height: 100vh; display: grid; place-items: center; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px;
  transition: transform .08s, opacity .15s, background .15s; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.link { background: none; color: var(--muted); padding: 6px 4px; min-height: 0; font-weight: 400; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 14px; border-radius: 8px; }
.danger-text { color: var(--red) !important; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.xs { padding: 4px; }
.icon-btn.xs svg { width: 14px; height: 14px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.spin { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
.spin.dark { color: var(--muted); width: 24px; height: 24px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
input:not([type=checkbox]):not([type=radio]), select, textarea, .full-input {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; margin: 4px 0 14px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.code-input { text-align: center; font-size: 28px !important; letter-spacing: 10px; font-weight: 700; }
.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
.notice { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.notice.info { background: color-mix(in srgb, var(--cold) 10%, var(--surface)); }
.notice.err { background: color-mix(in srgb, var(--red) 12%, var(--surface)); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid.sub:empty { display: none; }
.form-grid.sub { padding: 12px 12px 0; margin-bottom: 14px; background: var(--surface-2); border-radius: 12px; }
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; cursor: pointer; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; }
.seg .hot input:checked + span { background: var(--hot); border-color: var(--hot); color: #fff; }
.seg .warm input:checked + span { background: var(--warm); border-color: var(--warm); color: #fff; }
.seg .cold input:checked + span { background: var(--cold); border-color: var(--cold); color: #fff; }
.colors { display: flex; gap: 10px; flex-wrap: wrap; }
.colors input { display: none; }
.colors i { display: block; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; outline-offset: 2px; }
.colors input:checked + i { outline: 3px solid var(--ink); }
.strength { display: flex; gap: 4px; margin: -6px 0 14px; }
.strength i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.strength i.on.s1 { background: var(--red); } .strength i.on.s2 { background: var(--warm); }
.strength i.on.s3, .strength i.on.s4 { background: var(--green); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand h1 { font-size: 28px; font-weight: 900; margin-top: 14px; letter-spacing: 2px; }
.auth-brand.small h1 { font-size: 22px; letter-spacing: 0; }
.auth-brand p { color: var(--muted); margin: 8px 0 0; }
.logo { width: 64px; height: 64px; border-radius: 18px; background: #14213d; color: var(--accent); display: grid; place-items: center; font-size: 34px; font-weight: 900; margin: 0 auto; box-shadow: var(--shadow); }
.logo.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 17px; margin: 0; box-shadow: none; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 20px; padding: 24px; box-shadow: var(--shadow); }
.small-links { margin-top: 10px; }
.recovery { font-family: ui-monospace, Menlo, monospace; font-size: 18px; font-weight: 700; letter-spacing: 1px; text-align: center; padding: 16px; background: var(--surface-2); border: 2px dashed var(--accent); border-radius: 12px; margin: 14px 0; word-break: break-all; color: var(--ink); }
.center-card { max-width: 400px; margin: 20vh auto; text-align: center; padding: 16px; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--ink); font-size: 17px; }
.plan-badge { border: 0; border-radius: 99px; padding: 4px 12px; font-size: 13px; font-weight: 700; cursor: pointer; background: var(--surface-2); color: var(--muted); }
.plan-badge.pro { background: var(--accent); color: var(--accent-ink); }
main { max-width: 760px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { flex: 1; max-width: 140px; background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 6px 0; cursor: pointer; }
.tabbar svg { width: 22px; height: 22px; }
.tabbar button.active { color: var(--ink); font-weight: 700; }
.tabbar button.active svg { stroke: var(--accent); }
.page-title { font-size: 22px; font-weight: 900; margin: 4px 0 12px; }

/* ---------- home ---------- */
.hello { margin: 4px 0 16px; }
.hello p { margin: 0 0 2px; font-size: 14px; }
.hello h2 { font-size: 22px; font-weight: 900; }
.hello em { font-style: normal; color: var(--hot); }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: default; }
.stat[data-go] { cursor: pointer; }
.stat > span { font-size: 13px; color: var(--muted); }
.stat b { font-size: 26px; font-weight: 900; color: var(--ink); line-height: 1.2; }
.stat b small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat > small { color: var(--muted); font-size: 13px; }
.meter { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s; }
.meter.full i { background: var(--red); }
.panel { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.panel-head h3 { font-size: 16px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; font-size: 14px; }
.empty .btn { margin-top: 12px; }
.typebar { display: grid; grid-template-columns: 12px 64px 1fr auto; align-items: center; gap: 8px; padding: 6px 0; }
.tname { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; }
.bar i.c { opacity: .45; }
.tnum { font-size: 14px; font-weight: 700; white-space: nowrap; }
.tnum small { font-weight: 400; color: var(--muted); font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.lg { width: 14px; height: 14px; }
.heat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.heat-box { border-radius: 12px; padding: 10px; text-align: center; background: var(--surface-2); }
.heat-box b { display: block; font-size: 24px; font-weight: 900; }
.heat-box span { font-size: 13px; color: var(--muted); }
.heat-box.hot b { color: var(--hot); } .heat-box.warm b { color: var(--warm); } .heat-box.cold b { color: var(--cold); }

/* ---------- list ---------- */
.list-head h2 { font-size: 22px; font-weight: 900; }
.quota { font-size: 13px; font-weight: 700; background: var(--surface); border-radius: 99px; padding: 3px 10px; box-shadow: var(--shadow); }
.quota.full { color: var(--red); }
.search { margin: 12px 0 8px; }
.search input { border-radius: 12px; padding-left: 14px; }
.filters { display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; }
.filters select { width: auto; flex: 1; min-width: 0; font-size: 14px; padding: 8px 10px; }
.cards { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; transition: transform .1s; }
.card:active { transform: scale(.99); }
.card-top { display: flex; align-items: center; gap: 12px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; background: var(--surface-2); color: var(--ink); font-size: 17px; }
.avatar.hot { background: color-mix(in srgb, var(--hot) 16%, var(--surface)); color: var(--hot); }
.avatar.warm { background: color-mix(in srgb, var(--warm) 18%, var(--surface)); color: #c77700; }
.avatar.cold { background: color-mix(in srgb, var(--cold) 14%, var(--surface)); color: var(--cold); }
.avatar.done { background: color-mix(in srgb, var(--green) 14%, var(--surface)); color: var(--green); }
.card-main { flex: 1; min-width: 0; }
.card-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.card-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.card-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { --c: var(--muted); display: inline-block; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--c); white-space: nowrap; vertical-align: middle; }
.chip.done { --c: var(--green); }
.chip.pro { --c: #b86e00; }
.chip.small { font-size: 11px; }
.due { font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--muted); }
.due.today { color: var(--warm); }
.due.overdue { color: var(--red); }
.due.deal { color: var(--green); }
.heat-tag { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 99px; color: #fff; vertical-align: middle; }
.heat-tag.hot { background: var(--hot); } .heat-tag.warm { background: var(--warm); } .heat-tag.cold { background: var(--cold); }
.fab {
  position: fixed; right: max(16px, calc(50vw - 364px)); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 15;
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #14213d; cursor: pointer;
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(252, 163, 17, .45);
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.6; }

/* ---------- modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; background: rgba(10, 15, 28, .45); display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity .18s; }
.modal-wrap.show { opacity: 1; }
.modal { background: var(--surface); width: 100%; max-width: 480px; max-height: 92vh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; transform: translateY(24px); transition: transform .2s; padding-bottom: env(safe-area-inset-bottom); }
.modal.wide { max-width: 620px; }
.modal-wrap.show .modal { transform: none; }
@media (min-width: 640px) { .modal-wrap { align-items: center; } .modal { border-radius: 20px; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 18px 18px 10px; }
.modal-head h3 { font-size: 19px; font-weight: 900; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.modal-body { padding: 4px 18px 12px; overflow-y: auto; }
.modal-body p { margin: 0 0 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.quick { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.qbtn { flex: 1; min-width: 64px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px; border-radius: 12px; background: var(--surface-2); text-decoration: none; font-size: 12px; color: var(--ink); }
.qbtn svg { width: 20px; height: 20px; }
.kvs { margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); flex-shrink: 0; }
.kv b { font-weight: 500; text-align: right; word-break: break-word; }
.note { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; margin-bottom: 14px; }
.deal-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: color-mix(in srgb, var(--green) 10%, var(--surface)); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.deal-box .full { grid-column: 1 / -1; }
.deal-box span { display: block; font-size: 12px; color: var(--muted); }
.deal-box b { color: var(--ink); }
.modal h4 { font-size: 15px; margin: 12px 0 8px; }
.log-form { background: var(--surface-2); padding: 10px; border-radius: 12px; display: flex; flex-direction: column; gap: 8px; }
.log-form input[type=date] { width: auto; padding: 4px 8px; font-size: 14px; }
.log-form .btn { align-self: flex-end; }
.logs { margin-top: 10px; }
.log { position: relative; padding: 8px 28px 8px 14px; border-left: 2px solid var(--accent); margin-left: 4px; }
.log time { font-size: 12px; color: var(--muted); }
.log p { margin: 2px 0 0 !important; font-size: 14px; white-space: pre-wrap; }
.log .icon-btn { position: absolute; top: 6px; right: 0; opacity: .5; }

/* ---------- settings ---------- */
.usage { margin: 10px 0; font-size: 14px; }
.usage .meter { margin-top: 4px; }
.panel > .btn.block { margin-top: 10px; }
.type-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.types { margin-bottom: 14px; }
.backup-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.plan-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13px; }
.plan-card.pro { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.plan-card.cur { outline: 2px solid var(--ink); }
.plan-card h4 { margin: 0 0 6px !important; }
.plan-card ul { margin: 0; padding-left: 18px; }
.user-row { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 8px; display: flex; flex-direction: column; gap: 8px; }
.user-row b { word-break: break-all; }
.foot { text-align: center; margin: 20px 0; }

/* ---------- toast ---------- */
#toasts { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); animation: tin .2s; max-width: 90vw; transition: opacity .3s, transform .3s; }
.toast.ok { background: var(--green); color: #fff; }
.toast.err { background: var(--red); color: #fff; }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } }
