/* =========================================================
   BOOJEE BRAIN — App Styles
   Estate dark/gold premium · space/constellation aesthetic
   ========================================================= */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #050506;
  --bg2:       #09090c;
  --bg3:       #0e0e12;
  --panel:     #111118;
  --border:    rgba(255,255,255,.07);
  --border2:   rgba(255,255,255,.04);
  --cream:     #f2ece0;
  --cream2:    #d9d0c2;
  --muted:     #a9a095;
  --dim:       #7a7570;
  --ghost:     #3a3635;
  --gold:      #d4af37;
  --gold-dim:  rgba(212,175,55,.12);
  --gold-border: rgba(212,175,55,.25);
  --violet:    #8b5cf6;
  --blue:      #3b82f6;
  --pink:      #ec4899;
  --cyan:      #06b6d4;
  --green:     #4ade80;
  --orange:    #f97316;
  --rose:      #f43f5e;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--cream2);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  height: 50px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.topbar-brand {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--cream);
  letter-spacing: -.02em;
  white-space: nowrap;
}

.topbar-brand .brand-accent { color: var(--gold); }

.topbar-sep { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

.view-toggles {
  display: flex;
  gap: 2px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.view-btn {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.view-btn:hover  { color: var(--cream2); background: rgba(255,255,255,.05); }
.view-btn.active { color: var(--gold);   background: var(--gold-dim); }

.topbar-spacer { flex: 1; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.btn-top {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}

.btn-top:hover { opacity: .8; }
.btn-new  { background: var(--gold); color: #050506; }
.btn-ghost-sm { background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--muted); }

/* ── App Layout ── */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--cream2);
  font-size: .8125rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}

.search-input::placeholder { color: var(--dim); }
.search-input:focus { border-color: var(--gold-border); }

.note-list { flex: 1; overflow-y: auto; padding: 8px; }

.note-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}

.note-item:hover { background: rgba(255,255,255,.04); }
.note-item.active { background: var(--gold-dim); border-left: 2px solid var(--gold); padding-left: 8px; }

.note-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

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

.note-item-title {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item.active .note-item-title { color: var(--gold); }

.note-item-meta {
  font-size: .65rem;
  color: var(--dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-empty { padding: 20px 12px; font-size: .8rem; color: var(--dim); text-align: center; }

.sidebar-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  font-size: .65rem;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

/* ── Canvas / Graph Area ── */
#graphArea {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#graphCanvas {
  flex: 1;
  display: block;
  cursor: grab;
  touch-action: none;
}

#graphCanvas:active { cursor: grabbing; }

.graph-overlay {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.graph-tip {
  font-size: .65rem;
  color: rgba(255,255,255,.25);
  text-align: right;
  pointer-events: none;
}

/* ── Editor Area ── */
#editorArea {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ed-topbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ed-back {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--dim);
  cursor: pointer;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 11px;
  white-space: nowrap;
  transition: color .15s;
}

.ed-back:hover { color: var(--gold); }

.ed-title {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--cream);
  min-width: 0;
}

.ed-title::placeholder { color: var(--ghost); }

.btn-del {
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(244,63,94,.08);
  border: 1px solid rgba(244,63,94,.2);
  color: var(--rose);
  border-radius: 5px;
  padding: 5px 11px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s;
}

.btn-del:hover { background: rgba(244,63,94,.18); }

.ed-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.ed-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.ed-pane:last-child { border-right: none; }

.ed-pane-label {
  font-size: .6rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 7px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg3);
  flex-shrink: 0;
}

#edBody {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 16px;
  color: var(--cream2);
  font-family: 'Inter', monospace, sans-serif;
  font-size: .8125rem;
  line-height: 1.75;
  resize: none;
  overflow-y: auto;
}

#edBody::placeholder { color: var(--ghost); }

/* ── Preview pane ── */
.preview-scroll { flex: 1; overflow-y: auto; padding: 16px; }

#edPreview {
  font-size: .875rem;
  line-height: 1.75;
  color: var(--cream2);
}

#edPreview h1 { font-family: 'Cormorant Garamond',Georgia,serif; font-size: 1.6rem; font-weight: 300; color: var(--cream); margin-bottom: .6em; line-height: 1.15; }
#edPreview h2 { font-family: 'Cormorant Garamond',Georgia,serif; font-size: 1.25rem; font-weight: 400; color: var(--cream); margin-bottom: .5em; margin-top: 1.2em; }
#edPreview h3 { font-size: .9375rem; font-weight: 600; color: var(--cream); margin-bottom: .4em; margin-top: 1em; }
#edPreview h4 { font-size: .8125rem; font-weight: 600; color: var(--muted); margin-bottom: .3em; margin-top: .9em; }
#edPreview strong { color: var(--cream); font-weight: 600; }
#edPreview em { color: var(--muted); font-style: italic; }
#edPreview code { font-family: monospace; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 3px; font-size: .8rem; color: var(--cyan); }
#edPreview blockquote { border-left: 2px solid var(--gold-border); padding-left: 12px; color: var(--muted); font-style: italic; margin: .8em 0; }
#edPreview ul { padding-left: 1.4em; margin: .5em 0; }
#edPreview li { margin-bottom: .25em; }

.wikilink {
  color: var(--violet);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px solid rgba(139,92,246,.3);
  transition: border-color .15s, color .15s;
}

.wikilink:hover { color: #a78bfa; border-bottom-color: rgba(167,139,250,.6); }
.wikilink.missing { color: var(--rose); border-bottom-color: rgba(244,63,94,.3); }
.wikilink.missing:hover { border-bottom-color: rgba(244,63,94,.6); }

.hashtag {
  color: var(--gold);
  font-size: .8em;
  letter-spacing: .04em;
}

/* ── Backlinks & Sync ── */
.ed-right {
  width: 220px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg3);
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}

.ed-right-section {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ed-right-label {
  font-size: .6rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

#backlinks {
  padding: 8px;
  overflow-y: auto;
  max-height: 200px;
}

.backlinks-label {
  font-size: .65rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 6px;
  padding: 0 2px;
}

.backlink-item {
  display: flex;
  align-items: center;
  font-size: .8rem;
  color: var(--cream2);
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .12s;
  margin-bottom: 2px;
}

.backlink-item:hover { background: rgba(255,255,255,.05); color: var(--gold); }
.backlinks-empty { font-size: .75rem; color: var(--dim); padding: 8px 4px; }

/* Sync panel */
#syncPanel {
  padding: 10px 12px;
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.6;
}

.sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.sync-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sync-dot.green { background: var(--green); }

.sync-note {
  font-size: .7rem;
  color: var(--dim);
  line-height: 1.55;
}

.sync-link {
  color: var(--gold);
  text-decoration: none;
}

.sync-link:hover { text-decoration: underline; }

.btn-sync-action {
  margin-left: auto;
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  border-radius: 4px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

/* ── Mobile ── */
@media (max-width: 700px) {
  .sidebar { width: 0; overflow: hidden; position: absolute; z-index: 50;
    height: calc(100vh - 50px); top: 50px; transition: width .2s; }
  .sidebar.open { width: 240px; }
  .topbar-brand span.brand-sub { display: none; }
  .ed-right { display: none; }
  .view-toggles { gap: 0; }
  .view-btn { padding: 5px 9px; }
}

/* ── Welcome overlay (first-run) ── */
#welcomeOverlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 6, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

#welcomeOverlay.visible {
  opacity: 1;
  pointer-events: all;
}

.welcome-card {
  background: var(--panel);
  border: 1px solid var(--gold-border);
  border-radius: 18px;
  padding: 40px 44px 32px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 60px rgba(212, 175, 55, 0.1), 0 24px 64px rgba(0,0,0,0.6);
}

.welcome-logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 2rem;
  font-weight: 300;
  color: var(--cream);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.welcome-logo .brand-accent { color: var(--gold); }

.welcome-tagline {
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
}

.welcome-hints {
  list-style: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 28px;
}

.welcome-hints li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--cream2);
  line-height: 1.5;
}

.welcome-badge {
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-family: 'Inter', monospace, sans-serif;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
  letter-spacing: 0.02em;
}

.welcome-dismiss {
  background: var(--gold);
  color: #050506;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  font-family: inherit;
}

.welcome-dismiss:hover  { opacity: 0.85; transform: translateY(-1px); }
.welcome-dismiss:active { transform: translateY(0); }

.welcome-note {
  font-size: 0.65rem;
  color: var(--dim);
  margin-top: 16px;
  letter-spacing: 0.01em;
}

/* ── Focus ring ── */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ── Cloud sync float panel (topbar ☁ button) ── */
#syncFloat {
  font-size: .78rem;
  color: var(--cream2);
  line-height: 1.55;
}

/* ── Toast notification ── */
#bjbToast {
  font-family: 'Inter', system-ui, sans-serif;
}
