:root {
  --bg: #000; --panel: #0a0a0a; --line: #1c1c1c; --line2: #2a2a2a; --fg: #e8e8e8; --dim: #8a8a8a;
  --faint: #555; --accent: #fff; --neon: #00f0ff;
  font-family: ui-sans-serif, -apple-system, "Inter", "Segoe UI", Roboto, sans-serif; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
a { color: var(--fg); }
button, input, textarea, select { font: inherit; color: var(--fg); }
button { background: #111; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #555; background: #161616; }
button.primary { background: #fff; color: #000; border-color: #fff; font-weight: 600; }
button.primary:hover { background: #ddd; }
input, textarea, select { background: #0c0c0c; border: 1px solid var(--line2); border-radius: 8px; padding: 8px 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: #666; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: #222; border-radius: 4px; }

/* login */
body.login { display: grid; place-items: center; }
.login-box { display: flex; flex-direction: column; gap: 12px; width: 300px; text-align: center; }
.login-box h1 { font-weight: 500; font-size: 20px; letter-spacing: .5px; margin: 6px 0 10px; }
.err { color: #ff5a5a; font-size: 13px; }
.logo-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 16px var(--neon), 0 0 40px var(--neon); margin: 0 auto; }

/* layout */
#app { display: flex; height: 100vh; }
#sidebar { width: 210px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 2px; background: #000; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 600; letter-spacing: .4px; }
.brand .logo-dot { width: 9px; height: 9px; margin: 0; }
.nav { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; color: var(--dim); padding: 8px 10px; border-radius: 8px; }
.nav:hover { color: var(--fg); background: #0d0d0d; border-color: transparent; }
.nav.active { color: #fff; background: #141414; border-color: var(--line2); }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.nav kbd { margin-left: auto; font-size: 11px; color: var(--faint); border: 1px solid var(--line2); border-radius: 4px; padding: 0 4px; }
.nav.add { margin-top: 10px; color: #fff; border-color: var(--line2); }
.side-foot { margin-top: auto; font-size: 12px; color: var(--faint); padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.side-foot form button { background: none; border: none; padding: 0; color: var(--faint); font-size: 12px; }
.side-foot form button:hover { color: var(--fg); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #444; margin-right: 6px; }
.dot.on { background: #39ff14; box-shadow: 0 0 8px #39ff14; }
.dot.local { background: #fff01f; box-shadow: 0 0 8px #fff01f; }
main { flex: 1; position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; display: none; overflow: auto; }
.view.active { display: block; }
.page { max-width: 920px; margin: 0 auto; padding: 34px 28px 80px; }
.page h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
.page .sub { color: var(--dim); margin: 0 0 22px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--dim); font-weight: 500; margin: 28px 0 10px; }

/* graph */
#view-graphe { overflow: hidden; }
#graph { position: absolute; inset: 0; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.lbl { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; font-size: 11px; color: #bbb; text-shadow: 0 0 4px #000, 0 0 8px #000; letter-spacing: .3px; }
.lbl.big { font-size: 13px; color: #fff; font-weight: 600; }
.lbl b { color: #fff; }
.graph-tabs { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 4px; background: rgba(10,10,10,.85); border: 1px solid var(--line2); border-radius: 10px; padding: 4px; z-index: 3; }
.graph-tabs button { border: none; background: none; color: var(--dim); padding: 6px 12px; border-radius: 7px; }
.graph-tabs button.active { background: #fff; color: #000; }
.legend { position: absolute; top: 14px; right: 14px; z-index: 3; display: flex; flex-direction: column; gap: 2px; max-height: 60vh; overflow: auto; background: rgba(0,0,0,.6); padding: 6px; border-radius: 8px; }
.legend button { border: none; background: none; padding: 3px 6px; display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--dim); text-align: left; }
.legend button:hover, .legend button.on { color: #fff; }
.legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.stats { position: absolute; left: 14px; bottom: 14px; z-index: 3; background: rgba(8,8,8,.88); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; min-width: 190px; font-size: 12px; }
.stats .total { font-size: 22px; font-weight: 600; color: #fff; }
.stats .total small { font-size: 12px; color: var(--dim); font-weight: 400; margin-left: 4px; }
.yr { display: grid; grid-template-columns: 38px 1fr 34px; align-items: center; gap: 8px; margin-top: 5px; color: var(--dim); }
.yr .bar { height: 4px; background: #1a1a1a; border-radius: 2px; overflow: hidden; }
.yr .bar span { display: block; height: 100%; background: #fff; }
.yr .n { text-align: right; color: #ccc; }
.hint { position: absolute; bottom: 14px; right: 14px; color: var(--faint); font-size: 11px; z-index: 3; }
.float-tooltip-kap[hidden] { display: none; }
.float-tooltip-kap { position: absolute; z-index: 4; pointer-events: none; max-width: 320px; font-family: inherit !important; font-size: 12px !important; background: rgba(0,0,0,.85) !important; border: 1px solid #333 !important; padding: 6px 9px !important; border-radius: 7px !important; color: #fff !important; }
.scene-tooltip .d, .float-tooltip-kap .d { color: #999; font-size: 11px; }
.empty-graph[hidden] { display: none; }
.empty-graph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); z-index: 2; pointer-events: none; }

/* lists */
.list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: baseline; padding: 10px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:hover { background: #0b0b0b; }
.row i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.row .t { color: #fff; }
.row .s { color: var(--dim); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .m { color: var(--faint); font-size: 12px; white-space: nowrap; }
.chip { display: inline-block; font-size: 11px; color: #bbb; border: 1px solid var(--line2); border-radius: 20px; padding: 1px 8px; margin: 2px 4px 2px 0; cursor: pointer; background: #0b0b0b; }
.chip:hover { border-color: #666; color: #fff; }
.month-h { position: sticky; top: 0; background: #000; padding: 14px 0 8px; font-weight: 600; color: #fff; display: flex; gap: 10px; align-items: baseline; z-index: 1; }
.month-h span { color: var(--faint); font-weight: 400; font-size: 12px; }
.lists-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; }
.folder-list button { display: flex; width: 100%; justify-content: space-between; background: none; border: 1px solid transparent; color: var(--dim); padding: 6px 8px; }
.folder-list button.active, .folder-list button:hover { color: #fff; background: #111; border-color: var(--line2); }
.folder-list button.sub { padding-left: 22px; font-size: 13px; }
.muted { color: var(--faint); }

/* editor */
.editor-bar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.editor-bar input[name=title] { flex: 1; min-width: 200px; font-size: 16px; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; height: calc(100vh - 230px); min-height: 300px; }
.editor textarea { resize: none; height: 100%; font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; line-height: 1.55; }
.md { line-height: 1.6; overflow: auto; }
.editor .md { border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px; }
.md h1, .md h2, .md h3 { color: #fff; text-transform: none; letter-spacing: 0; font-size: 1.15em; margin: 1em 0 .4em; }
.md code { background: #151515; padding: 1px 4px; border-radius: 4px; }
.md pre { background: #0d0d0d; padding: 10px; border-radius: 8px; overflow: auto; }
.md blockquote { border-left: 2px solid #333; margin: 0; padding-left: 12px; color: var(--dim); }
.md a { color: var(--neon); }

/* files */
.drop { border: 1px dashed #333; border-radius: 12px; padding: 40px; text-align: center; color: var(--dim); cursor: pointer; }
.drop.over { border-color: var(--neon); color: #fff; background: #04090a; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--faint); font-weight: 500; }
.ok { color: #39ff14; } .ko { color: #ff5a5a; }
code.path { background: #111; padding: 2px 6px; border-radius: 5px; font-size: 12.5px; }

/* chat */
#view-ia .page { display: flex; flex-direction: column; height: 100%; padding-bottom: 20px; }
.chat { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 14px; padding: 10px 0; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; line-height: 1.55; }
.msg.user { align-self: flex-end; background: #161616; border: 1px solid var(--line2); }
.msg.ai { align-self: flex-start; border: 1px solid var(--line); }
.msg .srcs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.msg .mode { font-size: 11px; color: var(--faint); margin-top: 6px; }
.cite { color: var(--neon); cursor: pointer; font-size: .85em; vertical-align: super; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; padding: 12px 14px; }
.typing { color: var(--dim); font-style: italic; }

/* modal + drawer */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; z-index: 20; }
.overlay.open { display: block; }
.palette { position: absolute; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, 92vw); background: #0a0a0a; border: 1px solid #2c2c2c; border-radius: 14px; overflow: hidden; box-shadow: 0 20px 80px rgba(0,0,0,.8); }
.palette input { width: 100%; border: none; border-bottom: 1px solid var(--line2); border-radius: 0; padding: 16px 18px; font-size: 16px; background: transparent; }
.palette .results { max-height: 55vh; overflow: auto; }
.palette .row { grid-template-columns: 12px 1fr auto; padding: 10px 16px; border: none; }
.palette .row.sel { background: #151515; }
.palette .foot { padding: 8px 16px; font-size: 11px; color: var(--faint); border-top: 1px solid var(--line); }
mark { background: none; color: var(--neon); }
#drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100vw); background: #070707; border-left: 1px solid var(--line2); z-index: 15; transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column; }
#drawer.open { transform: none; }
#drawer .head { padding: 18px 20px 10px; border-bottom: 1px solid var(--line); }
#drawer .head h3 { margin: 0 0 6px; font-size: 17px; color: #fff; }
#drawer .meta { color: var(--dim); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
#drawer .body { padding: 14px 20px 30px; overflow: auto; flex: 1; }
#drawer .summary { color: #ccc; border-left: 2px solid var(--neon); padding-left: 10px; margin-bottom: 14px; font-size: 13.5px; }
#drawer .actions { display: flex; gap: 6px; margin-top: 10px; }
#drawer .close { position: absolute; top: 12px; right: 14px; background: none; border: none; font-size: 18px; color: var(--dim); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #fff; color: #000; padding: 8px 16px; border-radius: 8px; z-index: 50; font-size: 13px; }

@media (max-width: 760px) {
  #sidebar { width: 56px; padding: 10px 4px; }
  .nav span.txt, .nav kbd, .brand span, .side-foot { display: none; }
  .editor { grid-template-columns: 1fr; }
  .lists-grid { grid-template-columns: 1fr; }
  .graph-tabs { top: auto; bottom: 14px; left: auto; right: 10px; transform: none; flex-wrap: wrap; }
  .stats { display: none; }
}
