:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --ink: #182027;
  --muted: #69747e;
  --line: #dce1e6;
  --line-strong: #c4ccd4;
  --accent: #0f6d68;
  --accent-soft: #e3f4f2;
  --p0: #a12820;
  --p0-soft: #fae7e4;
  --p1: #9b5a12;
  --p1-soft: #fff1d9;
  --p2: #315f98;
  --p2-soft: #e8f1fb;
  --shadow: 0 18px 44px rgba(24, 32, 39, 0.08);
  --font: Inter, "Avenir Next", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
}

button,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.72rem 0.95rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--line-strong);
}

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

textarea {
  width: 100%;
  min-height: 21rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--panel-soft);
}

.app-shell {
  width: min(1720px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar,
.metric,
.priority-rail,
.review-pane,
.todo-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 18px 20px;
  border-radius: 8px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
}

h3 {
  font-size: 0.9rem;
}

.section-label {
  margin-bottom: 0.34rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.status-strip span,
.priority-badge,
.row-priority {
  border-radius: 999px;
  padding: 0.36rem 0.58rem;
  font-size: 0.72rem;
  font-weight: 800;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

#send-state[data-state="gated"] {
  background: var(--p1-soft);
  border-color: #efcf99;
}

#send-state[data-state="enabled"] {
  background: var(--accent-soft);
  border-color: #addbd7;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px;
  padding: 14px 16px;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.65rem;
}

.metric.p0 {
  border-color: #e4b6b1;
  background: var(--p0-soft);
}

.metric.p1 {
  border-color: #efcf99;
  background: var(--p1-soft);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 330px;
  gap: 12px;
  align-items: start;
}

.priority-rail,
.review-pane,
.todo-pane {
  min-height: 720px;
  border-radius: 8px;
}

.priority-rail,
.todo-pane {
  padding: 14px;
}

.rail-heading,
.panel-title,
.detail-head,
.button-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
}

.rail-heading {
  margin-bottom: 12px;
}

.search-box {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 12px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.68rem 0.76rem;
  background: var(--panel-soft);
  color: var(--ink);
  font: inherit;
}

.rail-heading span,
.panel-title span {
  color: var(--muted);
  font-size: 0.78rem;
}

.item-list,
.todo-list {
  display: grid;
  gap: 8px;
}

.item-row,
.todo-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  padding: 0.82rem;
}

.item-row[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.row-copy {
  display: grid;
  min-width: 0;
  gap: 0.22rem;
}

.mailbox-badge {
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.18rem 0.45rem;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 850;
}

.row-copy strong,
.todo-row strong {
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.28;
}

small {
  color: var(--muted);
  line-height: 1.35;
}

.p0 .row-priority,
.priority-badge.p0,
.todo-row.p0 span {
  background: var(--p0-soft);
  color: var(--p0);
}

.p1 .row-priority,
.priority-badge.p1,
.todo-row.p1 span {
  background: var(--p1-soft);
  color: var(--p1);
}

.p2 .row-priority,
.priority-badge.p2,
.todo-row.p2 span {
  background: var(--p2-soft);
  color: var(--p2);
}

.review-pane {
  padding: 0;
  overflow: hidden;
}

.detail-card {
  padding: 18px;
}

.detail-head {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.18;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
  padding-top: 16px;
}

.message-panel,
.reply-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.message-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.message-meta div {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.7rem;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

dd {
  margin: 0;
  line-height: 1.4;
}

.safe-content,
.recommended-action {
  padding: 1rem;
  border-radius: 8px;
  line-height: 1.55;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.recommended-action {
  background: var(--accent-soft);
  border-color: #addbd7;
}

.button-row {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.feedback {
  min-height: 2.4rem;
  color: var(--muted);
  line-height: 1.45;
}

.todo-row {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.todo-row[data-selected="true"] {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.todo-row span {
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 900;
}

.todo-row div {
  display: grid;
  gap: 0.22rem;
}

.todo-detail {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compact-meta div {
  grid-template-columns: 70px minmax(0, 1fr);
}

.preserve-lines {
  white-space: pre-line;
}

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

.empty-state {
  display: grid;
  place-items: center;
  min-height: 720px;
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .todo-pane {
    grid-column: 1 / -1;
    min-height: 0;
  }
}

@media (max-width: 840px) {
  .app-shell {
    width: min(100% - 18px, 720px);
    padding-top: 9px;
  }

  .topbar,
  .workspace,
  .content-grid,
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .priority-rail,
  .review-pane,
  .todo-pane,
  .empty-state {
    min-height: 0;
  }
}
