/* Readers' data (views/posts/contribute.js, views/posts/inbox.js): the send sheet, a contribution's card, the post
   page's section, the author's settings and the inbox. Built on base.css's controls (field, select, check, seg, chip,
   pill, notice) and its tokens, so it takes whatever shell the pages around it have (a hairline is the shell's
   --line where it sets one). */

/* ---- the send sheet ---- */
.ctb-form { display: flex; flex-direction: column; gap: 16px; }
.ctb-field { display: flex; flex-direction: column; min-width: 0; }
.ctb-field .label { margin-bottom: 6px; }
.ctb-set { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ctb-set > legend { padding: 0; }
.ctb-vrows { display: flex; flex-direction: column; gap: 8px; }
.ctb-vrow { display: grid; grid-template-columns: minmax(0, 1.3fr) 128px minmax(0, 1fr) 88px 32px; gap: 6px; align-items: center; }
.ctb-vslot { min-width: 0; display: block; }
.ctb-vslot > * { width: 100%; }
.ctb-vrow [hidden] { display: none; }
.ctb-price[hidden], .ctb-batch[hidden] { display: none; }
.ctb-more > summary { cursor: pointer; margin-bottom: 10px; }
.ctb-more { display: flex; flex-direction: column; gap: 10px; }
.ctb-to { font-weight: 600; color: var(--ink-2); }
@media (max-width: 560px) {
  .ctb-vrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 64px 32px; }
  .ctb-vrow > :first-child { grid-column: 1 / -1; }
}

/* ---- one contribution ---- */
.ctb-list { display: flex; flex-direction: column; }
.ctb-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 4px; border-bottom: 1px solid var(--line, var(--hair)); min-width: 0; }
.ctb-card.is-focus { background: var(--accent-wash); border-radius: 14px; padding: 14px 12px; border-bottom-color: transparent; }
.ctb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ctb-who { min-width: 0; align-items: center; }
.ctb-pills { gap: 6px; justify-content: flex-end; }
.ctb-post { color: var(--accent-ink); }
.ctb-title { font-size: var(--fs-body); font-weight: 650; letter-spacing: -0.01em; }
.ctb-summary, .ctb-notes { line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.ctb-values { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; font-size: var(--fs-small); }
.ctb-values dt { color: var(--ink-3); }
.ctb-values dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.ctb-raw { display: flex; flex-direction: column; gap: 8px; background: var(--s1); border-radius: 14px; padding: 12px 14px; }
.ctb-links { list-style: none; padding: 0; margin: 0; font-size: var(--fs-small); overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 4px; }
.ctb-links a { color: var(--accent-ink); }
.ctb-files { display: flex; flex-wrap: wrap; gap: 8px; }
.ctb-file { width: 84px; height: 84px; border-radius: 12px; overflow: hidden; background: var(--s2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--ink-2); font-size: 11px; text-align: center; padding: 4px; }
.ctb-file img { width: 100%; height: 100%; object-fit: cover; }
.ctb-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ctb-behind { display: inline-flex; align-items: center; gap: 6px; }
.ctb-behind svg, .ctb-use svg { width: 14px; height: 14px; flex: none; }
.ctb-meta { gap: 6px 12px; }
.ctb-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ctb-panel { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--s1); }
.ctb-terms-text { font-size: var(--fs-small); line-height: 1.5; color: var(--ink-2); }
.ctb-history > summary { cursor: pointer; }
.ctb-history ol { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }

/* ---- the post page and the author's panel ---- */
.ctb-sec { display: flex; flex-direction: column; gap: 8px; }
.ctb-sec-head { align-items: center; }
.ctb-sec-title { font-size: var(--fs-small); font-weight: 650; color: var(--ink-2); }
.ctb-counts { gap: 8px 12px; align-items: center; }
.ctb-settings { border-top: 1px solid var(--line, var(--hair)); padding-top: 12px; }
.ctb-settings .select { width: 100%; }
.ctb-batch { gap: 8px 12px; }
.ctb-batch .field { width: 96px; }
.ctb-use { display: inline-flex; align-items: center; gap: 4px; }

.ctb-none { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }

/* ---- the inbox ---- */
.ctb-filters[hidden] { display: none; }
.ctb-waiting { color: var(--accent-ink); }

/* ---- in the community's middle column (.ps-page, x.css): rows run edge to edge on the column's gutters, between
   its hairlines, as the timeline's do ---- */
.ps-page .ctb-sec { gap: 0; }
.ps-page .ctb-sec-head, .ps-page .ctb-counts, .ps-page .ctb-none { padding: 12px 16px; }
.ps-page .ctb-counts, .ps-page .ctb-none { border-bottom: 1px solid var(--line, var(--hair)); }
.ps-page .ctb-show-all:not(:empty) { padding: 12px 16px; }
.ps-page .ctb-card { padding: 12px 16px; }
.ps-page .ctb-card.is-focus { border-radius: 0; padding: 12px 16px; border-bottom-color: var(--line, var(--hair)); }
.ps-m-sec > .ctb-settings { border-top: 0; padding-top: 0; }
.ctb-inbox .ctb-filters { padding: 12px 16px 0; }
.ctb-inbox .ctb-lead { margin: 0; padding: 10px 16px 12px; border-bottom: 1px solid var(--line, var(--hair)); }

/* ================================================================== the community's look (x.css, posts.css)
   The send sheet as a composer: the post it goes to, four numbered steps that each say who sees what, the terms in
   switches and a line of what is being agreed beside the button. A contribution reads like a reply: the sender's
   avatar in its own column. */
.sheet:has(.ctb-form) { width: min(600px, 100%); background: var(--canvas); border-radius: 16px; box-shadow: 0 0 0 1px var(--line), 0 18px 60px rgba(0, 0, 0, 0.5); }
.sheet:has(.ctb-form) .sheet-head { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 12px 12px 10px 20px; border-bottom: 1px solid var(--line); }
.sheet:has(.ctb-form) .sheet-head h2 { font-size: 20px; font-weight: 800; }
.sheet:has(.ctb-form) .sheet-body { padding: 14px 20px 20px; }
.sheet:has(.ctb-form) .sheet-foot { background: var(--glass); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: inset 0 1px 0 var(--line); padding: 10px 16px 12px 20px; }
.ctb-form { gap: 14px; }
.ctb-form .field, .ctb-form .select { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 8px; }
.ctb-form .field:focus, .ctb-form .select:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.ctb-form .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }

.ctb-target { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); }
.ctb-target-ic { flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent-ink); }
.ctb-target-ic svg { width: 19px; height: 19px; }
.ctb-target-main { min-width: 0; display: flex; flex-direction: column; }
.ctb-target .ctb-to { color: var(--ink); font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctb-lead-line { margin: -4px 2px 0; line-height: 1.5; }

.ctb-step { position: relative; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0 0 0 40px; border: 0; min-width: 0; }
.ctb-step::before { content: ""; position: absolute; left: 13px; top: 32px; bottom: -10px; width: 2px; background: var(--line); border-radius: 1px; }
.ctb-step:last-of-type::before { display: none; }
.ctb-step-head { display: flex; align-items: flex-start; gap: 12px; padding: 0; margin: 0 0 4px -40px; }
.ctb-step-n { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--s2); color: var(--ink); font-size: 13px; font-weight: 800; box-shadow: 0 0 0 4px var(--canvas); }
.ctb-step:focus-within .ctb-step-n { background: var(--accent); color: var(--on-accent); }
.ctb-step-titles { display: flex; flex-direction: column; gap: 1px; padding-top: 3px; min-width: 0; }
.ctb-step-title { font-size: 16px; font-weight: 800; line-height: 22px; color: var(--ink); }
.ctb-step-note { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-3); }
.ctb-step-note svg { width: 13px; height: 13px; flex: none; }
.ctb-step-body { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ctb-step .ctb-set { gap: 6px; }
.ctb-step .ctb-set .hint { margin: -2px 0 2px; }

.ctb-kinds { display: flex; flex-wrap: wrap; gap: 6px; }
.ctb-kind { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 999px; background: none; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background var(--t-1), color var(--t-1), box-shadow var(--t-1), transform 0.12s; }
.ctb-kind svg { width: 15px; height: 15px; }
.ctb-kind:hover { background: var(--hover); color: var(--ink); }
.ctb-kind[aria-checked="true"] { background: var(--accent-wash); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-line, var(--accent)); }
.ctb-kind:active { transform: scale(0.96); }
.ctb-more > summary { display: inline-flex; align-items: center; gap: 4px; list-style: none; color: var(--accent-ink); font-size: 14px; font-weight: 700; margin: 0; }
.ctb-more > summary::-webkit-details-marker { display: none; }
.ctb-more > summary svg { width: 15px; height: 15px; transition: transform var(--t-1) var(--ease); }
.ctb-more[open] > summary svg { transform: rotate(90deg); }
.ctb-more[open] { gap: 12px; }

.ctb-form .seg { background: var(--s2); padding: 3px; }
.ctb-form .seg button { height: 32px; padding: 0 16px; font-size: 14px; }
.ctb-form .seg button[aria-pressed="true"] { background: var(--ink); color: var(--canvas); }
.ctb-switches { display: flex; flex-direction: column; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.ctb-switch { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; cursor: pointer; font-size: 14px; line-height: 20px; }
.ctb-switch + .ctb-switch { border-top: 1px solid var(--line); }
.ctb-switch:hover { background: var(--hover); }
.ctb-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.ctb-switch-ui { flex: none; position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--s3); transition: background 0.2s var(--ease); }
.ctb-switch-ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35); transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.2, 1.2); }
.ctb-switch input:checked + .ctb-switch-ui { background: var(--accent); }
.ctb-switch input:checked + .ctb-switch-ui::after { transform: translateX(16px); }
.ctb-switch input:focus-visible + .ctb-switch-ui { box-shadow: 0 0 0 3px var(--accent-wash); }

.ctb-foot { display: flex; align-items: center; gap: 8px; width: 100%; flex-wrap: wrap; }
.ctb-sum { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.ctb-sum-chip { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--s2); color: var(--ink-2); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.ctb-sum-chip svg { width: 13px; height: 13px; }
.ctb-sum-chip.is-paid { background: var(--accent-wash); color: var(--accent-ink); }
.ctb-foot .btn-primary { min-width: 88px; }

/* one contribution, like a reply */
.ps-page .ctb-card, .ctb-card { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px; align-items: start; padding: 12px 16px; transition: background var(--t-1); }
.ctb-card:hover { background: var(--hover); }
.ctb-card.is-focus, .ps-page .ctb-card.is-focus { background: color-mix(in srgb, var(--accent) 8%, transparent); box-shadow: inset 3px 0 0 var(--accent); }
.ctb-av { display: block; }
.ctb-anon-av { background: var(--s2); color: var(--ink-3); }
.ctb-anon-av svg { width: 18px; height: 18px; }
.ctb-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ctb-who { min-width: 0; flex: 1; }
.ctb-head { align-items: center; }
.ctb-pills .pill { font-size: 12px; font-weight: 700; }
.ctb-pills [data-status]::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
.ctb-pills [data-status="submitted"]::before { animation: ps-pulse 1.6s ease-in-out infinite; }
.ctb-post { font-size: 13px; font-weight: 600; }
.ctb-post:hover { text-decoration: underline; }
.ctb-title { font-size: 16px; font-weight: 700; line-height: 22px; }
.ctb-summary { font-size: 15px; line-height: 21px; }
.ctb-raw { background: none; padding: 0; border-radius: 0; gap: 8px; }
.ctb-values { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 8px; margin: 2px 0 0; }
.ctb-value { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.ctb-value dt { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctb-value dd { margin: 0; font-size: 19px; font-weight: 800; line-height: 24px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--ink); }
.ctb-notes { font-size: 14px; color: var(--ink-2); padding-left: 10px; box-shadow: inset 2px 0 0 var(--line-2); }
.ctb-behind { padding: 10px 12px; border-radius: 12px; background: repeating-linear-gradient(-45deg, transparent 0 7px, var(--hover) 7px 14px), var(--s1); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); }
.ctb-context, .ctb-method, .ctb-terms { font-size: 13px; }
.ctb-actions { gap: 8px; margin-top: 4px; }
.ctb-actions .btn { height: 34px; padding: 0 16px; border-radius: 999px; font-weight: 700; }
.ctb-actions .btn:not(.btn-primary):not(.btn-ghost) { background: transparent; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink); }
.ctb-actions .btn-ghost { color: var(--ink-3); }
.ctb-actions .btn-ghost:hover { color: var(--crit); background: var(--crit-wash); }
.ctb-panel { background: var(--s1); box-shadow: inset 0 0 0 1px var(--line); animation: ps-in 0.2s var(--ease) both; }
.ctb-history > summary { list-style: none; display: inline-flex; align-items: center; gap: 4px; }
.ctb-history > summary::-webkit-details-marker { display: none; }
.ctb-history > summary::before { content: "›"; display: inline-block; transition: transform var(--t-1); font-size: 15px; line-height: 1; }
.ctb-history[open] > summary::before { transform: rotate(90deg); }
.ctb-history ol { list-style: none; padding-left: 12px; border-left: 2px solid var(--line); margin-left: 3px; }

/* the post's tab: an invitation, the author's counts */
.ctb-cta { display: flex; align-items: center; gap: 12px; margin: 12px 16px; padding: 14px 16px; border-radius: 16px; background: linear-gradient(120deg, color-mix(in srgb, var(--accent) 14%, transparent), color-mix(in srgb, var(--accent) 4%, transparent)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.ctb-cta-ic { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); }
.ctb-cta-ic svg { width: 21px; height: 21px; }
.ctb-cta-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; line-height: 20px; }
.ctb-cta-text span { font-size: 14px; color: var(--ink-2); }
.ps-page .ctb-counts { display: flex; align-items: center; gap: 20px; }
.ctb-stat { display: inline-flex; align-items: baseline; gap: 4px; color: var(--ink-3); font-size: 14px; }
.ctb-stat strong { color: var(--ink); font-size: 18px; font-weight: 800; }
a.ctb-stat:hover span { text-decoration: underline; }
.ps-page .ctb-none { align-items: center; text-align: center; padding: 32px 24px; gap: 12px; }
.ctb-none-ic { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--s2); color: var(--ink-3); }
.ctb-none-ic svg { width: 22px; height: 22px; }

/* the inbox: filter pills that scroll on one line */
.ctb-inbox .ctb-filters { display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 12px 16px 4px; -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
.ctb-inbox .ctb-filters::-webkit-scrollbar { display: none; }
.ctb-inbox .chip { flex: none; height: 32px; padding: 0 14px; border-radius: 999px; background: none; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); font-size: 14px; font-weight: 600; }
.ctb-inbox .chip:hover { background: var(--hover); }
.ctb-inbox .chip[aria-pressed="true"] { background: var(--ink); color: var(--canvas); box-shadow: none; }
.ctb-inbox .ctb-lead { font-size: 13px; }

@media (max-width: 700px) {
  .sheet:has(.ctb-form) { border-radius: 16px 16px 0 0; max-height: 94vh; }
  .ctb-step { padding-left: 0; }
  .ctb-step::before { display: none; }
  .ctb-step-head { margin-left: 0; }
  .ctb-cta { flex-wrap: wrap; }
  .ctb-cta .btn { margin-left: 52px; }
  .ctb-values { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ctb-foot .ctb-sum { flex-basis: 100%; }
}

/* the post's own rules for new data (the author's panel): one box, switches that open what they need, the fixed rules
   folded, the kinds as chips, the budgets in a row */
.ctb-auto { gap: 12px; margin-top: 14px; padding: 14px 16px 16px; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line-2); }
.ctb-auto > .ctb-sec-title { font-size: 15px; font-weight: 800; color: var(--ink); }
.ctb-auto-state { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; background: var(--s1); }
p.ctb-auto-state { display: block; }
.ctb-auto > .check { font-weight: 600; }
.ctb-auto-judge, .ctb-auto-budget { margin-left: 26px; padding-left: 12px; border-left: 2px solid var(--accent-wash); gap: 8px; animation: ps-in 0.2s var(--ease) both; }
.ctb-auto-judge[hidden], .ctb-auto-budget[hidden] { display: none; }
.ctb-auto-budget > .row-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ctb-auto-budget .field.num { width: 100%; }
.ctb-auto-fixed { border-radius: 12px; background: var(--s1); }
.ctb-auto-fixed > summary { display: flex; align-items: center; gap: 6px; padding: 10px 12px; cursor: pointer; list-style: none; color: var(--ink-2); font-weight: 600; }
.ctb-auto-fixed > summary::-webkit-details-marker { display: none; }
.ctb-auto-fixed > summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform var(--t-1) var(--ease); }
.ctb-auto-fixed[open] > summary::before { transform: rotate(45deg); }
.ctb-auto-fixed > .stack { padding: 0 12px 12px; gap: 10px; }
fieldset.ctb-kinds { display: block; min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset.ctb-kinds > legend { padding: 0; margin-bottom: 6px; }
fieldset.ctb-kinds .row-wrap { gap: 6px; }
fieldset.ctb-kinds .check { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px 0 10px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); font-size: 13px; cursor: pointer; transition: background var(--t-1), box-shadow var(--t-1); }
fieldset.ctb-kinds .check:hover { background: var(--hover); }
fieldset.ctb-kinds .check:has(input:checked) { background: var(--accent-wash); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
fieldset.ctb-kinds .check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.ctb-auto > .row-wrap:last-child { padding-top: 4px; }
.ctb-reading { padding-left: 10px; border-left: 2px solid var(--line-2); }
