:root{
  --navy:#1E3A66; --navy-2:#16294A;
  --gold:#ECC24E; --gold-2:#D9A93A; --gold-ink:#B0851A;
  --bg:#F4F6F9; --card:#FFFFFF;
  --ink:#1E3A66; --muted:#6B7A90; --line:#E2E7EE;
  --danger:#C0492F; --ok:#2E8B6F;
  --radius:14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
}
*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body{ margin:0; }
body{
  font-family:var(--sans); background:var(--bg); color:var(--ink);
  line-height:1.5; min-height:100dvh; display:flex; flex-direction:column; -webkit-font-smoothing:antialiased;
}
body.lock{ overflow:hidden; }
.i{ width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; display:block; }

/* Update bar */
.update-bar{
  position:sticky; top:0; z-index:30; display:none; align-items:center; gap:12px;
  background:var(--gold); color:var(--navy-2); padding:10px 16px; font-size:14px; font-weight:700;
  padding-top:calc(env(safe-area-inset-top) + 10px);
}
.update-bar.show{ display:flex; }
.update-bar button{
  margin-left:auto; background:var(--navy-2); color:#fff; border:0; cursor:pointer;
  font-family:var(--sans); font-size:13px; font-weight:700; padding:7px 16px; border-radius:999px;
}

/* Header */
header{
  position:sticky; top:0; z-index:20; background:var(--navy); color:#fff;
  padding:calc(env(safe-area-inset-top) + 12px) 14px 12px;
  display:flex; align-items:center; gap:10px; box-shadow:0 1px 0 rgba(0,0,0,.12);
}
.update-bar.show ~ header{ top:auto; } /* 同時出現時不互相黏死 */
.brand{ display:flex; align-items:center; gap:10px; min-width:0; }
.brand-mark{ flex:0 0 auto; display:block; line-height:0; }
.brand h1{ font-size:17px; font-weight:700; margin:0; letter-spacing:.2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.spacer{ flex:1 1 auto; }
.icon-btn{
  flex:0 0 auto; width:40px; height:40px; border-radius:10px; border:0; cursor:pointer;
  background:rgba(255,255,255,.12); color:#fff; display:grid; place-items:center;
}
.icon-btn:active{ background:rgba(255,255,255,.22); }
.add{
  flex:0 0 auto; display:inline-flex; align-items:center; gap:6px;
  background:var(--gold); color:var(--navy-2); border:0; cursor:pointer;
  font-family:var(--sans); font-size:15px; font-weight:700; padding:9px 14px; border-radius:999px;
}
.add .i{ width:17px; height:17px; stroke-width:2.4; }
.add:active{ background:var(--gold-2); }

.wrap{ width:100%; max-width:560px; margin:0 auto; align-self:center; flex:1 0 auto; display:flex; flex-direction:column; padding:16px 16px calc(28px + env(safe-area-inset-bottom)); }

/* Search + toolbar */
.search{ position:relative; margin-bottom:10px; }
.search svg{ position:absolute; left:12px; top:50%; transform:translateY(-50%); width:18px; height:18px; stroke:var(--muted); fill:none; stroke-width:1.8; }
.search input{
  width:100%; font-family:var(--sans); font-size:16px; color:var(--ink);
  padding:12px 14px 12px 40px; border:1px solid var(--line); border-radius:12px; background:var(--card); outline:none;
}
.search input:focus{ border-color:var(--navy); box-shadow:0 0 0 3px rgba(30,58,102,.12); }
.toolbar{ display:flex; align-items:center; gap:8px; margin:2px 2px 14px; }
.count{ font-size:13px; color:var(--muted); }
.tools{ margin-left:auto; display:flex; gap:6px; }
.tbtn{
  display:inline-flex; align-items:center; gap:5px; cursor:pointer;
  background:transparent; border:1px solid var(--line); border-radius:9px;
  color:var(--navy); font-family:var(--sans); font-size:13px; font-weight:600; padding:6px 10px;
}
.tbtn .i{ width:15px; height:15px; }
.tbtn:active{ background:#eef1f6; }

/* Cards */
#list{ display:flex; flex-direction:column; gap:10px; }
.card{ background:var(--card); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
.card-head{
  width:100%; display:flex; align-items:center; gap:10px; text-align:left;
  background:transparent; border:0; cursor:pointer; padding:14px 16px; font-family:var(--sans); color:var(--ink);
}
.card-name{ font-size:16px; font-weight:700; flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.card-meta{ flex:0 0 auto; font-size:12px; color:var(--muted); background:#eef1f6; padding:3px 9px; border-radius:999px; }
.chev{ flex:0 0 auto; color:var(--muted); transition:transform .22s ease; }
.card.open .chev{ transform:rotate(180deg); }
.card-body{ max-height:0; overflow:hidden; transition:max-height .26s ease; }
.card.open .card-body{ max-height:2000px; }

.field{ padding:12px 16px; border-top:1px solid var(--line); }
.field-label{ font-size:12px; font-weight:600; color:var(--muted); margin-bottom:6px; }
.field-row{ display:flex; align-items:stretch; gap:8px; }
.chip{
  flex:1 1 auto; min-width:0; font-family:var(--mono); font-size:13.5px;
  background:#f6f8fb; border:1px solid var(--line); border-radius:9px; padding:9px 11px; color:var(--ink);
  display:flex; align-items:center; word-break:break-all; overflow-wrap:anywhere; line-height:1.45;
}
.chip.masked{ letter-spacing:3px; color:var(--muted); }
.ic{
  flex:0 0 auto; width:40px; border:1px solid var(--line); border-radius:9px;
  background:var(--card); color:var(--navy); cursor:pointer; display:grid; place-items:center;
}
.ic:active{ background:#eef1f6; }
.ic.copy{ background:var(--navy); border-color:var(--navy); color:#fff; }
.ic.copy:active{ background:var(--navy-2); }
.ic.ok{ background:var(--ok); border-color:var(--ok); color:#fff; }

.nofield{ padding:14px 16px; border-top:1px solid var(--line); color:var(--muted); font-size:14px; }
.card-actions{ display:flex; gap:8px; padding:12px 16px; border-top:1px solid var(--line); background:#fafbfc; }
.btn{
  display:inline-flex; align-items:center; gap:6px; cursor:pointer;
  font-family:var(--sans); font-size:14px; font-weight:600; padding:8px 14px;
  border-radius:10px; border:1px solid var(--line); background:var(--card); color:var(--navy);
}
.btn .i{ width:16px; height:16px; }
.btn:active{ background:#eef1f6; }
.btn.danger{ color:var(--danger); }

/* Empty */
.empty{ text-align:center; padding:56px 24px; color:var(--muted); }
.empty .ring{
  width:54px; height:54px; border-radius:14px; margin:0 auto 14px;
  background:var(--navy); border:2px solid var(--gold); display:grid; place-items:center;
}
.empty .ring svg{ width:26px; height:26px; stroke:var(--gold); fill:none; stroke-width:1.8; }
.empty p{ margin:6px 0; font-size:15px; }
.empty .sub{ font-size:13px; opacity:.85; }

.note{ margin-top:auto; padding-top:6px; font-size:12px; color:var(--muted); line-height:1.7; text-align:center; }

/* Footer */
.site-foot{
  margin-top:18px; padding-top:16px; border-top:1px solid var(--line);
  display:flex; align-items:center; justify-content:center; gap:7px;
  color:var(--muted); font-size:12px;
}
.foot-mark{ line-height:0; color:var(--muted); }

/* Modal: editor */
.overlay{ position:fixed; inset:0; z-index:50; background:rgba(15,25,45,.5); display:none; }
.overlay.show{ display:block; }
.sheet{
  position:absolute; left:0; right:0; bottom:0; background:var(--card);
  border-radius:18px 18px 0 0; max-height:92dvh; display:flex; flex-direction:column;
  padding-bottom:env(safe-area-inset-bottom); animation:rise .22s ease;
}
@keyframes rise{ from{ transform:translateY(18px); opacity:.6; } to{ transform:none; opacity:1; } }
.sheet-head{ display:flex; align-items:center; gap:10px; padding:16px; border-bottom:1px solid var(--line); }
.sheet-head h2{ font-size:17px; margin:0; font-weight:700; flex:1; }
.x{ width:36px; height:36px; border-radius:9px; border:0; background:#eef1f6; color:var(--navy); cursor:pointer; display:grid; place-items:center; }
.sheet-body{ overflow:auto; padding:16px; }
.lbl{ font-size:13px; font-weight:600; color:var(--muted); margin:0 0 6px; }
.name-in{
  width:100%; font-family:var(--sans); font-size:16px; color:var(--ink);
  padding:12px 14px; border:1px solid var(--line); border-radius:11px; background:var(--card); outline:none;
}
.name-in:focus, .f-label:focus, .f-value:focus{ border-color:var(--navy); box-shadow:0 0 0 3px rgba(30,58,102,.12); }
.fields-head{ display:flex; align-items:center; margin:20px 0 8px; }
.fields-head .lbl{ margin:0; }
.fields-head .hint{ margin-left:auto; font-size:12px; color:var(--muted); }
.frow{ display:grid; grid-template-columns:1fr auto; gap:8px; margin-bottom:10px; align-items:start; }
.f-label{
  grid-column:1 / 2; font-family:var(--sans); font-size:14px; color:var(--ink);
  padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:var(--card); outline:none;
}
.f-value{
  grid-column:1 / 2; font-family:var(--mono); font-size:14px; color:var(--ink);
  padding:10px 12px; border:1px solid var(--line); border-radius:10px; background:#f8fafc; outline:none;
  resize:none; min-height:42px; width:100%; line-height:1.5;
}
.f-del{ grid-column:2 / 3; grid-row:1 / 3; align-self:stretch; width:42px; }
.addfield{
  display:inline-flex; align-items:center; gap:6px; cursor:pointer; margin-top:4px;
  background:#eef1f6; color:var(--navy); border:1px dashed #b9c4d6; border-radius:10px;
  font-family:var(--sans); font-size:14px; font-weight:600; padding:10px 14px;
}
.addfield:active{ background:#e3e8f1; }
.sheet-foot{ display:flex; gap:10px; padding:14px 16px; border-top:1px solid var(--line); }
.sheet-foot .btn{ flex:1; justify-content:center; padding:13px; font-size:15px; }
.btn.primary{ background:var(--gold); border-color:var(--gold); color:var(--navy-2); font-weight:700; }
.btn.primary:active{ background:var(--gold-2); }

/* Confirm + changelog share .confirm shell */
.confirm{ position:fixed; inset:0; z-index:60; background:rgba(15,25,45,.5); display:none; align-items:center; justify-content:center; padding:24px; }
.confirm.show{ display:flex; }
.confirm .box{ background:var(--card); border-radius:16px; max-width:340px; width:100%; padding:22px; }
.confirm p{ margin:0 0 18px; font-size:15px; line-height:1.6; }
.confirm .row{ display:flex; gap:10px; }
.confirm .row .btn{ flex:1; justify-content:center; padding:12px; }
.btn.solid-danger{ background:var(--danger); border-color:var(--danger); color:#fff; }

/* Changelog popup */
.clog .box{ max-width:420px; padding:0; max-height:84dvh; display:flex; flex-direction:column; overflow:hidden; }
.clog-head{ display:flex; align-items:center; gap:10px; padding:16px; border-bottom:1px solid var(--line); }
.clog-head h2{ font-size:17px; margin:0; font-weight:700; flex:1; }
.clog-body{ overflow:auto; padding:16px; }
.cl{ padding:0; }
.cl-hero{ text-align:center; padding:6px 0 18px; margin-bottom:4px; border-bottom:1px solid var(--line); }
.cl-hero-label{ font-family:var(--mono); font-size:11px; letter-spacing:.24em; text-transform:uppercase; color:var(--muted); }
.cl-hero-ver{ font-family:var(--mono); font-size:40px; font-weight:700; color:var(--gold-ink); line-height:1.05; margin-top:8px; }
.cl-ver{ display:flex; align-items:baseline; gap:10px; margin:20px 0 10px; padding-bottom:8px; border-bottom:1px solid var(--line); }
.cl-ver:first-child{ margin-top:6px; }
.cl-v{ font-family:var(--mono); font-size:15px; color:var(--gold-ink); font-weight:600; }
.cl-v.cur{ background:var(--gold); color:var(--navy-2); padding:1px 9px; border-radius:999px; font-weight:700; }
.cl-date{ font-family:var(--mono); font-size:12px; color:var(--muted); }
.cl-item{ display:flex; gap:10px; align-items:flex-start; padding:5px 0; font-size:13.5px; color:var(--ink); line-height:1.6; }
.cl-tag{ flex:none; font-size:11px; border-radius:5px; padding:1px 8px; font-weight:600; margin-top:2px; }
.cl-feat{ background:rgba(46,139,111,.13); color:#1E7A5A; }
.cl-change{ background:rgba(217,169,58,.20); color:#9A6F12; }
.cl-fix{ background:rgba(192,73,47,.12); color:#B0402B; }

/* Toast */
.toast{
  position:fixed; left:50%; bottom:calc(env(safe-area-inset-bottom) + 24px); transform:translate(-50%, 12px);
  background:var(--navy-2); color:#fff; padding:11px 18px; border-radius:999px; font-size:14px; font-weight:600;
  z-index:80; opacity:0; pointer-events:none; transition:opacity .18s ease, transform .18s ease; max-width:88vw; text-align:center;
}
.toast.show{ opacity:1; transform:translate(-50%,0); }

.foot-line{ display:inline; }
.ver-btn{ font:inherit; font-family:var(--mono); color:var(--navy); background:none; border:0; cursor:pointer; padding:3px 7px; border-radius:7px; font-weight:700; text-decoration:underline; text-underline-offset:2px; text-decoration-thickness:1px; }
.ver-btn:hover{ color:var(--navy-2); }
.ver-btn:active{ background:#eef1f6; }

@media (prefers-reduced-motion: reduce){
  *{ animation:none !important; transition:none !important; }
}
:focus-visible{ outline:2px solid var(--gold); outline-offset:2px; }
