/* PESTIS v4 — surgical improvements for the original v1 layout */
:root { --tap: 42px; scrollbar-color: #72866b #0f1813; scrollbar-width:thin; }
html,body,#app,.app-shell,.main-shell { max-width:100%; }
html,body{ overflow-x:clip; }
::-webkit-scrollbar { width:7px; height:7px; }
::-webkit-scrollbar-track { background:#101a14; border-radius:20px; }
::-webkit-scrollbar-thumb { background:#5d765e; border:1px solid #243629; border-radius:20px; }
::-webkit-scrollbar-thumb:hover { background:#a0b88a; }
button,a,input,textarea,select { -webkit-tap-highlight-color:transparent; }
button { touch-action:manipulation; }
.brand { appearance:none; background:transparent; border:0; width:100%; text-align:left; cursor:pointer; padding:0 10px 25px; }
.brand-icon { width:45px;height:45px;filter:drop-shadow(0 0 15px #bcb58b33); }
.brand:focus-visible,.post-hitbox:focus-visible { outline:2px solid var(--gold); outline-offset:-3px; }
.left-sidebar { overflow-y:auto; overflow-x:hidden; scrollbar-width:thin; overscroll-behavior:contain; min-height:0; height:100dvh; }
.left-sidebar .side-spacer { min-height:15px; }
.quarantine { flex:none; overflow:hidden; padding:14px 13px; margin-top:20px; }
.quarantine:after {pointer-events:none;z-index:0;}
.quarantine> * {position:relative;z-index:1;}
.quarantine h4 {font-size:17px;line-height:1.28;margin:8px 0 7px;}
.quarantine p {font-size:10px;line-height:1.65;margin-bottom:13px;overflow-wrap:anywhere;}
.quarantine .btn {min-height:34px;max-width:100%;}
.sidebar-bottom{line-height:1.5;}
.topbar .btn {white-space:nowrap;}
/* The whole post is a real button; controls above it stay clickable. */
.post-card {position:relative; isolation:isolate; cursor:pointer; transform:none!important; transition:border-color .18s, background-color .18s,box-shadow .18s;}
.post-card:hover,.post-card:focus-within {border-color:#7f9879; background:#17221a;box-shadow:0 7px 24px #0005;}
.post-image { cursor:inherit; }
.post-image img {transform:none!important;transition:none; }
.post-image:after { background:linear-gradient(180deg, transparent 28%,#0b140fe0 100%); pointer-events:none; }
.post-hitbox{position:absolute;inset:0;display:block;width:100%;height:100%;border:0;background:transparent;color:transparent;padding:0;z-index:3;cursor:pointer;border-radius:12px;}
.post-card .post-bookmark {position:absolute;z-index:6;min-width:34px;min-height:34px;}
.post-info .author,.post-info .stat {position:relative;z-index:6;}
.post-info .author {padding:0;border:0;background:none;text-align:left;max-width:min(100%,170px);flex:0 1 auto;align-self:center;}
.author-meta{min-width:0;display:flex;flex-direction:column;align-items:flex-start;gap:2px;}
.author-name{max-width:145px;}
.role-badge{display:inline-flex;max-width:100%;white-space:nowrap;align-items:center;gap:3px;padding:2px 6px;border-radius:5px;border:1px solid #6d7757;background:#2b3527;color:#c6d5b3;font-size:9px;line-height:1.3;font-weight:800;vertical-align:middle;letter-spacing:.015em;}
.role-badge.creator{color:#f2d7a0;border-color:#80683e;background:#443521;}
.role-badge.admin{color:#bfd5f0;border-color:#435f79;background:#1c3445;}
.post-card.from-creator{border-color:#6b6147;}
.post-card.from-creator:hover{border-color:#c8aa70;}
.post-card .post-bottom {min-width:0;gap:6px;}
.post-stats {flex-wrap:wrap;justify-content:flex-end;min-width:0;gap:4px 9px;}
.post-stats .stat{min-height:28px;padding:5px 2px;}
.post-desc{height:auto; min-height:30px; display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
.reading-item-info strong .role-badge{margin-left:4px;}
/* User profile customization */
.profile-cover {min-height:160px;background-size:cover;background-position:center;overflow:hidden;}
.profile-cover:has(.cover-edit):after{pointer-events:none;}
.cover-edit{position:absolute;bottom:13px;right:13px;z-index:3;display:inline-flex;align-items:center;gap:7px;min-height:35px;border-radius:7px;border:1px solid #79816b;background:#0a120bd9;color:#e2e1d4;padding:0 11px;font-size:11px;}
.cover-edit:hover{background:#1c3024;}
.profile-identity{min-width:0;}
.profile-identity h2{overflow-wrap:anywhere;}
.profile-handle {color:#90a78e;font-size:11px;display:flex;align-items:center;gap:7px;flex-wrap:wrap;}
.profile-status{margin-top:7px;color:#d5c9a7;font-size:11px;max-width:380px;overflow-wrap:anywhere;}
.profile-details{display:flex;flex-wrap:wrap;gap:7px 18px;margin:-14px 25px 17px;color:#a8bba8;font-size:11px;}
.profile-details span,.profile-details a{display:inline-flex;gap:6px;align-items:center;}
.profile-details .icon{width:13px;height:13px;color:var(--gold);}
.profile-details a:hover{text-decoration:underline;}
.profile-file-row{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin-bottom:20px;}
.profile-image-upload{display:flex;flex-direction:column;gap:9px;min-width:0;position:relative;font-size:11px;font-weight:750;color:#bcc9b7;cursor:pointer;}
.profile-image-upload input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;}
.image-pick-preview{height:110px;border-radius:10px;border:1px dashed #6a7b62;background:linear-gradient(125deg,#202f25,#111e16);display:grid;place-items:center;overflow:hidden;}
.image-pick-preview.avatar-pick{width:min(115px,100%);border-radius:18px;}
.image-pick-preview.cover-pick{width:100%;}
.image-pick-preview img{width:100%;height:100%;object-fit:cover;}
.image-pick-preview .icon{width:30px;height:30px;color:#a0b295;}
.file-picker-label{display:flex;align-items:center;gap:6px;color:#d6c396;font-size:11px;}
.file-picker-label .icon{width:14px;height:14px;}
.palette-row{display:flex;flex-wrap:wrap;gap:7px;}
.palette-choice {display:flex;align-items:center;gap:7px;padding:7px 10px;border:1px solid #3e4b40;border-radius:7px;cursor:pointer;background:#17241c;color:#a9bba8;font-size:11px;}
.palette-choice input{accent-color:#b1c79b;}
.palette-choice:has(input:checked){border-color:#c6b281;background:#303727;color:#efeedb;}
.profile-form-actions{display:flex;gap:9px;justify-content:flex-end;flex-wrap:wrap;}
.role-select{height:33px;min-width:135px;padding:5px 9px;font-size:11px;}
/* Responsive dialogs and upload hit targets */
.modal-backdrop{overscroll-behavior:contain;}
.modal {min-width:0; overflow-x:hidden;scrollbar-width:thin;overscroll-behavior:contain;}
.modal .upload-area{min-width:0;overflow:hidden;}
.modal .upload-area strong, .modal .upload-area span{overflow-wrap:anywhere;max-width:100%;}
.modal .form-group,.modal form,.modal .form-grid>*,.modal .field,.modal .textarea {min-width:0;max-width:100%;}
.modal .form-grid{min-width:0;}
.modal-close{min-height:36px;min-width:36px;}
.profile-main .avatar img{object-fit:cover;}
.mobile-scrim {display:none;}
@media(max-width:1250px) {.content-layout{padding-inline:24px;} }
@media(max-width:1000px) {.hero-doctor{right:-35px;opacity:.75;} }
@media(max-width:760px){
  .mobile-scrim{display:block;position:fixed;inset:0;z-index:29;background:#000b;border:0;padding:0;width:100%;height:100dvh;}
  .left-sidebar{width:min(275px,86vw);padding:18px 15px 17px;box-shadow:12px 0 35px #0008;}
  .left-sidebar .brand{padding:0 6px 15px;}
  .sidebar-label{margin:8px 0 6px;}
  .nav-link{height:39px;}
  .sidebar-divider{margin:12px 8px;}
  .quarantine{margin-top:12px;}
  .topbar {padding:0 12px;height:61px;gap:7px;min-width:0;}
  .topbar>.icon-button {flex:none;width:35px;height:35px;}
  .topbar .searchbox{min-width:0;width:auto;flex:1 1 auto;height:37px;gap:5px;padding:0 9px;}
  .topbar .searchbox input{font-size:11px;width:100%;min-width:0;}
  .topbar .top-spacer{display:none;}
  .topbar>.btn {flex:0 0 36px;width:36px;min-width:36px;min-height:36px;padding:0;font-size:0;gap:0;overflow:hidden;}
  .topbar>.btn .icon{width:17px;height:17px;flex:none;}
  .topbar>.user-pill{padding:3px;min-width:35px;max-width:35px;overflow:hidden;}
  .topbar>.user-pill .avatar{height:28px;width:28px;}
  .content-layout{padding:20px 14px 70px;}
  .hero{height:282px;}
  .hero-content{padding:28px 24px;}
  .hero-doctor{right:-55px;opacity:.56;}
  .section-head,.page-heading{flex-wrap:wrap;align-items:flex-start;}
  .filters-bar {overflow-x:auto;overscroll-behavior-x:contain;scrollbar-width:none;}
  .filters-bar::-webkit-scrollbar{display:none;}
  .filter-select{max-width:none;}
  .profile-main{flex-wrap:wrap;transform:translateY(-22px);align-items:center;padding:0 12px;gap:10px;}
  .profile-main .avatar{height:72px;width:72px;}
  .profile-actions{flex:1 0 100%;margin-left:82px;align-self:auto;}
  .profile-bio{margin:0 12px 14px;overflow-wrap:anywhere;}
  .profile-details{margin:0 12px 15px;}
  .profile-numbers{padding:12px;flex-wrap:wrap;gap:9px 16px;}
  .modal-backdrop{align-items:flex-start;justify-content:center;padding:10px 8px;overflow-y:auto;min-width:0;}
  .modal,.modal.wide,.modal.detail{width:100%;max-width:100%;max-height:calc(100dvh - 20px);min-width:0;margin:auto 0;overflow-y:auto;overflow-x:hidden;border-radius:12px;padding:22px 16px;}
  .modal.detail{padding:0;}
  .modal h2{font-size:27px;max-width:calc(100% - 28px);overflow-wrap:anywhere;}
  .modal .modal-intro{font-size:11px;margin-bottom:16px;overflow-wrap:anywhere;}
  .modal .form-grid{grid-template-columns:1fr;gap:0;}
  .modal .upload-area{padding:19px 11px;min-height:145px;}
  .modal .upload-area input{max-width:100%;}
  .modal .textarea{min-height:100px;}
  .modal .detail-layout{display:flex;flex-direction:column;height:auto;max-height:none;overflow:visible;}
  .modal .detail-media{width:100%;height:min(38vh,260px);flex:none;min-height:170px;}
  .modal .detail-side{padding:18px 16px 22px;overflow:visible;min-width:0;}
  .modal .detail-side h2{margin-top:15px;}
  .modal .detail-actions{gap:8px;flex-wrap:wrap;}
  .modal .detail-actions button{min-height:33px;}
  .modal .detail-comments{max-height:200px;overflow-y:auto;min-height:60px;}
  .modal .detail-top{padding-right:37px;margin-right:0;}
  .admin-panel{min-width:0;}
  .admin-table-wrap{max-width:100%;}
  .profile-file-row{gap:11px;}
}
@media(max-width:540px){
  .post-grid{grid-template-columns:1fr;gap:14px;}
  .post-image,.post-card:nth-child(4n+2) .post-image,.post-card:nth-child(4n+3) .post-image{height:clamp(210px,57vw,275px);}
  .post-info{padding:13px 15px;}
  .post-stats .stat{font-size:10px;}
  .post-desc{font-size:11px;min-height:0;}
  .hero {height:270px;}
  .hero-content{padding:28px 20px;}
  .hero h1{font-size:clamp(29px,8.5vw,37px);}
  .hero p{font-size:11px;max-width:min(238px,65%);}
  .hero-doctor{right:-103px;bottom:-78px;opacity:.38;}
  .hero-actions{gap:7px;flex-wrap:wrap;}
  .hero-actions .btn{font-size:10px;min-height:35px;padding:0 10px;}
  .hero-ordinal{display:none;}
  .section-head h2{font-size:25px;}
  .sub-tabs{max-width:100%;}
  .admin-stat-grid{gap:9px;}
  .profile-cover{height:147px;min-height:147px;}
  .profile-identity h2{font-size:23px;}
  .profile-actions .btn{min-height:35px;}
}
@media(max-width:350px){
  .topbar{gap:5px;padding:0 8px;}
  .topbar>.icon-button{height:33px;width:33px;}
  .topbar>.btn{height:33px;width:33px;min-width:33px;flex-basis:33px;}
  .topbar .searchbox{height:34px;padding:0 7px;}
  .content-layout{padding-inline:10px;}
  .hero{height:266px;}
  .hero-content{padding:23px 15px;}
  .hero-actions .btn{font-size:9px;padding:0 8px;}
  .post-bottom{gap:3px;}
  .post-stats{gap:3px 6px;}
  .author-meta .role-badge{font-size:8px;}
  .profile-image-upload{font-size:10px;}
}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important;transition-duration:0s!important;animation-duration:0s!important;}}
/* Keep the keeper's note legible instead of cutting it off below the fold. */
@media(min-width:761px){
 .left-sidebar{padding:22px 15px 13px;}
 .left-sidebar .brand{padding:0 9px 20px;}
 .left-sidebar .nav-link{height:40px;}
 .left-sidebar .sidebar-divider{margin:15px 9px;}
 .left-sidebar .sidebar-label{margin:8px 0 7px;}
 .left-sidebar .quarantine{padding:12px 12px;margin-top:12px;}
 .left-sidebar .quarantine h4{font-size:16px;}
 .left-sidebar .quarantine p{line-height:1.45;margin-bottom:10px;}
 .left-sidebar .sidebar-bottom{padding:11px 9px 0;}
 .left-sidebar .sidebar-bottom small{margin-top:6px;}
 .hero-doctor{right:12px;height:380px;width:365px;bottom:-63px;opacity:.88;}
}
@media(max-width:760px){.hero-doctor{right:-22px;height:327px;width:305px;bottom:-56px;opacity:.5;}}
@media(max-width:540px){.hero-doctor{right:-58px;height:286px;width:267px;bottom:-50px;opacity:.38;}}

/* v5 · YouTube Archive */
.video-card { cursor:pointer; transition:border-color .18s,transform .18s; }
.video-card:hover, .video-card:focus-visible { border-color:#a38c69; transform:translateY(-2px); outline:none; }
.video-card:focus-visible { box-shadow:0 0 0 2px #cdb98f; }
.video-img { position:relative; }
.video-img img { width:100%; height:100%; object-fit:cover; }
.video-play {pointer-events:none}
.video-author {font-size:11px;color:#91a28e;max-width:100%;overflow-wrap:anywhere}
.youtube-preview-placeholder{margin:12px 0 21px;border:1px dashed #445848;border-radius:10px;padding:14px;color:#849788;font-size:12px;min-height:68px;display:flex;align-items:center;justify-content:center}
.youtube-preview-card{display:flex;align-items:center;gap:13px;width:100%}
.youtube-preview-card img{width:132px;max-width:38%;aspect-ratio:16/9;object-fit:cover;border-radius:8px}
.youtube-preview-card div{flex:1;min-width:0;display:grid;gap:5px}
.youtube-preview-card strong{font-size:13px;line-height:1.4;color:#ebe6d6;overflow-wrap:anywhere}
.youtube-preview-card small{color:#91a28e}
.youtube-preview-card span{font-size:11px;color:#c9b98e}
.youtube-player{width:100%;aspect-ratio:16/9;max-height:min(70vh,520px);border-radius:10px;overflow:hidden;background:#060a08;margin:14px 0}
.youtube-player iframe{border:0;width:100%;height:100%}
.youtube-detail-image{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:10px;margin:14px 0}
.video-detail-meta{display:flex;flex-wrap:wrap;align-items:center;gap:9px;margin:14px 0}
.review-line{display:flex;align-items:center;gap:14px;padding:14px 0;border-top:1px solid #354238}
.review-line img{height:85px;aspect-ratio:16/9;object-fit:cover;border-radius:7px}
.review-line>div:nth-child(2){min-width:0;flex:1;display:grid;gap:6px}
.review-line strong{color:#e4ded0;font-size:13px;overflow-wrap:anywhere}
.review-line small{color:#95a58f}
.review-line .review-actions{display:flex;flex-wrap:wrap;gap:8px}
.review-line .btn{width:fit-content}
@media(max-width:650px){
 .review-line{flex-wrap:wrap;align-items:flex-start}
 .review-line img{width:100px;height:65px}
 .review-line .review-actions{width:100%;padding-top:3px}
 .review-line .review-actions .btn{flex:1;min-width:100px}
 .youtube-preview-card img{width:105px}
 .video-card{transform:none!important}
}

/* PESTIS v5.7 moderation: compact, responsive video status filters */
.video-mod-filters{display:flex;gap:7px;flex-wrap:wrap;margin:16px 0 18px;align-items:center}
.video-mod-filters .chip{min-height:30px;padding:0 10px;font-size:11px}
.review-line .state-pill{width:max-content;max-width:100%}
.review-line .review-actions{align-items:center;justify-content:flex-start}
.review-line .review-actions .btn{white-space:nowrap}
@media(max-width:600px){
 .video-mod-filters{gap:5px}
 .video-mod-filters .chip{font-size:10px;min-height:30px;padding:0 8px}
 .review-line .review-actions .btn{min-width:0;flex:1 1 auto}
}

/* v5.8: profile cover uploaded to D1; keep edit controls above decorative artwork */
.profile-cover{background-repeat:no-repeat;background-position:center;background-size:cover;}
.profile-cover .cover-edit{z-index:2;position:absolute;}
.profile-file-row .profile-image-upload input[type=file]{cursor:pointer;}
