.media-gallery { position:relative; background:#080c06; margin:16px 0; border:1px solid var(--line2); min-width:0; }
body .media-gallery>img { display:block; width:100%; height:auto; max-height:600px; aspect-ratio:16/9; object-fit:contain; margin:0!important; border-radius:0; }
body .media-gallery>img[hidden] { display:none!important; }
.media-gallery .gallery-counter { position:absolute; top:12px; right:12px; color:#fff; background:#000b; padding:4px 9px; border-radius:16px; font-size:12px; pointer-events:none; }
body .media-gallery>button { position:absolute; top:50%; transform:translateY(-50%); border:1px solid #a5b48a; background:#0a100bdf; color:#fff; border-radius:50%; width:42px; height:42px; font-size:28px; line-height:1; cursor:pointer; z-index:2; }
.media-gallery .gallery-prev{left:10px}.media-gallery .gallery-next{right:10px}
[contenteditable=true] .media-gallery { display:flex; flex-wrap:wrap; gap:6px; padding:8px; outline:1px dashed var(--green-dim); }
body [contenteditable=true] .media-gallery>img { width:120px; max-height:90px; }
.gallery-editor-list { display:grid; gap:8px; max-height:35vh; overflow:auto; margin:12px 0; }
.gallery-editor-item { display:flex; align-items:center; gap:8px; }
.gallery-editor-item img { width:70px; height:50px; object-fit:contain; }
.gallery-editor-item input { min-width:0; flex:1; }
.table-cell-selected { outline:2px solid var(--green); outline-offset:-3px; background-color:#91ab5333; }
body :is(.wiki-view-content,.art-body,.ed-editor,.p-text) table { display:table; table-layout:fixed; max-width:100%; border-collapse:collapse; }
body :is(.wiki-view-content,.art-body,.ed-editor,.p-text) :is(td,th) { overflow-wrap:anywhere; }
body .news-compose { max-width:1100px; width:100%; }
body .news-compose .ed-card { overflow:visible; }
body .news-compose .tb { position:sticky; top:0; z-index:30; background:var(--panel); max-height:45dvh; overflow:auto; }
body .news-compose .ed-editor { max-height:none; }
.wiki-view-title [data-custom-icon] .terminal-icon { width:28px; height:28px; }

body :is(.wiki-view,.wiki-editor) .wiki-view-content p, body .ed-editor p { margin:0 0 10px; }
body .medal-progress { appearance:none; border:0; border-radius:4px; background:var(--line2); overflow:hidden; display:block; margin-top:7px; }
.medal-progress::-webkit-progress-bar { background:var(--line2); }
.medal-progress::-webkit-progress-value { background:var(--green); }
.medal-progress::-moz-progress-bar { background:var(--green); }
@media(max-width:550px) {
  .gallery-editor-item { flex-wrap:wrap; }
  .gallery-editor-item input { flex-basis:calc(100% - 80px); }
  body .medal-xp-form { flex-basis:100%; align-items:center; }
  body .medal-xp-form input[type=number] { width:100px; flex-basis:100px; }
  body .news-compose { padding:16px; }
}

.media-gallery { touch-action:pan-y pinch-zoom; }
button,select { touch-action:manipulation; }
body .wiki-view .wiki-view-content table, body .wiki-editor .wiki-view-content table { display:table; table-layout:fixed; max-width:100%; }
body .media-gallery>button { border-radius:50%!important; min-height:42px; padding:0; }

/* Frame visibility wins over saved inline styles and nested editor wrappers. */
body .media-gallery img[hidden] { display:none!important; }
body .media-gallery[data-gallery-ready] img:not([hidden]) { display:block!important; }
body .spoiler-header { cursor:pointer; }
body .spoiler-header:focus-visible { outline:2px solid var(--green); outline-offset:2px; }
body .spoiler-box:not(.open)>.spoiler-content { display:none!important; }
body .spoiler-box.open>.spoiler-content { display:block!important; }
body .ed-editor .spoiler-box>.spoiler-content { display:block!important; }
.ed-resize { position:sticky; bottom:8px; z-index:35; box-shadow:0 -3px 14px #0008; max-height:35dvh; overflow:auto; }
.image-frame-controls { display:flex; flex-wrap:wrap; align-items:center; gap:6px; }
.image-frame-controls input,.image-frame-controls select { min-height:32px; }
.table-resize-handle { position:absolute; z-index:36; background:transparent; border:0; padding:0; touch-action:none; }
.table-resize-handle.column { width:14px; cursor:col-resize; z-index:37; }
.table-resize-handle.row { height:14px; cursor:row-resize; }
.table-resize-handle:hover,.table-resize-handle:focus-visible { background:#91ab5355; outline:1px solid var(--green); }

/* Телефон: широкая таблица (форум, новости, вики) прокручивается вбок, а не сжимается до буквы в строке. */
@media (max-width:600px) {
  body :is(.p-text,.ed-editor,.art-body) table, body :is(.wiki-view,.wiki-editor) .wiki-view-content table { display:block; overflow-x:auto; table-layout:auto; }
  body :is(.p-text,.ed-editor,.art-body) table:not(:has(> thead)) > tbody, body :is(.wiki-view,.wiki-editor) .wiki-view-content table:not(:has(> thead)) > tbody { display:table; width:100%; border-collapse:collapse; }
  body :is(.p-text,.ed-editor,.art-body) :is(td,th), body :is(.wiki-view,.wiki-editor) .wiki-view-content :is(td,th) { min-width:4.5em; overflow-wrap:break-word; }
}
