*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0a;
  --surface: #131313;
  --surface-2: #171717;
  --border: rgba(255,255,255,0.09);
  --border-strong: rgba(255,255,255,0.18);
  --text: #a0a0a8;
  --text-heading: #fafafa;
  --text-muted: #6c6c76;
  --danger: #d66;
  --nav-h: 64px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Archivo', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.top-nav {
  min-height: var(--nav-h);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(10,10,11,0.88);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 16px 44px rgba(0,0,0,0.24);
}

.nav-container {
  width: 100%;
  min-height: var(--nav-h);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}

.nav-logo img {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 8px 22px rgba(0,0,0,0.35);
}

.nav-logo span {
  color: var(--text-heading);
  font-size: 15px;
  font-weight: 700;
}

.nav-logo .nav-context {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.035);
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.nav-link,
.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  transition: color 0.14s, border-color 0.14s, background 0.14s, opacity 0.14s;
}

.nav-link {
  color: var(--text-muted);
  padding: 7px 12px;
  border: 1px solid transparent;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-heading);
  background: rgba(255,255,255,0.065);
  border-color: var(--border);
}

.nav-btn {
  color: #0a0a0b;
  background: #fff;
  padding: 7px 15px;
  margin-left: 4px;
}

.nav-btn:hover { opacity: 0.86; }

.nav-toggle,
.panel-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: rgba(255,255,255,0.055);
  border: 1px solid var(--border);
  color: var(--text-heading);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle:hover,
.panel-menu-btn:hover { background: rgba(255,255,255,0.09); border-color: var(--border-strong); }

.panel-menu-btn {
  order: -1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  font-family: inherit;
  transition: opacity 0.12s, background 0.12s, border-color 0.12s;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: #fff; color: #0a0a0b; }
.btn-ghost { background: rgba(255,255,255,0.06); color: var(--text-heading); border-color: var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.1); opacity: 1; }
.btn-danger { background: rgba(214,102,102,0.12); color: #e79; border-color: rgba(214,102,102,0.3); }
.btn-danger:hover { background: rgba(214,102,102,0.2); opacity: 1; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }

/* Auth */

.auth-wrap {
  min-height: calc(100vh - var(--nav-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
}

.auth-logo { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-logo img { width: 48px; height: 48px; border-radius: 12px; }
.auth-title { text-align: center; font-size: 20px; font-weight: 700; color: var(--text-heading); margin-bottom: 4px; }
.auth-sub { text-align: center; font-size: 13.5px; color: var(--text-muted); margin-bottom: 24px; }

.provider-toggle { display: flex; gap: 6px; margin-bottom: 20px; }
.provider-toggle button {
  flex: 1;
  padding: 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.provider-toggle button img { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; }
.provider-toggle button.active { color: var(--text-heading); border-color: var(--border-strong); background: rgba(255,255,255,0.08); }

.tabs { display: flex; background: rgba(255,255,255,0.04); border-radius: 9px; padding: 3px; margin-bottom: 20px; }
.tabs button {
  flex: 1;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
}
.tabs button.active { background: rgba(255,255,255,0.1); color: var(--text-heading); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-heading);
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  font-family: inherit;
}
.field input:focus { border-color: var(--border-strong); background: rgba(255,255,255,0.06); }
.field .field-err { color: var(--danger); font-size: 12px; margin-top: 5px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; display: flex; }
.pw-wrap button:hover { color: var(--text-heading); }

.auth-submit { width: 100%; margin-top: 6px; padding: 11px; }
.auth-error { background: rgba(214,102,102,0.1); border: 1px solid rgba(214,102,102,0.28); color: #e79; font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-bottom: 16px; }
.auth-notice { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); color: rgba(255,255,255,0.75); font-size: 13px; padding: 10px 12px; border-radius: 9px; margin-bottom: 16px; }
.auth-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 18px; line-height: 1.6; }

/* Panel */

.panel { display: flex; min-height: calc(100vh - var(--nav-h)); }

.panel-side {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
}

.acct-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 11px;
}
.acct-card .acct-logo { width: 30px; height: 30px; border-radius: 8px; object-fit: contain; flex-shrink: 0; }
.acct-card .acct-info { min-width: 0; }
.acct-card .acct-email { font-size: 12.5px; color: var(--text-heading); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-card .acct-provider { font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }

.profile-switcher { margin-bottom: 16px; position: relative; }
.profile-switcher label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 7px; padding: 0 4px; }
.ps-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  color: var(--text-heading);
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.ps-trigger:hover { border-color: var(--border-strong); background: rgba(255,255,255,0.06); }
.ps-current { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.ps-cur-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-chev { width: 15px; height: 15px; opacity: 0.55; flex-shrink: 0; }
.ps-current .avatar { width: 22px; height: 22px; font-size: 10px; }

.ps-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  box-shadow: 0 20px 48px rgba(0,0,0,0.6);
  padding: 6px;
  z-index: 80;
  display: none;
  max-height: 320px;
  overflow-y: auto;
}
.ps-menu.open { display: block; }
.ps-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.ps-item:hover { background: rgba(255,255,255,0.06); }
.ps-item.active { background: rgba(255,255,255,0.08); color: var(--text-heading); }
.ps-item .avatar { width: 26px; height: 26px; font-size: 11px; }
.ps-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-check { width: 15px; height: 15px; color: var(--text-heading); flex-shrink: 0; }

.empty-panel {
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
}
.empty-panel .empty-icon { width: 30px; height: 30px; color: var(--text-muted); margin-bottom: 12px; }
.empty-panel .empty-title { font-size: 15px; font-weight: 600; color: var(--text-heading); margin-bottom: 6px; }
.empty-panel .empty-desc { font-size: 13px; color: var(--text-muted); max-width: 380px; margin: 0 auto; line-height: 1.6; }

.adv { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 6px; }
.adv summary {
  cursor: pointer;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 0;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary:hover { color: var(--text-heading); }
.adv[open] summary { color: var(--text-heading); }

.seg { display: inline-flex; background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: none;
  border: none;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.seg button.active { background: rgba(255,255,255,0.1); color: var(--text-heading); }

.col-preview { display: flex; flex-direction: column; gap: 26px; }
.col-block-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.col-block-title { font-size: 15px; font-weight: 600; color: var(--text-heading); }
.frow { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
.fcard { width: 116px; flex-shrink: 0; }
.fcard.wide { width: 200px; }
.fcard-art {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fcard.wide .fcard-art { aspect-ratio: 16 / 9; }
.fcard-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.fcard-emoji { font-size: 26px; opacity: 0.9; }
.fcard-art img + .fcard-emoji { display: none; }
.fcard-art.noimg .fcard-emoji { display: block; }
.fcard-title { font-size: 13px; font-weight: 600; color: var(--text-heading); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fcard-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  width: 100%;
}
.side-nav button svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; }
.side-nav button:hover { color: var(--text-heading); background: rgba(255,255,255,0.04); }
.side-nav button.active { color: var(--text-heading); background: rgba(255,255,255,0.08); }

.side-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.panel-main { flex: 1; min-width: 0; padding: 32px 40px 80px; }
.panel-main .sec-head { margin-bottom: 24px; }
.panel-main .sec-head h1 { font-size: 22px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.02em; }
.panel-main .sec-head p { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.inline-input {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-heading);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}
.inline-input:focus { border-color: var(--border-strong); }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.stat .stat-val { font-size: 24px; font-weight: 700; color: var(--text-heading); letter-spacing: -0.02em; }
.stat .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
}
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-size: 14px; color: var(--text-heading); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .row-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-heading); font-size: 14px; font-weight: 600;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.poster { width: 40px; height: 58px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); flex-shrink: 0; object-fit: cover; }

.tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.tag.on { color: var(--text-heading); border-color: var(--border-strong); }

.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; cursor: pointer; }
.switch input { display: none; }
.switch .track { position: absolute; inset: 0; background: rgba(255,255,255,0.12); border-radius: 20px; transition: background 0.15s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .track { background: rgba(255,255,255,0.4); }
.switch input:checked + .track + .thumb { transform: translateX(16px); }

.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 13.5px; }
.loading-sec { text-align: center; padding: 48px 20px; color: var(--text-muted); font-size: 13.5px; }

.json-edit {
  width: 100%;
  min-height: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-heading);
  font-family: 'SF Mono', ui-monospace, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  padding: 16px;
  outline: none;
  resize: vertical;
}
.json-edit:focus { border-color: var(--border-strong); }

.note-box { background: rgba(255,255,255,0.04); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 13px; color: var(--text-muted); margin-bottom: 18px; line-height: 1.6; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-heading);
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: rgba(214,102,102,0.4); color: #e79; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 300;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 22px; width: 100%; max-width: 380px;
}
.modal h3 { font-size: 16px; color: var(--text-heading); margin-bottom: 6px; }
.modal p { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.25); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 440px) {
  .nav-container { padding: 0 14px; gap: 8px; }
  .nav-logo .nav-context { display: none; }
  .nav-logo span:not(.nav-context) { font-size: 14px; }
}

@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; margin-left: auto; }
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    margin-left: 0;
    padding: 10px 16px 16px;
    background: rgba(10,10,11,0.97);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 22px 46px rgba(0,0,0,0.52);
  }
  .nav-links.open { display: flex; }
  .nav-link { min-height: 42px; padding: 10px 12px; font-size: 14px; }
  .nav-btn { min-height: 42px; justify-content: center; margin: 6px 0 0; }
  .panel { flex-direction: column; }
  .panel-side {
    position: fixed; top: var(--nav-h); left: 0; bottom: 0; width: 260px; z-index: 60;
    background: var(--surface); transform: translateX(-100%); transition: transform 0.2s; height: calc(100vh - var(--nav-h));
  }
  .panel-side.open { transform: translateX(0); }
  .panel-main { padding: 24px 18px 80px; }
  .panel-menu-btn { display: inline-flex; }
  .panel-overlay { position: fixed; inset: var(--nav-h) 0 0; background: rgba(0,0,0,0.5); z-index: 55; display: none; }
  .panel-overlay.open { display: block; }
}

.auth-alt { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

.auth-alt-label {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.auth-alt-row { display: flex; gap: 8px; }

.auth-alt-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s, background 0.14s;
}

.auth-alt-btn:hover { color: var(--text-heading); border-color: var(--border-strong); background: rgba(255,255,255,0.07); }
.auth-alt-btn img { width: 16px; height: 16px; object-fit: contain; border-radius: 4px; }
