/* Berlin Roleplay — Resource Manager | restrained shared visual language */
:root{
  --bg:#090a0c;--surface:#101216;--surface2:#15181d;
  --line:rgba(255,255,255,.09);--line2:rgba(255,255,255,.065);
  --text:#f4f5f6;--muted:#a5a9b0;--dim:#777d86;
  --danger:#ea6570;--ok:#7fc49b;--sidebar:254px;--radius:12px;
}
html,body{background:#090a0c;color:#f3f4f6;-webkit-font-smoothing:antialiased}
body{background:repeating-linear-gradient(135deg,transparent 0 31px,rgba(255,255,255,.011) 31px 32px),#090a0c}
body:before{background:none}body:after{display:none}
button,input,select,textarea{font-family:Inter,system-ui,sans-serif}
button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:2px solid #babfc6;outline-offset:2px}
.hidden{display:none!important}
.glass,.glass-lite{backdrop-filter:none;-webkit-backdrop-filter:none;background:#111317;border:1px solid rgba(255,255,255,.09);box-shadow:none}
.mono{font-family:'JetBrains Mono',monospace}
/* Authentication */
.login-shell{padding:36px;min-height:100vh}
.login-card{width:min(630px,100%);border-radius:18px;padding:48px;background:linear-gradient(135deg,transparent 34%,rgba(255,255,255,.009) 34.1%,transparent 34.4%),#111318;border:1px solid #303238;box-shadow:0 28px 90px rgba(0,0,0,.32)}
.login-card:after{display:none}
.brand-mark{width:auto;height:auto;border:none;border-radius:0;background:none;display:block;margin-bottom:44px}
.brand-mark img{width:180px;height:auto;max-height:90px;object-fit:contain;object-position:left center}
.login-copy h1{font-size:clamp(44px,6vw,66px);line-height:1.02;letter-spacing:-.055em;font-weight:800}
.login-copy h1 span{color:#9a9fa7;-webkit-text-stroke:0}
.login-copy p:not(.eyebrow){font-size:15px;line-height:1.7;color:#a4a9b2;max-width:480px;margin:24px 0 30px}
.eyebrow{color:#9da2aa;font-size:10px;letter-spacing:.14em}
.discord-login{background:#e9ebed;color:#101114;border-radius:9px;min-height:52px;font-size:14px;box-shadow:none}
.discord-login:hover{background:#fff;box-shadow:none;transform:translateY(-1px)}
.discord-glyph{font-size:18px}.login-foot{font-size:12px;color:#868b94;letter-spacing:0;text-align:left;margin-top:20px}
/* Sidebar and global header */
.app-shell{min-height:100vh}
.sidebar{background:#0d0f12;border-right:1px solid #282b31;padding:25px 15px;backdrop-filter:none}
.side-brand{display:flex;align-items:center;gap:13px;padding:5px 8px 26px;border-bottom:1px solid var(--line2);margin-bottom:24px}
.side-brand img{width:82px;height:40px;object-fit:contain;object-position:left center;flex-shrink:0}
.side-brand strong{font-size:13px;line-height:1.3;font-weight:700}
.side-brand span{font-family:Inter,sans-serif;font-size:11px;letter-spacing:0;color:#878d95;margin-top:3px}
.side-nav{gap:6px}.nav-item{font-size:13px;padding:13px 13px;border-radius:9px;font-weight:600;color:#969ba4;border:1px solid transparent}
.nav-item.active{background:#22262b;border-color:#34383e;color:#f3f4f6}
.nav-item:hover{background:#1c2024;border-color:rgba(255,255,255,.09);color:#fff}
.nav-item svg{width:17px;height:17px}
.scope-box{border-radius:10px;padding:13px;background:#13161a}
.scope-box span{font-size:10px;letter-spacing:.11em;color:#9298a1}
.scope-box strong{font-size:12px;margin:8px 0 5px}
.scope-box small{font-size:11px;color:#858b93}
.user-chip{grid-template-columns:38px 1fr 34px;padding:13px 3px;border-top-color:#292d32;gap:10px}
.avatar{width:38px;height:38px;background:#30353b;color:#f7f7f8;border-radius:9px}
.user-meta strong{font-size:12px}.user-meta span{font-size:10px;letter-spacing:.05em;color:#858b94}
.main-area{padding:0 32px 35px;margin-left:var(--sidebar)}
.topbar{height:85px;background:rgba(9,10,12,.97);backdrop-filter:none;border-bottom:1px solid #272b30}
.top-title span{font-size:10px;color:#8d949b;letter-spacing:.15em;margin-bottom:5px}
.top-title strong{font-size:23px;letter-spacing:-.035em;font-weight:760}
.top-actions{display:flex;align-items:center;gap:8px}
.zoom-controls{display:flex;align-items:center;gap:2px;border:1px solid #31353a;border-radius:9px;background:#181b20;padding:3px}
.zoom-controls button{min-width:41px;height:33px;border:0;background:transparent;border-radius:6px;color:#e0e3e6;font-size:12px;font-weight:800;cursor:pointer}
.zoom-controls button:hover{background:#30343a}
.zoom-controls span{font-size:12px;color:#b9bfc6;min-width:50px;text-align:center;white-space:nowrap}
.icon-button{border-radius:9px;background:#191b20;border-color:#30343a;color:#a9b1ba}
.icon-button:hover{background:#2a2e33;color:#fff;border-color:#454950}
.icon-button svg{width:17px;height:17px}
.view{padding-top:25px}
/* Utility tools */
.primary-button,.soft-button{padding:11px 14px;border-radius:8px;font-size:12px;font-weight:680;min-height:40px;transition:background .14s,color .14s,border-color .14s}
.primary-button{background:#e7e9eb;color:#14161a;border-color:#e7e9eb}
.primary-button:hover{background:#fff;border-color:#fff}
.soft-button{background:#202329;color:#e0e3e7;border-color:#363a40}
.soft-button:hover{background:#31353b;border-color:#535861}
.danger-button{background:rgba(185,56,69,.13)!important;color:#ffa1a9!important;border-color:rgba(235,90,104,.34)!important}
.danger-button:hover{background:rgba(185,56,69,.23)!important}
.explorer-toolbar{padding:15px 16px;border-radius:12px;gap:20px;margin-bottom:12px;background:#131519}
.crumb{font-size:12px;color:#9ea5ad;padding:8px 9px;border-radius:7px}
.crumb:last-child{color:#f3f3f4}.crumb-sep{color:#4b5058}
.toolbar-actions{flex-wrap:wrap}.toolbar-actions .soft-button,.toolbar-actions .primary-button{white-space:nowrap}
.explorer-searchbar{display:flex;align-items:center;gap:10px;padding:0 0 14px;flex-wrap:wrap}
.global-search{flex:1;min-width:260px;height:46px;display:flex;align-items:center;gap:11px;padding:0 14px;background:#16191d;border:1px solid #343840;border-radius:10px;transition:border-color .15s}
.global-search:focus-within{border-color:#939ca5}
.global-search>svg{width:18px;height:18px;color:#9ba4ae}
.global-search input{flex:1;min-width:0;background:transparent;border:0;outline:none;color:#f0f0f1;font-size:13px}
.global-search input::placeholder{color:#7d848d}
.global-search kbd{font:600 10px 'JetBrains Mono',monospace;color:#999fa8;background:#23272d;padding:5px 7px;border:1px solid #363a41;border-radius:5px}
.explorer-searchbar select,.sort-controls select{height:46px;padding:0 37px 0 13px;background:#1c1f24;color:#e0e3e5;border:1px solid #383c43;border-radius:9px;outline:none;font-size:12px;cursor:pointer}
.sort-controls{display:flex;align-items:center;gap:8px;margin-left:auto}
.sort-controls label{color:#999fa7;font-size:12px}.sort-controls select{height:40px}
#clearSearch{white-space:nowrap}
/* Resource list and file table */
.explorer-layout{grid-template-columns:250px minmax(0,1fr);gap:13px;align-items:start}
.resource-rail,.file-panel{border-radius:12px;min-height:min(72vh,850px);overflow:hidden;background:#111418}
.resource-rail{position:sticky;top:110px;padding:15px}
.rail-head{font-size:11px;letter-spacing:.13em;color:#b0b5bd;padding:3px 4px 15px}
.resource-list{max-height:calc(100vh - 233px);overflow:auto;align-content:start;gap:3px}
.resource-item{padding:11px 9px;grid-template-columns:31px minmax(0,1fr);gap:9px;border-radius:8px}
.resource-item span{font:550 12px Inter,sans-serif;color:#adb4bd}
.resource-item:hover,.resource-item.active{background:#24282e}
.resource-item.active span{color:#fff}
.resource-item .r-icon{width:30px;height:30px;border-radius:7px;background:#21252b;border:1px solid #30353c}
.resource-item .r-icon svg{width:15px;height:15px}
.file-panel{min-width:0;position:relative}
.file-head{padding:18px 22px;border-bottom:1px solid #30343b;gap:14px;align-items:flex-start}
.file-head strong{font-size:21px;letter-spacing:-.025em;color:#f2f3f4}
.file-head span{font-size:12px;color:#8c939b;margin:0;display:block;margin-top:5px}
.file-head-tools{display:flex;align-items:center;justify-content:flex-end;gap:12px;flex-wrap:wrap}
.permission-disclosure{position:relative;z-index:5}
.permission-disclosure summary{list-style:none;display:flex;align-items:center;gap:7px;min-height:40px;padding:10px 12px;border:1px solid #373c43;background:#1d2025;border-radius:8px;color:#c2c8d0;font-size:11px;font-weight:600;cursor:pointer;white-space:nowrap}
.permission-disclosure summary::-webkit-details-marker{display:none}
.permission-disclosure summary svg{width:14px;height:14px}
.permission-disclosure[open] .permission-summary{display:flex;position:absolute;right:0;top:45px;background:#202329;border:1px solid #3b4148;box-shadow:0 15px 40px rgba(0,0,0,.28);padding:13px;border-radius:8px;width:260px;z-index:6;justify-content:flex-start;gap:6px}
.permission-disclosure .perm-dot{font-size:10px;padding:6px 8px;border-radius:5px}
.permission-disclosure .perm-dot.on{color:#e8eaed;background:#353a41}

.table-wrap{width:100%;overflow:auto;max-height:calc(100vh - 342px);min-height:330px;scrollbar-color:#343941 transparent;scrollbar-width:thin}
.file-table{table-layout:fixed;min-width:490px}
.file-table th{background:#15181c;position:sticky;top:0;z-index:2;font:600 10px Inter,sans-serif;color:#9ca3ac;letter-spacing:.12em;padding:15px 18px;border-bottom:1px solid #30343b}
.file-table th:nth-child(2){width:106px}.file-table th:nth-child(3){width:150px}.file-table th.actions-col{width:123px}
.file-row{border-bottom:1px solid rgba(255,255,255,.063)}
.file-row:hover{background:#1a1e23}
.file-row td{padding:10px 18px;font-size:12px;color:#a7afb9}
.file-name-cell{gap:13px}
.file-icon{width:39px;height:39px;border-radius:8px;background:#22262c;border-color:#30353b;color:#b8bfc8}
.file-icon.resource{background:#25272d;border-color:#45464d;color:#f1f1f3}
.file-icon svg{width:18px;height:18px}
.file-label strong{font:650 13px Inter,sans-serif;color:#e9ebef;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.file-label small{font-size:11px;color:#818993;margin-top:3px;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.search-row .file-label small{color:#9299a3;font-family:'JetBrains Mono',monospace;font-size:10px}
.row-actions{opacity:1;gap:4px}
.row-action{width:31px;height:31px;border-radius:7px;color:#a0a8b3;border-color:transparent}
.row-action:hover{color:#fff;background:#30353b}
.empty-state{min-height:260px}.empty-state strong{font-size:15px}.empty-state span{font-size:12px}
.file-panel .drop-overlay{background:rgba(17,19,24,.96)}
.loading-state{color:#a2a9b1;font-size:13px}
/* Access / roles */
.section-heading h2{font-size:28px;letter-spacing:-.045em}
.section-heading p{font-size:13px;color:#979da6;line-height:1.6}
.access-layout{grid-template-columns:320px minmax(0,1fr);gap:14px;align-items:start}
.users-panel,.rules-panel,.audit-panel{border-radius:12px;background:#14161a}
.panel-title{padding:19px 20px}.panel-title strong{font-size:17px}
.user-search{display:flex;align-items:center;gap:9px;margin:0 14px 12px;border:1px solid #333840;border-radius:8px;background:#1c2025;padding:0 11px;height:42px}
.user-search svg{width:16px;color:#858d96}.user-search input{border:0;background:none;color:#f1f2f4;outline:none;width:100%;font-size:12px}
.user-list{max-height:68vh;overflow:auto}.user-entry{padding:13px 14px;min-height:64px;border-radius:8px}
.user-entry strong{font-size:13px}.user-entry span span{font-size:10px}
.rules-head{gap:15px}.rules-head strong{font-size:20px}.rules-head .soft-button{font-size:11px}
.rule-card{border-radius:9px;border-color:#353941;background:#1b1e23;padding:15px 16px}
.rule-top{display:flex;justify-content:space-between;align-items:center;gap:12px}
.rule-actions{display:flex;gap:6px;flex-wrap:wrap}.rule-actions .soft-button{padding:7px 10px;min-height:32px;font-size:11px}
.rule-path{font-size:13px;overflow-wrap:anywhere}.rule-perms span{font-size:10px;padding:5px 8px}
.scope-summary{border-color:#373a41;background:#1d2126}
.scope-summary>span{color:#a2aab4;font-size:10px}.scope-summary>strong{font-size:14px}.scope-summary>small{font-size:12px;color:#9ba2ab}
.permission-check{font:550 12px Inter,sans-serif;gap:10px;padding:12px;background:#1c2025;border:1px solid #373c44;border-radius:8px;color:#d3d8de}
.permission-check:hover{background:#242a31}.permission-check input,.folder-select input{accent-color:#b5bfc8;width:16px;height:16px}
.folder-picker{background:#171b20;border-color:#373b43}.folder-picker-state{background:#21252b}.folder-picker-state span,.folder-picker-toolbar>span{font-size:11px}
.folder-picker-state strong{font-size:13px}.folder-select>span{font:600 12px Inter,sans-serif}.folder-select>small{font-size:10px}
.folder-picker-tree{max-height:320px}.folder-picker-row{min-height:43px}
.audit-row{font-size:12px}
/* Modals, editors */
.modal-shell{background:rgba(0,0,0,.72);backdrop-filter:blur(3px)}
.editor-window{background:#101216;border:1px solid #383c43;border-radius:13px;box-shadow:0 28px 80px rgba(0,0,0,.5)}
.editor-header{background:#17191e;border-color:#30343b;padding:17px 21px}
.editor-file strong{font-size:15px}.editor-file span{font-size:11px}
.editor-actions{gap:8px}.save-state{font-size:11px;letter-spacing:.07em}
.editor-footer{background:#16191d;font-size:11px;color:#9299a3}
.CodeMirror{background:#101216!important;color:#e6e8ea;font-size:13px;line-height:1.65}
.CodeMirror-gutters{background:#12151a;border-color:#33363d}
.hex-editor{height:100%;display:flex;flex-direction:column;gap:0;background:#101216}
.hex-tip{display:flex;align-items:center;gap:12px;padding:16px 22px;border-bottom:1px solid #30353b}
.hex-tip svg{width:22px;color:#c1c8d0}.hex-tip strong{display:block;font-size:13px}.hex-tip span{display:block;font-size:12px;line-height:1.5;color:#a6aeb8;margin-top:4px}
#hexArea{width:100%;min-height:240px;height:100%;flex:1;resize:none;background:#101216;color:#e7e9ec;border:0;outline:0;padding:20px 26px;font:13px/1.8 'JetBrains Mono',monospace;letter-spacing:.025em;white-space:pre;tab-size:2;overflow:auto}
.preview-window,.dialog-card{border-radius:12px;background:#15181c;border:1px solid #3a3e46;box-shadow:0 30px 90px rgba(0,0,0,.6)}
.dialog-head{padding:20px 22px}.dialog-head span{font-size:10px;color:#adb2b9}.dialog-head h3{font-size:21px;letter-spacing:-.03em}
.dialog-content{padding:22px}.dialog-actions{padding:15px 22px}
.dialog-card-wide{width:min(880px,calc(100vw - 36px))}
.field label{font:700 11px Inter,sans-serif;letter-spacing:.05em;color:#b4bbc3}
.field input,.field select{background:#20242a;border:1px solid #41464d;border-radius:8px;font-size:13px;padding:12px 13px}
.field input:focus,.field select:focus{border-color:#979da7}
.confirm-path{font:500 11px/1.6 'JetBrains Mono',monospace;background:#1e2227;border:1px solid #363b43;border-radius:8px;padding:11px 13px;color:#cdd3db;overflow-wrap:anywhere}
.danger-note{background:rgba(165,66,74,.11);border-color:rgba(240,111,122,.3);font-size:12px;color:#edc0c4;padding:14px;line-height:1.6}
.destination-browser{max-height:325px;overflow:auto;border:1px solid #373b42;border-radius:9px;background:#181b20;padding:7px;margin-bottom:8px}
.destination-entry{width:100%;display:flex;align-items:center;gap:12px;background:transparent;border:0;border-radius:7px;padding:11px 12px;color:#d4dae1;cursor:pointer;text-align:left;font-size:13px}
.destination-entry span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis}.destination-entry svg{width:17px;flex:0 0 17px;color:#9ba4ae}
.destination-entry:hover{background:#2a2e35;color:#fff}
.pdf-frame{width:100%;height:min(72vh,780px);background:#fff;border:0;border-radius:7px}
.binary-card span{font-size:12px}.binary-card strong{font-size:15px}
.toast{background:#e4e8ec;border-radius:8px;font-size:12px}
/* Tablet / narrow desktops */
@media(max-width:1250px){.explorer-layout{grid-template-columns:200px minmax(0,1fr)}.main-area{padding-inline:20px}.toolbar-actions{gap:5px}.file-head-tools{gap:5px}.access-layout{grid-template-columns:275px minmax(0,1fr)}}
@media(max-width:900px){.explorer-searchbar{gap:9px}.sort-controls{margin-left:0}.file-head{align-items:start;flex-direction:column}.file-table th:nth-child(3),.file-table td:nth-child(3){display:none}}
@media(max-width:780px){
 :root{--sidebar:260px}.main-area{margin-left:0;padding:0 14px 25px}.topbar{height:74px}.top-title strong{font-size:18px}.top-title span{font-size:9px}
 .sidebar{z-index:60}.explorer-toolbar{flex-direction:column;align-items:stretch}.toolbar-actions{flex-wrap:nowrap;overflow:auto;width:100%}
 .toolbar-actions .soft-button span,.toolbar-actions .primary-button span{display:inline}.explorer-layout{display:block}
 .resource-rail{display:none}.file-panel{min-height:calc(100vh - 300px)}.table-wrap{min-height:220px;max-height:65vh}
 .file-table th:nth-child(2),.file-table td:nth-child(2){display:none}.file-table{min-width:0}.file-table th.actions-col{width:93px}
 .file-label strong{font-size:12px}.file-head strong{font-size:17px}.zoom-controls span{min-width:35px}.zoom-controls button{min-width:31px}
 .global-search{min-width:200px}.global-search kbd{display:none}.sort-controls{margin-left:0}
 .access-layout{display:block}.users-panel{margin-bottom:14px}.permission-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 .editor-window{width:100vw;height:100vh;border:0;border-radius:0}.editor-actions .soft-button{display:inline-flex}.editor-actions .soft-button span{display:none}
 .dialog-card{max-height:98vh;overflow:auto}.dialog-card-wide{width:100vw;height:100vh;max-height:100vh;border-radius:0;display:flex;flex-direction:column}
 .dialog-card-wide .dialog-content{overflow:auto;flex:1}.preview-window{border-radius:0}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition:none!important;animation:none!important}}

/* Brand accents are intentionally functional rather than decorative */
.nav-item.active{position:relative}
.nav-item.active:before{content:"";position:absolute;left:0;top:20%;bottom:20%;width:2px;background:#b8464e;border-radius:5px}
.side-brand{position:relative}
.side-brand:after{content:"";position:absolute;bottom:13px;left:8px;width:34px;height:3px;background:linear-gradient(90deg,#ae3845 0 34%,#e8e8e8 34% 66%,#ae3845 66%)}

/* V3: stable application frame. One scrolling file list, no document-wide scrolling. */
:root { --brm-font-scale: 1; --sidebar-expanded: 254px; }
html { height:100%; }
body.app-authenticated { height:100dvh; overflow:hidden; }
body.modal-open { overflow:hidden; }
.app-authenticated .app-shell { height:100dvh; min-height:0; }
.app-authenticated .main-area { height:100dvh; min-height:0; overflow:hidden; display:flex; flex-direction:column; transition:margin-left .2s ease; }
.app-authenticated .topbar { flex:0 0 85px; height:85px; min-height:85px; top:auto; }
.app-authenticated .view.active { display:flex; flex-direction:column; flex:1 1 0; min-height:0; padding-top:20px; overflow:hidden; }
.app-authenticated #view-access.active,
.app-authenticated #view-activity.active { overflow-y:auto; overscroll-behavior:contain; padding-bottom:25px; }
.app-authenticated .explorer-toolbar,
.app-authenticated .explorer-searchbar { flex:0 0 auto; }
.app-authenticated .explorer-layout { flex:1 1 auto; min-height:0; align-items:stretch; position:relative; }
.app-authenticated .resource-rail,
.app-authenticated .file-panel { height:100%; min-height:0; max-height:100%; }
.app-authenticated .resource-rail { position:relative; top:auto; display:flex; flex-direction:column; padding:14px 10px 10px; }
.app-authenticated .rail-head { flex:0 0 auto; padding:4px 8px 13px; }
.app-authenticated .rail-head-actions { display:flex; align-items:center; gap:4px; }
.app-authenticated .resource-list { flex:1 1 auto; min-height:0; max-height:none; overflow-y:auto; padding-right:3px; }
.app-authenticated .file-panel { display:flex; flex-direction:column; min-width:0; overflow:hidden; }
.app-authenticated .file-head { flex:0 0 auto; }
.app-authenticated .table-wrap { flex:1 1 auto; min-height:0; max-height:none; overflow:auto; overscroll-behavior:contain; }
.app-authenticated .empty-state { flex:1; }
.app-authenticated .sidebar { overflow:hidden; }
.app-authenticated .side-nav { flex:0 0 auto; }
.app-authenticated .side-bottom { min-height:0; }
.app-authenticated .side-brand { flex:0 0 auto; }

/* Hide redundant scrollbar chrome, preserve wheel, touchpad and keyboard scrolling. */
.app-authenticated .table-wrap,
.app-authenticated .resource-list,
.app-authenticated #view-access,
.app-authenticated #view-activity,
.app-authenticated .user-list,
.app-authenticated .folder-picker-tree,
.app-authenticated .destination-browser,
.app-authenticated .preview-body { scrollbar-width:none; -ms-overflow-style:none; }
.app-authenticated .table-wrap::-webkit-scrollbar,
.app-authenticated .resource-list::-webkit-scrollbar,
.app-authenticated #view-access::-webkit-scrollbar,
.app-authenticated #view-activity::-webkit-scrollbar,
.app-authenticated .user-list::-webkit-scrollbar,
.app-authenticated .folder-picker-tree::-webkit-scrollbar,
.app-authenticated .destination-browser::-webkit-scrollbar,
.app-authenticated .preview-body::-webkit-scrollbar { display:none; }

/* Sidebar / inner resource drawer */
.sidebar-collapsed { --sidebar:78px; }
.sidebar-collapsed .sidebar { padding:24px 10px 16px; }
.sidebar-collapsed .side-brand { padding:8px 0 22px; justify-content:center; }
.sidebar-collapsed .side-brand img { width:54px; height:34px; object-fit:contain; }
.sidebar-collapsed .side-brand > div,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .scope-box,
.sidebar-collapsed .user-meta { display:none; }
.sidebar-collapsed .nav-item { justify-content:center; padding:14px; }
.sidebar-collapsed .nav-item svg { width:21px; height:21px; }
.sidebar-collapsed .side-brand:after { left:50%; transform:translateX(-50%); }
.sidebar-collapsed .user-chip { display:flex; flex-direction:column; align-items:center; padding:12px 0 0; }
.sidebar-collapsed .user-chip .icon-button { width:34px;height:34px; }
.rail-reopen { position:absolute; top:7px; left:0; z-index:7; min-height:35px; }
.explorer-layout.rail-collapsed { grid-template-columns:minmax(0,1fr); }
.explorer-layout.rail-collapsed .resource-rail { display:none; }
.explorer-layout.rail-collapsed .file-panel { margin-top:0; }
.explorer-layout.rail-collapsed .file-head { padding-left:154px; min-height:78px; }

/* Display scale changes text without moving viewport-fixed editor windows. */
.app-authenticated .top-title strong { font-size:calc(23px * var(--brm-font-scale)); }
.app-authenticated .nav-item { font-size:calc(13px * var(--brm-font-scale)); }
.app-authenticated .file-label strong { font-size:calc(13px * var(--brm-font-scale)); }
.app-authenticated .file-label small,
.app-authenticated .file-row td,
.app-authenticated .resource-item span,
.app-authenticated .crumb,
.app-authenticated .file-head span,
.app-authenticated .file-head-tools summary,
.app-authenticated .sort-controls label,
.app-authenticated .global-search input { font-size:calc(12px * var(--brm-font-scale)); }
.app-authenticated .file-head strong { font-size:calc(21px * var(--brm-font-scale)); }
.app-authenticated .primary-button,
.app-authenticated .soft-button,
.app-authenticated .section-heading p,
.app-authenticated .context-action,
.app-authenticated .destination-entry { font-size:calc(12px * var(--brm-font-scale)); }
.app-authenticated .editor-file strong { font-size:calc(15px * var(--brm-font-scale)); }
.app-authenticated .CodeMirror,
.app-authenticated #hexArea { font-size:calc(13px * var(--brm-font-scale)); }
.app-authenticated .rule-path,
.app-authenticated .user-entry strong { font-size:calc(13px * var(--brm-font-scale)); }
.app-authenticated .field input,.app-authenticated .field select { font-size:calc(13px * var(--brm-font-scale)); }

/* Proper image avatar, letter fallback remains behind it. */
.avatar { position:relative; overflow:hidden; background:#222830; }
.avatar img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; border-radius:inherit; z-index:1; }
.avatar span { position:relative; z-index:0; }
.mini-avatar { position:relative;overflow:hidden; }
.mini-avatar img { position:absolute; inset:0; width:100%;height:100%;object-fit:cover; z-index:1; }
.side-brand img,.brand-mark img { display:block; object-fit:contain; }

/* Editor always has a usable close/save bar, without a second page scroll. */
#editorModal,#previewModal,#dialogModal { z-index:100; }
#editorModal { overflow:hidden; padding:24px; }
#editorModal .editor-window { width:min(1500px,100%);height:100%;max-height:calc(100dvh - 48px);min-width:0;min-height:0;grid-template-rows:auto minmax(0,1fr) 36px; }
#editorModal .editor-header { min-height:72px;flex-wrap:wrap;position:relative;z-index:2; }
#editorModal .editor-actions { flex-wrap:wrap; margin-left:auto; }
#editorModal .editor-file { min-width:160px; }
#editorModal .editor-body { position:relative;overflow:hidden; display:flex; min-height:0; }
#editorModal .CodeMirror { flex:1; height:100%; min-width:0; }
#editorModal .CodeMirror-scroll { overflow:auto!important; }
#editorModal #hexEditor { flex:1;min-width:0;min-height:0; }
#editorModal #editorClose,#previewClose { background:#24282e;color:#f1f2f4; border-color:#424850;flex:0 0 38px; }
#editorModal #editorClose:hover,#previewClose:hover { background:#383e47; }
.editor-actions button:disabled { opacity:.5;cursor:wait; }
.unsaved-message { margin:0;line-height:1.65;color:#c2c8d1;font-size:14px; }
#dialogModal { z-index:130; }
#previewModal .preview-window { max-height:calc(100dvh - 36px);display:flex;flex-direction:column; }
#previewModal .preview-body { flex:1;min-height:0; }

/* Native-feeling file context menu, with access checks still enforced on the server. */
.context-menu { position:fixed;z-index:180;width:258px;max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow-y:auto;padding:7px;background:#1a1d22;border:1px solid #424650;border-radius:11px;box-shadow:0 20px 70px rgba(0,0,0,.55); }
.context-heading { font:600 11px/1.3 'JetBrains Mono',monospace; color:#838b95;border-bottom:1px solid #363b43; padding:8px 10px 11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:5px; }
.context-action { cursor:pointer; width:100%;height:39px;display:flex;align-items:center;gap:11px;text-align:left;padding:0 10px;border:0;border-radius:6px;background:transparent;color:#e1e6ec; }
.context-action:hover { background:#30353d;color:#fff; }
.context-action svg { flex:0 0 16px;width:16px;height:16px;color:#aeb6c0; }
.context-action.context-danger { color:#ffacb5; }
.context-action.context-danger svg { color:#e77a88; }
.file-row:focus-visible { outline:2px solid #b2bbc6;outline-offset:-2px; }

@media(max-width:900px){
  .app-authenticated .file-head { gap:9px; }
  .app-authenticated .file-head-tools { justify-content:flex-start; }
}
@media(max-width:780px){
  body.app-authenticated { overflow:auto; height:auto; }
  .app-authenticated .app-shell { height:auto; min-height:100dvh; }
  .app-authenticated .main-area { height:auto;min-height:100dvh;display:block;overflow:visible; }
  .app-authenticated .topbar { position:sticky;top:0;height:74px;min-height:74px; }
  .app-authenticated .view.active { display:block;min-height:0;overflow:visible; }
  .app-authenticated .explorer-layout { display:block; }
  .app-authenticated .file-panel { min-height:50vh;height:auto;max-height:none; }
  .app-authenticated .table-wrap { overflow-x:auto; overflow-y:visible; flex:auto;max-height:none; }
  .app-authenticated .resource-rail { display:none; }
  .app-authenticated .explorer-layout.rail-collapsed .file-head { padding-left:18px;padding-top:52px; }
  .app-authenticated #view-access.active,.app-authenticated #view-activity.active {overflow:visible;}
  .sidebar-collapsed { --sidebar:260px; }
  .sidebar-collapsed .sidebar { padding:25px 15px; }
  .sidebar-collapsed .side-brand > div,.sidebar-collapsed .nav-item span,.sidebar-collapsed .scope-box,.sidebar-collapsed .user-meta {display:initial;}
  .sidebar-collapsed .side-bottom .scope-box {display:block;}
  .sidebar-collapsed .user-chip {display:grid;grid-template-columns:38px 1fr 34px; }
  .sidebar-collapsed .nav-item {justify-content:flex-start;}
  #sidebarToggle { display:none; }
  #editorModal { padding:0; }
  #editorModal .editor-window {width:100vw;height:100dvh;max-height:none;border-radius:0;}
  #editorModal .editor-header {min-height:100px;}
  #editorModal .editor-file {width:100%;}
  #editorModal .editor-actions .soft-button { display:inline-flex; }
  .app-authenticated .file-table {min-width:0;}
}
