:root { --bg:#111827; --card:#1f2937; --accent:#10b981; --text:#f1f5f9; --muted:#94a3b8; --line:#374151; }
* { box-sizing:border-box; }
html,body { height:100%; }
body { margin:0; font-family:system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; background:var(--bg); color:var(--text); display:flex; flex-direction:column; }
.hidden { display:none !important; }
.muted { color:var(--muted); }
.error { color:#f87171; }
button { cursor:pointer; }

/* login */
.login-overlay { position:fixed; inset:0; background:var(--bg); display:flex; align-items:center; justify-content:center; z-index:50; }
.card { background:var(--card); padding:2rem; border-radius:12px; width:min(22rem,90vw); }
.card form { display:flex; flex-direction:column; gap:.75rem; margin-top:1rem; }
input, textarea { padding:.6rem .75rem; border-radius:8px; border:1px solid var(--line); background:var(--bg); color:var(--text); font:inherit; }
.card button { padding:.75rem; border:0; border-radius:8px; background:var(--accent); color:#06251b; font-weight:700; }

/* top bar + persistent player */
.topbar { display:flex; align-items:center; gap:1rem; padding:.5rem .9rem; background:var(--card); border-bottom:1px solid var(--line); flex-wrap:wrap; }
.logo { font-weight:800; letter-spacing:.15em; font-size:1.2rem; }
.player { display:flex; align-items:center; gap:.75rem; margin-left:auto; background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:.4rem .7rem; min-width:0; }
.np { min-width:0; max-width:16rem; }
#np-title { font-size:.85rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#np-artist { font-size:.75rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pctl { display:flex; gap:.3rem; }
.pctl button, .lib-btn, .muted-btn { background:none; border:1px solid var(--line); color:var(--text); border-radius:8px; padding:.25rem .55rem; font-size:1rem; }
.lib-btn { color:var(--accent); font-size:1.1rem; }
.muted-btn { color:var(--muted); font-size:.8rem; }

/* library panel */
.library { position:fixed; top:4rem; right:.9rem; width:min(30rem,95vw); max-height:75vh; overflow:auto; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:1rem; z-index:40; box-shadow:0 8px 30px rgba(0,0,0,.5); }
.lib-head, .ed-head { display:flex; align-items:center; gap:.5rem; justify-content:space-between; }
.grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:.75rem; margin-top:.75rem; }
.album { background:var(--bg); border-radius:10px; padding:.75rem; cursor:pointer; text-align:center; }
.album:hover { outline:2px solid var(--accent); }
.album img { width:100%; border-radius:8px; }
ul { list-style:none; padding:0; margin:.5rem 0; }
#tracks li { padding:.5rem .6rem; border-radius:8px; cursor:pointer; display:flex; justify-content:space-between; font-size:.9rem; }
#tracks li:hover { background:var(--line); }
#tracks li.playing { background:var(--accent); color:#06251b; font-weight:700; }

/* desk layout */
.desk { flex:1; display:flex; min-height:0; }
#notes-list { width:14rem; border-right:1px solid var(--line); padding:.75rem; overflow:auto; }
.nl-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:.5rem; }
#new-note { border:0; background:var(--accent); color:#06251b; border-radius:6px; padding:.2rem .5rem; font-weight:700; }
#notes li { padding:.45rem .6rem; border-radius:8px; cursor:pointer; font-size:.85rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#notes li:hover { background:var(--line); }
#notes li.active { background:var(--accent); color:#06251b; font-weight:600; }
#editor-pane { flex:1; display:flex; flex-direction:column; min-width:0; padding:.75rem; }
#editor-wrap { flex:1; display:flex; min-height:0; gap:.5rem; }
#note-body, #preview { flex:1; min-width:0; }
#preview { overflow:auto; line-height:1.65; font-size:.95rem; padding:.25rem .5rem; }
#preview h1 { border-bottom:1px solid var(--line); padding-bottom:.3rem; }
#preview pre { background:var(--card); padding:.75rem; border-radius:8px; overflow:auto; }
#preview code { background:var(--card); padding:.1rem .3rem; border-radius:4px; }
#preview pre code { background:none; padding:0; }
#preview blockquote { border-left:3px solid var(--accent); margin:.5rem 0; padding:.2rem .8rem; color:var(--muted); }
#preview a, .wikilink { color:var(--accent); cursor:pointer; text-decoration:none; border-bottom:1px dotted var(--accent); }
#preview img { max-width:100%; }
#search { width:100%; margin:.4rem 0 .6rem; font-size:.8rem; padding:.4rem .5rem; }
.ed-head { flex-wrap:wrap; }
.file-btn { display:inline-flex; align-items:center; }
/* overlays: pdf viewer + present */
.overlay { position:fixed; inset:0; background:rgba(17,24,39,.97); z-index:60; display:flex; flex-direction:column; align-items:center; padding:1rem; }
.ov-head { width:100%; display:flex; justify-content:space-between; align-items:center; max-width:60rem; }
#pdf-canvas { max-width:100%; max-height:calc(100vh - 9rem); background:#fff; border-radius:4px; }
.ov-ctl { display:flex; gap:1rem; align-items:center; padding:.5rem; }
/* present mode */
.present { justify-content:center; }
#slide { width:100%; max-width:56rem; font-size:1.6rem; line-height:1.7; overflow:auto; padding:2rem; }
#slide h1 { font-size:2.6rem; border-bottom:2px solid var(--accent); }
#slide h2 { font-size:2.1rem; }
#slide pre { background:var(--card); padding:1rem; border-radius:10px; overflow:auto; }
#slide code { background:var(--card); padding:.1rem .4rem; border-radius:6px; }
#slide img { max-width:100%; border-radius:8px; }
#slide li { margin:.4rem 0; }
/* embeds */
.embed-chip { display:inline-flex; align-items:center; gap:.4rem; background:var(--card); border:1px solid var(--line); padding:.3rem .7rem; border-radius:8px; cursor:pointer; color:var(--accent); font-size:.9em; }
.embed-chip:hover { border-color:var(--accent); }
audio.embed-audio { width:100%; margin:.5rem 0; }
.ed-head { display:flex; gap:.5rem; align-items:center; margin-bottom:.5rem; }
#note-name { max-width:14rem; font-size:.85rem; }
#save-note { border:0; background:var(--accent); color:#06251b; border-radius:8px; padding:.45rem .9rem; font-weight:700; }
#save-state { font-size:.75rem; }
#note-body { resize:none; line-height:1.6; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:.9rem; }
h2,h3 { margin:.25rem 0; }

@media (max-width:640px) {
  #notes-list { display:none; }
  .np { max-width:8rem; }
}
