:root {
  --bg: #0b1220;
  --card: #16203a;
  --card2: #1c2a4a;
  --txt: #e8edf7;
  --muted: #8b96ad;
  --accent: #6366f1;
  --accent2: #8b5cf6;
  --danger: #f87171;
  --star: #fbbf24;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: contain;
}
#app { max-width: 640px; margin: 0 auto; padding: 0 16px 96px; }

/* --- top bar --- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0 6px;
}
.topbar h1 {
  font-size: 26px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar .sub { font-size: 15px; font-weight: 600; }
.icon-btn {
  background: var(--card); color: var(--muted); border: none;
  width: 34px; height: 34px; border-radius: 50%; font-size: 16px; font-weight: 700;
}
.icon-btn:active { transform: scale(.92); }

/* --- search --- */
.searchrow { display: flex; gap: 8px; padding: 8px 0; }
#search {
  flex: 1; background: var(--card); border: none; border-radius: 12px;
  padding: 12px 14px; color: var(--txt); font-size: 16px; outline: none;
  -webkit-appearance: none;
}
#search::placeholder { color: var(--muted); }
.star-filter {
  background: var(--card); border: none; border-radius: 12px; width: 46px;
  color: var(--muted); font-size: 20px;
}
.star-filter.on { color: var(--star); }

/* --- chips --- */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; background: var(--card); color: var(--muted);
  border: 1px solid transparent; border-radius: 999px; padding: 7px 14px;
  font-size: 14px; font-weight: 600;
}
.chip.on {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
}

/* --- offline --- */
.offline {
  background: #3a2e12; color: #fbbf24; border-radius: 10px;
  padding: 8px 12px; font-size: 13px; margin-bottom: 10px;
}
.hidden { display: none !important; }

/* --- cards --- */
.card {
  display: flex; gap: 12px; background: var(--card); border-radius: 16px;
  padding: 12px; margin-bottom: 10px; align-items: flex-start;
  animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } }
.card:active { background: var(--card2); }
.thumb {
  width: 68px; height: 68px; border-radius: 12px; object-fit: cover;
  background: var(--card2); flex-shrink: 0;
}
.thumb-fallback {
  width: 68px; height: 68px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff; font-weight: 800;
}
.card-body { flex: 1; min-width: 0; }
.card-title {
  font-size: 15px; font-weight: 700; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-note {
  font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap;
}
.card-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card-meta .favicon { width: 14px; height: 14px; border-radius: 4px; }
.card-meta .col-tag { background: var(--card2); border-radius: 6px; padding: 1px 7px; font-weight: 600; }
.card-act { display: flex; flex-direction: column; gap: 4px; }
.star-btn { background: none; border: none; font-size: 20px; color: var(--muted); padding: 2px; }
.star-btn.on { color: var(--star); }
.del-btn { background: none; border: none; font-size: 15px; color: var(--muted); padding: 2px; }
.del-btn:active, .star-btn:active { transform: scale(.85); }

.empty { text-align: center; padding: 60px 20px; font-size: 17px; font-weight: 600; line-height: 1.8; }
.muted { color: var(--muted); font-size: 13px; font-weight: 500; }

/* --- FAB --- */
.fab {
  position: fixed; right: max(20px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 30px; font-weight: 300; line-height: 1;
  box-shadow: 0 6px 20px rgba(99, 102, 241, .45); z-index: 50;
}
.fab:active { transform: scale(.92); }

/* --- sheets --- */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .2s ease;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet h2 { font-size: 19px; font-weight: 800; }
.lbl { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
.sheet input, .sheet textarea {
  width: 100%; background: var(--bg); border: 1px solid #2a3a55; border-radius: 12px;
  padding: 12px 14px; color: var(--txt); font-size: 16px; outline: none; font-family: inherit;
}
.sheet input:focus, .sheet textarea:focus { border-color: var(--accent); }
.urlrow { display: flex; gap: 8px; }
.paste-btn {
  background: var(--card2); color: var(--txt); border: none; border-radius: 12px;
  padding: 0 16px; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.paste-btn:active { transform: scale(.95); }
.btn-primary {
  width: 100%; margin-top: 18px; border: none; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 17px; font-weight: 800; padding: 14px;
}
.btn-primary:active { transform: scale(.98); }

/* --- help --- */
.help-steps { margin: 10px 0 4px 18px; font-size: 14px; line-height: 1.9; }
.help-steps ul { margin: 4px 0 4px 18px; color: var(--muted); line-height: 1.8; }
.help-steps code {
  background: var(--bg); border-radius: 6px; padding: 2px 7px;
  font-size: 12px; word-break: break-all; color: #a5b4fc;
}

/* --- toast --- */
.toast {
  position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%); background: #1e293b; color: #fff;
  border-radius: 999px; padding: 10px 20px; font-size: 14px; font-weight: 600;
  z-index: 200; box-shadow: 0 4px 16px rgba(0,0,0,.4); max-width: 85vw; text-align: center;
}
