:root {
  --primary: #6366f1; --primary-hover: #4f46e5;
  --accent: #06b6d4;
  --bg: #0f172a; --bg-card: #1e293b; --bg-hover: #334155;
  --text: #f1f5f9; --text-muted: #94a3b8;
  --border: #334155; --radius: 12px; --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.6; -webkit-font-smoothing: antialiased;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ── Typography ── */
h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; }
h2 { font-size: clamp(1.2rem, 3vw, 1.5rem); font-weight: 600; }
h3 { font-size: clamp(1rem, 2.5vw, 1.2rem); font-weight: 600; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .78rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600;
  transition: all .2s; cursor: pointer; border: none; font-family: inherit;
  min-height: 44px; /* Touch-friendly */;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg-card); }
.btn-ghost { background: transparent; color: var(--text-muted); border: none; }
.btn-ghost:hover { color: var(--text); background: var(--bg-card); }
.btn-sm { padding: 6px 14px; font-size: .82rem; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

/* ── Inputs ── */
input, textarea, select {
  width: 100%; padding: 10px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 16px; font-family: inherit; transition: border-color .2s;
  min-height: 44px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); }
textarea { min-height: 100px; resize: vertical; }

/* ── Cards ── */
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}

/* ── Tags ── */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: .75rem; background: rgba(99,102,241,.12); color: #a5b4fc;
}

/* ── Header ── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,23,42,.9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header .inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; height: 56px;
}
.logo { font-weight: 700; font-size: 1.1rem; white-space: nowrap; }
.logo span { color: var(--primary); }
.header-nav { display: flex; gap: 6px; align-items: center; font-size: .85rem; flex-shrink: 1; min-width: 0; }
.header-nav a { color: var(--text-muted); white-space: nowrap; }
.header-nav a:hover { color: var(--text); }
.logout-btn { font-size: .75rem !important; padding: 3px 6px !important; min-height: 28px !important; }
.email-badge { font-size: .65rem; cursor: pointer; color: var(--text-muted); white-space: nowrap; }
@media (max-width: 420px) {
  .notif-wrapper { display: none; }
  .email-badge { display: none; }
  .header-nav { gap: 4px; }
  .header .inner { padding: 0 8px; }
  .logo { font-size: .95rem; }
  .logout-btn { font-size: .7rem !important; padding: 2px 5px !important; }
}

/* ── Bottom Nav (mobile) ── */
.bottom-nav {
  display: flex; position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(15,23,42,.95); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border); z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 2px; padding: 8px 4px; font-size: .65rem; color: var(--text-muted);
  text-decoration: none; transition: color .2s;
}
.bottom-nav a .nav-icon { font-size: 1.3rem; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a:hover { text-decoration: none; }

/* ── Layout ── */
.layout { display: flex; max-width: 1200px; margin: 0 auto; padding: 16px; gap: 24px; flex: 1; }
.sidebar { display: none; width: 200px; flex-shrink: 0; }
.sidebar h3 { font-size: .75rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; letter-spacing: .5px; }
.sidebar-menu { list-style: none; }
.sidebar-menu li { margin-bottom: 4px; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  border-radius: var(--radius-sm); font-size: .88rem; color: var(--text-muted);
  transition: all .2s; min-height: 44px;
}
.sidebar-menu a:hover, .sidebar-menu a.active { background: var(--bg-card); color: var(--text); text-decoration: none; }
.main { flex: 1; min-width: 0; padding-bottom: 70px; }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.stat-card .num { font-size: clamp(1.3rem, 4vw, 1.8rem); font-weight: 700; }
.stat-card .label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* ── Section ── */
.section-title {
  font-size: 1rem; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ── Memory Items ── */
.memory-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px;
  transition: all .2s; cursor: pointer;
}
.memory-item:hover { border-color: rgba(99,102,241,.4); }
.memory-item:active { transform: scale(.99); }
.memory-item .title { font-weight: 600; font-size: .95rem; margin-bottom: 4px; }
.memory-item .preview {
  font-size: .82rem; color: var(--text-muted); margin-bottom: 8px;
  line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.memory-item .meta { display: flex; gap: 8px; font-size: .75rem; color: var(--text-muted); flex-wrap: wrap; align-items: center; }

/* ── Bot Status ── */
.bot-status { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; }
.bot-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bot-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.5); }
.bot-dot.offline { background: #ef4444; }
.bot-dot.degraded { background: #f59e0b; }

/* ── Modal ── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 200; align-items: flex-end; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; padding: 24px 20px;
  width: 100%; max-width: 600px; max-height: 85vh; overflow-y: auto;
}
.modal h2 { font-size: 1.05rem; margin-bottom: 14px; padding-right: 28px; }
.modal .label { font-size: .78rem; color: var(--text-muted); margin-bottom: 4px; }
.modal .value { margin-bottom: 10px; font-size: .9rem; line-height: 1.6; }
.modal-close {
  position: absolute; top: 16px; right: 16px; cursor: pointer;
  color: var(--text-muted); font-size: 1.3rem; background: none; border: none;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.modal-close:hover { color: var(--text); background: var(--bg-hover); }
.modal-overlay.show { align-items: flex-end; }

/* ── Status colors ── */
.status-verified { color: #22c55e; }
.status-unverified { color: #f59e0b; }
.status-disputed { color: #ef4444; }

/* ── Utility ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none; }

/* ── Notification Bell ── */
.notif-wrapper { position: relative; }
.notif-badge {
  display: none; background: #ef4444; color: #fff; font-size: .6rem;
  padding: 1px 5px; border-radius: 10px; position: absolute; top: -6px; right: -8px;
}

/* ── Notif Panel ── */
.notif-panel {
  position: fixed; top: 56px; right: 8px; left: 8px;
  max-height: 60vh; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); z-index: 1000; overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.notif-panel-header {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.notif-panel-body { overflow-y: auto; max-height: calc(60vh - 50px); }
.notif-item {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
}
.notif-item.unread { background: rgba(99,102,241,.05); }
.notif-item .title { font-size: .85rem; }
.notif-item .title.unread { font-weight: 600; }
.notif-item .body { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.notif-item .time { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }

/* ── Quick Input ── */
.quick-input-area { margin-bottom: 20px; }
.quick-input-area h3 { font-size: .95rem; margin-bottom: 10px; }
.input-row { display: flex; gap: 10px; }
.input-row input { flex: 1; }
.quick-result { margin-top: 10px; font-size: .85rem; color: var(--text-muted); }

/* ── Bind Section ── */
.bind-hero {
  background: linear-gradient(135deg,rgba(99,102,241,.08),rgba(6,182,212,.04));
  border: 1px solid rgba(99,102,241,.2); border-radius: 10px; padding: 16px;
  margin-bottom: 14px;
}
.bind-steps { font-size: .82rem; color: var(--text-muted); line-height: 1.8; padding-left: 18px; }
.bind-code-box {
  font-size: clamp(1.2rem, 5vw, 1.5rem); font-weight: 700; letter-spacing: 3px;
  background: var(--bg); padding: 10px 20px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* ── Verification status ── */
.verif-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 18px;
  font-size: .82rem; color: var(--text-muted); line-height: 1.7;
}

/* ── Tab content ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Search ── */
.search-result {
  padding: 16px; border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-result:active { background: var(--bg-card); }
.search-result .title { font-weight: 600; margin-bottom: 4px; }

/* ── Graph (placeholder) ── */
.graph-container {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); height: 60vh; min-height: 300px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); overflow: hidden;
}

/* ── Landing Page Specific ── */
.hero { padding: 60px 16px 50px; text-align: center; background: linear-gradient(180deg, rgba(99,102,241,.08) 0%, transparent 60%); }
.hero h1 { font-size: clamp(1.8rem, 6vw, 3.5rem); font-weight: 800; line-height: 1.2; margin-bottom: 16px; }
.hero h1 .gradient { background: linear-gradient(135deg, var(--primary), var(--accent)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero .subtitle { font-size: clamp(.9rem, 2.5vw, 1.2rem); color: var(--text-muted); max-width: 640px; margin: 0 auto 28px; line-height: 1.7; }
.hero .cta-group { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero .badge-group { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px;
  border-radius: 20px; font-size: .78rem;
  background: rgba(99,102,241,.12); color: #a5b4fc; border: 1px solid rgba(99,102,241,.2);
}
.stats-row { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; margin: 32px 0; text-align: center; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 2px; }
.section { padding: 50px 0; }
.section-title-center { text-align: center; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 700; margin-bottom: 10px; }
.section-subtitle { text-align: center; color: var(--text-muted); max-width: 560px; margin: 0 auto 36px; font-size: .9rem; }
.feature-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px 20px;
  transition: all .3s;
}
.feature-card:hover { border-color: var(--primary); }
.feature-card .icon { font-size: 1.6rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; margin-bottom: 8px; }
.feature-card p { color: var(--text-muted); font-size: .85rem; line-height: 1.7; }
.steps-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.step-card { text-align: center; padding: 24px 16px; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.step-card .num {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff;
  font-weight: 700; font-size: .9rem; margin: 0 auto 12px;
}
.step-card h3 { font-size: 1rem; margin-bottom: 6px; }
.step-card p { color: var(--text-muted); font-size: .82rem; line-height: 1.5; }
.use-case { display: flex; flex-direction: column; gap: 20px; margin-bottom: 24px; }
.use-case-content h3 { font-size: 1rem; margin-bottom: 6px; }
.use-case-content p { color: var(--text-muted); font-size: .85rem; }
.use-case-visual {
  background: var(--bg-card); border-radius: var(--radius); padding: 16px 20px;
  border: 1px solid var(--border); font-family: "SF Mono", "Fira Code", monospace;
  font-size: .78rem; white-space: pre-wrap; line-height: 1.5;
  overflow-x: auto;
}
.comp-table { overflow-x: auto; font-size: .82rem; }
.comp-table table { width: 100%; border-collapse: collapse; }
.comp-table th, .comp-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.comp-table th { background: var(--bg-card); font-weight: 600; white-space: nowrap; }
.check { color: #22c55e; }
.cross { color: #ef4444; }
.cta-block {
  background: linear-gradient(135deg, rgba(99,102,241,.12), rgba(6,182,212,.08));
  text-align: center; padding: 60px 20px; border-radius: 16px;
}
.faq-list { max-width: 700px; margin: 0 auto; }
.faq-item { border-bottom: 1px solid var(--border); }
.faq-q {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 0; font-weight: 600; font-size: .9rem; cursor: pointer;
  min-height: 44px;
}
.faq-q::after { content: "+"; font-size: 1.2rem; color: var(--text-muted); flex-shrink: 0; margin-left: 12px; }
.faq-item.open .faq-q::after { content: "−"; }
.faq-a { display: none; padding-bottom: 16px; color: var(--text-muted); font-size: .85rem; line-height: 1.7; }
.faq-item.open .faq-a { display: block; }
.footer { border-top: 1px solid var(--border); padding: 32px 0; text-align: center; color: var(--text-muted); font-size: .82rem; margin-top: auto; }
.footer-links { display: flex; gap: 20px; justify-content: center; margin-bottom: 10px; flex-wrap: wrap; }
.footer-links a { color: var(--text-muted); }

/* ── Auth pages ── */
.auth-body { display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 24px;
  width: 100%; max-width: 400px;
}
.auth-card h1 { text-align: center; margin-bottom: 6px; }
.auth-card > p { text-align: center; margin-bottom: 24px; font-size: .85rem; color: var(--text-muted); }
.auth-card label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
.auth-card input { margin-bottom: 16px; }
.auth-card .btn { width: 100%; margin-top: 4px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: .82rem; color: var(--text-muted); }
.auth-back { display: block; text-align: center; margin-top: 14px; font-size: .82rem; color: var(--text-muted); }
.auth-hint { font-size: .75rem; color: var(--text-muted); margin-top: -12px; margin-bottom: 16px; }
.msg-box { font-size: .82rem; text-align: center; margin-bottom: 14px; padding: 8px; border-radius: 6px; display: none; }
.msg-box.error { display: block; background: rgba(239,68,68,.1); color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.msg-box.success { display: block; background: rgba(34,197,94,.1); color: #22c55e; border: 1px solid rgba(34,197,94,.2); }
.step-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; }
.step-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.step-dot.active { background: var(--primary); }
.step-dot.done { background: #22c55e; }

/* ── Responsive ── */
@media (min-width: 768px) {
  .header .inner { padding: 0 24px; height: 60px; }
  .layout { padding: 24px; }
  .sidebar { display: block; }
  .bottom-nav { display: none; }
  .main { padding-bottom: 0; }
  .modal-overlay.show { align-items: center; }
  .modal { border-radius: var(--radius); padding: 28px; }
  .notif-panel { left: auto; right: 20px; width: 340px; }
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .steps-grid { grid-template-columns: repeat(3, 1fr); }
  .use-case { flex-direction: row; gap: 32px; }
  .use-case:nth-child(even) { flex-direction: row-reverse; }
  .use-case-content { flex: 1; }
  .use-case-visual { flex: 1; }
  .section { padding: 80px 0; }
  .hero { padding: 100px 0 80px; }
}
@media (min-width: 1024px) {
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .auth-card { padding: 40px; }
}

/* ── Collections Tab ── */
.collection-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}
.collection-item:hover {
  border-color: var(--accent);
}
.col-thumb {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-surface);
}
.col-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.col-info {
  flex: 1;
  min-width: 0;
}
.col-header {
  font-size: .82rem;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.col-source {
  font-weight: 600;
  color: var(--text-primary);
}
.col-preview {
  font-size: .82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.col-meta {
  font-size: .72rem;
  color: var(--text-muted);
}
.status-pending { color: #f59e0b; font-size: .78rem; }
.status-processing { color: #3b82f6; font-size: .78rem; }
.status-done { color: #22c55e; font-size: .78rem; }
.status-failed { color: #ef4444; font-size: .78rem; }
