/* Wishly OS campaign workspace.

   Contents
   Shared tokens live in theme.css.
   2. Base        page, type, focus
   3. Frame       top bar, page container, entry screens
   4. Controls    buttons, fields, search
   5. Surfaces    panels, banners, tags
   6. Campaigns   list and rows
   7. Campaign    page, activity
   8. Forms
   9. Motion
   10. Smaller screens */

/* 2. Base --------------------------------------------------------------- */
body { margin: 0; background: var(--app-bg); }
.os {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--app-bg);
  color: var(--app-text);
  font-family: var(--app-sans);
  font-size: var(--app-type-body);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
.os *, .os *::before, .os *::after { box-sizing: border-box; }
.os :is(h1, h2, p, dl, dd, ul, ol, fieldset, legend) { margin: 0; padding: 0; }
.os :is(ul, ol) { list-style: none; }
.os fieldset { border: 0; min-width: 0; }
:where(.os) :where(button, input, select, textarea) { font: inherit; color: inherit; }
.os [hidden] { display: none !important; }
.os :focus-visible { outline: 3px solid var(--app-focus); outline-offset: 2px; }
.os :is(h1, main, [role=alert])[tabindex="-1"]:focus-visible { outline: none; }

.os-sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
.os-display {
  font-family: var(--app-sans);
  font-size: var(--app-type-h1);
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -.02em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.os-h2 { font-size: var(--app-type-h3); font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.os-eyebrow {
  font-family: var(--app-sans);
  font-size: 12px; font-weight: 700; line-height: 1.4;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--app-muted);
  overflow-wrap: anywhere;
}
.os-lead { font-size: var(--app-type-lead); color: var(--app-muted); }
.os-muted, .os-note { color: var(--app-muted); }
.os-note { font-size: var(--app-type-small); margin: -6px 4px 0; }
.os-break { overflow-wrap: anywhere; }
.os-icon {
  flex: none; width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}

/* 3. Frame -------------------------------------------------------------- */
.os-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.os-skip {
  position: absolute; left: 12px; top: -80px; z-index: 30;
  min-height: var(--app-control); padding: 0 18px;
  border: 0; border-radius: var(--app-radius-pill);
  background: var(--app-text); color: var(--app-bg); font-weight: 700;
}
.os-skip:focus-visible { top: 10px; }

.os-top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--app-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--app-border);
  padding-top: env(safe-area-inset-top);
}
.os-top-inner {
  display: flex; align-items: center; gap: 12px;
  max-width: 1200px; margin: 0 auto;
  min-height: 64px;
  padding: 8px max(var(--app-pad-page), env(safe-area-inset-right)) 8px max(var(--app-pad-page), env(safe-area-inset-left));
}
.os-wordmark {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 0; padding: 6px 4px;
  border: 0; border-radius: 10px; background: none; cursor: pointer;
  font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -.045em;
  color: var(--app-text);
}
.os-wordmark img { border-radius: 9px; }
.os-account-nav { display: flex; align-items: center; gap: 2px; }
.os-account-nav a { text-decoration: none; }
.os-wordmark--gate { cursor: default; padding: 0; }
.os-top-workspace { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: auto; }
.os-workspace { min-width: 0; max-width: 280px; font-weight: 600; }
.os-workspace--only { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.os-role {
  flex: none; padding: 3px 10px; border-radius: var(--app-radius-pill);
  background: var(--app-soft); color: var(--app-muted);
  font-size: 12px; font-weight: 700;
}

.os-main {
  flex: 1; width: 100%; max-width: 1200px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: clamp(20px, 3vw, 36px) max(var(--app-pad-page), env(safe-area-inset-right)) calc(56px + env(safe-area-inset-bottom)) max(var(--app-pad-page), env(safe-area-inset-left));
}
.os-main:focus { outline: none; }
.os-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; }
.os-head > div:first-child { min-width: 0; display: grid; gap: 8px; }

.os-shell--gate { align-items: center; justify-content: center; padding: 24px; }
.os-gate, .os-gate .os-problem { display: grid; gap: 22px; justify-items: start; }
.os-gate {
  width: 100%; max-width: 560px;
  padding: clamp(28px, 6vw, 52px);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 32px;
  box-shadow: var(--app-shadow);
}
.os-gate--loading { background: none; border: 0; box-shadow: none; justify-items: center; }
.os-problem { display: grid; gap: 18px; justify-items: start; max-width: 640px; }
.os-loading { display: inline-flex; align-items: center; gap: 12px; color: var(--app-muted); font-weight: 600; }
.os-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid var(--app-border); border-top-color: var(--app-focus);
  animation: os-spin 800ms ease-in-out infinite;
}

/* 4. Controls ----------------------------------------------------------- */
.os-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--app-control); padding: 0 20px;
  border: 1px solid var(--app-border); border-radius: var(--app-radius-pill);
  background: var(--app-surface); color: var(--app-text);
  font-size: var(--app-type-body); font-weight: 700; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background var(--app-fast) var(--app-ease), border-color var(--app-fast) var(--app-ease), transform var(--app-fast) var(--app-ease);
}
.os-btn:hover { background: var(--app-soft); }
.os-btn:active { transform: scale(.98); }
.os-btn--primary { background: var(--app-primary); border-color: transparent; color: var(--app-primary-text); }
.os-btn--primary:hover { background: color-mix(in srgb, var(--app-primary) 86%, var(--app-primary-text)); }
.os-btn--quiet { background: none; border-color: transparent; color: var(--app-muted); padding: 0 14px; }
.os-btn--quiet:hover { color: var(--app-text); }
.os-btn--large { min-height: 52px; padding: 0 30px; font-size: var(--app-type-lead); }
.os-btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; transform: none; }
.os-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.os-back {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%; min-height: 40px; margin: -4px 0 -8px -10px; padding: 0 12px 0 8px;
  border: 0; border-radius: var(--app-radius-pill); background: none;
  color: var(--app-muted); font-weight: 600; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background var(--app-fast) var(--app-ease), color var(--app-fast) var(--app-ease);
}
.os-back:hover { background: var(--app-soft); color: var(--app-text); }

.os-link {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  color: var(--app-text); font-weight: 600; overflow-wrap: anywhere;
  text-decoration: underline; text-decoration-color: var(--app-focus);
  text-decoration-thickness: 2px; text-underline-offset: 3px;
  border-radius: 6px;
}
.os-link .os-icon { width: 15px; height: 15px; color: var(--app-muted); }

.os-input, .os-select {
  width: 100%; min-height: 48px; padding: 0 16px;
  border: 1px solid var(--app-border); border-radius: var(--app-radius-field);
  background: var(--app-surface); color: var(--app-text);
  font-size: 16px; line-height: 1.4;
  transition: border-color var(--app-fast) var(--app-ease), box-shadow var(--app-fast) var(--app-ease);
}
.os-input:hover, .os-select:hover { border-color: var(--app-muted); }
.os-input:focus-visible, .os-select:focus-visible {
  outline: none; border-color: var(--app-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--app-focus) 32%, transparent);
}
.os-input::placeholder { color: var(--app-muted); opacity: .8; }
.os-input--area { min-height: 76px; padding: 12px 16px; resize: vertical; }
.os-input[aria-invalid=true] { border-color: var(--app-text); }
.os-select {
  min-height: 40px; padding: 0 36px 0 14px; font-size: var(--app-type-body);
  appearance: none; cursor: pointer; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  border-radius: var(--app-radius-pill);
}

.os-search { display: flex; align-items: center; gap: 8px; }
.os-search-field { position: relative; flex: 1; min-width: 0; max-width: 520px; }
.os-search-field .os-icon { position: absolute; left: 16px; top: 50%; translate: 0 -50%; color: var(--app-muted); pointer-events: none; }
.os-search-field .os-input { padding-left: 44px; border-radius: var(--app-radius-pill); }

/* 5. Surfaces ----------------------------------------------------------- */
.os-panel {
  padding: var(--app-pad-card);
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius-card);
  box-shadow: var(--app-shadow);
}
.os-stack { display: grid; gap: var(--app-gap); align-content: start; min-width: 0; }
.os-panel > .os-h2, .os-panel > .os-eyebrow { margin-bottom: 14px; }

.os-banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 18px;
  border: 1px solid var(--app-border); border-radius: var(--app-radius-inner);
  background: var(--app-soft); font-weight: 600; overflow-wrap: anywhere;
}
.os-banner .os-icon { margin-top: 2px; }
.os-banner--notice { border-color: transparent; background: var(--app-soft); }
.os-banner--error { border-color: color-mix(in srgb, var(--app-text) 45%, transparent); background: var(--app-soft); color: var(--app-text); }
.os-banner--conflict { border: 2px solid var(--app-text); background: var(--app-surface); font-weight: 400; }
.os-banner--conflict > div { display: grid; gap: 8px; justify-items: start; }
.os-banner-title { font-weight: 700; font-size: var(--app-type-lead); }

.os-unknown {
  display: inline-block; padding: 1px 10px;
  border: 1px dashed var(--app-muted); border-radius: var(--app-radius-pill);
  color: var(--app-muted); font-size: var(--app-type-small); font-weight: 600; white-space: nowrap;
}
.os-tag {
  display: inline-block; margin-left: 8px; padding: 1px 9px;
  border-radius: var(--app-radius-pill); background: var(--app-soft);
  color: var(--app-muted); font-size: 12px; font-weight: 700; white-space: nowrap; vertical-align: 2px;
}
.os-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.os-chip {
  display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%;
  padding: 3px 11px; border-radius: var(--app-radius-pill);
  background: var(--app-soft); font-size: var(--app-type-small); font-weight: 700; overflow-wrap: anywhere;
}
.os-chip-key { color: var(--app-muted); font-weight: 600; }
.os-due { white-space: nowrap; color: var(--app-muted); font-size: var(--app-type-small); font-weight: 600; }
.os-due--late { color: var(--status-blocked); font-weight: 700; }

.os-empty { display: grid; gap: 18px; justify-items: start; padding-block: clamp(32px, 6vw, 64px); }
.os-empty h2 { font-family: var(--app-sans); font-size: var(--app-type-h2); font-weight: 500; overflow-wrap: anywhere; }

.os-skeleton { display: grid; gap: 14px; }
.os-skeleton-row { height: 56px; border-radius: var(--app-radius-inner); background: var(--app-soft); animation: os-pulse 1.4s var(--app-ease) infinite; }
.os-skeleton-row:nth-child(3) { animation-delay: .12s; }
.os-skeleton-row:nth-child(4) { animation-delay: .24s; }
.os-skeleton-row:nth-child(5) { animation-delay: .36s; }

/* 6. Campaigns ---------------------------------------------------------- */
.os-list-panel { padding: 8px; overflow: hidden; }
.os-list-head, .os-row {
  display: grid; gap: 6px 20px;
  grid-template-columns: minmax(0, 2.1fr) minmax(0, 1.5fr) minmax(0, 2fr) minmax(0, 1.2fr);
}
.os-list-head {
  padding: 12px 18px 10px;
  color: var(--app-muted); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}
.os-list > li + li { border-top: 1px solid var(--app-border); }
.os-row {
  width: 100%; align-items: center;
  padding: 16px 18px;
  border: 0; border-radius: var(--app-radius-inner); background: none;
  text-align: left; cursor: pointer;
  transition: background var(--app-fast) var(--app-ease);
}
.os-row.os-cover-choice { grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: center; }
.os-cover-choice > input { width: 18px; height: 18px; }
.os-cover-choice > .os-row-main { grid-column: auto; }
.os-cover-decision, .os-cover-selection { display: grid; gap: 8px; }
.os-cover-selection { overflow-wrap: anywhere; }
.os-cover-selection p { font-weight: 700; }
.os-cover-selection ul { list-style: disc; padding-inline-start: 1.3em; }
.os-cover-selection summary { width: fit-content; cursor: pointer; }
.os-cover-selection-more { margin-block-start: 8px; max-block-size: 11rem; overflow-y: auto; }
.os-row:hover { background: var(--app-soft); }
.os-row:focus-visible { outline-offset: -3px; }
.os-row-main, .os-cell { display: grid; gap: 3px; min-width: 0; justify-items: start; }
.os-row-title {
  font-family: var(--app-sans); font-size: 19px; font-weight: 500; line-height: 1.25; letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.os-row-sub { color: var(--app-muted); font-size: var(--app-type-small); font-weight: 600; overflow-wrap: anywhere; }
.os-row-next {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden;
  overflow-wrap: anywhere;
}
.os-row-owner { font-weight: 600; overflow-wrap: anywhere; }
.os-cell-label {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.os-list-more { display: flex; justify-content: center; padding: 16px 8px 10px; border-top: 1px solid var(--app-border); }

/* 7. Campaign ----------------------------------------------------------- */
.os-detail { display: grid; gap: var(--app-gap); grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); align-items: start; }
.os-next { background: var(--app-soft); box-shadow: none; }
.os-next-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; }
.os-next-header > h2 { margin: 0; }
.os-next-header + .os-next-text { margin-top: 10px; }
.os-next-text {
  font-family: var(--app-sans); font-size: clamp(22px, 2.8vw, 30px); font-weight: 500; line-height: 1.22; letter-spacing: -.015em;
  text-wrap: pretty; overflow-wrap: anywhere;
}
.os-next .os-facts { margin-top: 22px; }

.os-facts { display: grid; gap: 14px; }
.os-facts--row { align-items: start; grid-template-columns: repeat(auto-fit, minmax(140px, max-content)); gap: 14px 40px; }
.os-fact { display: grid; gap: 3px; min-width: 0; justify-items: start; }
.os-fact dt { color: var(--app-muted); font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.os-fact dd { max-width: 100%; font-size: var(--app-type-lead); font-weight: 600; overflow-wrap: anywhere; }
.os-fact dd .os-due { font-size: inherit; color: inherit; }
.os-fact dd .os-due--late { color: var(--status-blocked); }
.os-handoff-updates { grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); }
.os-handoff-updates .os-fact { align-content: start; gap: 6px; }
.os-handoff-updates .os-fact dd { font-size: var(--app-type-body); font-weight: 400; }
.os-handoff-message { display: grid; gap: 6px; min-width: 0; }
.os-handoff-message > .os-link { justify-self: start; }
.os-handoff-date { width: auto; }


.os-activity { display: grid; }
.os-activity-item { position: relative; display: grid; gap: 2px; padding: 0 0 20px 26px; }
.os-activity-item::before {
  content: ""; position: absolute; left: 0; top: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--app-surface); border: 2px solid var(--app-text);
}
.os-activity-item:first-child::before { background: var(--app-primary); }
.os-activity-item::after { content: ""; position: absolute; left: 6px; top: 24px; bottom: 2px; width: 1px; background: var(--app-border); }
.os-activity-item:last-child { padding-bottom: 0; }
.os-activity-item:last-child::after { display: none; }
.os-activity-kind { font-weight: 700; overflow-wrap: anywhere; }
.os-activity-meta { color: var(--app-muted); font-size: var(--app-type-small); }

/* 8. Forms -------------------------------------------------------------- */
.os-form-layout { display: grid; gap: var(--app-gap); max-width: 760px; align-items: start; }
.os-form-layout--aside { max-width: none; grid-template-columns: minmax(0, 760px) minmax(240px, 1fr); }
.os-form { display: grid; gap: 24px; min-width: 0; }
.os-fields { display: grid; gap: 18px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.os-field { display: grid; gap: 7px; align-content: start; min-width: 0; }
.os-field--wide { grid-column: 1 / -1; }
.os-label { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-weight: 700; }
.os-optional { color: var(--app-muted); font-size: 12px; font-weight: 600; }
.os-hint { color: var(--app-muted); font-size: var(--app-type-small); }
.os-field-error { color: var(--app-text); font-size: var(--app-type-small); font-weight: 700; }
.os-fieldset { display: grid; gap: 14px; padding-top: 24px; border-top: 1px solid var(--app-border); }
.os-evidence {
  padding: 12px 16px; border-radius: var(--app-radius-inner);
  background: var(--app-soft); color: var(--app-text); font-size: var(--app-type-small); font-weight: 600;
}
.os-actions--form { padding-top: 4px; }
.os-current { position: sticky; top: 88px; background: var(--app-soft); box-shadow: none; }

/* 9. Motion ------------------------------------------------------------- */
.os-enter .os-main > *, .os-enter .os-gate { animation: os-rise var(--app-slow) var(--app-ease) both; }
@keyframes os-rise { from { transform: translateY(3px); } }
@keyframes os-spin { to { transform: rotate(360deg); } }
@keyframes os-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) {
  .os *, .os *::before, .os *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* 10. Smaller screens --------------------------------------------------- */
@media (min-width: 901px) {
  .os-list-panel--shared :is(.os-list-head, .os-row) { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .os-detail, .os-form-layout--aside { grid-template-columns: minmax(0, 1fr); }
  .os-form-layout--aside { max-width: 760px; }
  .os-current { position: static; order: -1; }

  .os-list-head { display: none; }
  .os-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px 16px; align-items: start; padding: 18px 14px; }
  .os-row-main, .os-row .os-cell:nth-child(3) { grid-column: 1 / -1; }
  .os-cell-label {
    position: static; width: auto; height: auto; margin: 0; overflow: visible; clip-path: none;
    color: var(--app-muted); font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  }
}
@media (max-width: 640px) {
  .os-row .os-cell:nth-child(2) { grid-column: 1 / -1; }
  .os-top-inner { min-height: 56px; flex-wrap: wrap; gap: 4px; padding-top: 8px; padding-bottom: 4px; }
  .os-account-nav { flex-basis: 100%; justify-content: flex-start; }
  .os-account-nav .os-btn { min-height: 36px; }
  .os-role { display: none; }
  .os-workspace { max-width: 54vw; }
  .os-top .os-btn--quiet { padding: 0 8px; }

  .os-search { gap: 6px; }
  .os-search-field { max-width: none; }
  .os-search .os-btn { padding-inline: 12px; }

  .os-fields { grid-template-columns: minmax(0, 1fr); }
  .os-actions--form { flex-direction: column; }
  .os-actions--form .os-btn { width: 100%; min-height: 50px; }
  .os-head > .os-btn { min-height: 44px; }

  .os-head:has(.os-dock) { align-items: flex-start; }
  .os-dock { flex-basis: 100%; }
  .os-dock .os-btn { min-height: 44px; max-width: 100%; white-space: normal; }
}


.campaign-links { margin: 0; padding: 0; list-style: none; }
.campaign-links li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding-block: 8px; }
.campaign-links li:has(details[open]) { grid-template-columns: 1fr; }
.campaign-links a { overflow-wrap: anywhere; }
.campaign-link-editor summary { width: fit-content; cursor: pointer; }
.campaign-link-editor form { margin-block: 12px; }
.campaign-link-editor [role='alert']:empty { display: none; }

.os-brief-instructions { white-space: pre-wrap; overflow-wrap: anywhere; }

.os-messaging > p + p, .os-messaging > p + .os-actions, .os-messaging > p + details { margin-top: 0.65rem; }

.os-deliverables { list-style: none; padding: 0; margin: 0; }
.os-deliverables li + li { border-top: 1px solid var(--app-border); }
.os-deliverable { display: grid; gap: .2rem; padding: .7rem 0; border-radius: .55rem; color: inherit; overflow-wrap: anywhere; text-decoration: none; }
.os-deliverable strong { text-decoration: underline; text-underline-offset: .16em; }
.os-deliverable span { color: var(--app-muted); font-size: var(--app-type-small); }
.os-deliverable-feedback { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

.os-deliverable:hover, .os-deliverable:focus-visible { background: var(--app-soft); }

.os-deliverable-schedule { margin: 0 0 .75rem .7rem; padding: .25rem .8rem; border-inline-start: 2px solid var(--app-border); border-radius: 0; }
