:root {
  color-scheme: light dark;
  --canvas: #f3f0e8;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #202622;
  --muted: #68716b;
  --line: #dcd8cd;
  --teal: #1f665b;
  --teal-soft: #dbeae4;
  --amber: #9c5f22;
  --amber-soft: #f6e8d2;
  --rose: #a44e45;
  --rose-soft: #f5dfdc;
  --shadow: 0 14px 42px rgb(50 57 50 / 8%);
  --radius-lg: 22px;
  --radius-md: 15px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 9% -8%, rgb(31 102 91 / 10%), transparent 27rem),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--teal) 65%, white);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.eyebrow,
.lane-kicker {
  margin: 0 0 0.35rem;
  color: var(--teal);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sign-in {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
}

.sign-in-card {
  width: min(100%, 32rem);
  padding: clamp(1.5rem, 6vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: var(--shadow);
}

.sign-in-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 8vw, 3.8rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 0.98;
}

.sign-in-copy {
  margin: 1.15rem 0 1.75rem;
  color: var(--muted);
  line-height: 1.6;
}

.sign-in-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  font-weight: 750;
}

.sign-in-row {
  display: flex;
  gap: 0.65rem;
}

.sign-in-row input {
  min-width: 0;
  flex: 1;
  min-height: 48px;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface-strong);
}

.sign-in-row button {
  padding: 0.7rem 1.15rem;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--teal);
  cursor: pointer;
}

.form-error {
  margin: 0.75rem 0 0;
  color: var(--rose);
  font-size: 0.85rem;
}

.app-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 70px;
  padding: 0.75rem max(1rem, calc((100vw - 92rem) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  place-items: center;
  color: white;
  background: var(--teal);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  line-height: 1.05;
}

.brand small {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.principal-name {
  max-width: 12rem;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-button {
  min-height: 38px;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  cursor: pointer;
}

.workspace {
  width: min(100%, 92rem);
  margin: 0 auto;
  padding: clamp(1.2rem, 3vw, 2.5rem) clamp(0.85rem, 2.5vw, 2rem) 5rem;
}

.view-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.view-tabs button {
  min-height: 38px;
  padding: 0.45rem 0.9rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
}

.view-tabs button[aria-current="page"] {
  color: white;
  background: var(--teal);
}

.workspace-view {
  min-width: 0;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.workspace-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.65rem);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.last-updated {
  margin: 0 0 0.3rem;
  color: var(--muted);
  font-size: 0.78rem;
  text-align: right;
}

.source-status {
  margin-bottom: 1rem;
}

.source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 30px;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  font-size: 0.72rem;
  font-weight: 700;
}

.source-chip::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  content: "";
}

.source-chip[data-status="stale"]::before {
  background: var(--amber);
}

.source-chip[data-status="unavailable"]::before {
  background: var(--rose);
}

.source-warning {
  margin: 0.65rem 0 0;
  padding: 0.7rem 0.85rem;
  border-left: 3px solid var(--amber);
  border-radius: 0 10px 10px 0;
  color: var(--ink);
  background: var(--amber-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.alerts {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
}

.alert-card {
  margin: 0;
  padding: 0.8rem 1rem;
  border: 1px solid color-mix(in srgb, var(--rose) 25%, var(--line));
  border-radius: 13px;
  background: var(--rose-soft);
  font-size: 0.88rem;
  line-height: 1.5;
}

.directive {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.32fr);
  gap: 1rem;
  margin: 1rem 0 1.4rem;
  padding: clamp(1.15rem, 3vw, 2rem);
  border-radius: var(--radius-lg);
  color: #f8fffc;
  background: linear-gradient(135deg, #174d45, #247366);
  box-shadow: var(--shadow);
}

.directive h2 {
  margin: 0;
  max-width: 28ch;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3.2vw, 2.45rem);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.directive .eyebrow {
  color: #a9d5c8;
}

.directive-main > p:last-child {
  max-width: 70ch;
  margin: 0.9rem 0 0;
  color: #d8ebe5;
  line-height: 1.55;
  white-space: pre-line;
}

.next-commitment {
  padding: 1rem;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 9%);
}

.next-commitment span,
.next-commitment strong {
  display: block;
}

.next-commitment span {
  color: #b7d9d0;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.next-commitment strong {
  margin-top: 0.5rem;
  font-size: 1.5rem;
}

.next-commitment p {
  margin: 0.35rem 0 0;
  color: #d8ebe5;
  font-size: 0.82rem;
  line-height: 1.4;
}

.work-lanes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: start;
}

.lane {
  min-width: 0;
}

.calendar-lane {
  margin-bottom: 1.2rem;
}

.calendar-lane .lane-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0.8rem;
}

.lane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 0.2rem;
}

.lane-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.lane-kicker {
  margin-bottom: 0.15rem;
  color: var(--muted);
  font-size: 0.62rem;
}

.lane-count {
  display: grid;
  min-width: 28px;
  height: 28px;
  border-radius: 999px;
  place-items: center;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  font-size: 0.72rem;
  font-weight: 800;
}

.lane-items {
  display: grid;
  gap: 0.75rem;
}

.lane-empty {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.work-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 5px 18px rgb(50 57 50 / 5%);
}

.work-card.is-completed {
  opacity: 0.52;
}

.work-card.is-completed .card-title {
  text-decoration: line-through;
}

.card-topline {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.completion-checkbox {
  width: 19px;
  height: 19px;
  margin: 0.08rem 0 0;
  accent-color: var(--teal);
}

.card-copy {
  min-width: 0;
}

.card-title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.96rem;
  line-height: 1.38;
}

.card-note {
  margin: 0.42rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.meta-pill {
  padding: 0.2rem 0.45rem;
  border-radius: 7px;
  color: var(--muted);
  background: color-mix(in srgb, var(--canvas) 75%, transparent);
  font-size: 0.65rem;
  font-weight: 700;
}

.meta-pill.shared {
  color: var(--teal);
  background: var(--teal-soft);
}

.suggestion-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.suggestion-button {
  min-height: 31px;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.68rem;
}

.suggestion-button:disabled,
.instruction-input:disabled,
.completion-checkbox:disabled {
  cursor: not-allowed;
  opacity: 0.74;
}

.instruction-label {
  display: block;
  margin-top: 0.7rem;
}

.instruction-label > span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
}

.instruction-input {
  width: 100%;
  min-height: 40px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: color-mix(in srgb, var(--canvas) 62%, transparent);
  font-size: 0.75rem;
}

.shadow-note {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.61rem;
}

.brief-sections {
  display: grid;
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.daily-brief-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.daily-brief-content {
  min-width: 0;
}

.section-card {
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  box-shadow: 0 5px 18px rgb(50 57 50 / 4%);
}

.section-card.is-open {
  box-shadow: var(--shadow);
}

.section-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.section-heading-copy {
  display: grid;
  gap: 0.18rem;
}

.section-heading-copy strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 500;
}

.section-heading-copy > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.section-metrics {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.section-attention {
  display: grid;
  min-width: 28px;
  height: 28px;
  padding-inline: 0.4rem;
  border-radius: 999px;
  place-items: center;
  color: var(--teal);
  background: var(--teal-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.section-disclosure {
  color: var(--muted);
  font-size: 1.65rem;
  line-height: 1;
  transform: rotate(0deg);
  transition: transform 160ms ease;
}

.section-toggle[aria-expanded="true"] .section-disclosure {
  transform: rotate(90deg);
}

.section-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

.section-freshness {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.85rem 0;
}

.section-items {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.7rem;
}

.section-empty {
  margin: 0;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.status-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 26px;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  font-size: 0.68rem;
  font-weight: 750;
}

.status-badge[data-status="fresh"] {
  color: var(--teal);
  border-color: color-mix(in srgb, var(--teal) 30%, var(--line));
  background: var(--teal-soft);
}

.status-badge[data-status="stale"] {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge[data-status="unavailable"] {
  color: var(--rose);
  background: var(--rose-soft);
}

.hs-thread {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid color-mix(in srgb, var(--teal) 28%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--teal-soft) 48%, var(--surface));
}

.hs-thread-heading,
.scheduler-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.hs-thread-heading h2,
.scheduler-heading h1,
.scheduler-panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.hs-thread-heading h2 {
  font-size: 1.25rem;
}

.hs-messages {
  display: grid;
  gap: 0.65rem;
}

.hs-message {
  max-width: 70ch;
  margin: 0;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface);
  font-size: 0.84rem;
  line-height: 1.5;
}

.hs-message[data-direction="inbound"] {
  justify-self: end;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface-strong));
}

.hs-message[data-direction="outbound"] {
  justify-self: start;
}

.hs-message p {
  margin: 0.3rem 0 0;
  white-space: pre-line;
}

.message-class {
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#hs-message-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.72rem;
  font-weight: 750;
}

.hs-message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
}

.hs-message-row textarea {
  width: 100%;
  resize: vertical;
  min-height: 76px;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface-strong);
}

.hs-message-row button {
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--teal);
}

.hs-message-row textarea:disabled,
.hs-message-row button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

#hs-read-only-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.scheduler-heading {
  margin-bottom: 1rem;
  padding: clamp(1.1rem, 3vw, 1.6rem);
  border-radius: var(--radius-lg);
  color: #f8fffc;
  background: linear-gradient(135deg, #174d45, #247366);
}

.scheduler-heading h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
}

.scheduler-heading p:last-child {
  margin: 0.6rem 0 0;
  color: #d8ebe5;
}

.scheduler-heading .eyebrow {
  color: #a9d5c8;
}

.scheduler-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 0.85rem 0;
}

.scheduler-panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.scheduler-panel h2 {
  font-size: 1.3rem;
}

.scheduler-panel > p:last-child,
.hs-activity-row {
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

#hs-rules-list,
#hs-confirmations-list,
#hs-activity-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 0.7rem;
}

.hs-action,
.hs-rule {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
}

.hs-action-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}

.hs-action h3,
.hs-rule h3 {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.action-policy,
.action-verification,
.hs-rule p {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.action-verification {
  color: var(--teal);
  font-weight: 750;
}

.action-preview {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 0.65rem;
  margin: 0.7rem 0 0;
  font-size: 0.72rem;
}

.action-preview dt {
  color: var(--muted);
  font-weight: 750;
}

.action-preview dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.action-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}

.action-controls button:not(.quiet-button) {
  min-height: 38px;
  padding: 0.5rem 0.8rem;
  border: 0;
  border-radius: 10px;
  color: white;
  background: var(--teal);
}

.hs-action > a {
  display: inline-block;
  margin-top: 0.55rem;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 750;
}

.status-badge[data-status="completed"] {
  color: var(--teal);
  background: var(--teal-soft);
}

.status-badge[data-status="awaiting_confirmation"],
.status-badge[data-status="queued"],
.status-badge[data-status="executing"],
.status-badge[data-status="verifying"] {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-badge[data-status="failed"],
.status-badge[data-status="blocked"],
.status-badge[data-status="superseded"] {
  color: var(--rose);
  background: var(--rose-soft);
}

.hs-activity-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.empty-state {
  margin-top: 1rem;
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

noscript {
  display: block;
  padding: 2rem;
  text-align: center;
}

@media (max-width: 1023px) {
  .daily-brief-grid {
    grid-template-columns: 1fr;
  }

  .daily-thread-host {
    position: static;
  }
}

@media (max-width: 900px) {
  .work-lanes {
    grid-template-columns: 1fr;
  }

  .directive {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-header {
    align-items: flex-start;
  }

  .principal-name {
    display: none;
  }

  .brand small {
    display: none;
  }

  .quiet-button {
    padding-inline: 0.65rem;
    font-size: 0.76rem;
  }

  .agents-switch {
    padding-inline: 0.6rem;
    font-size: 0.76rem;
  }

  .workspace-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .last-updated {
    text-align: left;
  }

  .sign-in-row {
    flex-direction: column;
  }

  .sign-in-row button {
    width: 100%;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs button {
    flex: 1;
  }

  .section-toggle,
  .scheduler-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-metrics {
    width: 100%;
    justify-content: space-between;
  }

  .section-items,
  .scheduler-grid {
    grid-template-columns: 1fr;
  }

  .hs-message-row {
    grid-template-columns: 1fr;
  }

  .hs-message-row button {
    width: 100%;
  }
}

/* ── CR-0156 S4 — the Agents tab ─────────────────────────────────────────────────────────────────────── */

.threads-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.thread-list {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thread-item {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
}

.thread-item span,
.thread-item small {
  color: var(--muted);
  font-size: 0.74rem;
}

.thread-item[aria-current="true"] {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.thread-pane,
.new-thread-form {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.new-thread-form {
  padding: 0;
  border: 0;
  box-shadow: none;
}

.new-thread-form h2,
.thread-heading h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.new-thread-form label,
.thread-message-form label {
  font-size: 0.72rem;
  font-weight: 750;
}

.new-thread-form input[type="text"],
#thread-title {
  width: 100%;
  min-height: 44px;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: var(--surface-strong);
}

.thread-agents {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.thread-agents legend {
  padding: 0 0.3rem;
  font-size: 0.72rem;
  font-weight: 750;
}

.thread-agent {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0 0.6rem;
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 0.84rem;
}

.thread-form-actions {
  display: flex;
  gap: 0.5rem;
}

.thread-form-actions button[type="submit"] {
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 11px;
  color: white;
  background: var(--teal);
}

.thread-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.thread-messages {
  display: grid;
  gap: 0.65rem;
  max-height: min(62vh, 42rem);
  overflow-y: auto;
  padding: 0.2rem;
}

.thread-message {
  justify-self: start;
  max-width: 70ch;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  font-size: 0.84rem;
  line-height: 1.5;
}

.thread-message header {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}

.thread-message header small {
  color: var(--muted);
  font-size: 0.68rem;
}

.thread-message p {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.thread-message[data-mine="true"] {
  justify-self: end;
  background: color-mix(in srgb, var(--teal) 12%, var(--surface-strong));
}

.thread-message[data-author="system"] {
  justify-self: center;
  color: var(--muted);
  background: transparent;
  border: 1px dashed var(--line);
  font-size: 0.76rem;
}

.thread-message-form {
  display: grid;
  gap: 0.4rem;
}

.thread-note,
.threads-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

/* CR-0156 S4b — who a post is waiting on, under the conversation. */
.thread-awaiting {
  margin: 0.15rem 0.2rem 0.45rem;
  font-style: italic;
}

/* CR-0156 S4c — Cassie's own Agents tab switch, in the header so it stays reachable while the tab is off. */
.agents-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.8rem;
  cursor: pointer;
}

.agents-switch input {
  margin: 0;
  accent-color: var(--teal);
}

.agents-switch-note {
  color: var(--rose);
  font-size: 0.74rem;
}

/* Who else reads these threads — said plainly on Cassie's tab. */
.agents-readers {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .threads-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .thread-messages {
    max-height: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #161a18;
    --surface: #1d2320;
    --surface-strong: #242b27;
    --ink: #edf1ed;
    --muted: #aab3ac;
    --line: #38413b;
    --teal: #79b9aa;
    --teal-soft: #223d36;
    --amber: #e0aa73;
    --amber-soft: #3c3023;
    --rose: #e39a92;
    --rose-soft: #3c2827;
    --shadow: 0 18px 48px rgb(0 0 0 / 24%);
  }

  body {
    background: radial-gradient(circle at 9% -8%, rgb(87 153 137 / 13%), transparent 27rem),
      var(--canvas);
  }

  .directive {
    color: #f4fffb;
    background: linear-gradient(135deg, #16453e, #1d5a50);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* CR-0129 — a blocked section never reads as current. */
.source-warning {
  list-style: none;
}

.source-warning li + li {
  margin-top: 4px;
}

.section-card.is-blocked .section-heading-copy span {
  color: var(--rose);
  font-weight: 700;
}

.section-blocked {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--rose);
  border-radius: var(--radius-md);
  background: var(--rose-soft);
  color: var(--ink);
}

.section-blocked p {
  margin: 6px 0 0;
}

.section-items.is-not-current {
  opacity: 0.55;
}

.source-chip[data-status="not-connected"],
.source-chip[data-status="not-in-use"] {
  color: var(--muted);
  border-style: dashed;
}

/* CR-1031 — a source declared not in use is not an outage. */
.status-badge[data-status="not-in-use"] {
  color: var(--muted);
}

/* CR-0130 — one card per item. One treatment per category; Severity is the only escalation. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.signpost {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.item-card {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
}

.item-card[data-category="directive"] {
  border-left-color: var(--teal);
}

.item-card[data-category="recommendation"] {
  border-left-color: var(--amber);
}

.item-card[data-category="reference"],
.item-card[data-category="status"] {
  border-left-color: var(--line);
}

.item-card[data-severity="high"] {
  border-color: var(--rose);
  border-left-color: var(--rose);
  background: var(--rose-soft);
}

.item-card.is-completed {
  opacity: 0.6;
}

.item-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.item-category,
.item-severity,
.item-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.item-category {
  color: var(--muted);
}

.item-card[data-category="directive"] .item-category {
  color: var(--teal);
}

.item-card[data-category="recommendation"] .item-category {
  color: var(--amber);
}

.item-severity {
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  color: var(--surface-strong);
  background: var(--rose);
}

.item-label {
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
}

.item-claim {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-claim a {
  color: inherit;
}

/* CR-0145 — the card anatomy (visual-communication.md → "Rendering map: app UI"). One treatment per part;
   Directive is the lead, Exposition the unmarked baseline, Status and Reference recede. */
.item-directive {
  display: grid;
  gap: 0.2rem;
}

.item-steps-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.item-steps {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-steps li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.4;
}

.item-steps li::before {
  position: absolute;
  top: 0.2rem;
  left: 0;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid var(--teal);
  border-radius: 4px;
  content: "";
}

.item-status,
.item-exposition {
  display: grid;
  gap: 0.15rem;
}

.item-status p,
.item-exposition p,
.item-provenance {
  margin: 0;
  line-height: 1.4;
}

.item-status p {
  color: var(--muted);
  font-size: 0.8rem;
}

.item-exposition p {
  font-size: 0.88rem;
}

/* Severity — a hazard lead-word in its own warning treatment, never color alone. */
.item-severity-callout {
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-left: 3px solid var(--rose);
  border-radius: 8px;
  color: var(--ink);
  background: var(--rose-soft);
  font-size: 0.85rem;
  line-height: 1.4;
}

.hazard-word {
  margin-right: 0.2rem;
  color: var(--rose);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

/* Reference — compact key-value rows, the smallest text on the card after provenance. */
.item-reference {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.1rem 0.7rem;
  margin: 0;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
  font-size: 0.76rem;
  line-height: 1.45;
}

.item-reference dt {
  color: var(--muted);
  font-weight: 600;
}

.item-reference dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.item-reference a {
  color: var(--teal);
}

.item-reference code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
}

/* CR-0148 — a Reference block that outnumbers the body sits behind a disclosure; the rule moves to it. */
.item-reference-disclosure {
  border-top: 1px solid var(--line);
}

.item-reference-disclosure > summary {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.76rem;
  cursor: pointer;
  list-style: none;
}

.item-reference-disclosure > summary::-webkit-details-marker {
  display: none;
}

.item-reference-disclosure > summary::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 120ms ease;
}

.item-reference-disclosure[open] > summary::before {
  transform: rotate(45deg);
}

.item-reference-disclosure > .item-reference {
  padding-top: 0;
  padding-bottom: 0.35rem;
  border-top: 0;
}

.item-provenance {
  color: var(--muted);
  font-size: 0.72rem;
}

.item-exchange:empty {
  display: none;
}

.item-exchange {
  display: grid;
  gap: 0.35rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: var(--canvas);
}

.exchange-line p {
  margin: 0.1rem 0 0;
  font-size: 0.85rem;
  white-space: pre-line;
}

.exchange-who {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.exchange-line[data-direction="outbound"] .exchange-who {
  color: var(--teal);
}

.item-reply {
  display: grid;
  gap: 0.4rem;
  padding-top: 0.45rem;
  border-top: 1px dashed var(--line);
}

.item-reply-row {
  display: flex;
  gap: 0.4rem;
}

.item-reply-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-size: 0.88rem;
}

.item-reply-row button {
  padding: 0.5rem 1rem;
  border-radius: 10px;
}

/* One accent-filled action per card (CR-0145); everything else is neutral. */
.item-quick .is-primary {
  border-color: var(--teal);
  color: white;
  background: var(--teal);
  font-weight: 700;
}

.item-reply input:disabled,
.item-reply button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.item-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.item-quick button {
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
}

.item-reply-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.message-about {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

/* CR-0182 S3 — the safety view's one message (public/safety.html). */
.safety-text {
  margin: 0;
  padding: 1rem 1.15rem;
  border-left: 4px solid var(--rose);
  border-radius: var(--radius-md);
  background: var(--rose-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.safety-text p {
  margin: 0;
  line-height: 1.55;
}
