/* Product UI renders (built in HTML, not screenshots). Anything here that sits inside .wx-scope takes the
   client workspace's palette (see workspace.css), so every product surface on the page matches the dashboard. */

.app {
  position: relative; background: var(--sheet); border-radius: var(--r-xl); box-shadow: var(--sh-3);
  overflow: hidden; font-size: 13px; line-height: 1.4; color: var(--ink); isolation: isolate;
  display: grid; grid-template-rows: 44px 1fr; text-align: left;
}
.app-bar {
  display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--rule);
  background: color-mix(in srgb, var(--paper) 55%, var(--sheet)); font-size: 13px; color: var(--ink-2); white-space: nowrap; min-width: 0;
}
.app-bar .crumb { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; }
.app-bar .crumb b { font-weight: 500; color: var(--ink); }
.app-bar .crumb i { color: var(--ink-4); font-style: normal; }
.app-bar .sp { flex: 1; }
.app-bar .upd { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.app-bar .kbd { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); padding: 2px 6px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule-2); }
.app-body { display: grid; grid-template-columns: 176px 1fr; min-height: 0; }
.app--nosb .app-body { grid-template-columns: 1fr; }
.app--nosb .app-side { display: none; }

/* Sidebar */
.app-side { border-right: 1px solid var(--rule); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; background: color-mix(in srgb, var(--paper) 35%, var(--sheet)); }
.app-side h6 { margin: 10px 8px 4px; font: 500 11px/1 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.app-side a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: 7px; color: var(--ink-2); }
.app-side a svg { width: 14px; height: 14px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.5; }
.app-side a .n { margin-left: auto; font: 12px/1 var(--font-mono); color: var(--ink-3); }
.app-side a.on { background: var(--paper-3); color: var(--ink); font-weight: 500; }
.app-side .side-foot { margin-top: auto; padding: 10px 8px 2px; }
.app-side .side-foot .mini-btn { width: 100%; justify-content: center; }

/* Main */
.app-main { min-width: 0; display: flex; flex-direction: column; position: relative; }
.app-head { padding: 16px 18px 12px; display: grid; gap: 12px; }
.app-head .t { display: flex; align-items: baseline; gap: 10px; }
.app-head h5 { margin: 0; font-size: 14px; font-weight: 500; }
.app-head .sub { color: var(--ink-3); font-size: 12px; }
.counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--rule); overflow: hidden; }
.counter { padding: 10px 12px; border-left: 1px solid var(--rule); min-width: 0; }
.counter:first-child { border-left: 0; }
.counter b { display: block; font-size: 24px; line-height: 1.1; font-weight: 400; letter-spacing: -0.02em; }
.counter span { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.counter.hot b { color: var(--red); }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 0 18px 10px; flex-wrap: nowrap; overflow: hidden; }
.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--paper-2); }
.seg span { cursor: default; height: 26px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.seg span.on { background: var(--sheet); color: var(--ink); box-shadow: var(--sh-1); font-weight: 500; }
.seg svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.filt { height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 8px; font-size: 12px; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule); white-space: nowrap; }
.filt b { font-weight: 500; color: var(--ink); }
.filt.add { color: var(--ink-3); box-shadow: none; border: 1px dashed var(--rule-2); }
.mini-btn { height: 28px; display: inline-flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 8px; font-size: 12px; font-weight: 500; background: var(--sheet); box-shadow: inset 0 0 0 1px var(--rule-2); white-space: nowrap; }
.mini-btn.dark { background: var(--ink); color: var(--paper); box-shadow: none; }
.mini-btn svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* Table (database view) */
.tbl { position: relative; border-top: 1px solid var(--rule); overflow: hidden; flex: 1; }
.tr { display: grid; grid-template-columns: 34px minmax(0, 2.2fr) minmax(0, 1.3fr) 62px 84px 92px; align-items: center; min-height: 46px; border-bottom: 1px solid var(--rule); padding-right: 12px; background: var(--sheet); transition: background-color var(--dur-quick) var(--ease-out); }
.tr.th { min-height: 32px; background: color-mix(in srgb, var(--paper) 50%, var(--sheet)); font-size: 12px; color: var(--ink-3); }
.tr.th > div { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tr.th svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.5; }
.tr > div { padding: 0 8px; min-width: 0; }
.tr .cb { padding: 0 0 0 14px; }
.box { width: 15px; height: 15px; border-radius: 4px; box-shadow: inset 0 0 0 1.5px var(--rule-2); display: grid; place-items: center; transition: background-color var(--dur-quick), box-shadow var(--dur-quick); background: var(--sheet); }
.box svg { width: 11px; height: 11px; stroke: var(--paper); stroke-width: 2.2; fill: none; opacity: 0; transform: scale(.6); transition: opacity var(--dur-quick), transform var(--dur-quick) var(--ease-out); }
.tr.sel { background: var(--red-wash); }
.tr.sel .box { background: var(--ink); box-shadow: none; }
.tr.sel .box svg { opacity: 1; transform: none; }
.home b { display: block; font-weight: 500; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home small { display: block; font: 12px/1.3 var(--font-mono); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.why { display: inline-flex; max-width: 100%; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font: 12px/1 var(--font-mono); color: var(--red-ink); background: var(--red-wash); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.why.med { color: var(--ink-2); background: var(--paper-2); }
.d { font: 12px/1.2 var(--font-mono); color: var(--ink-2); white-space: nowrap; }
.d small { display: block; color: var(--ink-3); font-size: 11px; }
.tbl .fade { position: absolute; left: 0; right: 0; bottom: 0; height: 64px; background: linear-gradient(transparent, var(--sheet)); pointer-events: none; }

/* Map view */
.mapview { position: relative; flex: 1; min-height: 0; border-top: 1px solid var(--rule); background: var(--paper); overflow: hidden; }
.mapview canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mapview .legend { position: absolute; left: 14px; bottom: 14px; display: grid; gap: 6px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--sheet) 92%, transparent); box-shadow: var(--sh-1); font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 0; }
.legend .l-red { background: var(--red); } .legend .l-ink { background: var(--ink-2); } .legend .l-faint { background: var(--ink-4); }
.legend b { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 6px; }
.mapview .scale { position: absolute; right: 14px; bottom: 14px; font: 11px/1 var(--font-mono); color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.mapview .scale i { display: block; width: 52px; height: 6px; border: 1px solid var(--ink-3); border-top: 0; }
.mapview .attrib { position: absolute; right: 14px; bottom: 30px; font: 10px/1 var(--font-mono); color: var(--ink-3); }

/* Selection bar */
.selbar {
  position: absolute; left: 50%; bottom: 16px; z-index: 5; transform: translate(-50%, 140%); opacity: 0;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 12px;
  background: var(--ink); color: var(--paper); box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .45); font-size: 13px; white-space: nowrap;
  transition: transform var(--dur-enter) var(--ease-out), opacity var(--dur-quick);
}
.selbar.on { transform: translate(-50%, 0); opacity: 1; }
.selbar b { font-weight: 500; font-variant-numeric: tabular-nums; }
.selbar .mini-btn { background: color-mix(in srgb, var(--paper) 14%, var(--ink)); color: var(--paper); box-shadow: none; }
.selbar .mini-btn.red { background: var(--red); color: #fff; }

/* Cursor (demo pointer) */
.cursor { position: absolute; z-index: 8; width: 18px; height: 22px; left: 0; top: 0; pointer-events: none; opacity: 0;
  transition: transform 520ms var(--ease-out), opacity var(--dur-quick); filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.cursor.on { opacity: 1; }
.cursor svg { width: 100%; height: 100%; }

/* Letter */
.letter {
  position: absolute; z-index: 6; width: 300px; aspect-ratio: 210 / 297; background: var(--sheet); border-radius: 4px;
  box-shadow: 0 0 0 1px var(--rule), 0 30px 60px -20px rgba(18, 20, 23, .35); padding: 22px 22px 18px; font-size: 9.6px; line-height: 1.5; color: var(--ink-2);
  display: flex; flex-direction: column; gap: 9px;
}
.letter .lh { display: flex; justify-content: space-between; align-items: flex-start; }
.letter .logo-slot { width: 74px; height: 26px; border-radius: 4px; border: 1px dashed var(--rule-2); display: grid; place-items: center; font: 8px/1 var(--font-mono); color: var(--ink-3); letter-spacing: .06em; }
.letter .addr { font-family: var(--font-mono); font-size: 8.5px; color: var(--ink-3); text-align: right; line-height: 1.6; }
.letter .redact { display: inline-block; height: 7px; width: 62px; border-radius: 2px; background: var(--ink-4); vertical-align: -1px; }
.letter h6 { margin: 4px 0 0; font: 400 15px/1.15 var(--font-display); color: var(--ink); letter-spacing: -0.01em; }
.letter p { margin: 0; }
.letter .ft { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--rule); }
.letter .qr { width: 56px; height: 56px; }
.letter .batch { font: 8px/1.5 var(--font-mono); color: var(--ink-3); letter-spacing: .04em; }
.letter .batch b { color: var(--red-ink); font-weight: 500; }

/* Campaign (outcome) card */
.campaign { display: grid; gap: 14px; padding: 18px; }
.waffle { display: grid; grid-template-columns: repeat(50, 1fr); gap: 3px; }
.waffle i { aspect-ratio: 1; border-radius: 2px; background: var(--paper-3); transition: background-color 380ms var(--ease-out); }
.waffle i.hit { background: var(--red); }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; box-shadow: inset 0 0 0 1px var(--rule); border-radius: 12px; overflow: hidden; }
.kv > div { padding: 10px 12px; border-left: 1px solid var(--rule); }
.kv > div:first-child { border-left: 0; }
.kv b { display: block; font-size: 24px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; }
.kv span { font-size: 12px; color: var(--ink-3); }

/* Alert email */
.mail { background: var(--sheet); border-radius: var(--r-xl); box-shadow: var(--sh-3); overflow: hidden; font-size: 13px; color: var(--ink); text-align: left; }
.mail-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--ink-3); }
.mail-top .av { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--paper-2); }
.mail-top .from b { display: block; color: var(--ink); font-size: 13px; font-weight: 500; }
.mail-top .time { margin-left: auto; font-family: var(--font-mono); }
.mail-body { padding: 18px 18px 16px; display: grid; gap: 14px; }
.mail-body .kicker { font: 500 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--red-ink); display: flex; align-items: center; gap: 8px; }
.mail-body .kicker::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-wash); }
.mail-body h5 { margin: 0; font: 400 24px/1.12 var(--font-display); letter-spacing: -0.015em; color: var(--ink); }
.mail-body .desc { color: var(--ink-2); font-size: 13px; line-height: 1.55; padding: 10px 12px; border-left: 2px solid var(--red); background: color-mix(in srgb, var(--paper) 70%, var(--sheet)); border-radius: 0 8px 8px 0; }
.mail-body .facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--rule); overflow: hidden; }
.mail-body .facts div { padding: 9px 11px; border-left: 1px solid var(--rule); }
.mail-body .facts div:first-child { border-left: 0; }
.mail-body .facts span { display: block; font-size: 12px; color: var(--ink-3); }
.mail-body .facts b { font-weight: 500; font-size: 13px; }
.mail-body .row { display: flex; gap: 8px; flex-wrap: wrap; }

.app[data-live] .seg span[data-v] { cursor: pointer; }
.app[data-live] .seg span[data-v]:not(.on):hover { color: var(--ink); }

/* ---------- Hero film: command palette → agent pins on the map → reply → list, built in DOM ---------- */
.palette {
  position: absolute; z-index: 9; left: 50%; top: 64px; width: min(78%, 520px); transform: translate(-50%, -6px) scale(.98); opacity: 0;
  background: var(--sheet); border-radius: 14px; box-shadow: var(--sh-3); overflow: hidden; pointer-events: none;
  transition: opacity 200ms var(--ease-out), transform 300ms cubic-bezier(.16, 1, .3, 1);
}
.palette.on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.palette .pi { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 16px; font-size: 15px; border-bottom: 1px solid var(--rule); }
.palette .pi svg { width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 1.5; flex: none; }
.palette .pi .typed { color: var(--ink); white-space: nowrap; }
.palette .pi .ph { color: var(--ink-3); }
.palette .caret { width: 1.5px; height: 18px; background: var(--red); animation: caret 1s steps(1) infinite; }
.palette .ph-hint { display: flex; justify-content: space-between; padding: 9px 16px; font: 12px/1 var(--font-mono); color: var(--ink-3); }
.palette .ph-hint kbd { font: inherit; padding: 2px 6px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--rule-2); }
@keyframes caret { 50% { opacity: 0; } }
.pins { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.pin { position: absolute; display: flex; align-items: flex-start; gap: 7px; opacity: 0; transform: translateY(4px); filter: blur(2px);
  transition: opacity 300ms cubic-bezier(.16, 1, .3, 1), transform 300ms cubic-bezier(.16, 1, .3, 1), filter 300ms cubic-bezier(.16, 1, .3, 1); }
.pin.on { opacity: 1; transform: none; filter: none; }
.pin.dim { opacity: .4; }
.pin i { width: 7px; height: 7px; margin-top: 2px; border-radius: 50%; background: var(--ink); flex: none; position: relative; }
.pin.done i { box-shadow: 0 0 0 3px var(--sheet), 0 0 0 4.5px var(--red); }
.pin span { font: 500 10.5px/1.25 var(--font-mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink); white-space: nowrap; background: color-mix(in srgb, var(--paper) 80%, transparent); padding: 1px 3px; border-radius: 3px; }
.toast {
  position: absolute; z-index: 9; left: 50%; bottom: 18px; transform: translate(-50%, 10px); opacity: 0; filter: blur(2px);
  display: flex; align-items: center; gap: 10px; max-width: 90%; padding: 10px 14px; border-radius: 12px; background: var(--sheet); box-shadow: var(--sh-3);
  font-size: 13.5px; color: var(--ink); white-space: nowrap;
  transition: opacity 300ms cubic-bezier(.16, 1, .3, 1), transform 300ms cubic-bezier(.16, 1, .3, 1), filter 300ms cubic-bezier(.16, 1, .3, 1);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); filter: none; }
.toast .dotr { width: 8px; height: 8px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px var(--red-wash); flex: none; }
.app .tbl, .app .mapview { transition: opacity 400ms var(--ease-out); }
.app .fading { opacity: 0; }
.replay { font: 12px/1 var(--font-mono); color: var(--ink-3); display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; }
.replay:hover { color: var(--ink); }
.replay svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.6; }

/* the stage window carries a sidebar, so it drops the write-by column */
.app--stage .tr { grid-template-columns: 34px minmax(0, 2.4fr) minmax(0, 1.25fr) 60px 92px; }
.app--stage .tr > div:nth-child(5) { display: none; }

/* narrow windows: pins stack in a column, top-left, instead of floating over the map */
@container (max-width: 620px) {
  .pins { inset: 10px auto auto 10px; display: flex; flex-direction: column; gap: 5px; }
  .pin { position: static; }
  .pin span { font-size: 9.5px; }
  .palette { width: 90%; top: 54px; }
  .palette .pi { font-size: 14px; }
  .toast { white-space: normal; width: 88%; font-size: 13px; }
  .mapview .attrib { display: none; }
}

.mail-body .near { display: flex; align-items: center; gap: 6px; margin-top: -6px; font: 12px/1.3 var(--font-mono); color: var(--ink-3); }
.mail-body .near svg { width: 13px; height: 13px; stroke: var(--red); fill: none; stroke-width: 1.5; }

/* envelopes (SVG, drawn the right way up) */
.env { display: block; }
.env .env-body { fill: #FBFAF6; stroke: #D9D4C8; stroke-width: 1.2; }
.env .env-fold { fill: none; stroke: #E2DDD2; stroke-width: 1.2; }
.env .env-flap { fill: #F2EEE5; }
.env .env-flap-edge { fill: none; stroke: #D3CDBF; stroke-width: 1.2; stroke-linejoin: round; }
.env .env-logo { fill: none; stroke: #CFC8BA; stroke-width: 1; stroke-dasharray: 3 2; }
.env .env-t { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 6.5px; letter-spacing: .06em; fill: #8A857A; }
.env .env-postmark { fill: none; stroke: #B8B2A6; stroke-width: 1.1; }
.env .env-postmark text { fill: #9E978A; stroke: none; font-size: 5.6px; }
.env .env-stamp { fill: #FFFFFF; stroke: #D9B35E; stroke-width: 1.2; stroke-dasharray: 2.5 2; }
.env .env-stamp-in { fill: #FFF0CF; stroke: none; }
.env .env-stamp-t { fill: #8A4B04; font-size: 9px; font-weight: 600; letter-spacing: 0; }
.env .env-window { fill: #FFFFFF; stroke: #D9D4C8; stroke-width: 1.2; }
.env .env-addr { font-size: 7.5px; fill: #5D5D5D; }
.env .env-redact { fill: #E4E0D6; }
