/* Autopilot (src/routes/autopilot.ts, public/static/app/autopilot.js):
   "What's happening" above dashboards, the plan and goal suggestions, the
   Alerts card and history, and simple mode for clients. Colors are the
   shared tokens in site.css, so light and dark both follow them (contrast
   ratios are noted there). */

/* ---------------- above the dashboard ---------------- */

.ap {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}
.ap[hidden] {
  display: none;
}
.ap-slot {
  display: grid;
  gap: 12px;
}
.ap-slot:empty {
  display: none;
}
.ap + .dash {
  margin-top: 16px;
}
.ap-card {
  padding: 16px 18px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.ap-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ap-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.ap-when {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.ap-lead {
  margin: 6px 0 0;
  color: var(--text-dim);
}
.ap-sentences {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.ap-sentence {
  position: relative;
  padding-left: 18px;
  font-size: 16px;
  line-height: 1.5;
}
.ap-sentence::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.ap-sentence.is-thin {
  color: var(--text-dim);
}
.ap-sentence.is-thin::before {
  background: var(--line-strong);
}
.ap-sentence a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 3px;
}
.ap-sentence a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}
.ap-explain-out {
  margin: 12px 0 0;
  padding: 12px 14px;
  background: var(--bg-tint);
  border-radius: var(--radius);
  color: var(--text);
}
.ap-explain-out[hidden] {
  display: none;
}
.ap-filtered {
  margin: 0;
  color: var(--text-faint);
  font-size: 13px;
}

/* The plan and suggested goals. */
.ap-steps {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
  counter-reset: ap;
}
.ap-plan .ap-steps > li {
  counter-increment: ap;
}
.ap-step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.ap-step:first-child {
  border-top: 0;
  padding-top: 4px;
}
.ap-plan .ap-step-title::before {
  content: counter(ap) '. ';
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ap-step-title {
  margin: 0;
  font-weight: 600;
}
.ap-step-why {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}
.ap-step.is-applied .ap-step-title,
.ap-step.is-undone .ap-step-title {
  color: var(--text-dim);
}
.ap-step-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.ap-status {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.ap-status:empty {
  display: none;
}
.ap-preview {
  grid-column: 1 / -1;
  padding: 12px 14px;
  background: var(--bg-tint);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.ap-preview[hidden] {
  display: none;
}
.ap-preview-title {
  margin: 0 0 6px;
  font-weight: 650;
}
.ap-preview-lines {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px 14px;
  margin: 0 0 8px;
  font-size: 14px;
}
.ap-preview-lines dt {
  color: var(--text-faint);
}
.ap-preview-lines dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.ap-preview-note {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
}
.ap-preview .ap-step-actions {
  justify-content: flex-start;
}

/* "It works": the tag was found. */
.ap-yay {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--chip-ok-bg);
  border-color: var(--chip-ok-line);
}
.ap-yay-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--cta);
  color: var(--cta-ink);
  font-weight: 700;
}
.ap-yay-text {
  flex: 1;
  min-width: 0;
  color: var(--text);
}

@media (max-width: 720px) {
  .ap-step {
    grid-template-columns: minmax(0, 1fr);
  }
  .ap-step-actions {
    justify-content: flex-start;
  }
  .ap-step-actions .btn {
    min-height: 44px;
  }
  .ap-sentence {
    font-size: 15px;
  }
}

/* ---------------- settings and history ---------------- */

.ap-kinds {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  min-width: 0;
}
.ap-kind {
  display: grid;
  gap: 8px;
}
.ap-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.ap-check input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.ap-check > span {
  display: grid;
  gap: 2px;
}
.ap-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
  padding-left: 28px;
}
.ap-kinds + .ap-inline,
form > .ap-inline {
  padding-left: 0;
}
.ap-grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.ap-sub {
  margin: 8px 0 0;
  font-size: 15px;
}
@media (max-width: 720px) {
  .ap-grid3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ap-alerts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ap-alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.ap-alert:first-child {
  border-top: 0;
}
.ap-alert-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.ap-alert-tag_stopped .ap-alert-mark,
.ap-alert-traffic_drop .ap-alert-mark,
.ap-alert-ad_spend .ap-alert-mark {
  background: var(--chip-warn-bg);
  color: var(--chip-warn-fg);
}
.ap-alert-title {
  margin: 0;
  font-weight: 650;
}
.ap-alert-body {
  margin: 2px 0 0;
}
.ap-alert-meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-faint);
}
@media (max-width: 720px) {
  .ap-alert {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .ap-alert > .btn {
    grid-column: 2;
    justify-self: start;
  }
}

/* The developer email and the detected builder on /app/start. */
.setup-detected {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0 0;
  padding: 10px 12px;
  background: var(--brand-band);
  border-radius: var(--radius);
  color: var(--text);
}
.setup-detected svg {
  flex-shrink: 0;
  color: var(--accent);
}
.setup-dev {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.setup-dev > summary {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.setup-dev[open] > summary {
  margin-bottom: 10px;
}

/* ---------------- simple mode ---------------- */

.sm {
  display: grid;
  gap: 18px;
  max-width: 820px;
  margin: 0 auto;
  font-size: 18px;
}
.sm-preview {
  margin-bottom: -4px;
}
.sm-head {
  display: grid;
  gap: 6px;
}
.sm-logo {
  height: 36px;
  width: auto;
  justify-self: start;
  margin-bottom: 6px;
}
.sm-brand {
  margin: 0 0 4px;
  font-weight: 700;
}
.sm-eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  overflow-wrap: anywhere;
}
.sm-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 40px;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.sm-periods {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.sm-period {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  background: var(--bg-raised);
}
.sm-period:hover {
  background: var(--bg-hover);
}
.sm-period[aria-current='page'] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.sm-card {
  padding: 22px 24px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}
.sm-h {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 650;
}
.sm-sentences .ap-sentence {
  font-size: 20px;
  line-height: 1.45;
  padding-left: 22px;
}
.sm-sentences .ap-sentence::before {
  width: 9px;
  height: 9px;
  top: 0.55em;
}
.sm-sentences {
  gap: 10px;
  margin: 0;
}
.sm-numbers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.sm-num {
  padding: 20px 22px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  min-width: 0;
}
.sm-num-label {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-dim);
}
.sm-num-value {
  margin: 6px 0 4px;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 48px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.sm-num-note {
  margin: 0;
  font-size: 15px;
  color: var(--text-faint);
}
.sm-sources,
.sm-winlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.sm-source {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 4px 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.sm-source:first-child,
.sm-win:first-child {
  border-top: 0;
}
.sm-mark {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--bg-tint);
  color: var(--text);
}
.sm-mark svg {
  width: 22px;
  height: 22px;
}
.sm-source-name {
  font-weight: 600;
  font-size: 19px;
  overflow-wrap: anywhere;
}
.sm-source-n {
  font-family: var(--serif);
  font-size: 26px;
  font-variant-numeric: tabular-nums;
}
.sm-bar {
  grid-column: 2 / -1;
  height: 8px;
  border-radius: 999px;
  background: var(--bg-tint);
  overflow: hidden;
}
.sm-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.sm-win {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.sm-win .sm-mark {
  grid-row: auto;
}
.sm-win-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.sm-win-text span {
  color: var(--text-dim);
  font-size: 16px;
}
.sm-win-when {
  color: var(--text-faint);
  font-size: 15px;
  white-space: nowrap;
}
.sm-empty {
  margin: 0;
  color: var(--text-dim);
}
.sm-more {
  margin: 4px 0 0;
  text-align: center;
}
.sm-more .btn {
  min-height: 48px;
  font-size: 16px;
}
@media (max-width: 720px) {
  .sm {
    font-size: 17px;
    gap: 14px;
  }
  .sm-title {
    font-size: 32px;
  }
  .sm-card {
    padding: 18px 16px;
  }
  .sm-numbers {
    grid-template-columns: minmax(0, 1fr);
  }
  .sm-num {
    padding: 16px 18px;
  }
  .sm-num-value {
    font-size: 44px;
  }
  .sm-sentences .ap-sentence {
    font-size: 18px;
  }
  .sm-win {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .sm-win-when {
    grid-column: 2;
  }
}
