:root{--bg:#0b0b0f;--bg2:#111117;--surface:#16161e;--surface2:#1e1e28;--line:#2a2a36;--text:#f1f0ec;--muted:#9a99a6;--accent:#c6ff4d;--accent-ink:#121400;--danger:#ff5d5d;--ok:#5ee08a;--warn:#ffc04d;--r:12px;color-scheme:dark}
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;background:var(--bg);color:var(--text);font-size:14px;line-height:1.45;-webkit-font-smoothing:antialiased}
a{color:inherit}
button{font:inherit;color:inherit}
code{font-family:ui-monospace,Consolas,monospace;font-size:.92em;background:var(--surface2);padding:1px 5px;border-radius:5px}
[hidden]{display:none!important}
.muted{color:var(--muted)}
h1{font-size:22px;margin:0 0 4px;letter-spacing:-.01em}
h2{font-size:17px;margin:0 0 4px}

input,textarea,select{font:inherit;color:var(--text);background:var(--bg2);border:1px solid var(--line);border-radius:10px;padding:9px 11px;width:100%;outline:none}
input:focus,textarea:focus,select:focus{border-color:var(--accent);box-shadow:0 0 0 3px #c6ff4d22}
label{display:grid;gap:6px;font-weight:550;font-size:13px}

.btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;border:1px solid var(--line);background:var(--surface2);border-radius:10px;padding:8px 13px;font-weight:600;cursor:pointer;text-decoration:none;white-space:nowrap;font-size:13.5px}
.btn:hover{border-color:#3a3a4a;background:#24242f}
.btn:disabled{opacity:.55;cursor:default}
.btn.primary{background:var(--accent);color:var(--accent-ink);border-color:transparent}
.btn.primary:hover{background:#d4ff70}
.btn.danger{color:var(--danger)}
.btn.ghost{background:transparent;border-color:transparent}
.btn.ghost:hover{background:var(--surface2)}
.btn.small{padding:5px 9px;font-size:12.5px;border-radius:8px}
.btn.wide{width:100%}
.btn .ic{width:16px;height:16px;flex:none}

/* auth */
body.auth{min-height:100vh;display:grid;place-items:center;padding:24px 16px;background:radial-gradient(900px 500px at 50% -10%,#1d2410,transparent),var(--bg)}
.auth-box{width:100%;max-width:400px;display:grid;gap:18px}
.brand{display:flex;align-items:center;gap:9px;font-size:17px;font-weight:650;text-decoration:none;justify-self:center}
.brand b{color:var(--accent);font-weight:650}
.card{background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:24px;display:grid;gap:14px}
.msg{color:var(--danger);min-height:1em;margin:0;font-size:13px}
.msg:empty{display:none}

/* app shell */
body.app{min-height:100vh;display:flex;flex-direction:column}
.top{position:sticky;top:0;z-index:20;display:flex;align-items:center;gap:16px;padding:10px 20px;background:#0b0b0fe6;backdrop-filter:blur(10px);border-bottom:1px solid var(--line)}
.top .brand{justify-self:auto;font-size:15px}
.search{flex:1;max-width:520px;margin:0 auto}
.search input{padding:8px 12px;border-radius:999px;background:var(--surface)}
.nav{display:flex;align-items:center;gap:4px;position:relative}
.navlink{padding:7px 11px;border-radius:9px;text-decoration:none;color:var(--muted);font-weight:600}
.navlink:hover{color:var(--text);background:var(--surface2)}
.navlink.on{color:var(--text);background:var(--surface2)}
.menu{position:absolute;right:0;top:calc(100% + 6px);background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:6px;display:grid;min-width:190px;box-shadow:0 12px 40px #0008;z-index:30}
.menu button,.menu a{background:none;border:0;text-align:left;padding:8px 10px;border-radius:8px;cursor:pointer;text-decoration:none;display:flex;gap:9px;align-items:center}
.menu button:hover,.menu a:hover{background:var(--surface2)}
.menu .danger{color:var(--danger)}
.menu hr{border:0;border-top:1px solid var(--line);margin:4px 0}

.view{flex:1;width:100%;max-width:1180px;margin:0 auto;padding:22px 20px 80px}
.bar{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.bar .grow{flex:1}
.crumbs{display:flex;align-items:center;flex-wrap:wrap;gap:2px;font-size:18px;font-weight:650;min-width:0}
.crumbs a{text-decoration:none;padding:3px 7px;border-radius:8px;color:var(--muted)}
.crumbs a:hover{background:var(--surface2);color:var(--text)}
.crumbs a:last-child{color:var(--text)}
.crumbs .sep{color:#555}
.usage{font-size:12.5px;color:var(--muted);display:flex;align-items:center;gap:8px}
.meter{width:110px;height:6px;border-radius:9px;background:var(--surface2);overflow:hidden}
.meter i{display:block;height:100%;background:var(--accent);border-radius:9px}

.selbar{display:flex;align-items:center;gap:8px;background:var(--surface);border:1px solid var(--accent);border-radius:12px;padding:8px 10px;margin-bottom:12px}
.selbar .count{font-weight:650;margin-right:auto;padding-left:4px}

/* file list */
.list{background:var(--surface);border:1px solid var(--line);border-radius:14px;overflow:hidden;position:relative}
.row{display:grid;grid-template-columns:34px minmax(0,1fr) 100px 170px 40px;align-items:center;gap:8px;padding:0 10px;min-height:46px;border-top:1px solid var(--line)}
.row:first-child{border-top:0}
.row.head{min-height:36px;font-size:12px;color:var(--muted);font-weight:600;background:var(--bg2)}
.row:not(.head):hover{background:#1b1b24}
.row.sel{background:#1f2614}
.row.drop{outline:2px solid var(--accent);outline-offset:-2px;background:#1f2614}
.row input[type=checkbox]{width:16px;height:16px;accent-color:var(--accent);cursor:pointer}
.name{display:flex;align-items:center;gap:10px;min-width:0;text-decoration:none;cursor:pointer;padding:10px 0}
.name span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.name:hover span{text-decoration:underline}
.fi{width:30px;height:30px;border-radius:8px;display:grid;place-items:center;font-size:10px;font-weight:800;letter-spacing:.02em;flex:none;background:var(--surface2);color:var(--muted);text-transform:uppercase}
.fi.dir{background:#2c3317;color:var(--accent)}
.fi.dir svg{width:18px;height:18px}
.fi.img{background:#18283a;color:#78b6ff}
.fi.vid{background:#2d1a35;color:#d58cff}
.fi.aud{background:#33231a;color:#ffad6b}
.fi.txt{background:#1d2a25;color:#6be0ad}
.fi.exe{background:#3a1c1c;color:#ff8a8a}
.fi.zip{background:#33301a;color:#ffd666}
.fi.pdf{background:#3a1a22;color:#ff7591}
.size,.mod{color:var(--muted);font-size:12.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.more{width:32px;height:32px;border-radius:8px;border:0;background:none;cursor:pointer;color:var(--muted);font-size:18px;line-height:1}
.more:hover{background:var(--surface2);color:var(--text)}
.empty{padding:50px 20px;text-align:center;color:var(--muted)}
.empty b{display:block;color:var(--text);font-size:15px;margin-bottom:4px}
.where{display:block;font-size:11.5px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.dropzone{position:fixed;inset:0;z-index:50;background:#0b0b0fcc;display:grid;place-items:center;pointer-events:none}
.dropzone div{border:2px dashed var(--accent);border-radius:20px;padding:40px 60px;font-size:18px;font-weight:650;background:var(--surface)}

/* popup menu */
.pop{position:fixed;z-index:60;background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:6px;display:grid;min-width:180px;box-shadow:0 12px 40px #000a}
.pop button{background:none;border:0;text-align:left;padding:8px 10px;border-radius:8px;cursor:pointer}
.pop button:hover{background:var(--surface2)}
.pop .danger{color:var(--danger)}
.pop hr{border:0;border-top:1px solid var(--line);margin:4px 0}

/* modal */
.modal-bg{position:fixed;inset:0;z-index:70;background:#000a;display:grid;place-items:center;padding:16px}
.modal{width:100%;max-width:440px;background:var(--surface);border:1px solid var(--line);border-radius:16px;padding:22px;display:grid;gap:14px;box-shadow:0 20px 60px #000c;max-height:calc(100vh - 32px);overflow:auto}
.modal p{margin:0;color:var(--muted)}
.modal .actions{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.modal .check{display:flex;align-items:center;gap:8px;font-weight:500;color:var(--muted)}
.modal .check input{width:auto}
.picker{border:1px solid var(--line);border-radius:10px;max-height:300px;overflow:auto;background:var(--bg2)}
.picker .crumbs{font-size:13px;padding:6px;border-bottom:1px solid var(--line);position:sticky;top:0;background:var(--bg2)}
.picker button.f{display:flex;width:100%;align-items:center;gap:9px;background:none;border:0;padding:8px 10px;cursor:pointer;text-align:left}
.picker button.f:hover{background:var(--surface2)}
.picker .none{padding:14px;color:var(--muted);font-size:13px}

/* viewer & editor */
.viewer{display:grid;gap:14px}
.viewer .stage{background:var(--surface);border:1px solid var(--line);border-radius:14px;display:grid;place-items:center;min-height:300px;overflow:hidden}
.viewer .stage img{max-width:100%;max-height:75vh;display:block}
.viewer .stage video{max-width:100%;max-height:75vh;display:block}
.viewer .stage audio{width:min(520px,90%)}
.viewer .stage iframe{width:100%;height:78vh;border:0;background:#fff}
.info{padding:40px 20px;text-align:center;display:grid;gap:10px;justify-items:center}
.info .fi{width:64px;height:64px;font-size:15px;border-radius:16px}
.info dl{display:grid;grid-template-columns:auto auto;gap:4px 16px;margin:6px 0 0;color:var(--muted);font-size:13px;text-align:left}
.info dd{margin:0;color:var(--text)}
.note{font-size:12.5px;color:var(--muted);max-width:520px}

.editor{display:flex;flex-direction:column;gap:10px;height:calc(100vh - 140px);min-height:400px}
.editor .wrap{flex:1;display:flex;background:var(--bg2);border:1px solid var(--line);border-radius:12px;overflow:hidden;min-height:0}
.editor .gutter{padding:12px 8px 12px 12px;text-align:right;color:#565666;font:13px/1.55 ui-monospace,Consolas,"Cascadia Code",monospace;user-select:none;overflow:hidden;white-space:pre;min-width:44px;border-right:1px solid var(--line)}
.editor textarea{flex:1;border:0;border-radius:0;background:transparent;resize:none;padding:12px;font:13px/1.55 ui-monospace,Consolas,"Cascadia Code",monospace;tab-size:4;white-space:pre;overflow:auto;box-shadow:none}
.editor textarea.wrapon{white-space:pre-wrap}
.editor textarea:focus{box-shadow:none}
.status{display:flex;gap:14px;font-size:12px;color:var(--muted)}
.status .dirty{color:var(--warn)}
.status .saved{color:var(--ok)}

/* uploads panel */
.uploads{position:fixed;right:16px;bottom:16px;z-index:40;width:min(360px,calc(100vw - 32px));background:var(--surface);border:1px solid var(--line);border-radius:14px;box-shadow:0 12px 40px #000a;overflow:hidden}
.uploads .uh{display:flex;align-items:center;justify-content:space-between;padding:10px 12px;font-weight:650;border-bottom:1px solid var(--line)}
.uploads .ul{max-height:260px;overflow:auto}
.up{padding:8px 12px;display:grid;gap:5px;border-top:1px solid var(--line)}
.up:first-child{border-top:0}
.up .t{display:flex;justify-content:space-between;gap:8px;font-size:12.5px}
.up .t span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.up .t span:last-child{color:var(--muted);flex:none}
.up .pb{height:4px;border-radius:4px;background:var(--surface2);overflow:hidden}
.up .pb i{display:block;height:100%;width:0;background:var(--accent);transition:width .2s}
.up.err .t span:last-child{color:var(--danger)}
.up.done .pb i{background:var(--ok)}

.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);z-index:80;background:var(--text);color:#111;padding:10px 16px;border-radius:10px;font-weight:600;box-shadow:0 10px 30px #0008;max-width:calc(100vw - 32px)}
.toast.bad{background:var(--danger);color:#fff}

/* tables for owner pages */
.panel{background:var(--surface);border:1px solid var(--line);border-radius:14px;padding:18px;display:grid;gap:14px;margin-bottom:16px}
.grid3{display:grid;grid-template-columns:1fr 1fr 150px auto;gap:10px;align-items:end}
.tbl{width:100%;border-collapse:collapse;font-size:13px}
.tbl th{text-align:left;font-size:12px;color:var(--muted);font-weight:600;padding:8px;border-bottom:1px solid var(--line)}
.tbl td{padding:9px 8px;border-bottom:1px solid var(--line);vertical-align:middle}
.tbl tr:last-child td{border-bottom:0}
.tbl .acts{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}
.pill{display:inline-block;font-size:11px;font-weight:700;padding:2px 8px;border-radius:99px;background:var(--surface2);color:var(--muted)}
.pill.owner{background:#2c3317;color:var(--accent)}
.pill.off{background:#3a1c1c;color:#ff8a8a}
.log td:first-child{white-space:nowrap;color:var(--muted)}
.log td:nth-child(3){font-weight:600}
.scroll{overflow-x:auto}

@media (max-width:760px){
  .top{flex-wrap:wrap;padding:10px 16px;gap:10px}
  .search{order:3;flex-basis:100%;max-width:none}
  .nav{margin-left:auto}
  .navlink{padding:6px 8px}
  .view{padding:16px 16px 80px}
  .row{grid-template-columns:30px minmax(0,1fr) 36px}
  .row .size,.row .mod{display:none}
  .grid3{grid-template-columns:1fr}
  .editor{height:calc(100vh - 170px)}
  .editor .gutter{display:none}
}
