:root{
  --bg:#0b0f19;
  --panel:#101827;
  --panel2:#0f172a;
  --text:#e5e7eb;
  --muted:#9ca3af;
  --border:rgba(255,255,255,0.08);
  --shadow:0 12px 30px rgba(0,0,0,0.35);
  --primary:#60a5fa;
  --danger:#f87171;
  --radius:18px;
  --radius-s:14px;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family:ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  background:radial-gradient(1200px 800px at 20% 0%, #111b33 0%, var(--bg) 45%, #050712 100%);
  color:var(--text);
}

.hidden{display:none !important;}
.muted{color:var(--muted);} 
.tiny{font-size:12px;}
.row{display:flex; align-items:center; gap:10px;}

.screen{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:20px;}

/* Auth */
.auth-card{
  width:min(520px, 100%);
  background:linear-gradient(180deg, rgba(16,24,39,0.92), rgba(7,10,18,0.92));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:22px;
}
.brand{display:flex; gap:14px; align-items:center; margin-bottom:18px;}
.brand-icon{width:52px; height:52px; border-radius:14px; border:1px solid var(--border);}
.brand-title{font-weight:700; letter-spacing:0.3px; font-size:18px;}
.brand-subtitle{font-size:13px; color:var(--muted); margin-top:2px;}

.auth-mode h2{margin:0 0 10px 0; font-size:20px;}
.auth-mode p{margin:0 0 12px 0; line-height:1.35;}

.field{display:flex; flex-direction:column; gap:7px; margin:10px 0;}
.field span{font-size:12px; color:var(--muted);}
input, textarea{
  width:100%;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  color:var(--text);
  padding:12px 12px;
  outline:none;
}
input:focus, textarea:focus{border-color:rgba(96,165,250,0.55); box-shadow:0 0 0 4px rgba(96,165,250,0.12);}

button{
  border:1px solid var(--border);
  background:rgba(255,255,255,0.05);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
}
button:hover{background:rgba(255,255,255,0.08);}
button:active{transform:translateY(1px);}

.primary{background:linear-gradient(180deg, rgba(96,165,250,0.95), rgba(59,130,246,0.85)); border-color:rgba(96,165,250,0.35);}
.primary:hover{background:linear-gradient(180deg, rgba(96,165,250,1), rgba(59,130,246,0.95));}
.ghost{background:transparent;}
.danger{color:#fecaca; border-color:rgba(248,113,113,0.35);}
.danger:hover{background:rgba(248,113,113,0.08);}
.icon-btn{padding:8px 10px; border-radius:12px;}
.icon{font-size:16px;}

.auth-footer{margin-top:14px; display:flex; gap:10px; align-items:center; font-size:12px;}
kbd{background:rgba(255,255,255,0.08); border:1px solid var(--border); border-bottom-color:rgba(255,255,255,0.18); padding:2px 6px; border-radius:8px; font-size:11px;}

/* Main layout */
#main-screen{align-items:stretch; justify-content:stretch; padding:0;}
.topbar{
  height:62px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  padding:0 14px;
  position:sticky;
  top:0;
  background:rgba(5,7,18,0.72);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
  z-index:10;
}
.topbar .left,.topbar .center,.topbar .right{display:flex; align-items:center; gap:10px;}
.topbar .title{font-weight:700; letter-spacing:0.2px; padding:0 6px;}
.search{min-width:min(420px, 55vw);}
.pill{font-size:12px; padding:6px 10px; border-radius:999px; border:1px solid rgba(34,197,94,0.35); background:rgba(34,197,94,0.12); color:#bbf7d0;}

.layout{
  display:grid;
  grid-template-columns: 260px 340px 1fr;
  gap:12px;
  padding:12px;
  height:calc(100vh - 62px);
}

.sidebar, .notes, .editor{
  background:linear-gradient(180deg, rgba(16,24,39,0.85), rgba(10,14,26,0.85));
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:hidden;
  box-shadow:0 10px 24px rgba(0,0,0,0.25);
}

.sidebar{display:flex; flex-direction:column;}
.sidebar-head{display:flex; align-items:center; justify-content:space-between; padding:12px 12px; border-bottom:1px solid var(--border);}
.sidebar-title{font-weight:700;}
.section-list{padding:10px; overflow:auto; flex:1;}
.section-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid transparent;
  cursor:pointer;
}
.section-item:hover{background:rgba(255,255,255,0.06);}
.section-item.active{background:rgba(96,165,250,0.12); border-color:rgba(96,165,250,0.25);}
.section-name{font-weight:600; font-size:14px;}
.badge{font-size:12px; color:var(--muted);}
.sidebar-foot{padding:10px; border-top:1px solid var(--border); display:flex; flex-direction:column; gap:8px;}

.panel-head{padding:12px 12px; border-bottom:1px solid var(--border);}
.panel-title{font-weight:700;}
.panel-sub{font-size:12px; color:var(--muted); margin-top:4px;}

.notes-list{padding:10px; overflow:auto; height:calc(100% - 58px);}
.note-card{
  border:1px solid var(--border);
  border-radius:16px;
  padding:10px 10px;
  margin-bottom:10px;
  cursor:pointer;
  position:relative;
  overflow:hidden;
}
.note-card:hover{border-color:rgba(255,255,255,0.18);}
.note-card.active{border-color:rgba(96,165,250,0.55); box-shadow:0 0 0 4px rgba(96,165,250,0.12);}
.note-card .bar{position:absolute; left:0; top:0; bottom:0; width:8px; opacity:0.85;}
.note-card .t{font-weight:700; font-size:14px; margin-left:10px; display:flex; align-items:center; gap:8px;}
.note-card .pinned{font-size:12px; opacity:0.85;}
.note-card .s{font-size:12px; color:var(--muted); margin-left:10px; margin-top:6px; line-height:1.3;}
.note-card .d{font-size:11px; color:var(--muted); margin-left:10px; margin-top:8px;}

.editor{display:flex; flex-direction:column;}
.editor-head{display:flex; align-items:center; justify-content:space-between; gap:10px; padding:12px; border-bottom:1px solid var(--border);}
.note-title{font-size:16px; font-weight:800; padding:10px 12px;}
.editor-meta{display:flex; align-items:center; gap:10px;}
.color-picker{display:flex; gap:8px; padding:12px; border-bottom:1px solid var(--border); flex-wrap:wrap;}
.color-dot{width:26px; height:26px; border-radius:999px; border:1px solid rgba(255,255,255,0.18); cursor:pointer;}
.color-dot.active{outline:3px solid rgba(255,255,255,0.22);}
.note-body{flex:1; resize:none; padding:14px; border:0; border-radius:0; background:transparent; line-height:1.5; font-size:14px;}
.note-body:focus{box-shadow:none;}
.editor-foot{display:flex; align-items:center; gap:10px; padding:12px; border-top:1px solid var(--border);}
.spacer{flex:1;}

.toast{
  position:fixed;
  bottom:16px;
  left:50%;
  transform:translateX(-50%);
  background:rgba(16,24,39,0.92);
  border:1px solid var(--border);
  border-radius:999px;
  padding:10px 14px;
  box-shadow:var(--shadow);
  max-width:min(680px, calc(100% - 24px));
  text-align:center;
}

/* Dialog */
dialog.dlg{
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(16,24,39,0.98), rgba(7,10,18,0.98));
  color:var(--text);
  padding:0;
  box-shadow:var(--shadow);
}
dialog::backdrop{background:rgba(0,0,0,0.55);}
.dlg-inner{padding:18px; min-width:min(520px, 92vw);}
.dlg-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:12px;}

/* Responsive */
@media (max-width: 980px){
  .layout{grid-template-columns: 240px 1fr; grid-template-rows:auto auto;}
  .editor{grid-column: 1 / -1; height:55vh;}
  .search{min-width: min(240px, 40vw);}
}
@media (max-width: 720px){
  .layout{grid-template-columns: 1fr; height:auto;}
  .sidebar{height:auto;}
  .notes{height:52vh;}
  .editor{height:60vh;}
  .topbar{flex-wrap:wrap; height:auto; padding:12px;}
  .topbar .center{width:100%;}
  .search{width:100%; min-width:unset;}
}
