/* Soft Editorial, part two: the larger shared components, built on the
   tokens in app.css: panels (a white surface with a hairline, no
   shadow), callouts, the activity list, empty states, the drop zone,
   fields, the sheet and toast, the signed-out card, avatars, and the tile
   grid the upload panel and the client's page share. Loaded by
   index.html straight after app.css.

   Not everything is a panel. A screen puts its working area on a
   surface (the Files panel, the deliveries list, the token list) and
   leaves the reading parts on the paper (Activity, a lede, an empty
   state).

   The narrow-screen block at the end is last on purpose: at 820px its
   rules must beat the ties above it (.sheet.narrow against .sheet). */

/* --- panels, callouts, the two-column layout, activity ------------ */

.panel{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius-l);padding:var(--panel-pad);min-width:0}
.panel > h2,.panel-head{margin-bottom:var(--space-4)}
.panel-head{display:flex;align-items:center;gap:var(--space-2)}
.panel-head h2{flex:1;min-width:0}
/* A list inside a panel runs to the panel's edges; its rows carry the
   padding. */
.panel .list{margin-inline:calc(-1 * var(--panel-pad))}
.panel > .list:last-child{margin-bottom:calc(-1 * var(--panel-pad))}
/* A section on the paper: a heading and its content, no box. */
.section > h2{margin-bottom:var(--space-3)}
.cols{display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:var(--space-6);align-items:start}
.stack{display:flex;flex-direction:column;gap:var(--space-6)}

.callout{background:var(--warning-bg);border:0;border-radius:var(--radius-control);padding:12px 16px;font:400 var(--text-ui)/20px var(--font-sans);color:var(--ink);max-width:68ch}
.callout.teal{background:var(--accent-tint)}   /* the accent: a note about choosing or picking up where you left off */
.callout.info{background:var(--info-bg)}       /* information: a heads-up that asks for no choice */
.callout.red{background:var(--danger-bg)}
.callout b{font-weight:500}
.callout > .s{margin-top:var(--space-1);overflow-wrap:anywhere;color:var(--ink2)}
.callout > .s + .btn{margin-top:var(--space-3)}
.callout p{margin:6px 0 14px;font-size:var(--text-l)}
.callout p.s{font-size:var(--text-m)}
/* The panel of js/page-guard.js drawn where the whole page would be (a
   script of the app did not arrive): there is no page around it to give it
   room. */
.page-problem{max-width:560px;margin:12vh auto 0;padding:0 var(--space-4)}

/* Activity: a quiet timeline on the paper. The dot spans in the markup
   stay hidden: the words say what happened. */
.tl{list-style:none;margin:0;padding:0}
.tl li{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;padding:10px 0;border-top:1px solid var(--line);font:400 var(--text-m)/18px var(--font-sans);color:var(--ink2)}
.tl li:first-child{border-top:0;padding-top:0}
/* A line can carry a name nobody chose for us (a file a stranger sent),
   so it may break anywhere rather than push the page sideways. */
.tl li > span{display:flex;justify-content:space-between;gap:12px;min-width:0;overflow-wrap:anywhere}
.tl li::before,.tl .dot{display:none}
.tl .when2{grid-column:2;grid-row:1;color:var(--mute);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.when2{display:block;color:var(--mute);font-size:var(--text-m)}
.linkrow{display:flex;gap:var(--space-2);align-items:stretch}
.linkrow .text{flex:1;min-width:0}

/* --- empty states, the drop zone ---------------------------------- */

.empty{display:grid;justify-items:start;gap:var(--space-2);max-width:440px;margin:0;padding:0;text-align:left;color:var(--ink2)}
.empty b{font:400 var(--text-3xl)/1.15 var(--font-display);letter-spacing:-.012em;color:var(--ink)}
.empty p{margin:0;max-width:52ch;font:400 var(--text-l)/24px var(--font-sans);color:var(--ink2)}
.empty .btn{margin-top:var(--space-3)}
.empty-icon{display:none}
/* On the client's page the empty note sits under the title, not against
   it. */
.rc-files > .empty{margin-top:var(--space-6)}
.empty.inline{display:block;padding:0;max-width:none;color:var(--mute)}
.empty.inline,.panel .empty.inline{font-size:var(--text-ui)}
/* The drop zone answers a drag: its edge turns accent and its ground
   tints while files hover over it. */
.drop{display:flex;flex-direction:column;align-items:flex-start;gap:var(--space-2);border:1.5px dashed var(--line-strong);border-radius:var(--radius-l);background:var(--bg);padding:48px 32px;text-align:left;cursor:pointer;color:var(--ink2);transition:border-color var(--dur-fast),background-color var(--dur-fast)}
.drop b{font:400 var(--text-2xl)/28px var(--font-display);color:var(--ink)}
.drop:hover{border-color:var(--ink2)}
.drop.over{border-color:var(--accent);background:var(--accent-tint)}
.drop-icon,.drop > svg{display:none}

/* --- fields ------------------------------------------------------- */

.field{display:block;margin-top:var(--space-4)}
.field:first-child,.sheet .body > .field:first-of-type{margin-top:0}
.lbl{display:block;font:500 var(--text-m)/18px var(--font-sans);color:var(--ink2);margin-bottom:6px}
.lbl .s{font-weight:400;color:var(--mute)}
.hint{display:block;margin-top:6px;font:400 var(--text-m)/18px var(--font-sans);color:var(--mute)}
.text,textarea,select{width:100%;height:var(--control);padding:0 12px;background:var(--surface);border:1px solid var(--field-line);border-radius:var(--radius-control);font:400 var(--input-font)/20px var(--font-sans);color:var(--ink);transition:border-color var(--dur-fast),box-shadow var(--dur-fast)}
.text:hover,textarea:hover,select:hover{border-color:var(--ink2)}
/* Focus is the accent edge and a soft accent ring: the field you type in
   is never in doubt. */
.text:focus,textarea:focus,select:focus{outline:0;border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-tint)}
.text[aria-invalid=true],.text:user-invalid,textarea[aria-invalid=true]{border-color:var(--red);box-shadow:0 0 0 3px var(--danger-bg)}
::placeholder{color:var(--mute)}
textarea{height:auto;min-height:88px;padding:8px 12px;resize:vertical}
select{appearance:none;padding-right:30px;background-image:var(--select-caret);background-repeat:no-repeat;background-position:right 12px center}
.text[readonly]{background:var(--sunken);border-color:transparent;font:400 var(--text-m)/18px var(--font-mono);color:var(--ink2);text-overflow:ellipsis}
.err{font:400 var(--text-m)/18px var(--font-sans);color:var(--red);margin-top:6px}
/* A checked box is an accent square with a white tick drawn as a mask-free
   SVG background: the same tick every check in the app uses. */
input[type=checkbox]{appearance:none;flex:none;width:18px;height:18px;margin:0;border:1.5px solid var(--field-line);border-radius:var(--radius-s);background:var(--surface) center/12px no-repeat;cursor:pointer;transition:background-color var(--dur-fast),border-color var(--dur-fast)}
input[type=checkbox]:checked{border-color:var(--accent);background-color:var(--accent);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")}
@media (forced-colors:active){input[type=checkbox]:checked{background-color:CanvasText;forced-color-adjust:none}}
input[type=radio]{width:16px;height:16px;accent-color:var(--accent)}
.checks{border:0;padding:0;margin-left:0;margin-right:0}
.checks legend{padding:0;margin-bottom:var(--space-1)}
.check{display:flex;gap:var(--space-3);align-items:flex-start;padding:8px 0;font-size:var(--text-ui);cursor:pointer}
/* flex:none: a wrapping label must not squeeze the box (13px on a phone) */
.check input{margin-top:1px;flex:none}
.check b{display:block;font-weight:500}
.check .s{display:block}

/* --- overlays: sheet and toast ------------------------------------ */

/* The scrim fades in (180ms); the sheet rises 8px as it fades (220ms), so
   it reads as arriving from the page, not appearing on top of it. */
.overlay{position:fixed;inset:0;background:var(--scrim);display:flex;align-items:flex-start;justify-content:center;padding:12vh var(--space-4) var(--space-4);z-index:50;animation:fade var(--dur) var(--ease-out)}
.sheet{background:var(--surface);width:100%;max-width:560px;border:1px solid var(--line);border-radius:var(--radius-sheet);box-shadow:var(--shadow-overlay);display:flex;flex-direction:column;max-height:86vh;animation:rise var(--dur-slow) var(--ease-out)}
.sheet.narrow{max-width:460px}
.sheet header{display:flex;align-items:center;gap:var(--space-3);padding:var(--sheet-pad) var(--sheet-pad) 4px}
.sheet header h2{flex:1}
/* A title wrapped in a div (with its sub line) takes the room too, or the
   close button sits beside it instead of at the sheet's edge. One rule for
   every sheet, not a copy in each. */
.sheet header > div{flex:1;min-width:0}
/* A sheet that is a form wraps its header, body and buttons in the <form>,
   which becomes the flex item between the sheet and its body. Left as a
   plain block it grows to fit everything and the sheet's cap on its height
   cuts the buttons off in a short window; as a flex column that may shrink
   it passes the cap on, and the body scrolls. One rule for every sheet,
   not a copy in each. */
.sheet > form{display:flex;flex-direction:column;min-height:0}
.sheet > form > .body{flex:1 1 auto;min-height:0}
.sheet-sub{margin:4px 0 0;font:400 var(--text-m)/18px var(--font-sans);color:var(--mute)}
.sheet .body{padding:16px var(--sheet-pad) var(--sheet-pad);overflow:auto;-webkit-overflow-scrolling:touch}
.sheet footer{display:flex;align-items:center;justify-content:flex-end;gap:var(--space-3);padding:16px var(--sheet-pad);border-top:1px solid var(--line2);background:var(--bg);border-radius:0 0 var(--radius-sheet) var(--radius-sheet)}
.sheet footer .hint{flex:1;margin:0;min-width:0}
.sheet footer .hint:empty{display:none}
/* The toast rises into place: it confirms the thing you just did.
   width:max-content: at left:50% the box may only grow to the right half
   of the window, so a sentence of a dozen words would wrap in a 195px
   column on a phone; it takes the width its words need, up to the window
   less 32px. */
.toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;align-items:center;gap:var(--space-2);background:var(--ink);color:var(--bg);font:500 var(--text-m)/18px var(--font-sans);padding:12px 16px;border-radius:var(--radius-control);z-index:90;box-shadow:var(--shadow-overlay);animation:toast-in var(--dur-slow) var(--ease-out);width:max-content;max-width:calc(100% - 32px)}
.toast.bad{background:var(--solid-danger);color:var(--on-photo)}
.toast.bad::before{content:none}
@keyframes toast-in{from{opacity:0;transform:translate(-50%,8px)}}

/* --- the signed-out card, avatars --------------------------------- */

.rv{min-height:100dvh;display:flex;flex-direction:column;align-items:center;padding:0 var(--space-4) var(--space-7)}
.rv.auth{padding-top:clamp(48px,14vh,160px)}
.rcard{width:100%;max-width:400px;background:none;border:0;border-radius:0;padding:0;margin:0}
.rcard .brand{padding:0;margin-bottom:var(--space-6)}
.rcard h1{font:400 var(--text-4xl)/1.1 var(--font-display);letter-spacing:-.018em}
/* The lockup lives here, not on the framed contexts: "Signing you in" and
   "This link no longer works" draw it with no split frame around it.
   The gap is the lockup's half cap (.334em) from the flap's edge to the T,
   less the mark box's own margin (.083em) and the T's side bearing
   (.026em): .224em. */
.brand{display:flex;align-items:center;gap:.224em;font:500 21px/24px var(--font-display);letter-spacing:-.01em;color:var(--ink);text-decoration:none}
.from{display:flex;align-items:center;gap:var(--space-3);margin-bottom:var(--space-5);font-size:var(--text-ui)}
.from b{display:block}
/* An avatar is a rounded square: a person, not a badge. */
.avatar{width:34px;height:34px;border-radius:var(--radius-s);display:grid;place-items:center;font:500 var(--text-s)/1 var(--font-sans);background:var(--sunken);color:var(--ink2);box-shadow:inset 0 0 0 1px var(--line);flex:none}
.avatar.lg{width:52px;height:52px;font-size:18px;border-radius:var(--radius-control)}

/* A person's Gravatar, drawn over their initials by avatarHtml() in
   person-picture.js. Until it loads, and when there is none, the initials
   show. */
:root{--avatar-small:24px; --avatar-medium:28px}
.avatar{position:relative;overflow:hidden}
.avatar img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;display:block;border-radius:inherit}
.avatar-small{width:var(--avatar-small);height:var(--avatar-small);font-size:11px;border-radius:5px}
.avatar-medium{width:var(--avatar-medium);height:var(--avatar-medium);font-size:var(--text-s)}
.who-with-avatar{display:flex;align-items:center;gap:var(--space-3);min-width:0}
.user-row > .who-with-avatar{flex:1 0 100%}

/* --- the tile grid: the upload panel and the client's page -------- */

.bar{height:4px;background:var(--line2);border-radius:var(--radius-s);overflow:hidden}
/* Progress eases toward its new value instead of jumping. */
.bar i{display:block;height:100%;background:var(--progress);border-radius:inherit;transition:width var(--dur-slow) var(--ease-out)}
.wgrid{flex:1;overflow:auto;padding:0 20px 28px;display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--tile),1fr));gap:var(--space-2);align-content:start;-webkit-overflow-scrolling:touch}
.tile{position:relative;aspect-ratio:3/2;border-radius:var(--radius-control);background:var(--sunken)}
.tile img{width:100%;height:100%;object-fit:contain;display:block}

/* --- narrow screens ------------------------------------------------ */

@media (max-width:820px){
 .cols{grid-template-columns:minmax(0,1fr);gap:var(--space-6)}
 .overlay{padding:0;align-items:flex-end}
 .sheet,.sheet.narrow{max-width:none;border-radius:var(--radius-sheet) var(--radius-sheet) 0 0;border-bottom:0;max-height:calc(100% - 24px - env(safe-area-inset-top,0px));padding-bottom:env(safe-area-inset-bottom,0px);animation-name:rise-far}
 .sheet footer{flex-wrap:wrap;border-radius:0}
 .sheet footer .hint{flex-basis:100%}
 .sheet footer .btn{flex:1}
 .toast{bottom:auto;top:calc(12px + env(safe-area-inset-top,0px))}
 .drop{padding:32px 20px}
}
@keyframes rise-far{from{transform:translateY(32px);opacity:.4}}
