/* =========================================================================
    Flints — design tokens
   ========================================================================= */

:root{
  --bg:            #FAFAF8;
  --surface:       #FFFFFF;
  --surface-2:     #F4F2EC;
  --ink:           #22201D;
  --ink-soft:      #55514A;
  --muted:         #8B867B;
  --border:        #E7E3D9;
  --border-soft:   #F0EDE4;
  --accent:        #E8590C;
  --accent-ink:    #FFFFFF;
  --accent-soft:   #FCE7D6;
  --danger:        #C4432B;
  --graph-link-color: #E7E3D9;
  --graph-node-fill-opacity: 0.18;
  --act-l1: #FADEC9;
  --act-l2: #F5B88A;
  --act-l3: #EF8A4C;
  --highlight: #FFF3B0;
  --shadow:        0 1px 2px rgba(30,25,15,0.04), 0 8px 24px rgba(30,25,15,0.06);
  --shadow-lg:     0 4px 12px rgba(30,25,15,0.08), 0 16px 48px rgba(30,25,15,0.12);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --font-ui:  'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"]{
  --bg:            #171613;
  --surface:       #1E1C18;
  --surface-2:     #262420;
  --ink:           #ECE8E0;
  --ink-soft:      #C9C3B7;
  --muted:         #857F73;
  --border:        #322F29;
  --border-soft:   #2A2823;
  --accent:        #FF7A33;
  --accent-ink:    #1B1300;
  --accent-soft:   #3A2515;
  --danger:        #FF7A5C;
  --shadow:        0 1px 2px rgba(0,0,0,0.2), 0 12px 28px rgba(0,0,0,0.35);
  --shadow-lg:     0 4px 12px rgba(0,0,0,0.3), 0 16px 48px rgba(0,0,0,0.4);
  --graph-link-color: #3A362F;
  --graph-node-fill-opacity: 0.30;
  --act-l1: #4A2E1A;
  --act-l2: #7A4520;
  --highlight: #5A4E20;
  --act-l3: #C4602A;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background .15s ease, color .15s ease;
}

a{ color: inherit; text-decoration: none; }
button{ font-family: inherit; }
::selection{ background: var(--accent-soft); }

.icon{ width:17px; height:17px; stroke-width:1.8; display:block; flex-shrink:0; }

/* =========================================================================
   Auth screens
   ========================================================================= */

.auth-shell{
  min-height:100vh;
  display:grid;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 860px){
  .auth-shell{ grid-template-columns: 1fr; }
  .auth-visual{ display:none; }
}

.auth-visual{
  background: var(--ink);
  position:relative;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  padding:56px;
  overflow:hidden;
}
[data-theme="dark"] .auth-visual{ background:#0E0D0B; }

.auth-visual svg{ position:absolute; inset:0; width:100%; height:100%; }

.auth-visual .brand-mark{
  position:relative; z-index:2;
  color:#FAF8F3;
}
.auth-visual .brand-mark .logo-row{
  display:flex; align-items:center; gap:10px; margin-bottom:22px;
}
.auth-visual .brand-mark h1{
  font-family: var(--font-serif);
  font-size:38px; font-weight:600; margin:0 0 10px;
  letter-spacing:-0.01em;
}
.auth-visual .brand-mark p{
  font-size:15px; color:#B9B3A6; max-width:380px; line-height:1.6; margin:0;
}

.auth-form-side{
  display:flex; align-items:center; justify-content:center;
  padding: 32px;
}
.auth-card{ width:100%; max-width:360px; }
.auth-card .logo-row{ display:flex; align-items:center; gap:9px; margin-bottom:36px; }
.auth-card .logo-row span{ font-family: var(--font-serif); font-weight:600; font-size:19px; }

.auth-card h2{ font-size:22px; margin:0 0 6px; letter-spacing:-0.01em; }
.auth-card .sub{ color: var(--muted); font-size:14px; margin:0 0 28px; }

.field{ margin-bottom:16px; }
.field label{ display:block; font-size:13px; font-weight:600; color: var(--ink-soft); margin-bottom:6px; }
.field input{
  width:100%; padding:10px 12px; border-radius: var(--radius-sm);
  border:1px solid var(--border); background: var(--surface); color: var(--ink);
  font-size:14px; outline:none; transition: border-color .12s ease, box-shadow .12s ease;
}
.field input:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:10px 16px; border-radius: var(--radius-sm); border:1px solid transparent;
  font-size:14px; font-weight:600; cursor:pointer; transition: all .12s ease;
}
.btn-primary{ background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover{ filter:brightness(1.06); }
.btn-ghost{ background:transparent; border-color: var(--border); color: var(--ink); }
.btn-ghost:hover{ background: var(--surface-2); }
.btn-danger{ background:transparent; border:1px solid var(--danger); color:var(--danger); }
.btn-danger:hover{ background:var(--danger); color:#fff; }
.btn-danger-full{ background:var(--danger); color:#fff; width:100%; }
.btn-danger-full:hover{ filter:brightness(1.1); }
.btn-icon{
  width:25px; height:25px; padding:0; border-radius: var(--radius-sm);
  background:transparent; border:1px solid transparent; color: var(--ink-soft); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
}
.btn-icon:hover{ background: var(--surface-2); color: var(--ink); }

.error-msg{
  background: var(--accent-soft); color: var(--danger); border:1px solid transparent;
  padding:10px 12px; border-radius: var(--radius-sm); font-size:13px; margin-bottom:16px; display:none;
}
.error-msg.show{ display:block; }

.auth-switch{ margin-top:22px; font-size:13.5px; color: var(--muted); text-align:center; }
.auth-switch a{ color: var(--accent); font-weight:600; }

/* =========================================================================
   App shell
   ========================================================================= */

.app-shell{
  height:100vh; display:grid; grid-template-columns: 268px 1fr;
  background: var(--bg);
}
@media (max-width: 760px){
  .app-shell{ grid-template-columns: 0 1fr; }
  .sidebar{ position:fixed; z-index:40; height:100vh; width:268px; transform:translateX(-100%); transition: transform .18s ease; }
  .app-shell.sidebar-open .sidebar{ transform:translateX(0); box-shadow: var(--shadow); }
  .topbar{ padding:0 10px; gap:6px; }
  .saved-indicator span:not(.dot){ display:none; }
  .topbar-actions{ gap:2px; }
  .share-popover{ position:fixed; top:60px; right:10px; left:10px; width:auto; }
  .import-export-menu{ position:fixed; bottom:70px; left:10px; right:10px; width:auto; }
  .settings-shell{ width:100%; height:100vh; max-height:100vh; border-radius:0; max-width:100%; }
  .settings-sidebar{ width:100%; border-right:none; border-bottom:1px solid var(--border); flex-direction:row; overflow-x:auto; padding:8px; gap:2px; }
  .settings-group-label{ display:none; }
  .settings-nav-item{ white-space:nowrap; padding:6px 12px; font-size:12px; }
  .settings-body{ flex-direction:column; }
  .settings-content{ padding:20px 16px; }
  .lang-selector{ flex-direction:column; }
}

.sidebar{
  border-right:1px solid var(--border);
  background: var(--surface-2);
  display:flex; flex-direction:column;
  min-height:0;
}

.sidebar-header{
  padding:16px 14px 10px;
  display:flex; align-items:center; justify-content:space-between;
}
.sidebar-header .brand{ display:flex; align-items:center; gap:8px; }
.sidebar-header .brand span{ font-family: var(--font-serif); font-weight:600; font-size:17px; }

/* Notification bell */
.notif-bell{ position:relative; }
.notif-btn{
  background:none; border:none; cursor:pointer; position:relative;
  padding:4px; border-radius:var(--radius-sm); color:var(--muted);
  display:flex; align-items:center; justify-content:center;
  transition:color .12s ease;
}
.notif-btn:hover{ color:var(--ink); }
.notif-badge{
  display:none; position:absolute; top:-2px; right:-4px;
  min-width:16px; height:16px; border-radius:8px;
  background:var(--danger); color:#fff;
  font-size:10px; font-weight:700; line-height:16px;
  text-align:center; padding:0 4px;
  border:2px solid var(--surface-2);
}
.notif-badge.show{ display:block; }

/* Notification dropdown */
.notif-dropdown{
  display:none; position:fixed;
  width:320px; max-height:400px;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-md);
  box-shadow:var(--shadow); z-index:100;
  overflow:hidden;
}
.notif-dropdown.open{ display:block; animation:notifSlide .18s ease; }
@keyframes notifSlide{ from{opacity:0;transform:translateY(-6px)} to{opacity:1;transform:translateY(0)} }

.notif-header{
  padding:12px 14px; border-bottom:1px solid var(--border);
  font-size:13px; font-weight:600; color:var(--ink);
}
.notif-list{
  max-height:340px; overflow-y:auto;
}
.notif-empty{
  padding:28px 14px; text-align:center;
  font-size:13px; color:var(--muted);
}
.notif-card{
  padding:12px 14px; border-bottom:1px solid var(--border);
  cursor:pointer; transition:background .1s ease;
}
.notif-card:last-child{ border-bottom:none; }
.notif-card:hover{ background:var(--surface-2); }
.notif-card.unread{ background:var(--accent-soft); }
.notif-card.unread:hover{ background:var(--accent-soft); filter:brightness(.97); }
.notif-card-title{
  font-size:13px; font-weight:600; color:var(--ink);
  margin-bottom:2px; line-height:1.3;
}
.notif-card-body{
  font-size:12px; color:var(--muted); line-height:1.45;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.notif-card-meta{
  font-size:11px; color:var(--muted); margin-top:4px; opacity:.7;
}

.sidebar-search{
  margin:4px 14px 12px;
  display:flex; align-items:center; gap:8px;
  background: var(--surface); border:1px solid transparent; border-radius: var(--radius-md);
  padding:8px 11px;
}
.sidebar-search:hover{ border-color: transparent; }
.sidebar-search input{
  border:none; outline:none; background:transparent; font-size:13.5px; color: var(--ink); width:100%;
  font-family: var(--font-ui);
}
.sidebar-search input::placeholder{ color: var(--muted); }
.sidebar-search .icon{ color: var(--muted); width:15px; height:15px; flex-shrink:0; transition: color .15s ease; }
.sidebar-search:focus-within{ border-color: transparent; box-shadow: none; outline:none; }
.sidebar-search:focus-within input{ outline:none; box-shadow:none; }
.sidebar-actions{ display:flex; gap:8px; margin:0 14px 14px; }
.sidebar-actions .btn{ flex:1; font-size:13px; padding:8px 10px; }

.view-toggle{
  display:flex; gap:4px; margin:0 14px 12px; background: var(--surface);
  border:1px solid var(--border); border-radius: var(--radius-sm); padding:3px;
}
.view-toggle button{
  flex:1; border:none; background:transparent; padding:6px 8px; border-radius:calc(var(--radius-sm) - 2px);
  font-size:12.5px; font-weight:600; color: var(--muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:6px;
}
.view-toggle button.active{ background: var(--accent-soft); color: var(--accent); }
.view-toggle .icon{ width:14px; height:14px; }

.notes-list{ flex:1; overflow-y:auto; padding:0 8px 12px; }


/* Note context menu (⋯) */
.note-item .row1{ position:relative; }
.note-menu-btn{
  margin-left:auto; opacity:0; transition: opacity .12s ease;
}
.note-item:hover .note-menu-btn{ opacity:1; }
.note-item .note-menu-btn .icon{ width:14px; height:14px; }

.note-context-menu{
  position:fixed; z-index:200; min-width:180px;
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding:4px;
}
.ctx-item{
  display:flex; align-items:center; gap:8px; width:100%; padding:8px 10px;
  border:none; background:transparent; border-radius:calc(var(--radius-sm) - 2px);
  font-size:12.5px; color: var(--ink); cursor:pointer; text-align:left;
}
.ctx-item:hover{ background: var(--surface-2); }
.ctx-item .icon{ width:14px; height:14px; color: var(--muted); }
.ctx-danger{ color: var(--danger); }
.ctx-danger .icon{ color: var(--danger); }
.ctx-sep{ height:1px; background: var(--border); margin:3px 6px; }
.note-item{
  padding:9px 10px; border-radius: var(--radius-sm); cursor:pointer;
  display:flex; flex-direction:column; gap:2px; margin-bottom:2px;
}
.note-item:hover{ background: var(--surface); }
.note-item.active{ background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.note-item .row1{ display:flex; align-items:center; gap:6px; min-width:0; }
.note-item .row1 .icon{ width:14px; height:14px; color: var(--muted); flex-shrink:0; }
.note-item .title{ font-size:13.5px; font-weight:600; color: var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0; }
.note-item .excerpt{ font-size:12px; color: var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; padding-left:20px; }
.note-item .pin{ width:13px; height:13px; color: var(--accent); flex-shrink:0; }

.empty-state{ padding:26px 18px; text-align:center; color: var(--muted); font-size:13px; }

.sidebar-footer{
  border-top:1px solid var(--border); padding:8px 8px;
  display:flex; flex-direction:column; gap:0;
  margin-top:auto; position:relative;
}
.user-chip{
  display:flex; align-items:center; gap:8px; font-size:13px; color: var(--ink-soft); overflow:hidden;
  padding:8px 10px; border-radius: var(--radius-sm); cursor:pointer; transition: background .12s ease;
}
.user-chip:hover{ background: var(--surface); }
.user-chip .avatar{
  width:24px; height:24px; border-radius:50%; background: var(--accent); color:var(--accent-ink);
  display:flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; flex-shrink:0;
  overflow:hidden;
}
.user-chip .avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.user-menu{
  position:absolute; bottom:calc(100% + 4px); left:8px; right:8px; z-index:50;
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding:4px;
}
.user-menu .ctx-item{
  display:flex; align-items:center; gap:8px; width:100%; padding:8px 10px;
  border:none; background:transparent; border-radius:calc(var(--radius-sm) - 2px);
  font-size:13px; color: var(--ink); cursor:pointer; text-align:left;
}
.user-menu .ctx-item:hover{ background: var(--surface-2); }
.user-menu .ctx-item .icon{ width:15px; height:15px; color: var(--muted); }
.user-menu .ctx-sep{ height:1px; background: var(--border); margin:3px 6px; }

/* ---- submenu ---- */
.ctx-submenu-anchor{ position:relative; }
.ctx-submenu-anchor::after{
  content:''; position:absolute; top:0; bottom:0; left:100%; width:8px;
}
.ctx-submenu-arrow{ margin-left:auto!important; opacity:.4; transition:transform .12s ease; }
.ctx-submenu-anchor:hover > .ctx-submenu-arrow{ transform:translateX(2px); opacity:.7; }
.ctx-submenu{
  display:none; position:absolute; left:calc(100% + 4px); top:-4px;
  min-width:180px; z-index:60;
  background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius-sm); box-shadow:var(--shadow); padding:4px;
}
.ctx-submenu-anchor:hover > .ctx-submenu{ display:block; }

/* =========================================================================
   Main panel
   ========================================================================= */

.main{ display:flex; flex-direction:column; min-width:0; min-height:0; }

.topbar{
  height:52px; flex-shrink:0; display:flex; align-items:center; gap:10px;
  padding:0 18px; border-bottom:1px solid var(--border); background: var(--bg);
}
.topbar .crumb{ font-size:13px; color: var(--muted); display:flex; align-items:center; gap:6px; min-width:0; }
.topbar .crumb .current{ color: var(--ink); font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.topbar .spacer{ flex:1; }
.topbar .topbar-actions{ display:flex; align-items:center; gap:6px; }
.topbar .graph-topbar-actions{ display:flex; align-items:center; gap:6px; }
.graph-label{ font-size:12px; font-weight:600; color: var(--muted); white-space:nowrap; }
.saved-indicator{ font-size:12px; color: var(--muted); margin-right:4px; display:flex; align-items:center; gap:5px; }
.saved-indicator .dot{ width:6px; height:6px; border-radius:50%; background:#8FBF6B; }

.content-area{ flex:1; min-height:0; position:relative; }

/* Empty / welcome */
.welcome{
  height:100%; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:14px; color: var(--muted); text-align:center; padding:24px; overflow-y:auto; overflow-x:hidden;
}
.welcome .icon-badge{
  width:56px; height:56px; border-radius:16px; background: var(--accent-soft); color: var(--accent);
  display:flex; align-items:center; justify-content:center;
}
.welcome .icon-badge .icon{ width:26px; height:26px; }
.welcome h3{ color: var(--ink); font-family: var(--font-serif); font-size:20px; margin:0; font-weight:600; }
.welcome p{ font-size:13.5px; max-width:320px; margin:0; line-height:1.6; }

/* Contribution graph — LeetCode-style faoliyat xaritasi */
.activity-section{ width:100%; max-width:820px; margin-top:12px; text-align:left; }
.activity-header{ display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.activity-summary{ display:flex; align-items:baseline; gap:6px; }
.activity-count{ font-size:20px; font-weight:700; color:var(--ink); line-height:1; }
.activity-count-label{ font-size:13px; color:var(--muted); font-weight:500; }
.activity-stats{ display:flex; align-items:center; gap:14px; }
.activity-stat{ font-size:12.5px; color:var(--muted); white-space:nowrap; }
.activity-stat strong{ color:var(--ink); font-weight:700; }

.activity-year-select{ position:relative; }
.activity-year-btn{
  display:flex; align-items:center; gap:4px; background:var(--surface-2); border:1px solid var(--border);
  color:var(--ink); font-size:12.5px; font-weight:600; padding:5px 8px; border-radius:6px; cursor:pointer;
  transition:border-color .15s,background .15s;
}
.activity-year-btn:hover{ border-color:var(--accent); }
.activity-year-btn svg{ transition:transform .15s ease; }
.activity-year-select.open .activity-year-btn svg{ transform:rotate(180deg); }
.activity-year-dropdown{
  display:none; position:absolute; top:calc(100% + 6px); right:0; z-index:20;
  background:var(--surface); border:1px solid var(--border); border-radius:8px;
  box-shadow:var(--shadow); min-width:88px; max-height:220px; overflow-y:auto; padding:4px;
}
.activity-year-select.open .activity-year-dropdown{ display:block; }
.activity-year-option{ font-size:12.5px; padding:6px 10px; border-radius:5px; cursor:pointer; color:var(--ink-soft); font-weight:500; }
.activity-year-option:hover{ background:var(--surface-2); color:var(--ink); }
.activity-year-option.active{ color:var(--accent); font-weight:700; background:var(--accent-soft); }

.activity-grid-col{ width:100%; overflow-x:auto; overflow-y:hidden; padding-top:36px; margin-top:-36px; padding-bottom:4px; }
.activity-months{ display:grid; margin-bottom:4px; white-space:nowrap; width:max-content; }
.activity-months span{ font-size:10.5px; color:var(--muted); overflow:visible; }
.activity-grid{ display:grid; grid-template-rows:repeat(7, 10px); grid-auto-flow:column; grid-auto-columns:10px; gap:3px; width:max-content; }
.activity-cell{ width:10px; height:10px; border-radius:2px; background:var(--surface-2); position:relative; box-sizing:border-box; }
.activity-cell:hover{ box-shadow:0 0 0 1.5px var(--accent); z-index:2; }
.activity-tip{ position:fixed; background:var(--ink); color:var(--surface); font-size:11px; font-weight:500; padding:5px 9px; border-radius:6px; white-space:nowrap; z-index:9999; pointer-events:none; box-shadow:var(--shadow); }
.activity-cell.l0{ background:var(--surface-2); }
.activity-cell.l1{ background:var(--act-l1); }
.activity-cell.l2{ background:var(--act-l2); }
.activity-cell.l3{ background:var(--act-l3); }
.activity-cell.l4{ background:var(--accent); }
.activity-cell.empty{ background:transparent; }
.activity-legend{ display:flex; align-items:center; gap:4px; margin-top:10px; justify-content:flex-end; }
.activity-legend span{ font-size:10.5px; color:var(--muted); }
.activity-legend .activity-cell{ width:10px; height:10px; cursor:default; }
.activity-legend .activity-cell:hover{ box-shadow:none; }

/* Editor */
.editor-wrap{ height:100%; display:flex; flex-direction:column; }
.editor-scroll{ flex:1; overflow-y:auto; }
.editor-inner{ max-width:1180px; margin:0 auto; padding:44px 48px 120px; }

.title-input{
  width:100%; border:none; outline:none; background:transparent; color: var(--ink);
  font-family: var(--font-serif); font-size:32px; font-weight:600; letter-spacing:-0.01em;
  margin-bottom:6px;
}
.title-input::placeholder{ color: var(--muted); }
.meta-line{ font-size:12px; color: var(--muted); margin-bottom:24px; display:flex; gap:14px; }

.editor-tabs{
  display:inline-flex; gap:4px; margin-bottom:18px; background: var(--surface);
  border:1px solid var(--border); border-radius: var(--radius-sm); padding:3px;
}
.editor-tabs .tab-btn{
  border:none; background:transparent; padding:7px 14px; border-radius:calc(var(--radius-sm) - 2px);
  font-size:12.5px; font-weight:600; color: var(--muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center; gap:6px;
}
.editor-tabs .tab-btn.active{ background: var(--accent-soft); color: var(--accent); }
.editor-tabs .tab-btn .icon{ width:14px; height:14px; }

.editor-pane{ width:100%; }

.editor-content{
  width:100%; min-height:560px; border:none; outline:none; background:transparent;
  color: var(--ink); font-family: var(--font-serif); font-size:15.5px; line-height:1.8;
  outline:none; position:relative;
}
.editor-content:empty::before{
  content: attr(data-placeholder); color: var(--muted); pointer-events:none; font-style:italic;
}
.editor-content:focus{ outline:none; }
.editor-content img{ max-width:100%; border-radius:6px; margin:8px 0; display:block; }
.editor-content h1,.editor-content h2,.editor-content h3{ font-family: var(--font-serif); color: var(--ink); font-weight:600; }
.editor-content h1{ font-size:24px; margin:22px 0 10px; }
.editor-content h2{ font-size:20px; margin:20px 0 8px; }
.editor-content h3{ font-size:17px; margin:18px 0 6px; }
.editor-content p{ margin:0 0 12px; }
.editor-content blockquote{ border-left:3px solid var(--accent); margin:0 0 14px; padding:2px 0 2px 14px; color: var(--muted); }
.editor-content pre{ background: var(--surface-2); padding:14px; border-radius: var(--radius-sm); overflow-x:auto; font-family: var(--font-mono); font-size:13.5px; line-height:1.6; margin:0 0 14px; }
.editor-content code{ background: var(--surface-2); padding:2px 5px; border-radius:4px; font-family: var(--font-mono); font-size:.88em; }
.editor-content pre code{ background:none; padding:0; }
.editor-content ul,.editor-content ol{ padding-left:22px; margin:0 0 14px; }
.editor-content table{ width:100%; border-collapse:collapse; margin:0 0 18px; font-size:14px; }
.editor-content th,.editor-content td{ border:1px solid var(--border); padding:8px 12px; text-align:left; }
.editor-content th{ background: var(--surface-2); font-weight:600; color: var(--ink); }
.editor-content hr{ border:none; border-top:1px solid var(--border); margin:20px 0; }
.editor-content a.wikilink{ color: var(--accent); border-bottom:1px solid var(--accent-soft); padding-bottom:1px; font-weight:600; cursor:pointer; }
.editor-content a.wikilink:hover{ border-color: var(--accent); }
.editor-content a.wikilink.is-new::after{ content:" +"; color: var(--muted); font-weight:400; }
.editor-content .task-item{ display:flex; align-items:flex-start; gap:8px; margin:4px 0; }
.editor-content .task-checkbox{
  width:16px; height:16px; border:2px solid var(--border); border-radius:3px; cursor:pointer; flex-shrink:0; margin-top:4px;
  display:flex; align-items:center; justify-content:center; background:var(--surface); transition:all .15s;
}
.editor-content .task-checkbox:hover{ border-color: var(--accent); }
.editor-content .task-item.checked .task-checkbox{ background: var(--accent); border-color: var(--accent); }
.editor-content .task-item.checked .task-checkbox::after{ content:""; width:8px; height:5px; border-left:2px solid #fff; border-bottom:2px solid #fff; transform:rotate(-45deg) translateY(-1px); }
.editor-content .task-item.checked{ text-decoration: line-through; color: var(--muted); }

.preview{
  font-size:15.5px; line-height:1.8; color: var(--ink-soft); min-height:560px; word-wrap:break-word;
}
.preview h1,.preview h2,.preview h3{ font-family: var(--font-serif); color: var(--ink); font-weight:600; }
.preview h1{ font-size:24px; margin:22px 0 10px; }
.preview h2{ font-size:20px; margin:20px 0 8px; }
.preview h3{ font-size:17px; margin:18px 0 6px; }
.preview p{ margin:0 0 14px; }
.preview code{ background: var(--surface-2); padding:2px 5px; border-radius:4px; font-family: var(--font-mono); font-size:.88em; }
.preview pre{ background: var(--surface-2); padding:14px; border-radius: var(--radius-sm); overflow-x:auto; }
.preview pre code{ background:none; padding:0; }
.preview pre code.hljs{ background: transparent !important; }
.preview ul, .preview ol{ padding-left:22px; margin:0 0 14px; }
.preview blockquote{ border-left:3px solid var(--accent); margin:0 0 14px; padding:2px 0 2px 14px; color: var(--muted); }
.preview table{ width:100%; border-collapse:collapse; margin:0 0 18px; font-size:14px; }
.preview th, .preview td{ border:1px solid var(--border); padding:8px 12px; text-align:left; }
.preview th{ background: var(--surface-2); font-weight:600; color: var(--ink); }
.preview tr:nth-child(even) td{ background: var(--surface-2); }
.preview ul.contains-task-list{ list-style:none; padding-left:2px; }
.preview li.task-list-item{ display:flex; align-items:flex-start; gap:8px; }
.preview li.task-list-item input[type="checkbox"]{
  margin-top:5px; width:15px; height:15px; accent-color: var(--accent); cursor:pointer; flex-shrink:0;
}
.preview a.wikilink{
  color: var(--accent); border-bottom:1px solid var(--accent-soft); padding-bottom:1px; font-weight:600; cursor:pointer;
}
.preview a.wikilink:hover{ border-color: var(--accent); }
.preview a.wikilink.is-new::after{ content:" +"; color: var(--muted); font-weight:400; }
.preview hr{ border:none; border-top:1px solid var(--border); margin:20px 0; }
.preview s{ text-decoration:line-through; color: var(--muted); }
.preview u{ text-decoration:underline; text-underline-offset:3px; }
.preview mark{ background:var(--highlight, #fff3b0); padding:1px 3px; border-radius:3px; }
.preview a:not(.wikilink){ color: var(--accent); text-decoration:underline; text-underline-offset:2px; }
.preview img{ max-width:100%; border-radius:6px; margin:8px 0; display:block; }

.editor-statusbar{ display:flex; align-items:center; gap:8px; padding:10px 0; font-size:11.5px; color: var(--muted); border-top:1px solid var(--border); margin-top:12px; user-select:none; }
.editor-statusbar .sep{ opacity:.4; }

.find-replace-panel{
  position:fixed; top:8px; right:16px; z-index:50; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding:10px 12px; box-shadow: var(--shadow-lg); min-width:320px;
  display:flex; flex-direction:column; gap:8px;
}
.fr-row{ display:flex; align-items:center; gap:6px; }
.fr-input{
  flex:1; border:1px solid var(--border); border-radius:4px; padding:6px 10px; font-size:13px;
  background: var(--surface); color: var(--ink); outline:none; font-family: var(--font-mono);
}
.fr-input:focus{ border-color: var(--accent); }
.fr-count{ font-size:11px; color: var(--muted); min-width:28px; text-align:center; }
.fr-btn{
  border:1px solid var(--border); background: var(--surface); border-radius:4px; padding:5px 10px;
  font-size:12px; color: var(--ink-soft); cursor:pointer; white-space:nowrap; display:flex; align-items:center; gap:3px;
}
.fr-btn:hover{ background: var(--surface-2); color: var(--ink); }
.fr-btn .icon{ width:14px; height:14px; }
.export-popup{ position:fixed; z-index:60; background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-sm); padding:4px; box-shadow: var(--shadow-lg); min-width:180px; }
.export-popup .ctx-item{ width:100%; border:none; background:transparent; text-align:left; }
.export-popup .ctx-item:hover{ background: var(--surface-2); }

.links-section{ margin-top:36px; border-top:1px solid var(--border); padding-top:20px; }
.local-graph-section{ margin-top:28px; border-top:1px solid var(--border); padding-top:20px; }
.local-graph-section h4{
  font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color: var(--muted);
  margin:0 0 12px; display:flex; align-items:center; gap:6px;
}
.local-graph-section h4 .icon{ width:13px; height:13px; }
.local-graph-svg{
  width:100%; min-height:190px; display:block; background: var(--surface-2);
  border:1px solid var(--border); border-radius: var(--radius-md);
}
.links-group{ margin-bottom:18px; }
.links-group h4{
  font-size:11px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color: var(--muted);
  margin:0 0 10px; display:flex; align-items:center; gap:6px;
}
.links-group h4 .icon{ width:13px; height:13px; }
.link-pill{
  display:inline-flex; align-items:center; gap:6px; background: var(--surface-2); border:1px solid var(--border);
  padding:6px 10px; border-radius: 999px; font-size:12.5px; margin:0 6px 6px 0; cursor:pointer; color: var(--ink-soft);
}
.link-pill:hover{ border-color: var(--accent); color: var(--accent); }
.link-pill .icon{ width:12px; height:12px; }
.no-links{ font-size:12.5px; color: var(--muted); }

/* Graph */
.graph-wrap{ height:100%; position:relative; }
.graph-wrap svg{ width:100%; height:100%; display:block; cursor:grab; }
.graph-wrap svg:active{ cursor:grabbing; }
.graph-toolbar{
  position:absolute; top:16px; left:16px; z-index:5; display:flex; gap:8px;
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:6px; box-shadow: var(--shadow);
}
.graph-empty{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color: var(--muted); font-size:13.5px;
}
.graph-node-label{
  font-family: var(--font-ui); font-size:11px; fill: var(--ink-soft); pointer-events:none; user-select:none;
}
.graph-node{ transition: opacity .18s ease; }
.graph-node circle{ transition: opacity .18s ease, filter .18s ease, r .18s ease; fill-opacity: var(--graph-node-fill-opacity) !important; }
.graph-node .graph-node-label{ transition: opacity .18s ease; }
.graph-node.is-dimmed{ opacity:.16; }
.graph-node.is-external circle{ fill-opacity:0.25 !important; stroke-opacity:0.4; }
.graph-node.is-external .graph-node-label{ opacity:0.45; }
.graph-node.is-focused circle{ filter: drop-shadow(0 0 7px var(--node-color)); }
.graph-link{ stroke: var(--graph-link-color) !important; transition: opacity .18s ease, stroke-width .18s ease; }
.graph-link.is-dimmed{ opacity:.08; }
.graph-link.is-focused{ opacity:1; stroke-width:1.8px; }
.graph-hint{
  position:absolute; bottom:16px; right:16px; font-size:11.5px; color: var(--muted);
  background: var(--surface); border:1px solid var(--border); padding:6px 10px; border-radius: var(--radius-sm);
}
.graph-count{
  position:absolute; top:16px; right:16px; z-index:5; align-items:center; gap:6px;
  font-size:12.5px; font-weight:600; color: var(--ink-soft);
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:7px 12px; box-shadow: var(--shadow);
}

/* Toast */
.toast{
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%) translateY(12px);
  background: var(--ink); color: var(--bg); padding:9px 16px; border-radius: var(--radius-sm);
  font-size:13px; font-weight:500; opacity:0; pointer-events:none; transition: all .18s ease; z-index:100;
  box-shadow: var(--shadow);
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

/* Mobile top bar burger */
.burger{ display:none; }
.sidebar-scrim{ display:none; } 
@media (max-width: 760px){
  .burger{ display:flex; }
  .sidebar-scrim{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:35; }
  .app-shell.sidebar-open .sidebar-scrim{ display:block; }
}

/* Scrollbars */
::-webkit-scrollbar{ width:9px; height:9px; }
::-webkit-scrollbar-thumb{ background: var(--border); border-radius:99px; }
::-webkit-scrollbar-track{ background:transparent; }

/* Focus visibility */
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible{
  outline: 2px solid var(--accent); outline-offset:2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ transition:none !important; animation:none !important; }
}

/* =========================================================================
   Share popover
   ========================================================================= */

.popover-anchor{ position:relative; }

.share-popover{
  position:absolute; top:calc(100% + 8px); right:0; z-index:50;
  width:300px; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow); padding:16px;
}
.share-popover .sp-title{
  display:flex; align-items:center; gap:8px; font-size:13.5px; font-weight:700; color: var(--ink);
  margin-bottom:4px;
}
.share-popover .sp-title .icon{ width:15px; height:15px; color: var(--accent); }
.share-popover .sp-sub{ font-size:12px; color: var(--muted); margin:0 0 14px; line-height:1.5; }

.sp-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:12px; }
.sp-row .label{ font-size:13px; font-weight:600; color: var(--ink-soft); }

.switch{ position:relative; display:inline-block; width:38px; height:22px; flex-shrink:0; }
.switch input{ opacity:0; width:0; height:0; }
.switch .track{
  position:absolute; inset:0; background: var(--border); border-radius:999px; cursor:pointer; transition: background .15s ease;
}
.switch .track::before{
  content:""; position:absolute; width:16px; height:16px; left:3px; top:3px; background:#fff;
  border-radius:50%; transition: transform .15s ease; box-shadow:0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + .track{ background: var(--accent); }
.switch input:checked + .track::before{ transform: translateX(16px); }

.share-link-row{
  display:flex; align-items:center; gap:6px; background: var(--surface-2); border:1px solid var(--border);
  border-radius: var(--radius-sm); padding:6px 6px 6px 10px;
}
.share-link-row input{
  flex:1; border:none; outline:none; background:transparent; font-size:12px; color: var(--ink-soft);
  font-family: var(--font-mono); min-width:0;
}
.share-link-row button{
  border:none; background: var(--surface); border:1px solid var(--border); border-radius:calc(var(--radius-sm) - 2px);
  width:26px; height:26px; display:flex; align-items:center; justify-content:center; cursor:pointer; color: var(--ink-soft); flex-shrink:0;
}
.share-link-row button:hover{ color: var(--accent); border-color: var(--accent); }
.share-link-row .icon{ width:13px; height:13px; }

.sp-hint{ font-size:11.5px; color: var(--muted); margin-top:10px; line-height:1.5; }

.share-popover.wide{ width:340px; }
.map-note-list{
  max-height:220px; overflow-y:auto; border:1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom:12px; background: var(--surface-2);
}
.map-note-row{
  display:flex; align-items:center; gap:9px; padding:8px 10px; font-size:13px; color: var(--ink-soft);
  border-bottom:1px solid var(--border);
}
.map-note-row:last-child{ border-bottom:none; }
.map-note-row input[type="checkbox"]{ flex-shrink:0; width:15px; height:15px; accent-color: var(--accent); cursor:pointer; }
.map-note-row label{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; }
.map-note-empty{ padding:14px 10px; font-size:12.5px; color: var(--muted); text-align:center; }

.link-like{
  background:none; border:none; padding:0; color: var(--accent); font-size:inherit;
  cursor:pointer; text-decoration:underline; text-underline-offset:2px;
}
.link-like:hover{ opacity:.8; }

/* =========================================================================
   Import / Export
   ========================================================================= */

.import-export-menu{
  width:230px; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow); padding:6px;
}
.ie-item{
  display:flex; align-items:center; gap:10px; width:100%; padding:9px 10px; border-radius: var(--radius-sm);
  border:none; background:transparent; color: var(--ink); font-size:13px; font-weight:600; cursor:pointer; text-align:left;
}
.ie-item:hover{ background: var(--surface-2); }
.ie-item .icon{ width:15px; height:15px; color: var(--muted); }
.ie-item .ie-desc{ display:block; font-size:11px; font-weight:400; color: var(--muted); margin-top:1px; }

html,body{ overflow-x: hidden; }
.app-shell{ overflow-x: hidden; }

/* =========================================================================
   Wikilink autocomplete
   ========================================================================= */

.wikilink-autocomplete{
  position:fixed; z-index:300; min-width:230px; max-width:340px; max-height:260px;
  overflow-y:auto; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding:4px;
}
.wa-item{
  display:flex; align-items:center; gap:8px; padding:7px 9px; border-radius:calc(var(--radius-sm) - 2px);
  font-size:13px; color: var(--ink); cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.wa-item .icon{ width:14px; height:14px; color: var(--muted); flex-shrink:0; }
.wa-item.active{ background: var(--accent-soft); color: var(--accent); }
.wa-item.active .icon{ color: var(--accent); }

/* =========================================================================
   Formatlash paneli (toolbar)
   ========================================================================= */

.fmt-toolbar{
  display:flex; align-items:center; gap:2px; margin-bottom:10px; padding:4px;
  background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius-sm);
  width:fit-content;
}
.fmt-btn{
  display:flex; align-items:center; justify-content:center; width:30px; height:30px;
  border:none; background:transparent; border-radius:calc(var(--radius-sm) - 2px);
  color: var(--ink-soft); cursor:pointer;
}
.fmt-btn:hover{ background: var(--surface); color: var(--accent); }
.fmt-btn .icon{ width:15px; height:15px; }

.floating-fmt-toolbar{
  position:fixed; z-index:300; display:flex; align-items:center; gap:2px;
  background: var(--ink); border-radius: var(--radius-sm); padding:4px; box-shadow: var(--shadow);
}
.floating-fmt-toolbar .fmt-btn{ color:#D8D3C8; }
.floating-fmt-toolbar .fmt-btn:hover{ background: rgba(255,255,255,0.12); color:#fff; }

.slash-command-menu{ min-width:220px; }

/* =========================================================================
   Tezkor o'tish (Ctrl+K)
   ========================================================================= */

.quick-switcher-overlay{
  position:fixed; inset:0; z-index:500; background:rgba(20,17,12,0.45);
  display:flex; align-items:flex-start; justify-content:center; padding-top:14vh;
}
.quick-switcher{
  width:100%; max-width:520px; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow); overflow:hidden;
}
.qs-input-row{
  display:flex; align-items:center; gap:10px; padding:14px 16px; border-bottom:1px solid var(--border);
}
.qs-input-row .icon{ color: var(--muted); width:17px; height:17px; }
.qs-input-row input{
  flex:1; border:none; outline:none; background:transparent; font-size:15px; color: var(--ink);
}
.qs-results{ max-height:320px; overflow-y:auto; padding:6px; }
.qs-item{
  display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius: var(--radius-sm);
  font-size:13.5px; color: var(--ink); cursor:pointer;
}
.qs-item .icon{ width:15px; height:15px; color: var(--muted); flex-shrink:0; }
.qs-item.active{ background: var(--accent-soft); color: var(--accent); }
.qs-item.active .icon{ color: var(--accent); }
.qs-empty{ padding:16px 10px; font-size:13px; color: var(--muted); text-align:center; }

/* =========================================================================
   Inline input dialog (replaces prompt())
   ========================================================================= */

.input-dialog-overlay{
  position:fixed; inset:0; z-index:500; background:rgba(20,17,12,0.45);
  display:flex; align-items:center; justify-content:center;
}
.input-dialog{
  width:100%; max-width:440px; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow); padding:20px;
}
.input-dialog-title{ font-size:14px; font-weight:700; color: var(--ink); margin-bottom:12px; }
.input-dialog-field{
  width:100%; padding:10px 12px; border-radius: var(--radius-sm);
  border:1px solid var(--border); background: var(--surface-2); color: var(--ink);
  font-size:14px; font-family: var(--font-ui); outline:none; margin-bottom:16px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.input-dialog-field:focus{ border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-dialog-actions{ display:flex; gap:8px; justify-content:flex-end; }
.input-dialog-actions .btn{ padding:8px 16px; font-size:13px; flex:1; }

/* =========================================================================
   Settings modal — Claude.ai style
   ========================================================================= */

.modal-overlay{
  position:fixed; inset:0; z-index:500; background:rgba(20,17,12,0.55);
  display:flex; align-items:center; justify-content:center;
  animation: fadeIn .12s ease;
}
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }

.settings-shell{
  width:100%; max-width:760px; height:520px; max-height:85vh;
  display:flex; flex-direction:column;
  background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: 0 24px 64px rgba(0,0,0,.18);
  overflow:hidden;
  animation: settingsUp .2s cubic-bezier(.16,1,.3,1);
}
@keyframes settingsUp{ from{ opacity:0; transform:scale(.96) translateY(8px); } to{ opacity:1; transform:scale(1) translateY(0); } }

/* ---- header ---- */
.settings-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 24px; border-bottom:1px solid var(--border);
  flex-shrink:0;
}
.settings-header h2{ font-size:15px; font-weight:700; color:var(--ink); margin:0; }

/* ---- body (sidebar + content) ---- */
.settings-body{
  display:flex; flex:1; min-height:0;
}

/* ---- sidebar ---- */
.settings-sidebar{
  width:200px; flex-shrink:0; border-right:1px solid var(--border);
  background: var(--surface-2); padding:12px 8px;
  display:flex; flex-direction:column; gap:2px;
  overflow-y:auto;
}
.settings-group-label{
  font-size:11px; font-weight:600; color:var(--muted);
  text-transform:uppercase; letter-spacing:.04em;
  padding:8px 12px 4px; user-select:none;
}
.settings-nav-item{
  display:flex; align-items:center; gap:8px;
  padding:8px 12px; border-radius:var(--radius-sm);
  font-size:13px; color:var(--ink-soft); cursor:pointer;
  border:none; background:none; width:100%; text-align:left;
  transition: background .1s ease, color .1s ease;
}
.settings-nav-item:hover{ background: var(--surface); color:var(--ink); }
.settings-nav-item.active{ background: var(--surface); color:var(--ink); font-weight:600; box-shadow: inset 0 0 0 1px var(--border); }
.settings-nav-item .icon{ width:15px; height:15px; color:var(--muted); flex-shrink:0; }
.settings-nav-item.active .icon{ color:var(--accent); }

/* ---- content ---- */
.settings-content{
  flex:1; min-width:0; overflow-y:auto;
  padding:28px 32px;
}
.settings-content-section{ display:none; }
.settings-content-section.active{ display:block; }

.settings-section-title{
  font-size:14px; font-weight:700; color:var(--ink); margin:0 0 4px;
}
.settings-section-desc{
  font-size:12.5px; color:var(--muted); margin:0 0 20px; line-height:1.5;
}

/* ---- language cards ---- */
.lang-selector{ display:flex; gap:10px; }

.lang-card{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:8px;
  padding:18px 12px; border-radius:var(--radius-md);
  border:2px solid var(--border); background:var(--surface-2);
  cursor:pointer; transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.lang-card:hover{ border-color:var(--ink-soft); background:var(--surface); }
.lang-card.active{ border-color:var(--accent); background:var(--accent-soft); box-shadow:0 0 0 1px var(--accent); }

.lang-flag{ font-size:28px; line-height:1; }
.lang-name{ font-size:13px; font-weight:600; color:var(--ink); }

/* ---- theme row (future) ---- */
.theme-row{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 0;
}
.theme-row-label{ font-size:13px; color:var(--ink); font-weight:500; }

/* ---- shortcuts list ---- */
.shortcuts-list{ display:flex; flex-direction:column; gap:0; }
.shortcut-row{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0; border-bottom:1px solid var(--border);
}
.shortcut-row:last-child{ border-bottom:none; }
.shortcut-label{ font-size:13px; color:var(--ink); font-weight:500; }
.shortcut-keys{ display:flex; gap:4px; align-items:center; }
.shortcut-keys kbd{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:22px; height:22px; padding:0 6px;
  font-family:inherit; font-size:11px; font-weight:600;
  color:var(--ink-soft); background:var(--surface-2);
  border:1px solid var(--border); border-radius:4px;
  box-shadow:0 1px 0 var(--border);
}