/* Tidewater Support. A tide-chart palette: sea-glass paper, deep-sounding ink,
   channel teal for actions, shoal sand for writes held offshore (in review), and
   buoy red only for rejected or hijacked things. The one memorable element is the
   tide line in the ticket list: delivered above, held below. */

:root {
  --paper: #eef3f2;
  --surface: #f8fbfa;
  --band: #e1eae8;
  --ink: #13343b;
  --ink-soft: #4b6a70;
  --channel: #1f7a78;
  --channel-ink: #ffffff;
  --shoal: #e2c98f;
  --shoal-wash: #f5ecd6;
  --buoy: #b8392a;
  --buoy-wash: #f6e1dc;
  --line: #c9d7d5;
  --focus: #0b5f8a;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f2227;
    --surface: #16313a;
    --band: #1c3b44;
    --ink: #dce9e7;
    --ink-soft: #9db8b6;
    --channel: #4fb3ae;
    --channel-ink: #0b1d21;
    --shoal: #d9b86a;
    --shoal-wash: #3a3423;
    --buoy: #ef7a66;
    --buoy-wash: #42241f;
    --line: #2c4d55;
    --focus: #7cc7f0;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson Hyperlegible Next", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

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

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

/* ── Bar ─────────────────────────────────────────────────────────────── */

.bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.wordmark b {
  font-weight: 800;
}

.mark {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: var(--channel);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.mark circle {
  fill: var(--shoal);
  stroke: none;
}

.personas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.personas-hint {
  color: var(--ink-soft);
  margin-right: 4px;
}

.personas button {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  cursor: pointer;
}

.personas button small {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.personas button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.personas button[aria-pressed="true"] small {
  color: inherit;
  opacity: 0.75;
}

.protected {
  margin: 0;
  padding: 8px clamp(16px, 4vw, 40px);
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* ── Layout ──────────────────────────────────────────────────────────── */

main {
  padding: 8px clamp(16px, 4vw, 40px) 64px;
  outline: none;
}

.welcome h1,
.pane h1 {
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
  margin: 24px 0 8px;
}

.welcome p {
  max-width: 60ch;
  color: var(--ink-soft);
  font-size: 1.125rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  align-items: start;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

h2 {
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

h3 {
  font-size: 1rem;
  margin: 0 0 6px;
}

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

/* ── Ticket list and the tide line ───────────────────────────────────── */

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

.ticket-row {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 0 0 2px;
  cursor: pointer;
}

.ticket-row:hover,
.ticket-row[aria-current="true"] {
  background: var(--band);
}

.ticket-row .subject {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.ticket-row .meta {
  display: block;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

.held .ticket-row {
  background: var(--shoal-wash);
  box-shadow: inset 3px 0 0 var(--shoal);
}

.held .ticket-row.rejected {
  background: var(--buoy-wash);
  box-shadow: inset 3px 0 0 var(--buoy);
}

.tide {
  margin: 14px 0 10px;
  color: var(--shoal);
}

.tide svg {
  display: block;
  width: 100%;
  height: 10px;
}

.tide p {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* ── Panels, forms, buttons ──────────────────────────────────────────── */

.pane {
  background: var(--surface);
  border-radius: 14px;
  padding: clamp(16px, 3vw, 28px);
  min-width: 0;
}

.pane h1 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin-top: 0;
  overflow-wrap: anywhere;
}

.body-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 70ch;
}

.thread {
  list-style: none;
  margin: 20px 0;
  padding: 0;
}

.thread li {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.thread .who {
  font-weight: 700;
}

.thread li.staff .who {
  color: var(--channel);
}

.thread li.held {
  background: var(--shoal-wash);
  padding: 12px;
  border-radius: var(--radius);
  border-top: 0;
  margin-top: 6px;
}

form {
  display: grid;
  gap: 10px;
  max-width: 70ch;
}

label {
  font-weight: 700;
  font-size: 0.9375rem;
}

input,
textarea {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  background: var(--channel);
  color: var(--channel-ink);
  justify-self: start;
}

.button.quiet {
  background: transparent;
  color: var(--channel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ── Status tracker for held writes ──────────────────────────────────── */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 700;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--shoal);
}

.status.delivered::before {
  background: var(--channel);
}

.status.rejected {
  color: var(--buoy);
}

.status.rejected::before {
  background: var(--buoy);
}

.receipt {
  font-size: 0.8125rem;
  color: var(--ink-soft);
}

/* ── Agent: proposals and the replay ─────────────────────────────────── */

.stack {
  display: grid;
  gap: clamp(16px, 3vw, 28px);
}

.proposal {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.proposal .amount {
  font-weight: 800;
  font-size: 1.125rem;
}

.replay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

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

.replay-side {
  border-radius: 12px;
  padding: 16px;
  background: var(--band);
}

.replay-side.off {
  background: var(--buoy-wash);
}

.replay-side .total {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 8px;
}

.replay-side.off .total {
  color: var(--buoy);
}

.replay-side ol {
  margin: 8px 0 0;
  padding-left: 20px;
}

.replay-side li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}

.replay-side li.hijacked {
  color: var(--buoy);
  font-weight: 700;
}

.payload {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-left: 3px solid var(--buoy);
  background: var(--paper);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
}

.simulated-note {
  font-size: 0.875rem;
  color: var(--ink-soft);
  max-width: 75ch;
}

/* ── Toast ───────────────────────────────────────────────────────────── */

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  max-width: min(560px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  #toast {
    transition: none;
  }
}
