:root {
  --bg: #0b0d11;
  --surface: #12161c;
  --surface-hi: #171c24;
  --line: rgba(255, 255, 255, 0.072);
  --line-strong: rgba(255, 255, 255, 0.13);
  --text: #e9edf2;
  --muted: #949eab;
  --dim: #7c8695;
  --accent: #d9a95c;
  --accent-dim: rgba(217, 169, 92, 0.13);
  --danger: #e0575b;
  --warn: #d99a4e;
  --ok: #59a97c;
  --radius: 14px;
  --radius-sm: 10px;
  --dock-h: 96px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", "Roboto Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100lvh;
  overflow-x: clip;
}

.shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  min-height: 100lvh;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* ---------------- appbar ---------------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(calc(env(safe-area-inset-top) + 14px), 24px) 20px 14px;
  background: var(--bg);
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
}

.brand-name {
  font-size: 15px;
  font-weight: 590;
  letter-spacing: 0.14em;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.16s, border-color 0.16s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn:active { transform: scale(0.94); }

.appbar-note {
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.ico {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------------- hero ---------------- */
.stage { padding: 4px 20px 28px; }

.hero { padding: 10px 0 24px; }

.hero-cap {
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.hero-num {
  font-family: var(--mono);
  font-size: 54px;
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.hero-num .cur { font-size: 30px; color: var(--muted); margin-right: 2px; letter-spacing: 0; }
.hero-num .frac { font-size: 30px; color: var(--dim); letter-spacing: -0.01em; }

.hero-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.sep { width: 1px; height: 11px; background: var(--line-strong); }

/* ---------------- pulse banner ---------------- */
.pulse {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  padding: 12px 14px;
  border: 1px solid rgba(224, 87, 91, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(224, 87, 91, 0.07);
}
.pulse[hidden] { display: none; }
.pulse p { margin: 0; font-size: 13px; line-height: 1.5; color: #f0b9bb; }
.pulse-dot {
  flex: none;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(224, 87, 91, 0.18);
}

/* ---------------- filters ---------------- */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.chip {
  padding: 8px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.16s, color 0.16s, border-color 0.16s;
}
.chip:active { transform: scale(0.95); }
.chip.is-on {
  background: var(--accent-dim);
  border-color: rgba(217, 169, 92, 0.42);
  color: var(--accent);
}

/* ---------------- list ---------------- */
.list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.list-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dim);
  text-transform: uppercase;
}
.list-count { font-size: 13px; color: var(--dim); font-variant-numeric: tabular-nums; }

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.item-body {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 15px 16px 13px;
}

.rail {
  flex: none;
  width: 2px;
  margin-right: 1px;
  align-self: stretch;
  min-height: 34px;
  border-radius: 2px;
  background: var(--line-strong);
}
.item[data-urgency="soon"] .rail { background: var(--warn); }
.item[data-urgency="urgent"] .rail { background: var(--danger); }

.logo-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  margin-top: 0;
}

.logo {
  width: 16px;
  height: 16px;
}

.logo-text {
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: 0;
}

.item-id { flex: 1; min-width: 0; }

.item-name {
  margin: 0;
  font-size: 15.5px;
  font-weight: 550;
  line-height: 1.3;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-sub .dot-sep { margin: 0 5px; opacity: 0.6; }

.item-cost {
  flex: none;
  text-align: right;
  padding-top: 1px;
}
.item-price {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.item-cycle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--dim);
}

.item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 16px 13px 31px;
  font-size: 12.5px;
  color: var(--muted);
}
.item-date { font-variant-numeric: tabular-nums; }

.badge {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.badge[data-tone="soon"] { color: var(--warn); border-color: rgba(217, 154, 78, 0.34); background: rgba(217, 154, 78, 0.08); }
.badge[data-tone="urgent"] { color: #f08a8d; border-color: rgba(224, 87, 91, 0.38); background: rgba(224, 87, 91, 0.1); }
.badge[data-tone="past"] { color: var(--dim); }

/* empty / skeleton */
.empty {
  padding: 46px 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}
.empty[hidden] { display: none; }
.empty p { margin: 0 0 6px; font-size: 14.5px; color: var(--muted); }
.empty span { font-size: 13px; color: var(--dim); }

.skeleton { display: flex; flex-direction: column; gap: 10px; }
.skeleton[hidden] { display: none; }
.sk-row {
  height: 92px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-hi) 50%, var(--surface) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

/* ---------------- dock ---------------- */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  padding: 10px 20px max(12px, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--line);
  pointer-events: none;
}
.dock .add-btn { pointer-events: auto; }

.add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 520px;
  justify-content: center;
  padding: 14px 22px;
  border: 1px solid rgba(217, 169, 92, 0.4);
  border-radius: 13px;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: inherit;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.16s;
}
.add-btn:hover { background: rgba(217, 169, 92, 0.19); }
.add-btn:active { transform: scale(0.97); }
.add-btn .ico {
  width: 17px;
  height: 17px;
  stroke-width: 1.8;
}

.ico { width: 17px; height: 17px; stroke-width: 1.8; }

/* ---------------- sheet ---------------- */
.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-top: 1px solid var(--line-strong);
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--text);
  max-height: 92lvh;
  overflow: hidden;
}
.sheet::backdrop {
  background: rgba(4, 6, 9, 0.66);
  backdrop-filter: blur(3px);
}
.sheet[open] { animation: sheet-in 0.26s cubic-bezier(0.22, 0.9, 0.24, 1); }
@keyframes sheet-in {
  from { transform: translateY(18px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.sheet-sm { max-width: 460px; }

.sheet-form { display: flex; flex-direction: column; max-height: 92lvh; }

.grip {
  width: 34px;
  height: 4px;
  margin: 9px auto 0;
  border-radius: 2px;
  background: var(--line-strong);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 10px;
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }

.sheet-body {
  padding: 4px 20px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--muted);
}
.field > span em {
  font-style: normal;
  font-size: 12px;
  color: var(--dim);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.3;
  transition: border-color 0.16s, background 0.16s;
}
.field textarea { resize: vertical; min-height: 56px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--dim); }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(217, 169, 92, 0.5);
  background: #0e1116;
}
.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 20px, calc(100% - 12px) 20px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

.form-err {
  margin: 2px 0 10px;
  font-size: 13px;
  color: #f08a8d;
}
.form-err[hidden] { display: none; }

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 10px 20px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.btn-primary {
  flex: 1;
  padding: 14px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #16120a;
  font-family: inherit;
  font-size: 15px;
  font-weight: 620;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), filter 0.16s;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.sm { flex: none; width: 100%; padding: 12px 16px; font-size: 14px; margin-top: 4px; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.16s, border-color 0.16s;
}
.btn-ghost[hidden] { display: none; }
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn-ghost:active { transform: scale(0.97); }
.btn-ghost.sm { padding: 9px 15px; font-size: 13px; }
.btn-ghost.wide { width: 100%; margin-top: 16px; }
.btn-ghost.danger { color: #e07579; border-color: rgba(224, 87, 91, 0.26); }
.btn-ghost .ico {
  width: 16px;
  height: 16px;
}

.ico { width: 16px; height: 16px; }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
}
.set-title { margin: 0 0 4px; font-size: 14.5px; }
.set-desc { margin: 0; font-size: 12.5px; color: var(--dim); }
.pw-box { padding-top: 16px; }
.pw-box[hidden] { display: none; }

/* ---------------- toast ---------------- */
.toast-stack {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(420px, calc(100% - 40px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #1b2029;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  animation: toast-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast[data-tone="err"] { border-color: rgba(224, 87, 91, 0.4); color: #f3b6b8; }
.toast.is-out { animation: toast-out 0.18s ease forwards; }
@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateY(6px); opacity: 0; }
}

/* ---------------- login ---------------- */
.login-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100lvh;
  padding: 0 24px calc(24px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin: 0 auto;
}
.login-mark {
  width: 12px; height: 12px;
  border: 1.5px solid var(--accent);
  border-radius: 2px;
  transform: rotate(45deg);
  margin-bottom: 26px;
}
.login-title { margin: 0 0 8px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.login-desc { margin: 0 0 30px; font-size: 14px; line-height: 1.6; color: var(--muted); }
.login-wrap .field input { font-size: 16px; }

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