/* Caisson palette: bone paper, ink, one signal orange. Sans throughout, Anthropic Sans where it is
   installed, Instrument Sans otherwise (the same stack as the site). */

:root {
  color-scheme: light;
  --bg: #ebe7de;
  --plate: #f4f1ea;
  --fg: #171a21;
  --muted: #50545e;
  --subtle: #777b84;
  --line: rgb(23 26 33 / 0.16);
  --line-soft: rgb(23 26 33 / 0.08);
  --signal: #df5a2b;
  --signal-ink: #b03f17;
  --rail: #171a21;
  --rail-fg: #ebe7de;
  --rail-muted: #a9a79f;
  --rail-line: rgb(235 231 222 / 0.12);
  --font: "Anthropic Sans Web", "Instrument Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.3, 0.5, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #14161b;
    --plate: #1b1e25;
    --fg: #ece8df;
    --muted: #b5b1a8;
    --subtle: #8b8880;
    --line: rgb(236 232 223 / 0.16);
    --line-soft: rgb(236 232 223 / 0.08);
    --signal: #ef7247;
    --signal-ink: #f49a78;
    --rail: #0d0f13;
    --rail-fg: #ece8df;
    --rail-muted: #8b8880;
    --rail-line: rgb(236 232 223 / 0.1);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161b;
  --plate: #1b1e25;
  --fg: #ece8df;
  --muted: #b5b1a8;
  --subtle: #8b8880;
  --line: rgb(236 232 223 / 0.16);
  --line-soft: rgb(236 232 223 / 0.08);
  --signal: #ef7247;
  --signal-ink: #f49a78;
  --rail: #0d0f13;
  --rail-fg: #ece8df;
  --rail-muted: #8b8880;
  --rail-line: rgb(236 232 223 / 0.1);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

h1 { font-size: 30px; }
h2 { font-size: 19px; }

p { margin: 0; }

a { color: var(--signal-ink); }

button, input, textarea {
  font: inherit;
  color: inherit;
}

button {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  background: var(--fg);
  color: var(--bg);
  cursor: pointer;
  transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out), opacity 180ms var(--ease-out);
}

button:hover { opacity: 0.88; }
button:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

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

button.danger { color: var(--signal-ink); }

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
.nav__item:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 2px;
}

input, textarea, select {
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 12px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 180ms var(--ease-out);
}

input:focus, textarea:focus { box-shadow: inset 0 0 0 1.5px var(--fg); }

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

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--fg);
  box-shadow: none;
}

/* ---- sign in and reset ---------------------------------------------------------------------- */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(400px, 100%);
  background: var(--plate);
  border-radius: 28px;
  padding: 32px;
  box-shadow: 0 1px 0 var(--line-soft), 0 30px 60px -36px rgb(23 26 33 / 0.35);
  display: grid;
  gap: 16px;
}

.kicker {
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.stack { display: grid; gap: 10px; }

.stack label, .quiet, label.quiet {
  font-size: 14px;
  color: var(--muted);
}

.lead { color: var(--muted); font-size: 15px; }

.msg {
  min-height: 1.4em;
  font-size: 14px;
  color: var(--muted);
}

.msg[data-error="true"] { color: var(--signal-ink); }

a.quiet { text-decoration: none; }
a.quiet:hover { text-decoration: underline; }

/* ---- the app shell -------------------------------------------------------------------------- */

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 12px;
  padding: 12px;
}

.rail {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  padding: 22px 16px 16px;
  background: var(--rail);
  color: var(--rail-fg);
  border-radius: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand__mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 30%, #f6c2a6 0 12%, transparent 13%),
    linear-gradient(145deg, var(--signal), #b03f17);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.35), 0 8px 18px -10px var(--signal);
}

.brand__name { font-weight: 600; font-size: 16px; }
.brand__who { font-size: 13px; color: var(--rail-muted); }

.nav { display: grid; gap: 2px; }

.nav__item {
  text-align: left;
  background: transparent;
  color: var(--rail-muted);
  padding: 10px 12px;
  border-radius: 12px;
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}

.nav__item:hover { opacity: 1; background: rgb(235 231 222 / 0.06); color: var(--rail-fg); }

.nav__item[aria-current="page"] {
  background: rgb(235 231 222 / 0.12);
  color: var(--rail-fg);
}

.rail__out {
  margin-top: auto;
  background: transparent;
  color: var(--rail-muted);
  box-shadow: inset 0 0 0 1px var(--rail-line);
}

.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--plate);
  border-radius: 28px;
  padding: 28px;
  overflow: hidden;
  box-shadow: 0 1px 0 var(--line-soft);
}

.view__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.view__sub {
  margin-top: 4px;
  font-size: 14px;
  color: var(--muted);
}

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 14px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.seg button {
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.seg button[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
}

.split {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
}

/* ---- message list -------------------------------------------------------------------------- */

.list {
  list-style: none;
  margin: 0;
  padding: 4px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 0;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-soft);
}

.row__button {
  width: 100%;
  display: grid;
  gap: 3px;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  background: transparent;
  color: var(--fg);
  opacity: 1;
}

.row__button:hover { background: var(--plate); opacity: 1; }

.row[aria-current="true"] .row__button {
  background: var(--plate);
  box-shadow: inset 0 0 0 1px var(--line);
}

.row[data-unread="true"] .row__from::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--signal);
  vertical-align: middle;
}

.row__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.row__from {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__time, .row__meta { font-size: 13px; color: var(--muted); }

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

/* ---- reader --------------------------------------------------------------------------------- */

.reader {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 6px 4px 6px 6px;
}

.empty {
  margin: auto;
  color: var(--muted);
  text-align: center;
  max-width: 34ch;
}

.thread__head { display: grid; gap: 6px; }

.thread__meta {
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.thread__log { display: grid; gap: 12px; }

.bubble {
  max-width: 88%;
  padding: 14px 16px;
  border-radius: 20px;
}

.bubble--in {
  justify-self: start;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  border-bottom-left-radius: 8px;
}

.bubble--out {
  justify-self: end;
  background: var(--fg);
  color: var(--bg);
  border-bottom-right-radius: 8px;
}

.bubble--out .bubble__who { color: var(--rail-muted); }

.bubble__who {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}

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

.compose {
  display: grid;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.compose__row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---- team and account ----------------------------------------------------------------------- */

.team {
  overflow-y: auto;
  min-height: 0;
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 2px;
}

.card-form {
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  max-width: 560px;
}

.card-form h2 { margin-bottom: 2px; }

.fields {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.fields legend {
  padding: 0;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  cursor: pointer;
}

.person {
  display: grid;
  gap: 16px;
  padding: 22px;
  border-radius: 20px;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  max-width: 760px;
}

.person__head .lead { margin-top: 4px; }

.person__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.person__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 860px) {
  .app {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
  }
  .rail { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px; }
  .nav { display: flex; gap: 2px; }
  .rail__out { margin-top: 0; margin-left: auto; }
  .view { padding: 20px 16px; }
  .split { grid-template-columns: 1fr; }
  .list { max-height: 45vh; }
  .reader { min-height: 50vh; }
  h1 { font-size: 24px; }
}

select { padding: 9px 12px; border: 0; border-radius: 12px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); width: auto; }
