/* ============================================================================
   Catalyst Content Studio
   ----------------------------------------------------------------------------
   Light and editorial. White surfaces, generous whitespace, hairline rules and
   soft shadows; the page reads like a printed weekly rather than a dashboard.

   Three colour decisions, held consistently:

     NAVY  (--navy) is voice — headings, nav text, the serif display face.
     AMBER (--amber) is attention — the active tab, the today chip, progress.
                     It is the ONLY accent, which is what makes it work.
     BLUE  (--blue) is action — links and the things you press.

   The post previews are dark navy artwork. They sit in white cards precisely
   so they pop; the chrome staying quiet is what makes the content loud.

   Mobile-first throughout. The real workflow is one person on a phone saving
   an image and pasting a caption into Instagram, so touch targets stay 44px
   and every layout starts at one column.
   ========================================================================== */

:root {
  /* ---- brand, from brand/tokens.json ---- */
  --navy: #072B5E;
  --navy-deep: #04193F;
  --navy-soft: #0E3A73;
  --blue: #083678;
  --blue-bright: #0495C9;
  --amber: #E8A33D;
  --amber-deep: #B87716;
  --ok: #2E9E6B;
  --bad: #D25B5B;

  /* ---- surfaces ---- */
  --bg: #FBFCFD;
  --surface: #FFFFFF;
  --surface-2: #F4F7FA;
  --surface-3: #EAF1F7;

  /* Hairlines. Tinted with the navy rather than neutral grey, so the whole
     page sits in one colour family instead of looking like white plus grey. */
  --line: rgba(7, 43, 94, .09);
  --line-strong: rgba(7, 43, 94, .16);

  --ink: #12203A;
  --ink-2: #3D4C68;
  --muted: #5B6B85;
  --faint: #8C99AD;

  /* Soft and low. A hard shadow on a white page reads as a modal. */
  --shadow-sm: 0 1px 2px rgba(7, 43, 94, .05);
  --shadow: 0 1px 2px rgba(7, 43, 94, .04), 0 8px 24px rgba(7, 43, 94, .06);
  --shadow-lg: 0 4px 12px rgba(7, 43, 94, .08), 0 24px 60px rgba(7, 43, 94, .14);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --pill: 999px;

  --tap: 44px;
  /* Every control in the top bar resolves to this height. They were drifting
     to 40, 44 and 46px independently, which read as sloppy at a glance. */
  --control-h: 42px;

  /* Georgia rather than a webfont: it echoes the serif in the post templates,
     it is on every machine this will ever open on, and it costs nothing to
     load — which matters on the connection this is actually used over. */
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  font: 16px/1.6 var(--sans);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

img, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }

a { color: var(--blue); text-decoration-color: rgba(8, 54, 120, .3); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Not applicable right now: keeps its footprint, cannot be clicked. Hiding
   these re-flowed the whole header and the view switch visibly jumped. */
.is-off { opacity: .3; pointer-events: none; filter: saturate(.3); }

/* ============================================================================
   type
   ========================================================================== */

.eyebrow {
  display: block;
  font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--amber-deep);
}

/* ============================================================================
   buttons
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 18px;
  font: 600 14.5px/1 var(--sans);
  border: 1px solid var(--line-strong);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }

.btn--primary {
  background: var(--blue); border-color: var(--blue); color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { background: #0A4090; border-color: #0A4090; }

.btn--ghost {
  background: transparent; border-color: var(--line-strong); color: var(--ink-2);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn--ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn--ok:hover { background: #268A5C; border-color: #268A5C; }

.btn--bad { background: transparent; border-color: rgba(210, 91, 91, .45); color: var(--bad); }
.btn--bad:hover { background: rgba(210, 91, 91, .08); }

.btn--wide { flex: 1; }
.btn--sm { min-height: 38px; padding: 0 15px; font-size: 13.5px; }

/* Sign out is used once a session — quiet it so it does not compete with the
   controls people actually reach for. */
#logout { border-color: transparent; color: var(--muted); }
#logout:hover { color: var(--ink); background: var(--surface-2); }

/* ============================================================================
   pills
   ========================================================================== */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .005em;
  padding: 5px 11px; border-radius: var(--pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill--ok { color: #1F7A50; border-color: rgba(46, 158, 107, .3); background: rgba(46, 158, 107, .09); }
.pill--warn { color: var(--amber-deep); border-color: rgba(232, 163, 61, .38); background: rgba(232, 163, 61, .12); }
.pill--bad { color: #A94141; border-color: rgba(210, 91, 91, .32); background: rgba(210, 91, 91, .09); }

/* ============================================================================
   loading bar
   ========================================================================== */

.loadbar {
  position: fixed; inset: 0 0 auto 0; height: 2px; z-index: 60;
  background: transparent; pointer-events: none;
  opacity: 0; transition: opacity .2s ease;
}
.loadbar::after {
  content: ''; display: block; height: 100%; width: 34%;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  transform: translateX(-100%);
}
body.is-loading .loadbar { opacity: 1; }
body.is-loading .loadbar::after { animation: sweep 1.15s cubic-bezier(.4, 0, .2, 1) infinite; }

@keyframes sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============================================================================
   run banner — a build happening on another machine
   ========================================================================== */

.runbar {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px calc(10px) 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: linear-gradient(180deg, #FDF6E9, #FBF1DC);
  border-bottom: 1px solid rgba(232, 163, 61, .35);
  color: #6B4A11;
  font-size: 13.5px; font-weight: 550;
}
.runbar--bad {
  background: linear-gradient(180deg, #FCF0F0, #F9E8E8);
  border-bottom-color: rgba(210, 91, 91, .35);
  color: #8A3A3A;
}
.runbar__dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--amber);
  animation: pulse 1.6s ease-in-out infinite;
}
.runbar--bad .runbar__dot { background: var(--bad); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.runbar__text { flex: 1; min-width: 0; }
.runbar__link { color: inherit; font-weight: 650; }
.runbar__close {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 6px; opacity: .6;
}
.runbar__close:hover { opacity: 1; }
body.has-runbar .topbar { top: 0; }

/* ============================================================================
   top bar
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr;
  gap: 13px;
}

.topbar__brand { display: flex; align-items: center; gap: 11px; }
.topbar__names { min-width: 0; }

/* The mark: a small navy disc with the brand's cyan arc through it. Enough to
   read as a logo at 34px without pretending to be the real artwork. */
.mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, .5) 0 12%, transparent 40%),
    conic-gradient(from 210deg, var(--blue-bright) 0 22%, var(--navy) 22% 100%);
  box-shadow: 0 2px 8px rgba(7, 43, 94, .22);
}

.topbar h1 {
  font: 700 18px/1.15 var(--serif);
  letter-spacing: -.005em;
  color: var(--navy);
}
.sub { font-size: 11.5px; color: var(--muted); letter-spacing: .01em; }

.topbar__right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.field { display: flex; align-items: center; }
.field select {
  font: 620 14px/1 var(--sans);
  height: var(--control-h);
  padding: 0 34px 0 16px;
  border-radius: var(--pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%235B6B85' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px;
}
.field select:hover { background-color: var(--surface-2); }

/* ---- the view switch ---- */

.segmented {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--pill);
  overflow-x: auto;
  scrollbar-width: none;
}
.segmented::-webkit-scrollbar { display: none; }
.segmented__btn {
  flex: 1;
  min-height: 36px; padding: 0 16px;
  border: 0; border-radius: var(--pill);
  background: transparent;
  font: 620 14px/1 var(--sans);
  color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: color .15s ease, background .15s ease;
}
/* :not(--on) is load-bearing. `.segmented__btn:hover` is a class plus a
   pseudo-class, so it outranks the plain `.segmented__btn--on` modifier and
   repaints the SELECTED tab in the unselected colour the moment the pointer
   touches it. The same trap has shipped three times in this file. */
.segmented__btn:not(.segmented__btn--on):hover { color: var(--navy); }
/* The active tab is the one place amber does its main job. */
.segmented__btn--on {
  background: var(--surface);
  color: var(--navy);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  position: relative;
}
.segmented__btn--on::after {
  content: ''; position: absolute; left: 50%; bottom: 5px; translate: -50% 0;
  width: 16px; height: 2px; border-radius: 2px; background: var(--amber);
}

/* ---- countdown + spend ---- */

.countdown {
  display: flex; align-items: baseline; gap: 6px;
  height: var(--control-h); padding: 0 14px;
  border-radius: var(--pill);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.countdown b { color: var(--navy); font-weight: 700; }
.countdown small { font-size: .78em; font-weight: 600; color: var(--faint); margin-left: 1px; }
.countdown__label { font-size: 11px; color: var(--faint); }

.cost {
  display: flex; align-items: center;
  height: var(--control-h); padding: 0 14px;
  border-radius: var(--pill);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cost--over { color: var(--amber-deep); border-color: rgba(232, 163, 61, .4); background: rgba(232, 163, 61, .1); }

/* ============================================================================
   review progress
   ========================================================================== */

.progress {
  padding: 14px 16px 0;
  max-width: 1180px; margin: 0 auto;
}
.progress__bar {
  height: 5px; border-radius: var(--pill);
  background: var(--surface-3); overflow: hidden;
}
.progress__fill {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--amber), #F0BC68);
  border-radius: var(--pill);
  transition: width .4s cubic-bezier(.4, 0, .2, 1);
}
.progress__text { margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* ============================================================================
   day chips
   ========================================================================== */

.daybar {
  display: flex; gap: 8px;
  padding: 16px;
  max-width: 1180px; margin: 0 auto;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.daybar::-webkit-scrollbar { display: none; }

.daychip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  flex: 1 0 auto; min-width: 72px; min-height: var(--tap);
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font: 650 14px/1 var(--sans);
  color: var(--muted);
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
/* Same trap, and here it was invisible text rather than a wrong shade: the
   selected chip is navy with white type, and an unguarded hover set the label
   to navy — on navy. */
.daychip:not(.daychip--on):hover { border-color: var(--line-strong); color: var(--navy); }
.daychip--on {
  background: var(--navy); border-color: var(--navy); color: #fff;
  box-shadow: var(--shadow-sm);
}
.daychip--on .daychip__now { color: var(--amber); }
/* Today gets the amber ring whether or not it is the day you are on. */
.daychip--today { border-color: rgba(232, 163, 61, .55); }
.daychip--today.daychip--on { border-color: var(--amber); }
.daychip__day { letter-spacing: .01em; }
.daychip__now {
  font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber-deep);
}
.daychip__dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.daychip__dot--posted, .daychip__dot--approved { background: var(--ok); }
.daychip__dot--rejected { background: var(--bad); }
.daychip--on .daychip__dot { background: rgba(255, 255, 255, .35); }
.daychip--on .daychip__dot--posted, .daychip--on .daychip__dot--approved { background: #6BD8A6; }
.daychip--on .daychip__dot--rejected { background: #F09292; }

.daynote {
  max-width: 1180px; margin: 0 auto;
  padding: 0 16px 4px;
  font-size: 13px; color: var(--muted); font-style: italic;
}

/* ============================================================================
   board
   ========================================================================== */

.board {
  display: grid;
  gap: 18px;
  padding: 18px 16px 40px;
  max-width: 1180px; margin: 0 auto;
  grid-template-columns: 1fr;
}
.board--single { max-width: 620px; }
.board--all { max-width: 1000px; }

/* ============================================================================
   card
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .2s ease, opacity .2s ease;
}
.card--busy { opacity: .55; pointer-events: none; }
.card--rejected { opacity: .72; }
/* State reads as a hairline down the leading edge, not a wash of colour over
   somebody's artwork. */
.card--posted, .card--approved { border-left: 3px solid var(--ok); }
.card--rejected { border-left: 3px solid var(--bad); }
.card--blocked { border-left: 3px solid var(--bad); }
.card--error { border-left: 3px solid var(--amber); }

.card__head { padding: 18px 20px 14px; }
.card__topic {
  margin-top: 6px;
  font: 600 21px/1.28 var(--serif);
  letter-spacing: -.005em;
  color: var(--navy);
}
.card--wide .card__topic { font-size: 24px; }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.card__body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.card__foot {
  display: flex; gap: 10px;
  padding: 0 20px 20px;
}

/* ============================================================================
   preview carousel
   ========================================================================== */

.preview {
  position: relative;
  background: var(--surface-3);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* The scroll snapper. behavior:'auto' is used for programmatic scrolling on
   purpose — smooth scrolling is silently reverted by the snap engine, which
   leaves the carousel one slide behind the label. */
.preview__frame {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  aspect-ratio: 4 / 5;
}
.preview__frame::-webkit-scrollbar { display: none; }
.preview--video .preview__frame { aspect-ratio: 9 / 16; max-height: 78vh; }

.preview__item {
  flex: 0 0 100%;
  scroll-snap-align: center;
  display: grid; place-items: center;
  background: var(--navy-deep);
  overflow: hidden;
}
.preview__item img, .preview__item video {
  width: 100%; height: 100%; object-fit: contain;
}
.preview__item--zoomable { cursor: zoom-in; }

.preview__role {
  position: absolute; left: 12px; bottom: 12px;
  padding: 5px 11px; border-radius: var(--pill);
  background: rgba(4, 25, 63, .72);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 11px; font-weight: 650; letter-spacing: .02em;
  pointer-events: none;
}

/* ---- prev / next ---- */
.nav {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--navy);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: .9;
  transition: opacity .15s ease;
}
.nav:hover { opacity: 1; }
.nav:disabled { opacity: 0; pointer-events: none; }
.nav--prev { left: 10px; }
.nav--next { right: 10px; }

/* ---- slide rail ---- */
.rail {
  display: flex; gap: 8px;
  padding: 12px;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.rail::-webkit-scrollbar { display: none; }
.rail__item {
  flex: 0 0 auto;
  border-radius: 9px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: border-color .15s ease, opacity .15s ease;
  line-height: 0;
}
.rail__item--on { border-color: var(--amber); }
.rail__item--muted { opacity: .45; }
.rail__go {
  border: 0; padding: 0; background: var(--surface-3);
  width: 46px; height: 58px;
  cursor: pointer; display: block;
}
.rail__go img { width: 100%; height: 100%; object-fit: cover; }

/* ---- the two buttons that matter ---- */
.assetbar {
  display: flex; gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

/* ---- a post whose images did not publish ---- */
.preview--none { background: var(--surface-2); }
.nopub {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  padding: 44px 28px;
  /* Proportioned like the frame it stands in for, so the card still reads as
     "a post", but capped: there is no image here to need the room, and a
     full-height 4:5 void on a wide Day view is a screen of nothing. */
  aspect-ratio: 4 / 5;
  max-height: 360px;
  background:
    repeating-linear-gradient(135deg,
      transparent 0 11px, rgba(7, 43, 94, .028) 11px 22px),
    var(--surface-2);
}
.nopub__icon { color: var(--faint); }
.nopub__head {
  font: 600 17px/1.3 var(--serif);
  color: var(--navy);
  max-width: 22ch;
}
.nopub__why { font-size: 13.5px; color: var(--muted); max-width: 34ch; }

/* On an error card it is a block inside the body, not a frame. */
.nopub--error {
  aspect-ratio: auto;
  padding: 24px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(232, 163, 61, .3);
  background: rgba(232, 163, 61, .07);
}

/* ============================================================================
   the failed image placeholder (media.js)
   ========================================================================== */

.imgfail {
  width: 100%; height: 100%; min-height: 80px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 0; cursor: pointer;
  padding: 14px;
  background: linear-gradient(150deg, #EEF3F9, #E2EBF4);
  color: var(--faint);
  text-align: center;
}
.imgfail__icon { line-height: 0; }
.imgfail__role {
  font-size: 11.5px; font-weight: 650; color: var(--muted);
}
.imgfail__hint { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; }

/* A failure we have a still for — the cover frame behind, the words legible
   over it. */
.imgfail--poster {
  background-size: cover; background-position: center;
  color: rgba(255, 255, 255, .85);
  position: relative;
}
.imgfail--poster::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(4, 25, 63, .58);
}
.imgfail--poster > * { position: relative; }
.imgfail--poster .imgfail__role { color: #fff; }
/* In a 46px rail thumbnail there is no room for words. */
.rail__go .imgfail { padding: 4px; }
.rail__go .imgfail__role, .rail__go .imgfail__hint { display: none; }
.daycell__thumb .imgfail__hint { display: none; }
.pickcell .imgfail__role, .pickcell .imgfail__hint { display: none; }

/* ============================================================================
   caption block
   ========================================================================== */

.hook {
  font: 600 17px/1.42 var(--serif);
  color: var(--navy);
}
.captionblock { display: flex; flex-direction: column; gap: 10px; }
.caption {
  font-size: 15px; line-height: 1.62; color: var(--ink-2);
  white-space: pre-wrap;
}
.caption--full {
  font: 13px/1.6 var(--mono);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  white-space: pre-wrap; word-break: break-word;
  color: var(--ink-2);
  max-height: 460px; overflow: auto;
}
.tags { font-size: 13.5px; color: var(--blue); word-break: break-word; }
.caption-toggle {
  align-self: flex-start;
  border: 0; background: transparent;
  padding: 4px 0;
  font: 620 13px/1 var(--sans);
  color: var(--blue);
  cursor: pointer;
}
.caption-toggle:hover { text-decoration: underline; }

/* ============================================================================
   research provenance
   ========================================================================== */

.research {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 12px 14px;
  font-size: 13.5px;
}
.research > summary {
  cursor: pointer; list-style: none;
  font-weight: 620; color: var(--muted);
}
.research > summary::-webkit-details-marker { display: none; }
.research > summary::before {
  content: '▸'; display: inline-block; margin-right: 7px;
  color: var(--faint); transition: rotate .15s ease;
}
.research[open] > summary::before { rotate: 90deg; }
.research--week {
  max-width: 1180px; margin: 0 auto; width: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.research__list { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); }
.research__list li { margin-bottom: 5px; line-height: 1.5; }
.research__link { font-size: 12px; font-weight: 620; }
.research__note { margin-top: 8px; font-size: 12.5px; color: var(--muted); font-style: italic; }

/* ============================================================================
   market brief (WS6 mount)
   ========================================================================== */

.brief {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 24px;
}
.brief__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.brief__window { font-size: 12px; color: var(--faint); }
.brief__headline {
  margin-top: 8px;
  font: 600 23px/1.25 var(--serif);
  color: var(--navy);
}
.brief__summary { margin-top: 10px; font-size: 15px; line-height: 1.62; color: var(--ink-2); }
.brief__points { margin: 12px 0 0; padding-left: 20px; color: var(--ink-2); font-size: 14.5px; }
.brief__points li { margin-bottom: 5px; }

/* ============================================================================
   flags
   ========================================================================== */

.flags { display: flex; flex-direction: column; gap: 8px; }
.flag {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.5;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.flag b {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted);
}
.flag--block { border-color: rgba(210, 91, 91, .32); background: rgba(210, 91, 91, .07); }
.flag--block b { color: #A94141; }
.flag--warn { border-color: rgba(232, 163, 61, .34); background: rgba(232, 163, 61, .08); }
.flag--warn b { color: var(--amber-deep); }
.flag__why { flex-basis: 100%; font-size: 12px; color: var(--muted); font-style: italic; }
.flag__fix {
  margin-left: auto;
  border: 1px solid var(--line-strong); border-radius: var(--pill);
  background: var(--surface); color: var(--ink-2);
  padding: 5px 12px; font: 620 12px/1 var(--sans); cursor: pointer;
}
.flag__fix:hover { background: var(--surface-2); }
.flag__fix:disabled { opacity: .5; cursor: default; }

.fixednote { font-size: 12.5px; color: var(--muted); }
.fixednote > summary { cursor: pointer; }
.fixednote__list { margin: 8px 0 0; padding-left: 18px; }

/* ============================================================================
   per-post tools
   ========================================================================== */

.tools {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.tools__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 9px;
}
.tools__row { display: flex; flex-wrap: wrap; gap: 8px; }
.tools__select {
  min-height: 38px; padding: 0 32px 0 14px;
  font: 620 13.5px/1 var(--sans);
  border: 1px solid var(--line-strong); border-radius: var(--pill);
  background: var(--surface); color: var(--ink-2);
  cursor: pointer; appearance: none;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%235B6B85' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 10px;
  max-width: 100%;
}

/* ---- inline editor ---- */
.editor {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.editor__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint);
  margin-top: 6px;
}
.editor__row { display: flex; gap: 8px; margin-top: 12px; }

.note {
  width: 100%;
  font: 14.5px/1.55 var(--sans);
  color: var(--ink);
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  resize: vertical;
}
.note::placeholder { color: var(--faint); }

.notewrap { display: flex; flex-direction: column; gap: 8px; }
.notewrap .note { display: none; }
.notewrap--open .note { display: block; }
.notewrap--open .notewrap__open { display: none; }
.notewrap__open {
  align-self: flex-start;
  border: 0; background: transparent; padding: 4px 0;
  font: 620 13px/1 var(--sans); color: var(--blue); cursor: pointer;
}
.notewrap__open:hover { text-decoration: underline; }

/* ============================================================================
   empty, error and saved-copy states
   ========================================================================== */

.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; text-align: center;
  padding: 56px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  grid-column: 1 / -1;
}
.empty__icon {
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--surface-3);
  color: var(--navy-soft);
  margin-bottom: 2px;
}
.empty__head {
  font: 600 19px/1.3 var(--serif);
  color: var(--navy);
  max-width: 30ch;
}
.empty__why { font-size: 14px; color: var(--muted); max-width: 42ch; }
.empty__actions { display: flex; gap: 10px; margin-top: 8px; }
.empty--bad .empty__icon { background: rgba(210, 91, 91, .1); color: var(--bad); }

.stale {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border: 1px solid rgba(232, 163, 61, .35);
  border-radius: var(--radius-sm);
  background: rgba(232, 163, 61, .09);
  color: #6B4A11;
  font-size: 13.5px;
}
.stale__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex: none; }
.stale__text { flex: 1; min-width: 0; }
.stale__action {
  border: 1px solid rgba(232, 163, 61, .5); border-radius: var(--pill);
  background: rgba(255, 255, 255, .7); color: #6B4A11;
  padding: 5px 13px; font: 650 12.5px/1 var(--sans); cursor: pointer;
}
.stale__action:hover { background: #fff; }
.stale__action:disabled { opacity: .55; cursor: default; }
.stale__close {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 19px; line-height: 1; padding: 2px 5px; opacity: .55;
}
.stale__close:hover { opacity: 1; }

/* ============================================================================
   skeletons
   ========================================================================== */

.skeleton { pointer-events: none; }
.sk {
  display: block;
  border-radius: 7px;
  background: linear-gradient(100deg,
    var(--surface-2) 30%, var(--surface-3) 50%, var(--surface-2) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
@keyframes shimmer {
  0%   { background-position: 130% 0; }
  100% { background-position: -130% 0; }
}
.sk--eyebrow { width: 120px; height: 10px; }
.sk--title { width: 78%; height: 20px; margin-top: 12px; }
.sk--frame { width: 100%; aspect-ratio: 4 / 5; border-radius: 0; }
.sk--frame-tall { aspect-ratio: 4 / 5; }
.sk--btn { height: var(--control-h); flex: 1; border-radius: var(--pill); }
.sk--btn-narrow { flex: 0 0 130px; }
.sk--line { height: 13px; width: 100%; }
.sk--line-short { width: 58%; }
.sk--cell { aspect-ratio: 3 / 4; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  .sk { animation: none; background: var(--surface-2); }
  .loadbar::after { animation: none; width: 100%; transform: none; opacity: .5; }
  .runbar__dot { animation: none; }
  * { scroll-behavior: auto !important; }
}

/* ============================================================================
   history
   ========================================================================== */

.histnote {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px; color: var(--muted);
}

.weekrow {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.weekrow--expiring { border-color: rgba(232, 163, 61, .4); }
.weekrow__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.histmeta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.histactions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.weekrow__grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.daycell {
  display: flex; flex-direction: column; gap: 6px;
  padding: 0 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer; text-align: left;
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.daycell:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.daycell--posted, .daycell--approved { border-left: 3px solid var(--ok); }
.daycell--rejected { border-left: 3px solid var(--bad); opacity: .7; }
.daycell__thumb {
  aspect-ratio: 4 / 5;
  background: var(--surface-3);
  overflow: hidden;
}
.daycell__thumb img { width: 100%; height: 100%; object-fit: cover; }
.daycell__day {
  padding: 0 10px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--amber-deep);
}
.daycell__topic {
  padding: 0 10px;
  font: 600 13.5px/1.35 var(--serif);
  color: var(--navy);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================================================
   sheets (bottom sheet on a phone, centred dialog on a desktop)
   ========================================================================== */

.sheet {
  position: fixed; inset: 0; z-index: 70;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(7, 25, 55, .42);
  backdrop-filter: blur(3px);
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.sheet__panel {
  width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  animation: rise .24s cubic-bezier(.32, .72, 0, 1);
}
@keyframes rise { from { transform: translateY(18px); opacity: .6; } }
.sheet__panel--narrow { max-width: 460px; }

.sheet__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 18px;
}
.sheet__title {
  margin-top: 6px;
  font: 600 22px/1.25 var(--serif);
  color: var(--navy);
}
.sheet__close {
  border: 0; background: var(--surface-2); cursor: pointer;
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  font-size: 20px; line-height: 1; color: var(--muted);
}
.sheet__close:hover { background: var(--surface-3); color: var(--ink); }
.sheet__foot { display: flex; gap: 10px; margin-top: 18px; }
.sheet__note { margin-top: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* ---- share picker ---- */
.pickgrid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
}
.pickcell {
  position: relative;
  aspect-ratio: 4 / 5;
  border: 2px solid var(--amber);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
  cursor: pointer; padding: 0;
  transition: opacity .15s ease, border-color .15s ease;
}
.pickcell img { width: 100%; height: 100%; object-fit: cover; }
.pickcell--off { opacity: .35; border-color: var(--line-strong); }
.pickcell__n {
  position: absolute; left: 5px; top: 5px;
  min-width: 19px; height: 19px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(4, 25, 63, .78);
  color: #fff; font-size: 11px; font-weight: 650;
}

/* The Redo rows and the one-shot ask bar stood here. Both belonged to the
   stub components/chat.js used to be; the conversation panel at the end of
   this file replaced them, and nothing references either any more. */

/* ---- plan list ---- */
.planlist { display: flex; flex-direction: column; gap: 8px; }
.planrow {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.planrow__day {
  flex: none; width: 38px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--amber-deep);
}
.planrow__mid { flex: 1; min-width: 0; }
.planrow__topic { font: 600 15px/1.35 var(--serif); color: var(--navy); }
.planrow__angle { margin-top: 2px; font-size: 12.5px; color: var(--muted); }

/* ============================================================================
   full-screen viewer
   ========================================================================== */

.viewer {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(4, 18, 44, .97);
  display: grid;
  grid-template-rows: auto 1fr;
  animation: fade .18s ease;
}
.viewer__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  color: rgba(255, 255, 255, .9);
}
.viewer__title { font-size: 13.5px; font-weight: 600; letter-spacing: .01em; }
.viewer__tools { display: flex; align-items: center; gap: 6px; }
.viewer__btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff; font-size: 17px; line-height: 1;
  cursor: pointer;
}
.viewer__btn:hover { background: rgba(255, 255, 255, .16); }
.viewer__btn:disabled { opacity: .3; cursor: default; }
.viewer__btn--close { background: rgba(255, 255, 255, .16); }
.viewer__level {
  min-width: 48px; text-align: center;
  font-size: 12px; font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, .7);
}

.viewer__stage {
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  touch-action: none;
  cursor: grab;
}
.viewer--zoomed .viewer__stage { cursor: grab; }
.viewer__img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none; -webkit-user-drag: none;
}

.viewer__nav {
  position: absolute; top: 50%; translate: 0 -50%;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer;
}
.viewer__nav:hover { background: rgba(255, 255, 255, .2); }
.viewer__nav--prev { left: 14px; }
.viewer__nav--next { right: 14px; }
/* Panning around a zoomed image should not be interrupted by two big targets
   sitting over the middle of it. */
.viewer--zoomed .viewer__nav { opacity: 0; pointer-events: none; }

.viewer__hint {
  position: absolute; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  translate: -50% 0;
  padding: 7px 15px; border-radius: var(--pill);
  background: rgba(255, 255, 255, .12);
  color: rgba(255, 255, 255, .85);
  font-size: 12px; white-space: nowrap;
  transition: opacity .5s ease;
  pointer-events: none;
}
.viewer__hint--gone { opacity: 0; }

/* ============================================================================
   toast
   ========================================================================== */

.toast {
  position: fixed; left: 50%; translate: -50% 0;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: var(--pill);
  background: var(--navy);
  color: #fff;
  font-size: 14px; font-weight: 550; text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(10px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast--show { opacity: 1; transform: translateY(0); }

/* ============================================================================
   login
   ========================================================================== */

.login-body {
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(4, 149, 201, .1), transparent 60%),
    var(--bg);
}
.login { width: 100%; max-width: 400px; }
.login__card {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; text-align: center;
  padding: 40px 32px 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.login__mark {
  width: 46px; height: 46px; border-radius: 50%;
  margin-bottom: 6px;
  background:
    radial-gradient(circle at 32% 30%, rgba(255, 255, 255, .5) 0 12%, transparent 40%),
    conic-gradient(from 210deg, var(--blue-bright) 0 22%, var(--navy) 22% 100%);
  box-shadow: 0 3px 12px rgba(7, 43, 94, .25);
}
.login__title {
  font: 700 27px/1.15 var(--serif);
  letter-spacing: -.01em;
  color: var(--navy);
}
.login__sub { font-size: 14px; color: var(--muted); max-width: 30ch; }
.login__form { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 20px; }
.login__input {
  width: 100%; min-height: 48px;
  padding: 0 18px;
  font: 16px/1 var(--sans);
  text-align: center; letter-spacing: .04em;
  border: 1px solid var(--line-strong);
  border-radius: var(--pill);
  background: var(--surface-2);
  color: var(--ink);
}
.login__input::placeholder { color: var(--faint); letter-spacing: normal; }
.login__input:focus { background: var(--surface); }
.login__form .btn { min-height: 48px; }
.login__error {
  margin-top: 14px;
  font-size: 13.5px; color: var(--bad);
}

/* ============================================================================
   wider screens
   ========================================================================== */

@media (min-width: 700px) {
  .board { gap: 22px; padding: 22px 24px 56px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .progress, .daybar, .daynote { padding-left: 24px; padding-right: 24px; }

  /* The sheet stops being a sheet and becomes a dialog. */
  .sheet { align-items: center; padding: 24px; }
  .sheet__panel {
    border-radius: var(--radius-lg);
    padding-bottom: 24px;
    max-height: 86vh;
  }
  @keyframes rise { from { transform: translateY(10px) scale(.99); opacity: .6; } }
}

@media (min-width: 900px) {
  .board:not(.board--single):not(.board--all) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (min-width: 1150px) {
  /* Everything fits on one line, so the header becomes one line. */
  .topbar {
    grid-template-columns: auto auto 1fr;
    align-items: center;
    gap: 20px;
  }
  .topbar__right { justify-content: flex-end; }
  .segmented { overflow: visible; }
  .segmented__btn { flex: 0 0 auto; }

  .board:not(.board--single):not(.board--all) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- newsletters view ---- */

/* ============================================================================
   The monthly letter is a document, not a post, so it does not get the tall
   4:5 artwork card the feed uses. It gets a ROW: the story graphic small on
   the leading edge, the title where a headline belongs, and the three things
   you do with a letter — open it, copy its link, copy its caption — lined up
   underneath at a full touch target.

   Same palette as everything above it: white surface, navy serif heading,
   amber only where something wants attention.
   ========================================================================== */

.letters__intro {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.letters__words { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.letters__lede { font-size: 13.5px; color: var(--muted); max-width: 52ch; }
/* Everything you can press in this view clears the thumb target, including
   the ones the shared .btn sizes to the tighter control height. */
.letters__intro .btn,
.letter__actions .btn { min-height: var(--tap); }

/* ---- waiting on a build machine somewhere else ---- */

.letters__pending {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border: 1px solid rgba(232, 163, 61, .38);
  background: rgba(232, 163, 61, .1);
  border-radius: var(--radius);
  font-size: 13.5px; color: var(--amber-deep);
}
.letters__pulse {
  flex: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  animation: letterpulse 1.6s ease-in-out infinite;
}
@keyframes letterpulse { 50% { opacity: .25; } }

/* ---- one issue ---- */

.letter {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.letter:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }

/* 9:16, because that is what a story graphic is. Narrow enough that the title
   beside it still gets most of a phone's width. */
.letter__thumb {
  flex: none; width: 76px;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-3);
}
.letter__thumb img { width: 100%; height: 100%; object-fit: cover; }
/* The retry hint does not fit in a strip this narrow; the tap target does. */
.letter__thumb .imgfail { width: 100%; height: 100%; }
.letter__thumb .imgfail__hint { display: none; }

.letter__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.letter__title {
  font: 600 19px/1.28 var(--serif);
  letter-spacing: -.005em;
  color: var(--navy);
}
.letter__meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.letter__facts { font-size: 13px; color: var(--muted); }

.letter__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
/* On the narrowest phones the three buttons would otherwise break one to a
   line with a ragged edge; letting them grow fills the row instead. */
.letter__actions .btn { flex: 1 1 auto; }

/* ---- the loading placeholder, in the same shape ---- */

.letter.skeleton .letter__thumb { background: var(--surface-3); }
.letter.skeleton .letter__main > .sk { display: block; }

/* ---- the caption sheet ---- */

.letter-caption { display: flex; flex-direction: column; gap: 10px; }
.letter-caption .caption--full { max-height: 46vh; overflow-y: auto; }
.letter-caption__bad { font-size: 13.5px; color: var(--bad); }

@media (min-width: 700px) {
  .letter { gap: 20px; padding: 20px; }
  .letter__thumb { width: 96px; }
  .letter__title { font-size: 21px; }
  /* Room for all three at their natural width, so they stop stretching. */
  .letter__actions .btn { flex: 0 0 auto; }
}

/* ---- market brief ---- */

/* The "Last week in the market" panel, above the week grid.
   It keeps the card chrome declared for .brief further up this file — white
   surface, amber edge, full grid width — and adds the three things the panel
   itself needs: a lid that opens, a row of stat chips that wraps on a phone,
   and a story list whose links are the point of the whole panel.

   Quiet by design. This sits above five loud post cards and is read only when
   someone wants to check a number, so nothing in here competes with them. */

.brief__head {
  cursor: pointer;
  list-style: none;
  gap: 8px 10px;
}
.brief__head::-webkit-details-marker { display: none; }
.brief__head::before {
  content: '▸';
  color: var(--faint);
  transition: rotate .15s ease;
}
.brief[open] > .brief__head::before { rotate: 90deg; }

/* The card headline is a lid here rather than a title over prose, so it sits on
   the summary's own line instead of below it. */
.brief__head .brief__headline {
  margin-top: 0;
  font-size: 19px;
}
.brief__head:hover .brief__headline { color: var(--navy-soft); }

/* Window and counts, on their own line, indented under the headline: which
   seven days this covers and how much is inside, without opening it. */
.brief__sub {
  flex-basis: 100%;
  padding-left: 20px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
}
.brief__count { font-size: 12px; color: var(--muted); }
.brief__dot { color: var(--line-strong); }

.brief__body { margin-top: 14px; display: flex; flex-direction: column; gap: 18px; }
.brief__body > .brief__summary { margin-top: 0; }

.brief__label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint);
}

/* ---- stat chips ----
   Mobile-first: one chip per row on a phone, two or three as the card widens.
   The basis is what does the wrapping, so no breakpoint has to know how many
   series a week happened to fetch. */

.brief__stats { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 9px; }
.brief__stat {
  flex: 1 1 200px; min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 11px 13px;
}
.brief__stat-label {
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  line-height: 1.35;
  color: var(--muted);
}
.brief__stat-row {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px;
  margin-top: 5px;
}
.brief__stat-value { font: 600 22px/1.1 var(--serif); color: var(--navy); }
.brief__delta {
  font-size: 12.5px; font-weight: 620;
  color: var(--ink-2);
  white-space: nowrap;
}
.brief__delta--flat { color: var(--faint); }
.brief__arrow { font-size: 10px; }
.brief__stat-meta { margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--faint); }
.brief__src { font-size: 12px; font-weight: 620; }

/* ---- stories ---- */

.brief__stories {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 13px;
}
.brief__story { padding-left: 12px; border-left: 2px solid var(--surface-3); }
.brief__story-title { font-size: 14.5px; font-weight: 620; line-height: 1.45; }
span.brief__story-title { color: var(--ink); }
.brief__story-meta { margin-top: 3px; font-size: 12px; color: var(--faint); }
.brief__story-sum { margin-top: 5px; font-size: 13.5px; line-height: 1.55; color: var(--ink-2); }

/* ---- what was missing ----
   Small, muted, and last. Never hidden: on a week with no key these lines are
   the only account of why the numbers above are absent. */

.brief__notes { padding-top: 12px; border-top: 1px solid var(--line); }
.brief__note { font-size: 12px; line-height: 1.5; color: var(--muted); font-style: italic; }
.brief__note + .brief__note { margin-top: 4px; }

@media (max-width: 480px) {
  .brief { padding: 18px 16px; }
  .brief__head .brief__headline { font-size: 17px; }
  .brief__stat-value { font-size: 20px; }
}

/* ---- chat panel ---- */

/* One post, one conversation (public/js/components/chat.js).
 *
 * The shell is the existing sheet — same scrim, same Escape handling, same
 * bottom-sheet entrance on a phone — with one structural difference: the panel
 * itself does not scroll, the THREAD inside it does. That is what keeps the
 * composer on screen with the keyboard up, which is the posture this is
 * actually used in. Wide enough, it stops being a sheet and becomes a
 * right-hand rail, so the card it is about stays visible beside it.
 */

.sheet--chat .chat {
  display: flex;
  flex-direction: column;
  height: 86vh;
  max-height: 86vh;
  overflow: hidden;
  /* Each section carries its own padding, so the thread's scrollbar sits at
     the panel edge rather than floating in a gutter. */
  padding: 0;
}

.chat__head {
  flex: none;
  margin-bottom: 0;
  padding: 16px 20px 13px;
  border-bottom: 1px solid var(--line);
}
.chat__titles { min-width: 0; }
.chat__title {
  margin-top: 4px;
  font-size: 19px;
  /* A topic is a sentence, not a label: two lines, then an ellipsis. */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.chat__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

.chat__thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 16px 20px 10px;
}

.chat__foot {
  flex: none;
  padding: 10px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.chat__hosted {
  margin-top: 9px;
  font-size: 11.5px; line-height: 1.5;
  color: var(--faint);
}

/* ---- messages ---- */

.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg--user { align-self: flex-end; align-items: flex-end; }
.msg--ai { align-self: flex-start; align-items: flex-start; }

.msg__bubble {
  padding: 10px 14px;
  border-radius: 17px;
  font: 14.5px/1.55 var(--sans);
  /* Replies have paragraphs in them, and a long URL in one must not push the
     panel sideways. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--user .msg__bubble {
  background: var(--blue); color: #fff;
  border-bottom-right-radius: 6px;
}
.msg--ai .msg__bubble {
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
/* Something went wrong and the reason IS the message. It reads as an answer,
   because it is one — just not the answer they wanted. */
.msg--bad .msg__bubble {
  background: rgba(210, 91, 91, .08);
  border-color: rgba(210, 91, 91, .28);
  color: #A94141;
}

/* What the turn actually moved, in the pipeline's own words. */
.msg__applied {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 7px; padding-left: 2px;
}
.msg__applied-label {
  font: 650 10px/1 var(--sans);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--faint);
}
.applied {
  padding: 3px 9px;
  border-radius: var(--pill);
  font: 500 11.5px/1.5 var(--sans);
  color: #1F7A50;
  background: rgba(46, 158, 107, .09);
  border: 1px solid rgba(46, 158, 107, .3);
}

/* ---- a change running somewhere else ---- */

.buildpill {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px; padding: 7px 13px;
  border-radius: var(--pill);
  font: 500 12px/1.4 var(--sans);
  color: var(--amber-deep);
  background: rgba(232, 163, 61, .12);
  border: 1px solid rgba(232, 163, 61, .34);
}
.buildpill__dot {
  width: 7px; height: 7px; flex: none;
  border-radius: 50%;
  background: currentColor;
  animation: chat-pulse 1.6s ease-in-out infinite;
}
.buildpill__link { color: inherit; font-weight: 650; white-space: nowrap; }
.buildpill--done {
  color: #1F7A50;
  background: rgba(46, 158, 107, .09);
  border-color: rgba(46, 158, 107, .3);
}
.buildpill--failed, .buildpill--lost {
  color: #A94141;
  background: rgba(210, 91, 91, .08);
  border-color: rgba(210, 91, 91, .28);
}
/* Scrollback about a build that ended hours ago. A spinner on it would be a
   claim that we are still watching something. */
.buildpill--past {
  color: var(--muted);
  background: var(--surface-2);
  border-color: var(--line);
}
.buildpill--done .buildpill__dot,
.buildpill--failed .buildpill__dot,
.buildpill--lost .buildpill__dot,
.buildpill--past .buildpill__dot { animation: none; }

@keyframes chat-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* ---- waiting ---- */

.msg__bubble--typing { display: flex; align-items: center; gap: 5px; padding: 14px; }
.typing__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--faint);
  animation: chat-typing 1.2s ease-in-out infinite;
}
.typing__dot:nth-child(2) { animation-delay: .15s; }
.typing__dot:nth-child(3) { animation-delay: .3s; }

@keyframes chat-typing {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1; transform: translateY(-3px); }
}

.chatsk { height: 40px; border-radius: 17px; }

/* ---- nothing said yet, and notes this browser added ---- */

.chat__empty { margin: auto 0; padding: 4px 2px 18px; }
.chat__empty-head { font: 600 17px/1.3 var(--serif); color: var(--navy); }
.chat__empty-why {
  margin-top: 7px;
  font-size: 13.5px; line-height: 1.6;
  color: var(--muted);
}
.chat__note {
  align-self: center; max-width: 92%;
  padding: 6px 13px;
  border-radius: var(--pill);
  background: var(--surface-2);
  font-size: 11.5px; line-height: 1.5; text-align: center;
  color: var(--muted);
}

/* ---- quick actions ----
 *
 * Every chip sends ordinary text through the same POST the box does, so a chip
 * and a typed sentence are the same kind of turn. 38px matches .btn--sm, the
 * touch target the card's own tools row already uses; the send button and the
 * composer keep the full 44px.
 */
.chat__chips { padding-bottom: 9px; }
.chat__chiprow { display: flex; flex-wrap: wrap; gap: 7px; }
.chat__chiprow--looks { margin-top: 7px; }

.qchip {
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--ink-2);
  font: 500 13px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.qchip:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.qchip:active:not(:disabled) { transform: translateY(1px); }
.qchip:disabled { opacity: .45; cursor: default; transform: none; }
.qchip--more { color: var(--blue); border-color: rgba(8, 54, 120, .28); }
.qchip--look { background: var(--surface-2); }

/* ---- composer ---- */

.composer { display: flex; align-items: flex-end; gap: 8px; }
.composer__input {
  flex: 1; min-width: 0;
  min-height: var(--tap); max-height: 128px;
  padding: 11px 16px;
  /* 16px exactly: below that, iOS zooms the whole page when the box takes
     focus, and the panel this sits in is used on a phone. */
  font: 16px/1.4 var(--sans);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--surface-2);
  resize: none;
  overflow-y: auto;
}
.composer__input::placeholder { color: var(--faint); }
.composer__input:focus { background: var(--surface); }
.composer__input:disabled { opacity: .6; }

.composer__go {
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: 50%;
  background: var(--blue); color: #fff;
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.composer__go:hover:not(:disabled) { background: #0A4090; }
.composer__go:disabled { opacity: .4; cursor: default; }

/* ---- the rail ---- */

@media (min-width: 700px) {
  .sheet--chat {
    align-items: stretch;
    justify-content: flex-end;
    padding: 0;
  }
  .sheet--chat .chat {
    width: min(440px, 100%);
    max-width: 440px;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: 0;
    box-shadow: -6px 0 44px rgba(7, 43, 94, .16);
    animation: chat-slide .24s cubic-bezier(.32, .72, 0, 1);
  }
}

@keyframes chat-slide { from { transform: translateX(22px); opacity: .5; } }

@media (prefers-reduced-motion: reduce) {
  .sheet--chat .chat { animation: none; }
  .buildpill__dot, .typing__dot { animation: none; }
  .typing__dot { opacity: .55; transform: none; }
}
