:root {
  color-scheme: light;
  --ink: #17231f;
  --muted: #596963;
  --paper: #fffdf9;
  --canvas: #f1eee6;
  --forest: #174d3d;
  --forest-dark: #0f382c;
  --line: #d4d8d1;
  --danger: #9b2828;
  --danger-dark: #751d1d;
  --danger-soft: #fbe9e5;
  --warning-soft: #fff3cd;
  --shadow: 0 0.75rem 2.5rem rgb(23 58 47 / 10%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 18rem;
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--forest);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 0.2rem solid #df8d29;
  outline-offset: 0.2rem;
}

button,
input {
  font: inherit;
}

button,
.button,
.primary-nav a {
  min-height: 2.75rem;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 24ch;
  margin-bottom: 0.5rem;
  font-size: clamp(1.75rem, 4vw, 2.7rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

h2 {
  font-size: 1.15rem;
  line-height: 1.25;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 0.75rem max(1rem, calc((100vw - 76rem) / 2));
  background: var(--forest-dark);
  color: white;
}

.brand {
  color: white;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.account {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #dce8e3;
  font-size: 0.875rem;
}

.account form {
  margin: 0;
}

.app-shell {
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding-bottom: 4rem;
}

.primary-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.primary-nav a {
  display: inline-flex;
  align-items: center;
  padding: 0 0.9rem;
  border-radius: 0.5rem;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav a[aria-current="page"] {
  background: var(--paper);
  color: var(--forest-dark);
  box-shadow: 0 0.15rem 0.5rem rgb(23 58 47 / 8%);
}

.main-content {
  padding-top: clamp(1.5rem, 4vw, 3rem);
}

.page-heading,
.detail-heading,
.card-heading,
.message-card,
.decision-panel,
.attachment-panel,
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.page-heading {
  align-items: flex-end;
  margin-bottom: 1.5rem;
}

.page-heading p {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.4rem;
  color: var(--forest);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.count {
  display: grid;
  flex: 0 0 auto;
  width: 3rem;
  height: 3rem;
  place-items: center;
  border-radius: 50%;
  background: var(--forest);
  color: white;
  font-weight: 800;
}

.message-list {
  display: grid;
  gap: 0.75rem;
}

.message-card,
.detail-card,
.confirmation-card,
.empty-state,
.login-card {
  border: 1px solid rgb(17 56 44 / 8%);
  border-radius: 0.9rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.message-card {
  align-items: flex-end;
  padding: 1.2rem;
}

.message-card-main {
  min-width: 0;
  flex: 1;
}

.card-heading {
  align-items: flex-start;
}

.card-heading h2 {
  margin-bottom: 0.25rem;
}

.meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.excerpt {
  display: -webkit-box;
  overflow: hidden;
  max-width: 75ch;
  margin-bottom: 0;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: pre-wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--forest);
  border-radius: 0.55rem;
  background: var(--forest);
  color: white;
  font-weight: 800;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--forest-dark);
}

.button-secondary,
.button-quiet {
  border-color: #aeb9b4;
  background: transparent;
  color: var(--forest-dark);
}

.button-secondary:hover {
  background: #edf1ee;
}

.button-quiet {
  border-color: #89a298;
  color: white;
}

.button-small {
  min-height: 2.75rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
}

.button-danger {
  border-color: var(--danger);
  background: var(--danger);
}

.button-danger:hover {
  background: var(--danger-dark);
}

button:disabled,
[disabled].button {
  cursor: wait;
  opacity: 0.55;
}

.status {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 99rem;
  background: #e8edeb;
  color: #344a42;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.035em;
}

.status-pending {
  background: var(--warning-soft);
  color: #745a00;
}

.status-deleted {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

.status-moderated,
.status-passed,
.status-passed_auto {
  background: #dff1e8;
  color: #14553e;
}

.empty-state,
.confirmation-card {
  max-width: 48rem;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.empty-state {
  text-align: center;
  margin-inline: auto;
}

.empty-state p {
  color: var(--muted);
}

.back-row {
  margin-bottom: 1rem;
}

.back-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  font-weight: 750;
  text-decoration: none;
}

.detail-card {
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.detail-card > section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.detail-heading {
  align-items: flex-start;
}

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 1.5rem 0 0;
  border: 1px solid var(--line);
  border-radius: 0.7rem;
}

.facts div {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
}

.facts div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.facts dd {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
}

.message-content,
pre {
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: #f5f6f3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attachment-panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.6rem;
}

.attachment-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

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

.data-list li,
.timeline li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}

.timeline span:first-child {
  color: var(--muted);
}

.decision-panel {
  align-items: flex-end;
  padding: 1.25rem;
  border: 0 !important;
  border-radius: 0.7rem;
  background: #edf3ef;
}

.analysis-panel {
  padding: 1.25rem;
  border: 1px solid var(--line) !important;
  border-radius: 0.7rem;
  background: #f7f8f5;
}

.analysis-failed {
  border-color: #d4a99f !important;
  background: #fff8f6;
}

.analysis-pending,
.analysis-processing {
  background: #fffbec;
}

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

.analysis-heading h2,
.analysis-panel > p,
.analysis-scores h3 {
  margin-bottom: 0.5rem;
}

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

.analysis-facts div {
  min-width: 0;
}

.analysis-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.analysis-facts dd {
  margin: 0.15rem 0 0;
  overflow-wrap: anywhere;
}

.analysis-scores {
  margin: 1rem 0;
}

.analysis-scores h3 {
  font-size: 0.9rem;
}

.analysis-retry-notice {
  margin-top: 1rem;
  color: #65211b;
  font-weight: 700;
}

.decision-panel h2,
.decision-panel p {
  margin-bottom: 0.25rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.actions form {
  margin: 0;
}

.alert {
  max-width: 52rem;
  margin-bottom: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid #d4a99f;
  border-radius: 0.65rem;
  background: var(--danger-soft);
  color: #65211b;
}

.alert p {
  margin: 0.25rem 0 0;
}

.alert-success {
  border-color: #9fc7b5;
  background: #e4f3eb;
  color: #124d39;
}

.warning-box {
  margin: 1.5rem 0;
  padding: 1rem;
  border-left: 0.35rem solid #d19600;
  background: var(--warning-soft);
}

.warning-box p {
  margin: 0.25rem 0 0;
}

.pagination {
  margin-top: 1.5rem;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--forest-dark);
}

.login-card {
  width: min(100%, 27rem);
  padding: clamp(1.5rem, 6vw, 2.5rem);
}

.stack {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.stack label {
  margin-top: 0.5rem;
  font-weight: 750;
}

.stack input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #86958f;
  border-radius: 0.5rem;
  background: white;
}

.stack .button {
  margin-top: 1rem;
}

.error-state {
  border-color: #d4a99f;
}

@media (max-width: 42rem) {
  .site-header,
  .account,
  .message-card,
  .decision-panel,
  .attachment-panel,
  .detail-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header {
    gap: 0.5rem;
  }

  .account {
    gap: 0.25rem;
  }

  .account .button,
  .message-card > .button,
  .actions,
  .actions .button,
  .actions form,
  .actions button {
    width: 100%;
  }

  .facts,
  .analysis-facts {
    grid-template-columns: 1fr;
  }

  .facts div:nth-last-child(2) {
    border-bottom: 1px solid var(--line);
  }

  .page-heading {
    align-items: flex-start;
  }
}

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