:root {
  --bg: #f6f6fb;
  --surface: #ffffff;
  --surface-2: #f1f0f8;
  --border: #e6e4f0;
  --text: #17152b;
  --muted: #6b6883;
  --faint: #9d9ab3;
  --accent: #6d4dff;
  --accent-2: #ff5c8a;
  --accent-soft: #efebff;
  --success: #12a37b;
  --success-soft: #e3f7f0;
  --warn: #c98a06;
  --warn-soft: #fff4d9;
  --danger: #e0445a;
  --danger-soft: #fde8eb;
  --shadow: 0 1px 2px rgba(23, 21, 43, .04), 0 8px 24px rgba(23, 21, 43, .06);
  --radius: 14px;
  --grad: linear-gradient(135deg, #7c5cff 0%, #ff5c8a 100%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0d17;
    --surface: #161422;
    --surface-2: #1f1c2f;
    --border: #2a2640;
    --text: #efedf8;
    --muted: #a19db8;
    --faint: #6f6b88;
    --accent: #8f76ff;
    --accent-soft: #241e45;
    --success-soft: #0f2d25;
    --warn-soft: #2e2510;
    --danger-soft: #34151c;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
kbd {
  font: 600 12px/1 Inter, sans-serif; padding: 3px 7px; border-radius: 6px;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
}
.muted { color: var(--muted); }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: transform .06s, background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { border-color: var(--faint); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 6px 18px rgba(124,92,255,.35); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-block { width: 100%; height: 44px; font-size: 14px; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 8px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--muted); font-size: 16px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .input {
  height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-error { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }
.brand-lg { font-size: 18px; }
.brand-lg img { width: 38px; height: 38px; }

/* ---------- auth ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(900px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-brand { justify-content: center; margin-bottom: 24px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 264px 1fr; height: 100vh; }
.sidebar { display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface); padding: 18px 12px 12px; min-height: 0; }
.sidebar > .brand { padding: 2px 8px 18px; }
.side-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); font-weight: 700; }
.new-list { padding: 4px 4px 8px; }
.new-list input { width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--accent); border-radius: 9px; background: var(--surface); outline: none; box-shadow: 0 0 0 4px var(--accent-soft); }
.list-nav { overflow-y: auto; display: grid; gap: 2px; align-content: start; }
.list-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.list-nav a:hover { background: var(--surface-2); color: var(--text); }
.list-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.list-nav .ln-icon { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; flex: none; }
.list-nav .ln-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-nav .ln-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.list-nav .ln-live { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); animation: pulse 1.2s infinite; }
.side-foot { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 6px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.side-link:hover, .side-link.active { background: var(--surface-2); color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; }
.me-info { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.me-info strong { font-size: 13px; }
.me-info span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; overflow: hidden; object-fit: cover; }
img.avatar { background: var(--surface-2); }

.main { overflow-y: auto; padding: 28px 36px 48px; min-width: 0; }

/* ---------- list header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title { display: flex; align-items: center; gap: 8px; }
.page-title h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; outline: none; border-radius: 8px; padding: 0 6px; margin-left: -6px; }
.page-title h1[contenteditable="true"]:hover { background: var(--surface-2); }
.page-title h1:focus { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.subtitle { color: var(--muted); margin-top: 4px; font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .k i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

.toolbar { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.search { flex: 1; min-width: 200px; position: relative; }
.search input { width: 100%; height: 36px; padding: 0 12px 0 34px; }
.search::before { content: "⌕"; position: absolute; left: 12px; top: 50%; transform: translateY(-52%); color: var(--faint); font-size: 16px; }
.add-url { display: flex; gap: 6px; flex: 1.3; min-width: 260px; }
.add-url input { flex: 1; height: 36px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.fresh { animation: flash 1.6s ease-out; }
.person { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.person .avatar { width: 38px; height: 38px; }
.person strong { display: block; font-weight: 600; }
.person span { display: block; font-size: 12.5px; color: var(--muted); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr:hover .row-actions { opacity: 1; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-done { background: var(--success-soft); color: var(--success); }
.chip-pending, .chip-enriching { background: var(--warn-soft); color: var(--warn); }
.chip-enriching::before, .chip-pending::before { animation: pulse 1.2s infinite; }
.chip-error { background: var(--danger-soft); color: var(--danger); }

.skeleton { display: inline-block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }

.empty { text-align: center; padding: 64px 24px; }
.empty .big { font-size: 42px; }
.empty h3 { margin: 10px 0 4px; font-size: 18px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 18px; }

/* ---------- extension page ---------- */
.ext-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 18px; align-items: start; }
.panel { padding: 22px; }
.panel h2 { margin: 0 0 4px; font-size: 17px; letter-spacing: -.01em; }
.panel > p { color: var(--muted); margin: 0 0 16px; }
.token-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border); border-radius: 12px; padding: 10px 10px 10px 14px; }
.token-box code { flex: 1; font: 500 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.token-box code.blur { filter: blur(5px); user-select: none; }
.pair-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; margin-top: 14px; background: var(--surface-2); font-weight: 500; }
.pair-status.ok { background: var(--success-soft); color: var(--success); }
.install-steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 14px; }
.install-steps li { counter-increment: s; display: flex; gap: 12px; }
.install-steps li::before { content: counter(s); flex: none; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.install-steps code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.howto { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.howto .card { padding: 16px; box-shadow: none; }
.howto .card .emo { font-size: 22px; font-weight: 700; }
.howto .card strong { display: block; margin: 6px 0 2px; }
.howto .card span { color: var(--muted); font-size: 13px; }
.howto kbd { background: var(--surface-2); border-color: var(--border); }

.side-ic { width: 8px; display: inline-grid; place-items: center; font-size: 12px; }

/* ---------- team ---------- */
.team-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; align-items: start; }
.team-grid form .btn { margin-top: 4px; }
.member { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: 0; }
.member .info { flex: 1; min-width: 0; }
.member .info strong { display: block; }
.member .info span { color: var(--muted); font-size: 12.5px; }
.member .nums { color: var(--muted); font-size: 12.5px; text-align: right; white-space: nowrap; }
.you { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.created-note { background: var(--success-soft); color: var(--success); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
@media (max-width: 960px) { .team-grid { grid-template-columns: 1fr; } }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10, 8, 25, .35); backdrop-filter: blur(2px); z-index: 40; animation: fade .2s; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); z-index: 50; transform: translateX(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1);
  overflow-y: auto; box-shadow: -20px 0 60px rgba(0,0,0,.15);
}
.drawer.open { transform: none; }
.d-cover { height: 120px; background: var(--grad) center/cover; position: relative; }
.d-close { position: absolute; top: 12px; right: 12px; background: rgba(0,0,0,.35); color: #fff; }
.d-close:hover { background: rgba(0,0,0,.55); color: #fff; }
.d-head { padding: 0 24px 16px; margin-top: -44px; position: relative; }
.d-head .avatar { width: 88px; height: 88px; border: 4px solid var(--surface); font-size: 28px; }
.d-head h2 { margin: 10px 0 2px; font-size: 22px; letter-spacing: -.02em; }
.d-head p { margin: 0; color: var(--muted); }
.d-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.d-actions { display: flex; gap: 8px; margin-top: 14px; }
.d-section { padding: 16px 24px; border-top: 1px solid var(--border); }
.d-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin: 0 0 12px; }
.d-section p { margin: 0; white-space: pre-wrap; }
.timeline { display: grid; gap: 14px; }
.tl-item { display: flex; gap: 12px; }
.tl-item img, .tl-item .tl-ph { width: 40px; height: 40px; border-radius: 8px; flex: none; background: var(--surface-2); object-fit: cover; }
.tl-item strong { display: block; font-weight: 600; }
.tl-item span { display: block; color: var(--muted); font-size: 13px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
details.raw summary { cursor: pointer; color: var(--muted); font-weight: 600; }
details.raw pre { font-size: 11.5px; background: var(--surface-2); padding: 12px; border-radius: 10px; overflow: auto; max-height: 360px; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; }
.toast { background: #17152b; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-weight: 500; animation: rise .25s ease-out; }
.toast.error { background: var(--danger); }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes flash { from { background: var(--accent-soft); } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; height: auto; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .list-nav { max-height: 220px; }
  .main { padding: 20px 16px 40px; overflow: visible; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .ext-grid, .howto { grid-template-columns: 1fr; }
}
