/* ---------- User reports + inbox + admin triage (js/reports.js, js/admin-reports.js) ----------
   Reuses the app's tokens (--card/--line/--muted/--coral/--yellow/--blue, --fs-* scale,
   .chip/.btn/.admin-input) and the shared .fullscreen-overlay/.ep-bar/.ep-body shell. */

/* overlay shell (same background/layout pair as #legal-overlay) */
#messages-overlay{background:var(--paper); display:flex; flex-direction:column;}
#messages-panel{flex:1; display:flex; flex-direction:column; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch;}
.rp-body{display:flex; flex-direction:column; gap:0; max-width:680px;}

.rp-wrap{padding:6px 0 90px;}
.rp-head{display:flex; align-items:flex-start; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:16px;}
.rp-title{font-size:var(--fs-2xl); font-weight:800; line-height:1.2;}
.rp-sub{font-size:var(--fs-sm); color:var(--muted); margin-top:3px; max-width:46ch;}
.rp-new-btn{width:auto; padding:10px 18px;}
.rp-muted{color:var(--muted); font-weight:500; font-size:var(--fs-sm);}
.rp-empty{text-align:center; color:var(--muted); font-size:var(--fs-base); padding:40px 12px; line-height:1.7;}
.rp-label{display:block; font-size:var(--fs-sm); font-weight:700; margin:16px 0 6px;}
.rp-hint{font-size:var(--fs-xs); color:var(--muted); margin-top:6px; line-height:1.5;}
.rp-section-title{font-weight:800; font-size:var(--fs-md); margin:28px 0 10px;}
.rp-noreply{font-size:var(--fs-xs); color:var(--muted); background:rgba(18,18,18,0.05); border-radius:12px; padding:10px 12px; margin:16px 0; line-height:1.5;}

/* sub-tabs */
.rp-tabs{display:flex; gap:6px; border-bottom:1px solid var(--line); margin-bottom:14px;}
.rp-tab{background:none; border:none; font:inherit; font-size:var(--fs-base); font-weight:600; color:var(--muted); padding:10px 12px; border-bottom:3px solid transparent; margin-bottom:-1px; cursor:pointer; display:flex; align-items:center; gap:7px; transition:color 160ms ease, border-color 160ms ease;}
.rp-tab.active{color:var(--ink); border-bottom-color:var(--black);}
.rp-tab-count{background:var(--coral); color:#fff; border-radius:999px; font-size:var(--fs-2xs); font-weight:700; padding:1px 7px; min-width:19px; text-align:center;}
.rp-tab-count-muted{background:rgba(18,18,18,0.08); color:var(--muted);}

/* nav unread badge */
.nav-btn[data-tab="messages"], .nav-btn[data-tab="admin-reports"], .side-nav-btn[data-tab="messages"], .side-nav-btn[data-tab="admin-reports"]{position:relative;}
.rp-nav-badge{background:var(--coral); color:#fff; border-radius:999px; font-size:10px; font-weight:800; line-height:1; padding:3px 6px; min-width:17px; text-align:center; pointer-events:none;}
.nav-btn .rp-nav-badge{position:absolute; top:-3px; left:calc(50% + 4px);}
.side-nav-btn .rp-nav-badge{margin-left:auto;}
.side-nav-collapsed .side-nav-btn .rp-nav-badge{position:absolute; top:4px; right:8px; margin:0;}

/* inbox + my-reports rows */
.rp-list{display:flex; flex-direction:column; gap:8px;}
.rp-mail-row, .rp-report-row{width:100%; text-align:left; font:inherit; color:inherit; background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px 16px; cursor:pointer; display:flex; gap:12px; transition:transform 140ms var(--ease-pop), border-color 160ms ease;}
.rp-mail-row:active, .rp-report-row:active, .rp-card:active{transform:scale(0.985);}
.rp-report-row{flex-direction:column; gap:6px;}
.rp-dot{flex:none; width:9px; height:9px; border-radius:50%; background:transparent; margin-top:7px;}
.rp-mail-row.unread{border-color:var(--black);}
.rp-mail-row.unread .rp-dot{background:var(--coral);}
.rp-mail-row.unread .rp-mail-subject{font-weight:800;}
.rp-mail-main{flex:1; min-width:0; display:flex; flex-direction:column; gap:3px;}
.rp-mail-top{display:flex; justify-content:space-between; gap:10px; align-items:baseline; font-size:var(--fs-sm);}
.rp-mail-date{font-size:var(--fs-xs); color:var(--muted);}
.rp-mail-subject{font-size:var(--fs-base); font-weight:600; word-break:break-word;}
.rp-mail-preview{font-size:var(--fs-sm); color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.rp-report-top{display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:var(--fs-sm); font-weight:600;}
.rp-pill{display:inline-block; font-size:var(--fs-xs); font-weight:700; border-radius:999px; padding:3px 10px; white-space:nowrap;}

/* email view */
.rp-mail-h{font-size:var(--fs-xl); font-weight:800; line-height:1.3; margin:6px 0 12px; word-break:break-word;}
.rp-mail-meta{display:grid; grid-template-columns:auto 1fr; gap:4px 12px; font-size:var(--fs-sm); margin:0 0 16px; padding-bottom:14px; border-bottom:1px solid var(--line);}
.rp-mail-meta dt{color:var(--muted); font-weight:600;} .rp-mail-meta dd{margin:0; word-break:break-word;}
.rp-mail-text{white-space:pre-wrap; word-break:break-word; font-size:var(--fs-base); line-height:1.75;}
.rp-own-text{background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px 16px; margin-top:12px;}
.rp-quote{margin-top:26px; border-left:4px solid var(--line); padding:4px 0 4px 14px; color:var(--muted);}
.rp-quote-head{font-size:var(--fs-xs); font-weight:700; margin-bottom:8px;}
.rp-quote-subject{font-size:var(--fs-sm); font-weight:700; color:var(--ink); margin-bottom:4px; word-break:break-word;}
.rp-quote-body{font-size:var(--fs-sm); white-space:pre-wrap; word-break:break-word; line-height:1.6;}
.rp-quote-meta{font-size:var(--fs-xs); margin-top:8px;}
.rp-detail-meta{font-size:var(--fs-sm); color:var(--muted); line-height:1.6;}

/* progress stepper (user view of status) */
.rp-stepper{list-style:none; display:flex; margin:4px 0 16px; padding:0;}
.rp-stepper li{flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; position:relative; font-size:var(--fs-xs); color:var(--muted); text-align:center;}
.rp-stepper li + li::before{content:""; position:absolute; top:13px; right:50%; width:100%; height:3px; background:var(--line); z-index:0;}
.rp-stepper li.done + li::before, .rp-stepper li.current::before{background:var(--success);}
.rp-step-dot{position:relative; z-index:1; width:28px; height:28px; border-radius:50%; background:var(--card); border:2px solid var(--line); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:var(--fs-xs);}
.rp-stepper li.done .rp-step-dot{background:var(--success); border-color:var(--success); color:#fff;}
.rp-stepper li.current .rp-step-dot{background:var(--yellow); border-color:var(--black); color:var(--black);}
.rp-stepper li.current .rp-step-label{color:var(--ink); font-weight:800;}
.rp-closed-note{display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:var(--fs-sm); color:var(--muted); margin:6px 0 12px;}
.rp-reply-card{background:var(--card); border:1px solid var(--line); border-radius:14px; padding:12px 14px; margin-bottom:8px; display:flex; flex-direction:column; gap:4px;}
.rp-reply-card[data-open-mail]{cursor:pointer;}
.rp-reply-card.unread{border-color:var(--black);}

/* compose form */
.rp-form{display:flex; flex-direction:column;}
.rp-kinds{display:flex; flex-wrap:wrap; gap:8px;}
.rp-counter{align-self:flex-end; font-size:var(--fs-xs); color:var(--muted); margin-top:4px;}
.rp-form-actions{display:flex; align-items:center; gap:12px; margin-top:20px; flex-wrap:wrap;}

/* image grid (compose thumbs + viewing) */
.rp-img-grid{display:grid; grid-template-columns:repeat(auto-fill, minmax(96px, 1fr)); gap:8px; margin:10px 0;}
.rp-img-grid:empty{display:none;}
.rp-img-cell{position:relative; aspect-ratio:1; border-radius:12px; overflow:hidden; background:rgba(18,18,18,0.06); cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:var(--fs-xs); color:var(--muted); text-align:center;}
.rp-img-cell img{width:100%; height:100%; object-fit:cover; display:block;}
.rp-img-loading{background:linear-gradient(90deg, rgba(18,18,18,0.06) 25%, rgba(18,18,18,0.13) 50%, rgba(18,18,18,0.06) 75%); background-size:200% 100%; animation:motionShimmer 1.2s ease-in-out infinite;}
.rp-img-x{position:absolute; top:4px; right:4px; width:24px; height:24px; border-radius:50%; border:none; background:rgba(18,18,18,0.75); color:#fff; font-size:12px; cursor:pointer; line-height:1;}

/* ---- admin triage ---- */
.rp-tiles{display:grid; grid-template-columns:repeat(4, 1fr); gap:8px; margin-bottom:16px;}
.rp-tile{font:inherit; color:inherit; background:var(--card); border:2px solid var(--line); border-radius:16px; padding:12px 6px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:2px; transition:transform 140ms var(--ease-pop), border-color 160ms ease, background 160ms ease;}
.rp-tile:active{transform:scale(0.96);}
.rp-tile-n{font-size:var(--fs-2xl); font-weight:800; line-height:1.1;}
.rp-tile-l{font-size:var(--fs-xs); font-weight:600; color:var(--muted); white-space:nowrap;}
.rp-tile.active{border-color:var(--black); background:var(--black); color:#fff;}
.rp-tile.active .rp-tile-l{color:#D8D6CC;}
.rp-tile.t-urgent:not(.active) .rp-tile-n{color:var(--danger);}
.rp-cat-chips{display:flex; gap:8px; overflow-x:auto; padding-bottom:6px; margin-bottom:14px; -webkit-overflow-scrolling:touch;}
.rp-group{margin-bottom:22px;}
.rp-group-head{display:flex; flex-direction:column; gap:2px; margin-bottom:8px;}
.rp-group-title{font-weight:800; font-size:var(--fs-md);}
.rp-group-count{background:rgba(18,18,18,0.08); border-radius:999px; font-size:var(--fs-xs); padding:1px 8px; margin-left:4px;}
.rp-group-hint{font-size:var(--fs-xs); color:var(--muted);}
.rp-cards{display:flex; flex-direction:column; gap:8px;}
.rp-card{position:relative; width:100%; text-align:left; font:inherit; color:inherit; background:var(--card); border:1px solid var(--line); border-left-width:6px; border-radius:14px; padding:12px 14px; cursor:pointer; display:flex; align-items:center; gap:12px; transition:transform 140ms var(--ease-pop), border-color 160ms ease, background 160ms ease;}
.rp-card:focus-visible{outline:2px solid var(--black); outline-offset:2px;}
.rp-card-body{flex:1; min-width:0; display:flex; flex-direction:column; gap:6px;}
.rp-card-del{flex:none; width:36px; height:36px; border-radius:10px; border:1px solid var(--line); background:transparent; color:var(--muted); display:flex; align-items:center; justify-content:center; cursor:pointer; transition:color 150ms ease, background 150ms ease, border-color 150ms ease;}
.rp-card-del:hover{color:var(--danger); border-color:var(--danger); background:rgba(var(--danger-rgb),0.07);}
.rp-card-del:active{transform:scale(0.92);}
.rp-card-del svg{width:16px; height:16px;}
.rp-check{flex:none; width:24px; height:24px; border-radius:7px; border:2px solid #B7B5AB; background:var(--card); color:transparent; display:flex; align-items:center; justify-content:center; font-size:14px; font-weight:800; transition:background 140ms ease, border-color 140ms ease, color 140ms ease;}
.rp-card.selected{border-color:var(--black); background:rgba(18,18,18,0.04);}
.rp-card.selected .rp-check{background:var(--black); border-color:var(--black); color:#fff;}
.rp-card.p-urgent{border-left-color:var(--coral);}
.rp-card.p-normal{border-left-color:var(--yellow-deep);}
.rp-card.p-later{border-left-color:var(--blue-deep);}
.rp-card.p-none{border-left-color:#B7B5AB; border-left-style:dashed;}
.rp-card-top{display:flex; justify-content:space-between; align-items:center; gap:8px; font-size:var(--fs-xs); font-weight:600; color:var(--muted);}
.rp-card-subject{font-size:var(--fs-base); font-weight:700; word-break:break-word;}
.rp-card-bottom{display:flex; flex-wrap:wrap; gap:4px 12px; font-size:var(--fs-xs); color:var(--muted);}
.rp-stale{color:var(--danger); font-weight:700;}
.rp-cat-tag{background:rgba(18,18,18,0.06); border-radius:999px; padding:1px 8px;}
.rp-cat-none{background:transparent; border:1px dashed var(--line);}

/* admin detail: triage controls */
.rp-triage{background:var(--card); border:1px solid var(--line); border-radius:18px; padding:16px; margin-top:20px;}
.rp-segs{display:grid; grid-template-columns:repeat(3, 1fr); gap:8px;}
.rp-seg{font:inherit; font-size:var(--fs-base); font-weight:700; border:2px solid var(--line); background:var(--card); border-radius:14px; padding:12px 6px; cursor:pointer; transition:transform 120ms var(--ease-pop), background 160ms ease, border-color 160ms ease;}
.rp-seg:active{transform:scale(0.96);}
.rp-seg.active{border-color:var(--seg-color); background:var(--seg-bg); color:var(--seg-color);}
.rp-triage-row{display:grid; grid-template-columns:1fr 1fr; gap:12px;}
.rp-canned{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:4px;}

@media (max-width:480px){
  .rp-triage-row{grid-template-columns:1fr;}
  .rp-tile-l{font-size:var(--fs-2xs);}
  .rp-new-btn{width:100%;}
}
@media (prefers-reduced-motion:reduce){
  .rp-img-loading{animation:none;}
}

/* ---- round 2: select-to-delete bar, save buttons, templates, danger zone ---- */
.rp-select-btn{width:auto; padding:9px 16px; font-size:var(--fs-sm);}
.rp-selbar{position:sticky; bottom:12px; z-index:3; display:flex; align-items:center; gap:10px; flex-wrap:wrap; background:var(--black); color:#fff; border-radius:16px; padding:10px 14px; margin-top:16px; box-shadow:0 8px 24px rgba(18,18,18,0.25);}
.rp-selbar #rp-sel-count{flex:1; min-width:120px; font-size:var(--fs-sm); font-weight:700;}
.rp-selbar .chip{background:transparent; color:#fff; border-color:rgba(255,255,255,0.35);}
.rp-sel-del{width:auto; padding:9px 16px; font-size:var(--fs-sm); border-radius:12px; border:none; background:var(--coral); color:#fff; font-weight:700; cursor:pointer; display:inline-flex; align-items:center; gap:6px; font-family:inherit;}
.rp-sel-del:disabled{opacity:0.4; cursor:not-allowed;}
.rp-sel-del svg{width:15px; height:15px;}
.rp-save-btn{width:auto; padding:6px 14px; font-size:var(--fs-sm); margin-top:8px; transition:background 160ms ease, color 160ms ease, border-color 160ms ease;}
.rp-save-btn.rp-saved{background:var(--success-bg); border-color:var(--success); color:var(--success);}
.rp-link-btn{background:none; border:none; font:inherit; font-size:var(--fs-sm); font-weight:700; color:var(--info); cursor:pointer; padding:6px 2px;}
.rp-link-btn:active{opacity:0.6;}
.rp-link-danger{color:var(--danger);}
.rp-tpl-head{display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin:14px 0 8px;}
.rp-tpl-panel{background:var(--card); border:1px solid var(--line); border-radius:16px; padding:14px; margin:10px 0 4px; display:flex; flex-direction:column; gap:12px;}
.rp-tpl-panel[hidden]{display:none;}
.rp-tpl-title{font-weight:800; font-size:var(--fs-base);}
.rp-tpl-item{display:flex; flex-direction:column; gap:8px; padding-bottom:12px; border-bottom:1px dashed var(--line);}
.rp-tpl-new{border-bottom:none; background:rgba(18,18,18,0.03); border-radius:12px; padding:12px;}
.rp-tpl-actions{display:flex; align-items:center; gap:14px;}
.rp-tpl-actions .rp-save-btn{margin-top:0;}
.rp-danger-zone{margin-top:36px; padding-top:18px; border-top:1px solid var(--line);}
@media (max-width:859px){
  .rp-selbar{bottom:92px;} /* clear the mobile bottom nav */
}
