.site-menu-toggle,.mobile-only { display:none }
#interface-layout-help,#interface-layout-status { max-width:65ch; font-size:.9rem }

.dialog-fallback-backdrop { position:fixed; inset:0; background:var(--backdrop); z-index:1000 }
body.dialog-fallback-open { overflow:hidden }
dialog:not([open]) { display:none }
dialog.dialog-fallback {
  position:fixed; top:50%; right:auto; bottom:auto; left:50%;
  transform:translate(-50%,-50%); margin:0; max-height:calc(100vh - 24px); overflow:auto; z-index:1001
}
dialog.dialog-fallback-covered { display:none }

html[data-layout=mobile] body { width:100%; max-width:680px; margin:0 auto }
html[data-layout=mobile] .content-wrap {
  min-width:0; max-width:100%; padding:14px max(12px,env(safe-area-inset-right)) 18px max(12px,env(safe-area-inset-left))
}
html[data-layout=mobile] .server-nav-wrap { padding-bottom:0 }
html[data-layout=mobile] .server-nav-wrap + .content-wrap { padding-top:12px }
html[data-layout=mobile] .page-heading { flex-wrap:wrap; gap:8px; margin-bottom:12px }
html[data-layout=mobile] h1 { font-size:1.65rem }
html[data-layout=mobile] :is(button,select) { min-height:42px }
html[data-layout=mobile] :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea) {
  min-width:0; max-width:100%; font-size:16px
}
html[data-layout=mobile] :where(input[type=checkbox],input[type=radio]) { width:17px; height:17px; flex:none }
html[data-layout=mobile] .mobile-only { display:block }

html[data-layout=mobile] .site-bar {
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:6px 10px; min-height:0;
  padding: max(8px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left))
}
html[data-layout=mobile] .site-brand { grid-column:1; grid-row:1; font-size:1.14rem; align-self:center }
html[data-layout=mobile] .site-brand img { width:34px; height:34px }
html[data-layout=mobile] .site-brand small { margin-top:1px }
html[data-layout=mobile] .site-menu-toggle { display:inline-flex; align-items:center; gap:7px; grid-column:2; grid-row:1 }
html[data-layout=mobile] .site-menu-toggle::before { content:"☰"; font-size:1rem; font-weight:500 }
html[data-layout=mobile] .site-menu-toggle[aria-expanded=true] { background:var(--ok-bg); color:var(--ok-text); border-color:var(--ok-line) }
html[data-layout=mobile] .site-bar :is(.site-nav,.site-account) { display:none }
html[data-layout=mobile] .site-bar[data-menu-open=true] :is(.site-nav,.site-account) {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-column:1 / -1;
  width:100%; min-width:0; margin:0; gap:4px 6px; padding:6px 0; border-top:1px solid var(--line)
}
html[data-layout=mobile] .site-nav { grid-row:2 }
html[data-layout=mobile] .site-account { grid-row:3 }
html[data-layout=mobile] :is(.site-nav a,.site-account a,.site-account button) {
  display:flex; align-items:center; min-height:42px; width:100%; white-space:normal; padding:6px 8px
}
html[data-layout=mobile] .site-health {
  grid-row:4; grid-column:1 / -1; min-width:0; max-width:100%; gap:5px;
  flex-wrap:nowrap; overflow:auto; justify-content:flex-start; justify-content:safe center
}
html[data-layout=mobile] .health-chip { min-height:29px; flex:none }

html[data-layout=mobile] dialog[open] {
  position:fixed; top:auto; right:0; bottom:var(--viewport-bottom,0px); left:0;
  width:100%; max-width:680px; max-height:calc(100vh - 12px); max-height:calc(var(--visible-height,100dvh) - 12px);
  margin:0 auto; transform:none; border-radius:16px 16px 0 0; overflow:auto; overscroll-behavior:contain;
  padding:14px max(12px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))
}
html[data-layout=mobile] dialog[open] :is(h2,p,code,dd) { overflow-wrap:anywhere }
html[data-layout=mobile] dialog[open] :is(.actions,.dialog-actions,.server-dialog-footer,.file-dialog-actions) { flex-wrap:wrap }
html[data-layout=mobile] .account-screen { min-height:calc(100vh - 61px); min-height:calc(100dvh - 61px); padding:16px 12px }
html[data-layout=mobile] :is(.account-card,.settings-card) { min-width:0; padding:14px }
html[data-layout=mobile] .settings-line select { width:100% }

html[data-layout=mobile] .editor-tabs {
  display:grid; grid-template-columns:1.18fr 1fr .85fr; gap:4px; margin-bottom:12px
}
html[data-layout=mobile] .editor-tabs button { min-width:0; padding:6px; line-height:1.2; white-space:normal }
html[data-layout=mobile] .permission-editor .panel-heading { display:block; margin-bottom:3px }
html[data-layout=mobile] .permission-editor .panel-heading h2 { font-size:1.2rem }
html[data-layout=mobile] .permission-editor .panel-heading .actions { gap:6px }
html[data-layout=mobile] .permission-editor #rcon-status { flex-basis:100%; margin:0 }
html[data-layout=mobile] .permission-editor .toolbar { display:grid; gap:7px; padding:8px 0 }
html[data-layout=mobile] .permission-editor .toolbar :is(input,select) { width:100%; max-width:100%; min-width:0 }
html[data-layout=mobile] .matrix-mobile-tools {
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:end; gap:7px
}
html[data-layout=mobile] .matrix-mobile-tools label { display:grid; gap:3px; min-width:0; color:var(--muted); font-size:.86rem }
html[data-layout=mobile] #matrix-options { display:none }
html[data-layout=mobile] #matrix-options[data-open] { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:center; gap:7px }
html[data-layout=mobile] #matrix-options :is(select,button) { width:100%; padding-inline:7px; white-space:normal }
html[data-layout=mobile] #matrix-options > select { grid-column:1 / -1 }
html[data-layout=mobile] #matrix-options .rows-control { grid-column:1 / -1; justify-content:space-between }
html[data-layout=mobile] #matrix-options #page-size { width:auto }
html[data-layout=mobile] #matrix-legend { margin:0 0 8px; color:var(--muted); font-size:.86rem }
html[data-layout=mobile] #matrix-legend summary { display:list-item; cursor:pointer; padding:6px 0 }
html[data-layout=mobile] #matrix-legend .legend { display:grid; gap:5px; margin:5px 0 9px }
html[data-layout=mobile] .matrix-swipe { margin:0 0 6px; color:var(--muted); font-size:.82rem }
html[data-layout=mobile] #matrix-wrap {
  max-height:min(56vh,520px); max-height:min(56dvh,520px); overscroll-behavior:auto;
}
html[data-layout=mobile] .matrix { --permission-width:clamp(150px,45vw,215px); --profile-width:88px }
html[data-layout=mobile] .matrix[data-single-profile] { --permission-width:72%; --profile-width:28%; min-width:0 }
html[data-layout=mobile] .matrix :is(td,th):first-child { padding:7px 8px }
html[data-layout=mobile] .matrix tr.child-row td:first-child { padding-left:12px }
html[data-layout=mobile] .matrix .rowdesc { font-size:.8rem }
html[data-layout=mobile] .matrix .cell { width:44px; min-height:44px }
html[data-layout=mobile] .matrix .profile-heading { min-height:40px }
html[data-layout=mobile] .matrix .rowkey { min-height:24px }
html[data-layout=mobile] .matrix .section-about { display:none }
html[data-layout=mobile] .plugin-grid { grid-template-columns:minmax(0,1fr) }
html[data-layout=mobile] .guide { overflow-wrap:anywhere }
html[data-layout=mobile] #modal .close-row {
  position:sticky; top:0; z-index:2; padding-bottom:5px; background:var(--card)
}
html[data-layout=mobile] #modal :is(.choice-list,.profile-parents) { max-height:42vh }
html[data-layout=mobile] #modal .tag-entry { grid-template-columns:minmax(0,1fr) auto; gap:6px }
html[data-layout=mobile] #modal .tag-entry label:first-child { grid-column:1 / -1 }
html[data-layout=mobile] #modal .profile-tabs { display:flex; flex-wrap:wrap }
html[data-layout=mobile] #modal .cm-content { font-size:16px }

html[data-layout=mobile] :is(.server-top,.world-controls) { grid-template-columns:minmax(0,1fr); gap:8px }
html[data-layout=mobile] :is(.server-card,.world-panel) { padding:12px; min-width:0 }
html[data-layout=mobile] .server-card :is(.server-actions button,.world-inline-form button) { white-space:normal }
html[data-layout=mobile] :is(.world-target label,.world-inline-form label) { min-width:0 }
html[data-layout=mobile] .world-target label { flex-basis:100% }
html[data-layout=mobile] .schedule-row { grid-template-columns:minmax(0,1fr) minmax(62px,80px) auto }
html[data-layout=mobile] .server-table-wrap { max-width:100% }
html[data-layout=mobile] .server-players .server-table-wrap { overflow:visible; border:0 }
html[data-layout=mobile] .server-players :is(.server-table,tbody,td) { display:block }
html[data-layout=mobile] .server-players thead {
  position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%)
}
html[data-layout=mobile] .server-players tbody tr {
  display:grid; gap:5px; padding:8px; margin-top:5px; border:1px solid var(--line); border-radius:8px
}
html[data-layout=mobile] .server-players td { padding:0; border:0; white-space:normal }
html[data-layout=mobile] .server-players td:last-child { width:auto }
html[data-layout=mobile] .server-players .player-actions { flex-wrap:wrap; min-width:0 }

html[data-layout=mobile] :is(.log-page,.map-page) { flex:1 1 auto; min-height:0; padding-bottom:max(10px,env(safe-area-inset-bottom)) }
html[data-layout=mobile] .log-page .page-heading { display:grid; gap:5px; margin-bottom:5px }
html[data-layout=mobile] .log-page .log-actions { gap:5px }
html[data-layout=mobile] .log-page :is(.log-actions button,#log-older) { min-height:38px; padding:4px 7px; font-size:.84rem }
html[data-layout=mobile] .log-page #log-filter-toggle { display:inline-flex; align-items:center }
html[data-layout=mobile] .log-page:not([data-filters-open]) :is(#log-mode,.log-follow-label,.log-levels) { display:none }
html[data-layout=mobile] .log-page .log-tools { gap:4px; margin-bottom:3px }
html[data-layout=mobile] .log-page #log-state { margin-bottom:5px; font-size:.8rem }
html[data-layout=mobile] .server-log { min-height:130px; padding:7px; font-size:12px; line-height:1.45 }

html[data-layout=mobile] .audit-filters { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px; margin-bottom:12px }
html[data-layout=mobile] .audit-filter { grid-column:1 / -1 }
html[data-layout=mobile] .audit-filters :is(input,select) { width:100% }
html[data-layout=mobile] .audit-filters a { margin:0 }
html[data-layout=mobile] .audit-table-wrap { background:none; border:0; overflow:visible }
html[data-layout=mobile] .audit-table { min-width:0 }
html[data-layout=mobile] .audit-table tbody,html[data-layout=mobile] .audit-table { display:block }
html[data-layout=mobile] .audit-table thead {
  position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%)
}
html[data-layout=mobile] .audit-table tr {
  display:flex; flex-direction:column; gap:6px; margin-bottom:8px; padding:10px 12px;
  background:var(--card); border:1px solid var(--line); border-radius:9px
}
html[data-layout=mobile] .audit-table tr td {
  display:block; width:auto; max-width:none; min-width:0; padding:0; border:0; overflow-wrap:anywhere
}
html[data-layout=mobile] .audit-table .audit-action { order:-2; font-weight:680 }
html[data-layout=mobile] .audit-table .audit-when { order:-1; color:var(--muted); font-size:.84rem; white-space:normal }
html[data-layout=mobile] .audit-table td[data-label]::before {
  content:attr(data-label) " · "; color:var(--muted); font:inherit; font-size:.84rem
}
html[data-layout=mobile] .audit-table .audit-client summary { padding:5px 0 }
html[data-layout=mobile] .audit-pagination a { padding:8px 0 }

html[data-layout=mobile] .mail-card { padding:12px; display:grid; grid-template-columns:minmax(0,1fr); gap:8px }
html[data-layout=mobile] .mail-card .mail-actions {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px;
  grid-template-areas:"password reveal" "login copy"
}
html[data-layout=mobile] .mail-card .mail-password { grid-area:password; overflow-wrap:anywhere }
html[data-layout=mobile] .mail-card [data-mail-action=copy-login] { grid-area:login }
html[data-layout=mobile] .mail-card [data-mail-action=reveal] { grid-area:reveal }
html[data-layout=mobile] .mail-card [data-mail-action=copy-password] { grid-area:copy }
html[data-layout=mobile] .mail-card button { min-width:0; padding:5px 7px; font-size:.85rem }
html[data-layout=mobile] .mail-workspace { grid-template-columns:minmax(0,1fr); gap:8px; margin-top:13px }
html[data-layout=mobile] .mail-tabs { grid-template-columns:repeat(3,minmax(0,1fr)) }
html[data-layout=mobile] .mail-tabs button { min-width:0; padding:4px; font-size:.83rem; text-align:center }
html[data-layout=mobile] .mail-letter { grid-template-columns:minmax(0,1fr) }
html[data-layout=mobile] .mail-letter-meta { grid-template-columns:minmax(0,1fr) }
html[data-layout=mobile] .mail-letter-options { display:flex; flex-wrap:wrap; align-items:center }
html[data-layout=mobile] .mail-editor-content .tiptap { font-size:16px }
html[data-layout=mobile] .mail-send-settings { display:grid; grid-template-columns:minmax(0,1fr); gap:8px }

html[data-layout=mobile] .file-table-wrap { border:0 }
html[data-layout=mobile] .file-table,html[data-layout=mobile] .file-table :is(thead,tbody) { display:block }
html[data-layout=mobile] .file-table thead tr { display:block; padding:0 5px 7px }
html[data-layout=mobile] .file-table th { padding:0; border:0; background:none }
html[data-layout=mobile] .file-table th:not(:first-child) { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%) }
html[data-layout=mobile] .file-select-all { display:inline-flex; align-items:center; gap:5px }
html[data-layout=mobile] .file-select-all span { display:inline }
html[data-layout=mobile] .file-table tbody tr {
  display:grid; grid-template-columns:auto minmax(0,1fr); gap:5px 8px; margin:0 0 8px;
  padding:9px; border:1px solid var(--line); border-radius:8px; background:var(--surface)
}
html[data-layout=mobile] .file-table td { display:block; grid-column:2; padding:0; border:0; min-width:0 }
html[data-layout=mobile] .file-table td.file-select { grid-column:1; grid-row:1 }
html[data-layout=mobile] .file-table .file-name { grid-row:1 }
html[data-layout=mobile] .file-table .file-comment:empty { display:none }
html[data-layout=mobile] .file-date time { white-space:normal }
html[data-layout=mobile] :is(.file-date,.file-size)::before { content:attr(data-label) " · "; color:var(--muted) }
