/* Engagement Kit: local interface styles. System fonts only; works offline. */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;

  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --text: #18221c;
  --muted: #5a675f;
  --border: #d7ded5;
  --border-strong: #b9c4b6;

  --accent: #7ab648;          /* Caylent green: fills, meters, marks */
  --accent-strong: #4b7a22;   /* text and button background on light surfaces (AA) */
  --accent-ink: #ffffff;      /* text on --accent-strong */
  --accent-soft: #e8f2dc;

  --ok: #3d7a20;
  --ok-bg: #e6f2db;
  --warn: #8a5300;
  --warn-bg: #fbf0dc;
  --danger: #b0281f;
  --danger-bg: #fbe7e5;
  --info: #255f9e;
  --info-bg: #e3edf8;
  --neutral: #4f5a53;
  --neutral-bg: #e9ede8;

  --focus: #2d6fd1;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --shadow: 0 1px 2px rgba(24, 34, 28, 0.06);
  --max: 1200px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101511;
    --surface: #171e19;
    --surface-2: #1e2721;
    --text: #e2e9e3;
    --muted: #9aa79e;
    --border: #2b3530;
    --border-strong: #3c4842;

    --accent: #7ab648;
    --accent-strong: #8dc75b;
    --accent-ink: #0f1a09;
    --accent-soft: #233519;

    --ok: #95d06a;
    --ok-bg: #1f3317;
    --warn: #f0b85a;
    --warn-bg: #3a2c12;
    --danger: #ff8f84;
    --danger-bg: #3d1c19;
    --info: #8cb9ee;
    --info-bg: #182a3d;
    --neutral: #b4bfb8;
    --neutral-bg: #252e29;

    --focus: #7fb0ff;
    --shadow: none;
  }
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
}

h1 {
  font-size: 1.75rem;
  letter-spacing: -0.015em;
}

h2 {
  font-size: 1.125rem;
}

h3 {
  font-size: 1.0625rem;
}

h4 {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 600;
  margin-top: var(--space-3);
}

p {
  margin: 0;
}

a {
  color: var(--accent-strong);
  text-underline-offset: 2px;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.875em;
}

ul {
  margin: var(--space-2) 0 0;
  padding-left: 1.25rem;
}

li + li {
  margin-top: 2px;
}

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

[tabindex="-1"]:focus {
  outline: none;
}

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

.small {
  font-size: 0.8125rem;
}

.nowrap {
  white-space: nowrap;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -48px;
  z-index: 20;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent-strong);
  color: var(--accent-ink);
  font: inherit;
  cursor: pointer;
}

.skip-link:focus {
  top: var(--space-2);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* a thin rule in the accent: the kit's one bit of color in the chrome */
  box-shadow: inset 0 3px 0 var(--accent);
}

.site-header-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
}

.brand-mark rect {
  fill: var(--accent-strong);
}

.brand-mark path {
  stroke: var(--accent-ink);
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}

.site-nav {
  display: flex;
  gap: var(--space-1);
}

.site-nav a {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 550;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  background: var(--accent-soft);
}

/* ── Banner ─────────────────────────────────────────────────────────────── */
.banner {
  background: var(--warn-bg);
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.banner-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
}

.banner-inner p:first-child {
  font-weight: 600;
}

.banner-note {
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.view {
  max-width: var(--max);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
  min-height: 60vh;
}

.view:focus {
  outline: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.page-head .muted {
  margin-top: var(--space-1);
}

.page-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.actions {
  margin-top: var(--space-4);
}

.back {
  display: inline-block;
  margin-bottom: var(--space-2);
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

.back::before {
  content: "‹ ";
}

.back:hover {
  color: var(--text);
  text-decoration: underline;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel + .panel,
.panel + .two-col,
.two-col + .panel,
.notice + .panel {
  margin-top: var(--space-4);
}

.panel > h2 {
  margin-bottom: var(--space-3);
}

.panel > h2 + .muted {
  margin-bottom: var(--space-4);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}

.section-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.two-col > .panel + .panel {
  margin-top: 0;
}

.stack > * + * {
  margin-top: var(--space-3);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
}

.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}

.btn-primary:hover {
  background: var(--accent-strong);
  filter: brightness(1.08);
}

.btn-danger {
  color: var(--danger);
  border-color: currentColor;
  background: var(--surface);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-small {
  min-height: 32px;
  padding: var(--space-1) var(--space-3);
  font-size: 0.875rem;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.link-button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
  text-underline-offset: 2px;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.link-button:hover {
  text-decoration-color: currentColor;
}

/* ── Badges, chips ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-ready,
.badge-tone-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge-needs-attention,
.badge-tone-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge-generating,
.badge-tone-info {
  background: var(--info-bg);
  color: var(--info);
}

.badge-interrupted,
.badge-tone-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-legacy,
.badge-tone-neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

.badge-ready::before,
.badge-needs-attention::before,
.badge-generating::before,
.badge-interrupted::before,
.badge-legacy::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-generating::before {
  animation: pulse 1.6s ease-in-out infinite;
}

/* Team sync badges: a hollow ring, so they read apart from the filled-dot state badges. */
.badge-sync::before {
  content: "";
  width: 7px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0 0;
}

.chips li + li {
  margin-top: 0;
}

.chip {
  padding: 2px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.8125rem;
}

/* ── Fill meter: a bar with tick marks every 10% ────────────────────────── */
.meter-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.meter {
  position: relative;
  flex: 1;
  height: 10px;
  border-radius: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  overflow: hidden;
}

.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 calc(10% - 1px), var(--surface) calc(10% - 1px) 10%);
  pointer-events: none;
}

.meter-bar {
  display: block;
  height: 100%;
  background: var(--accent);
}

.meter-value {
  min-width: 3.2ch;
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ── Home: cards ────────────────────────────────────────────────────────── */
.toolbar {
  margin-bottom: var(--space-4);
}

.input {
  width: 100%;
  min-height: 40px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

.search {
  max-width: 420px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: var(--space-4);
}

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  min-width: 0;
}

.eng-card {
  color: var(--text);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  border-left: 4px solid var(--border);
}

.eng-card:hover {
  border-color: var(--border-strong);
  border-left-color: var(--accent);
}

.eng-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.eng-card-title {
  min-width: 0;
}

.eng-card-title h2 {
  overflow-wrap: anywhere;
}

.eng-card-badges {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.eng-card-sub {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.eng-card-meta,
.eng-card-counts {
  font-size: 0.875rem;
  color: var(--muted);
}

.eng-card-counts {
  color: var(--text);
}

.eng-card-folder {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  overflow-wrap: anywhere;
  border-top: 1px solid var(--border);
  padding-top: var(--space-2);
}

.get-panel {
  margin-bottom: var(--space-4);
  max-width: 720px;
}

.get-panel .notice {
  margin: var(--space-3) 0 0;
}

.get-panel .form-actions {
  margin-top: var(--space-4);
}

.no-match {
  grid-column: 1 / -1;
}

.running-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-bg);
  color: var(--info);
  text-decoration: none;
}

.running-link:hover strong {
  text-decoration: underline;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.empty {
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty h2 {
  overflow-wrap: anywhere;
}

.empty p {
  margin: var(--space-2) auto 0;
  max-width: 52ch;
  color: var(--muted);
}

.empty .actions {
  justify-content: center;
}

/* ── Loading, notices, toasts ───────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) 0;
  color: var(--muted);
}

.spinner {
  flex: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner-small {
  width: 14px;
  height: 14px;
}

.btn .spinner {
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
}

.notice {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
}

.notice > * + * {
  margin-top: var(--space-2);
}

.notice-title {
  font-weight: 650;
}

.notice-ok {
  background: var(--ok-bg);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}

.notice-warn {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.notice-danger {
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.notice-info {
  background: var(--info-bg);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}

.notice ul {
  margin-top: var(--space-2);
}

.notice .actions {
  margin-top: var(--space-3);
}

.toasts {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(400px, calc(100vw - 2 * var(--space-4)));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  border-left: 4px solid var(--neutral);
}

.toast-success {
  border-left-color: var(--accent);
}

.toast-warn {
  border-left-color: #e0a030;
}

.toast-error {
  border-left-color: #e5534b;
}

.toast-message {
  flex: 1;
  overflow-wrap: anywhere;
}

.toast-action {
  color: inherit;
  font-weight: 650;
}

.toast-close {
  border: 0;
  background: none;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0 var(--space-1);
  cursor: pointer;
  opacity: 0.75;
}

.toast-close:hover {
  opacity: 1;
}

/* ── Wizard ─────────────────────────────────────────────────────────────── */
.steps {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-5);
  counter-reset: none;
}

.steps li + li {
  margin-top: 0;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 3px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  min-width: 0;
}

.step-done {
  border-top-color: var(--accent);
}

.step-current {
  border-top-color: var(--accent-strong);
  color: var(--text);
  font-weight: 650;
}

.step-num {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.step-done .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #10200a;
}

.step-current .step-num {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-ink);
}

.step-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  min-height: 220px;
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone strong {
  font-size: 1.125rem;
}

.dropzone-icon {
  font-size: 1.75rem;
  line-height: 1;
  color: var(--accent-strong);
}

.wizard-body > .panel + .panel {
  margin-top: var(--space-4);
}

.file-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.file-line strong {
  overflow-wrap: anywhere;
}

.file-line .btn {
  margin-left: auto;
}

.detected > * + * {
  margin-top: var(--space-2);
}

.detected-line {
  font-size: 1.0625rem;
}

.rationale {
  max-width: 75ch;
  padding-left: var(--space-3);
  border-left: 3px solid var(--accent);
}

.plain-list {
  list-style: none;
  padding: 0;
}

.form .field + .field {
  margin-top: var(--space-4);
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.field-help {
  margin-top: var(--space-1);
  font-size: 0.8125rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-5);
}

.field-grid .field + .field {
  margin-top: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.inline-field .input {
  flex: 1 1 240px;
  width: auto;
  min-width: 0;
}

.form-feedback {
  margin-top: var(--space-4);
}

.form-feedback:empty {
  display: none;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.form-actions .field-help {
  margin-top: 0;
}

/* ── Progress timeline ──────────────────────────────────────────────────── */
.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tl-row {
  position: relative;
  display: flex;
  gap: var(--space-4);
  padding-bottom: var(--space-5);
  margin: 0;
}

.tl-row + .tl-row {
  margin-top: 0;
}

.tl-row:last-child {
  padding-bottom: 0;
}

.tl-row::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 22px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.tl-row:last-child::before {
  display: none;
}

.tl-done::before {
  background: var(--accent);
}

.tl-dot {
  flex: none;
  position: relative;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
}

.tl-done .tl-dot {
  background: var(--accent);
  border-color: var(--accent);
}

.tl-done .tl-dot::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid #10200a;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.tl-running .tl-dot {
  border-color: var(--accent-strong);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

.tl-warn .tl-dot {
  background: var(--warn-bg);
  border-color: var(--warn);
}

.tl-failed .tl-dot,
.tl-stopped .tl-dot {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.tl-skipped .tl-dot {
  border-style: dashed;
}

.tl-body {
  flex: 1;
  min-width: 0;
}

.tl-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  font-weight: 650;
}

.tl-state {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.tl-running .tl-state {
  color: var(--accent-strong);
}

.tl-failed .tl-state,
.tl-stopped .tl-state {
  color: var(--danger);
}

.tl-warn .tl-state {
  color: var(--warn);
}

.tl-detail {
  margin-top: 2px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.tl-detail > * + * {
  margin-top: var(--space-1);
}

.tl-detail strong {
  color: var(--text);
}

.path {
  color: var(--text);
}

.last-message {
  max-width: 75ch;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.875rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.log {
  max-height: 240px;
  overflow: auto;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.job-footer {
  margin-top: var(--space-4);
}

.job-running {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.done .notice {
  margin-bottom: 0;
}

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.dash-head {
  margin-bottom: var(--space-5);
}

.dash-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.dash-title {
  min-width: 0;
}

.dash-title h1 {
  overflow-wrap: anywhere;
}

.dash-sub {
  font-size: 1.125rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.dash-title .mono {
  margin-top: var(--space-1);
  overflow-wrap: anywhere;
}

.dash-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  align-items: end;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.meta-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin: 0;
}

.meta-list dt,
.status-list dt,
.dates dt {
  font-size: 0.8125rem;
  color: var(--muted);
}

.meta-list dd,
.status-list dd,
.dates dd {
  margin: 0;
  font-weight: 550;
}

/* Team sharing strip in the dashboard header */
.sync-bar {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.sync-bar[hidden] {
  display: none;
}

.sync-bar > * + * {
  margin-top: var(--space-3);
}

.sync-bar .notice {
  margin-bottom: 0;
}

.sync-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-4);
}

.sync-loading {
  justify-content: flex-start;
  gap: var(--space-2);
}

.sync-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  min-width: 0;
}

.sync-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
}

.sync-repo {
  font-family: var(--mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
  min-width: 0;
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.file-list {
  list-style: none;
  padding: 0;
}

.file-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin: 0;
  padding: var(--space-2) 0;
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.file-list-path {
  min-width: 0;
  overflow-wrap: anywhere;
}

.error-detail {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dash-fill .muted {
  margin-bottom: var(--space-1);
}

.tabs {
  display: flex;
  gap: var(--space-1);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-4);
  position: relative;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tabs a {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-3);
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--text);
}

.tabs a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-row {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border);
}

.check-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.check-row + .check-row {
  margin-top: 0;
}

.check-main {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.check-main .badge {
  flex: none;
  min-width: 56px;
  justify-content: center;
}

.check-items {
  margin: var(--space-2) 0 0;
  padding-left: calc(56px + var(--space-3));
  list-style: none;
}

.notes {
  list-style: none;
  padding: var(--space-3) 0 0;
  margin: var(--space-3) 0 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
}

.dates {
  margin: 0;
  display: grid;
  gap: var(--space-3);
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--surface-2);
  font-weight: 650;
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

.table th.num,
.table td.num {
  text-align: right;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table td p + p {
  margin-top: 2px;
}

.cell-wide {
  min-width: 240px;
  max-width: 480px;
}

.row-attention td {
  background: color-mix(in srgb, var(--warn-bg) 60%, transparent);
}

.row-pending td {
  background: color-mix(in srgb, var(--warn-bg) 45%, transparent);
}

.row-skip td {
  background: var(--surface-2);
}

.row-actions {
  display: flex;
  gap: var(--space-2);
}

.skip-form > * + * {
  margin-top: var(--space-2);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.field-inline {
  flex: 1 1 180px;
  max-width: 260px;
}

.field-inline label {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 600;
}

.adr-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
}

.adr-head h3 {
  overflow-wrap: anywhere;
}

.adr > * + * {
  margin-top: var(--space-3);
}

.adr-badges {
  flex: none;
}

.prose {
  max-width: 75ch;
  white-space: pre-line;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.meeting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: var(--space-4);
}

.meeting ul {
  margin-top: var(--space-1);
}

.tree,
.tree .tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree .tree {
  margin-left: 9px;
  padding-left: var(--space-4);
  border-left: 1px solid var(--border);
}

.tree li {
  margin: 0;
  padding: 3px 0;
}

.tree summary {
  cursor: pointer;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tree-name {
  font-family: var(--mono);
  font-size: 0.875rem;
}

.tree-file .link-button {
  font-family: var(--mono);
  font-size: 0.875rem;
  padding-left: 1.1rem;
}

.tree-empty {
  padding-left: var(--space-4);
}

/* ── Settings, gate ─────────────────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.settings-grid > .panel + .panel {
  margin-top: 0;
}

.status-list {
  margin: 0 0 var(--space-4);
  display: grid;
  gap: var(--space-3);
}

.status-list dd .small {
  font-weight: 400;
  margin-top: var(--space-1);
}

.gate {
  max-width: 560px;
  margin: 12vh auto 0;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  border-top: 4px solid var(--accent);
}

.gate h1 {
  font-size: 1.375rem;
  margin-bottom: var(--space-3);
}

.gate p + p {
  margin-top: var(--space-2);
}

.noscript {
  padding: var(--space-5);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .two-col,
  .settings-grid,
  .dash-meta {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.5rem;
  }

  .view {
    padding: var(--space-4) var(--space-4) var(--space-6);
  }

  .panel {
    padding: var(--space-4);
  }

  .card {
    padding: var(--space-4);
  }

  .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .step-label {
    display: none;
  }

  .step-current .step-label {
    display: inline;
  }

  .file-line .btn {
    margin-left: 0;
  }

  .search {
    max-width: none;
  }

  .field-inline {
    max-width: none;
  }

  .check-items {
    padding-left: var(--space-4);
  }

  .site-header-inner {
    padding: var(--space-2) var(--space-4);
  }

  .dash-title-row {
    flex-direction: column-reverse;
    gap: var(--space-2);
  }

  .sync-actions {
    width: 100%;
  }

  .sync-actions .btn {
    flex: 1 1 auto;
  }
}

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

.path-link {
  display: block;
  text-align: left;
  overflow-wrap: anywhere;
}

/* Similar past engagements (Overview) */
.case-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.case-list li { border-top: 1px solid var(--border); padding-top: 12px; }
.case-list li:first-child { border-top: 0; padding-top: 0; }
.case-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.case-list p { margin: 4px 0; }
.done-cases { margin: 12px 0 0; color: var(--muted); }

/* ── Cloud mode ─────────────────────────────────────────────────────────── */
/* Header: brand, nav, then who is signed in. */
.is-cloud .site-header-inner {
  justify-content: flex-start;
}

.is-cloud .site-nav {
  margin-left: auto;
}

.site-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  font-size: 0.875rem;
}

.site-user-email {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

.site-user .link-button {
  white-space: nowrap;
}

.banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.gate .actions {
  margin-top: var(--space-4);
}

.account-panel {
  max-width: 560px;
}

.account-panel .status-list {
  margin: var(--space-3) 0;
}

/* File viewer (cloud "Open"): a native modal dialog. */
.file-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.file-dialog::backdrop {
  background: rgba(16, 21, 17, 0.55);
}

.file-dialog-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-height: calc(100vh - 66px);
  padding: var(--space-4);
}

.file-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.file-dialog-head h2 {
  margin: 0;
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.file-dialog-tools {
  display: flex;
  flex: none;
  gap: var(--space-2);
}

.file-dialog-status:empty {
  display: none;
}

.file-dialog-body {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.file-view {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

@media (max-width: 640px) {
  .site-user-email {
    max-width: 160px;
  }

  .file-dialog-head {
    flex-direction: column;
  }
}
