.view-chat{flex:none;display:flex;flex-direction:column;height:calc(100vh - var(--header-h));min-height:520px;overflow:hidden}
.ed{position:relative;flex:1;display:flex;flex-direction:column;padding:20px 40px 16px;min-height:0;gap:12px;max-width:1440px;width:100%;margin:0 auto}
.tools{display:flex;gap:14px;flex:none}
.tool{
  flex:1;text-align:center;border:1.5px solid var(--plum-2);border-radius:999px;padding:10px 6px;font-weight:700;
  color:var(--plum);font-size:17px;background:#fff;transition:background .15s;white-space:nowrap
}
.tool:hover{background:#F7EFFA}
.tool.on{background:var(--lilac)}
.sheet{
  position:relative;flex:1;min-height:0;background:#fff;border-radius:6px;box-shadow:0 8px 22px rgba(60,40,20,.14);
  overflow:auto;padding:12px 12px 0;
}
.spreads{display:flex;flex-direction:column;align-items:center;gap:24px;padding-bottom:24px}
.spread{display:flex;gap:24px;justify-content:center;align-items:flex-start;--pz:1.48}
.spread .pg{zoom:var(--pz);box-shadow:0 1px 3px rgba(0,0,0,.15)}
.spread.pending{background:repeating-linear-gradient(135deg,#faf6f0,#faf6f0 10px,#f4efe6 10px,#f4efe6 20px);border-radius:3px}
.foot{
  position:absolute;left:52px;bottom:26px;background:rgba(60,60,60,.7);color:#fff;border-radius:6px;padding:6px 14px;
  font-weight:700;font-size:15px;z-index:4;pointer-events:none
}
.empty-note{padding:60px 20px;text-align:center;color:var(--ink-soft);font-size:18px}

/* floating panels under the tool buttons */
.panel{
  position:absolute;top:66px;width:300px;max-width:calc(100% - 24px);background:#fff;border:1.5px solid var(--plum-2);border-radius:6px;padding:14px;
  z-index:20;box-shadow:0 10px 24px rgba(0,0,0,.18);
}
.panel h4{font-size:15px;color:var(--plum);margin-bottom:10px}
.panel .r{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;font-weight:700;font-size:15px;color:var(--ink-soft)}
.panel .r label{display:flex;align-items:center;gap:4px;cursor:pointer;font-size:14px}
.panel .name{background:none;border:0;border-bottom:1.5px dashed transparent;font-weight:700;color:var(--ink-soft);font-size:15px;width:110px;outline:none;padding:2px}
.panel .name:hover,.panel .name:focus{border-bottom-color:var(--plum-2)}
.sw{display:flex;margin-bottom:12px}
.sw button{flex:1;height:26px;border:0;position:relative}
.sw button[aria-pressed="true"]::after{content:"✓";position:absolute;inset:0;display:grid;place-items:center;color:#fff;font-size:14px;text-shadow:0 0 2px rgba(0,0,0,.6)}
.panel .ghost-btn{display:flex;gap:6px;align-items:center;font-weight:700;color:var(--plum);font-size:14px;padding:4px 0}
.panel .avatar{width:28px;height:28px;border-radius:50%;object-fit:cover;background:#D4D8DA}
.panel .row2{display:flex;gap:8px;align-items:center;margin-bottom:10px}
.panel .row2 .in{margin:0;padding:6px 10px;font-size:15px}
.bg-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.bg-grid button{height:54px;border-radius:6px;border:2px solid #E1D6C4;font-size:12px;font-weight:700;color:#4A3B2C;display:flex;align-items:flex-end;justify-content:center;padding-bottom:3px;background-size:cover}
.bg-grid button[aria-pressed="true"]{border-color:var(--plum-2);box-shadow:0 0 0 2px #EBD9F2}
.seg{display:flex;border:1.5px solid var(--plum-2);border-radius:10px;overflow:hidden;margin-bottom:12px}
.seg button{flex:1;padding:6px;font-weight:700;color:var(--plum);font-size:14px;border-left:1px solid var(--plum-2)}
.seg button:last-child{border-left:0}
.seg button[aria-pressed="true"]{background:var(--lilac)}
.panel input[type=range]{width:100%;accent-color:var(--plum-2)}
.panel .hint{font-size:13px;color:var(--ink-soft);line-height:1.6;margin-top:6px}
.panel .btn{padding:8px 16px;font-size:14px}

.pop{position:fixed;z-index:60;background:#fff;border:1.5px solid var(--plum-2);border-radius:10px;box-shadow:0 10px 24px rgba(0,0,0,.2);padding:10px;display:flex;flex-direction:column;gap:8px;min-width:220px}
.pop textarea{width:100%;min-height:70px;border:1.5px solid #CDBFAE;border-radius:8px;padding:8px;font-size:15px;line-height:1.7}
.pop .acts{display:flex;gap:8px;flex-wrap:wrap}
.pop .acts .btn{padding:6px 14px;font-size:14px}
.pop .danger{background:#B0405A}

@media (max-width:900px){
  .ed{padding:12px 10px 10px}
  .tools{overflow-x:auto;gap:8px;padding-bottom:2px;-webkit-overflow-scrolling:touch}
  .tool{flex:none;padding:8px 16px;font-size:15px}
  .panel{right:10px !important;left:10px !important;width:auto;top:56px}
  .foot{left:22px;bottom:16px}
  .spread{flex-direction:column;align-items:center;gap:14px}
}

.editbar{position:absolute;left:50%;transform:translateX(-50%);bottom:24px;z-index:5;background:rgba(60,60,60,.85);color:#fff;border-radius:999px;padding:6px 8px 6px 16px;display:flex;align-items:center;gap:12px;font-weight:700;font-size:15px}
.editbar .btn{padding:6px 14px;font-size:14px}
.person{margin-bottom:6px}
.panel .sides{display:flex;gap:10px;align-items:center}
.panel .nm-wrap{display:flex;align-items:center;color:var(--ink-soft)}

.pv-link{position:absolute;right:52px;bottom:26px;background:var(--plum);color:#fff;border-radius:999px;padding:7px 18px;font-weight:700;font-size:15px;z-index:4;box-shadow:0 4px 12px rgba(0,0,0,.2)}
@media (max-width:900px){.pv-link{right:22px;bottom:16px}}

/* Mobile review 1: natural two-finger pinch, no zoom buttons. Display only. */
@media(max-width:900px){
 .sheet{touch-action:pan-x pan-y}
 .sheet.magnified .spreads{align-items:flex-start;width:max-content;min-width:100%}
}
/* Mobile review 2: every tool remains visible, with predictable panel placement. */
@media(max-width:900px){
 .tools-wrap{position:relative;flex:none}
 .tools{display:flex;gap:8px;overflow-x:auto;overflow-y:hidden;scroll-snap-type:x proximity;padding:0 26px 0 0;scrollbar-width:none}
 .tools::-webkit-scrollbar{display:none}
 .tool{flex:none;padding:9px 14px;font-size:13.5px;min-height:44px;scroll-snap-align:start;white-space:nowrap}
 .tools-hint{position:absolute;top:0;bottom:0;left:0;width:44px;display:flex;align-items:center;justify-content:flex-start;pointer-events:none;opacity:0;transition:opacity .15s;background:linear-gradient(90deg,var(--bg) 55%,rgba(241,235,224,0))}
 .tools-hint b{display:grid;place-items:center;width:26px;height:26px;border-radius:50%;background:#fff;border:1.5px solid var(--plum-2);color:var(--plum);font-size:16px;font-weight:800;box-shadow:0 2px 6px rgba(60,40,20,.18)}
 .tools-wrap.more .tools-hint{opacity:1}
 .tools-wrap.at-end .tools-hint{display:none}
 .ed:has(.tools) .panel{top:56px;max-height:calc(100dvh - 210px);overflow-y:auto}
}
/* Mobile review 3: use the measured header and reserve a real footer row. */
@media(max-width:900px){
 .view-chat{height:calc(100dvh - var(--editor-header,130px));min-height:0}
 .ed-bottom{display:flex;align-items:center;justify-content:space-between;gap:8px;flex:none;min-height:42px}
 .ed-bottom .foot,.ed-bottom .pv-link{position:static;font-size:12px;padding:8px 10px;white-space:nowrap}
 .ed-bottom .foot{border-radius:6px}
}
/* Mobile review 4: edit status has its own row, never covers the sheet. */
@media(max-width:900px){
 .editbar{position:static;transform:none;order:0;flex:none;justify-content:space-between;gap:8px;border-radius:10px;padding:6px 10px;font-size:12px}
 .editbar .btn{font-size:12px;padding:6px 10px;min-height:38px;white-space:nowrap}
 .editbar .cnt{white-space:nowrap}
 .ed:has(.editbar:not([hidden])) .panel{top:194px}
}

/* search */
.sx-seg{display:flex;gap:6px;margin-bottom:8px}
.sx-seg button{flex:1;border:1.5px solid var(--plum-2);border-radius:999px;background:#fff;color:var(--plum);font-weight:700;padding:8px 4px;min-height:40px}
.sx-seg button[aria-pressed=true]{background:var(--lilac)}
.sx-in{width:100%;margin-bottom:6px}
.sx-note{font-size:13px;color:var(--ink-soft);min-height:0;margin-bottom:6px}
.sx-list{display:flex;flex-direction:column;gap:6px;max-height:240px;overflow-y:auto}
.sx-item{display:flex;flex-direction:column;align-items:flex-start;text-align:right;gap:2px;border:1px solid #e6dcec;border-radius:8px;background:#fff;padding:8px 10px;min-height:44px}
.sx-item b{color:var(--plum);font-size:14px}
.sx-item span{font-size:13px;color:var(--ink-soft)}
.sx-item:hover{background:#F7EFFA}
@keyframes hit{0%,60%{box-shadow:0 0 0 3px #e8a317,0 0 18px 4px rgba(232,163,23,.55)}100%{box-shadow:0 0 0 0 rgba(232,163,23,0)}}
.hit{animation:hit 2.4s ease-out;outline-offset:2px}

.sx-item{flex-shrink:0}
