:root {
  --ink: #172a31;
  --ink-soft: #516268;
  --navy: #173642;
  --teal: #2c6d68;
  --teal-dark: #225752;
  --cream: #f4f1eb;
  --paper: #fffdf9;
  --line: #d9dcd7;
  --line-strong: #bcc5c2;
  --sage: #dce7df;
  --sage-deep: #b9cec1;
  --error: #a13f38;
  --error-bg: #fff0ed;
  --success: #256044;
  --success-bg: #e9f5ed;
  --shadow: 0 18px 50px rgba(28, 47, 54, 0.1);
  --radius-lg: 24px;
  --radius-md: 15px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  margin: 0;
}

a {
  color: var(--teal-dark);
  font-weight: 650;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid rgba(44, 109, 104, 0.35);
  outline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.12;
}

.eyebrow {
  margin-bottom: 0.55rem;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: inline-flex;
  width: 35px;
  height: 30px;
  align-items: flex-end;
  justify-content: center;
}

.brand-mark i {
  display: block;
  width: 16px;
  height: 24px;
  border: 2px solid currentColor;
  border-radius: 12px 12px 4px 4px;
  transform: rotate(-12deg);
}

.brand-mark i + i {
  margin-left: -3px;
  transform: rotate(12deg);
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(330px, 0.86fr) minmax(520px, 1.14fr);
}

.auth-aside {
  position: relative;
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(2rem, 5vw, 4.8rem);
  background: var(--navy);
  color: #f7f4ed;
}

.auth-aside::before,
.auth-aside::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  pointer-events: none;
}

.auth-aside::before {
  right: -13rem;
  bottom: 2rem;
  width: 31rem;
  height: 31rem;
}

.auth-aside::after {
  right: -4rem;
  bottom: 9rem;
  width: 17rem;
  height: 17rem;
  background: rgba(117, 170, 156, 0.08);
}

.auth-aside .brand,
.auth-message,
.auth-footnote {
  position: relative;
  z-index: 1;
}

.auth-message {
  max-width: 35rem;
  padding: 5rem 0;
}

.auth-message .eyebrow {
  color: #94c6b6;
}

.auth-message h1 {
  max-width: 10ch;
  margin-bottom: 1.5rem;
  color: #fffdf7;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.7rem, 5.2vw, 5.6rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.99;
}

.auth-message > p:last-child {
  max-width: 31rem;
  color: #cbd8d6;
  font-size: 1.05rem;
  line-height: 1.7;
}

.auth-footnote {
  margin-bottom: 0;
  color: #9eb0b1;
  font-size: 0.78rem;
}

.auth-main {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: clamp(1.5rem, 6vw, 5rem);
  background-color: var(--cream);
  background-image: radial-gradient(rgba(23, 54, 66, 0.07) 0.6px, transparent 0.6px);
  background-size: 16px 16px;
}

.auth-card {
  width: min(100%, 460px);
  padding: clamp(1.6rem, 4vw, 3rem);
  border: 1px solid rgba(23, 54, 66, 0.11);
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 249, 0.96);
  box-shadow: var(--shadow);
}

.auth-card-wide {
  width: min(100%, 590px);
}

.auth-card-heading {
  margin-bottom: 1.8rem;
}

.auth-card-heading h2 {
  margin-bottom: 0.55rem;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
}

.auth-card-heading > p:last-child,
.page-heading > div > p:last-child,
.field-hint,
.auth-switch {
  color: var(--ink-soft);
}

.form-stack {
  display: grid;
  gap: 1.2rem;
}

.form-stack label {
  display: grid;
  gap: 0.48rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
}

.form-stack .field-group {
  display: grid;
  gap: 0.48rem;
}

.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  min-height: 48px;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  font: inherit;
  /* iOS Safari auto-zooms the page on focus for any field under 16px — the
     wrapping <label>'s 0.86rem was inherited into the field itself, which
     triggered that zoom on every tap and left the fixed/sticky header
     looking "unstuck" until the page was pinched back out. */
  font-size: 16px;
  transition: border-color 130ms ease, box-shadow 130ms ease;
}

.form-stack textarea {
  min-height: 110px;
  resize: vertical;
}

.form-stack input:hover,
.form-stack select:hover,
.form-stack textarea:hover {
  border-color: #8ca29c;
}

.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(44, 109, 104, 0.12);
  outline: none;
}

.form-stack input:disabled {
  color: var(--ink-soft);
  background: #f2f1ec;
}

.invite-link-box {
  overflow-wrap: anywhere;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--cream);
  font-size: 0.86rem;
}

.member-list {
  display: grid;
  margin: 0 0 1.6rem;
  padding: 0;
  list-style: none;
  gap: 0.7rem;
}

.member-list:last-child {
  margin-bottom: 0;
}

.member-row {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.7rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.member-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.7rem;
}

.member-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--sage-deep);
  border-radius: 50%;
  background: var(--sage);
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.member-avatar-pending {
  border-style: dashed;
  color: var(--ink-soft);
}

.member-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.member-pills form {
  margin: 0 0 0 auto;
}

.member-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 750;
}

.member-role {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.member-row-empty {
  color: var(--ink-soft);
  font-size: 0.86rem;
  list-style: none;
}

.status-pill-pending {
  border-color: #e3cf9a;
  background: #fdf3df;
  color: #8a6416;
}

.score-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.score-good {
  border-color: #b9d7c1;
  background: var(--success-bg);
  color: var(--success);
}

.score-warn {
  border-color: #e3cf9a;
  background: #fdf3df;
  color: #8a6416;
}

.score-bad {
  border-color: #efc4bd;
  background: var(--error-bg);
  color: var(--error);
}

.unack-list {
  display: grid;
  margin: 1.2rem 0 0;
  padding: 0;
  list-style: none;
  gap: 0.9rem;
}

.unack-row {
  padding: 1rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.unack-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.8rem;
  margin-bottom: 0.4rem;
  min-width: 0;
}

.unack-sender {
  font-weight: 800;
}

.unack-conversation {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 700;
}

.unack-time {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: 0.74rem;
}

.unack-body {
  margin: 0 0 0.9rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.unack-actions {
  display: flex;
  gap: 0.6rem;
}

.unack-actions form {
  margin: 0;
}

/* Per-account accent themes: override the variables that drive color
   throughout the app — buttons/links/focus rings (--teal, --teal-dark),
   nav-active and avatar/monogram fills (--sage, --sage-deep), and a faint
   page-background wash (--app-bg) — so an account is recognizable at a glance. */
.theme-teal { --teal: #2c6d68; --teal-dark: #225752; --sage: #dce7df; --sage-deep: #b9cec1; --app-bg: #f2f5f2; }
.theme-navy { --teal: #173642; --teal-dark: #0f242c; --sage: #dbe3e6; --sage-deep: #b7c3c7; --app-bg: #eff2f3; }
.theme-plum { --teal: #6f4e7c; --teal-dark: #59405f; --sage: #e8dfec; --sage-deep: #cbb9d1; --app-bg: #f6f1f7; }
.theme-rust { --teal: #b0592f; --teal-dark: #8f4623; --sage: #f3e2d6; --sage-deep: #dcb99e; --app-bg: #faf2ec; }
.theme-forest { --teal: #3f6b45; --teal-dark: #2f5233; --sage: #dfe9e0; --sage-deep: #b9cabb; --app-bg: #f1f5f1; }
.theme-berry { --teal: #9c3b5e; --teal-dark: #7c2f4b; --sage: #f0dde5; --sage-deep: #d9b0c0; --app-bg: #f9f0f3; }
.theme-slate { --teal: #3f5b8c; --teal-dark: #33496f; --sage: #dee3ee; --sage-deep: #b7c2da; --app-bg: #f0f2f6; }
.theme-amber { --teal: #a9762e; --teal-dark: #875d24; --sage: #f2e6d3; --sage-deep: #dcc399; --app-bg: #faf4ea; }
.theme-indigo { --teal: #4a4a9e; --teal-dark: #3b3b7e; --sage: #e0e0f2; --sage-deep: #bcbce0; --app-bg: #f2f2f9; }
.theme-crimson { --teal: #a03e3e; --teal-dark: #7f3131; --sage: #f2dcdc; --sage-deep: #dcb3b3; --app-bg: #faf1f1; }

.theme-fieldset {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.theme-fieldset legend {
  padding: 0 0.4rem;
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 800;
}

.color-swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  margin-top: 0.7rem;
}

.color-swatch-label {
  display: grid;
  justify-items: center;
  gap: 0.4rem;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
}

.color-swatch-label input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.color-dot {
  width: 42px;
  height: 42px;
  border: 2px solid transparent;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  transition: transform 120ms ease, border-color 120ms ease;
}

.color-swatch-label input:checked + .color-dot {
  border-color: var(--ink);
  transform: scale(1.08);
}

.color-swatch-label input:focus-visible + .color-dot {
  outline: 3px solid rgba(44, 109, 104, 0.35);
  outline-offset: 2px;
}

.form-stack .checkbox-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.form-stack .checkbox-row input[type="checkbox"] {
  width: 18px;
  min-height: 0;
  height: 18px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--teal);
}

.field-label {
  display: block;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
}

.conversation-list {
  display: grid;
  gap: 0.9rem;
}

.conversation-row {
  position: relative;
  display: block;
  overflow: hidden;
  max-width: 100%;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
  transition: border-color 130ms ease, transform 130ms ease;
}

.conversation-row:hover {
  border-color: var(--sage-deep);
  transform: translateY(-1px);
}

.conversation-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.3rem;
}

.conversation-subject {
  overflow: hidden;
  min-width: 0;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

.conversation-type {
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.conversation-preview {
  margin: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unread-badge {
  position: absolute;
  top: 1.1rem;
  right: 1.3rem;
  display: grid;
  min-width: 22px;
  height: 22px;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--teal);
  color: white;
  font-size: 0.72rem;
  font-weight: 800;
  place-items: center;
}

.thread-card {
  display: grid;
  gap: 1.2rem;
  padding: clamp(1.3rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
}

.message-list {
  display: grid;
  gap: 0.9rem;
}

.message-bubble {
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.7);
}

.message-bubble.message-own {
  border-color: var(--sage-deep);
  background: var(--sage);
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.message-sender {
  min-width: 0;
  overflow-wrap: anywhere;
}

.message-time {
  flex: 0 0 auto;
}

.message-body {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.delivery-ladder {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.6rem;
}

.ladder-sent {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #35a862;
}

.ladder-entry {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
}

.ladder-avatar {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid var(--sage-deep);
  border-radius: 50%;
  background: var(--sage);
  color: var(--teal-dark);
  font-size: 0.62rem;
  font-weight: 800;
}

.ladder-word {
  color: var(--ink-soft);
}

.ladder-ticks {
  color: #2f9e52;
  font-weight: 900;
  letter-spacing: -1px;
}

.ladder-ticks.ladder-gold {
  color: #b8860b;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: -0.3rem 0 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.typing-dots {
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-soft);
  animation: typing-bounce 1.1s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.message-bubble form {
  margin-top: 0.6rem;
}

.message-compose {
  display: grid;
  gap: 0.7rem;
}

.message-compose textarea {
  min-height: 90px;
  padding: 0.72rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  resize: vertical;
}

.message-compose textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(44, 109, 104, 0.12);
  outline: none;
}

.message-compose button {
  justify-self: end;
}

.classify-preview {
  padding-bottom: 1.2rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
}

.classify-value {
  margin: 0 0 0.9rem;
  color: var(--ink);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.classify-value:last-child {
  margin-bottom: 0;
}

.classify-suggestion {
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--sage-deep);
  border-radius: var(--radius-md);
  background: var(--sage);
}

.classify-suggestion h2 {
  margin-bottom: 0.4rem;
  font-size: 1.4rem;
}

.classify-suggestion form {
  margin-top: 0.9rem;
}

.classify-override {
  margin-top: 1rem;
}

.classify-override summary {
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 700;
}

.classify-override .form-stack {
  margin-top: 0.9rem;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 4.2rem;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  padding: 0.3rem;
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
  transform: translateY(-50%);
}

.field-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr 1fr;
}

.name-fieldset {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.name-fieldset legend {
  padding: 0 0.4rem;
  color: var(--navy);
  font-size: 0.86rem;
  font-weight: 800;
}

.name-fieldset .field-hint { margin: 0; }

.name-grid {
  display: grid;
  gap: 0.8rem;
}

.name-grid-primary {
  grid-template-columns: repeat(3, 1fr);
}

.name-grid-secondary {
  grid-template-columns: repeat(2, minmax(0, 140px));
}

.optional {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 600;
}

.field-hint {
  margin: -0.5rem 0 0;
  font-size: 0.78rem;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.68rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  transition: background-color 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.button:hover:not(.button-disabled) {
  transform: translateY(-1px);
}

.button-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.button-primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.button-secondary {
  border-color: var(--line-strong);
  background: var(--paper);
  color: var(--ink);
}

.button-quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.button-small {
  min-height: 36px;
  padding: 0.55rem 0.75rem;
  font-size: 0.76rem;
}

.button-full {
  width: 100%;
  margin-top: 0.2rem;
}

.button-disabled {
  border-color: var(--line);
  background: #eef0ed;
  color: #78837f;
  cursor: not-allowed;
}

.auth-switch {
  margin: 1.6rem 0 0;
  text-align: center;
  font-size: 0.88rem;
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.alert span {
  display: grid;
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 900;
}

.alert p {
  margin: 0;
}

.alert-error {
  border-color: #efc4bd;
  background: var(--error-bg);
  color: var(--error);
}

.alert-error span {
  background: var(--error);
  color: white;
}

.alert-success {
  border-color: #bcd9c4;
  background: var(--success-bg);
  color: var(--success);
}

.alert-success span {
  background: var(--success);
  color: white;
}

.app-page {
  padding-top: 72px;
  background: var(--app-bg, #f5f4ef);
}

.app-header {
  position: fixed;
  z-index: 20;
  top: 0;
  right: 0;
  left: 0;
  display: grid;
  height: 72px;
  align-items: center;
  padding: 0 4vw;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.96);
  grid-template-columns: 1fr auto 1fr;
}

.brand-compact {
  justify-self: start;
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.desktop-nav a {
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 0.82rem;
  text-decoration: none;
}

.desktop-nav a:hover,
.desktop-nav a.is-active {
  background: var(--sage);
  color: var(--ink);
}

.user-menu {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 0.6rem;
}

.user-menu form {
  margin: 0;
}

.user-name {
  max-width: 130px;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar,
.account-avatar,
.family-monogram {
  display: grid;
  place-items: center;
  border: 1px solid var(--sage-deep);
  border-radius: 50%;
  background: var(--sage);
  color: var(--teal-dark);
  font-weight: 850;
}

.avatar {
  width: 34px;
  height: 34px;
  font-size: 0.78rem;
}

.mobile-nav {
  display: none;
}

.app-main {
  width: min(1120px, calc(100% - 3rem));
  margin: 0 auto;
  padding: clamp(2.2rem, 6vw, 5.5rem) 0 5rem;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.4rem;
}

.page-heading-sticky {
  position: sticky;
  z-index: 10;
  top: 72px;
  align-items: center;
  margin: 0 0 1.5rem;
  padding: 1.1rem 0;
  background: var(--app-bg, #f5f4ef);
  border-bottom: 1px solid var(--line);
}

.page-heading-sticky h1 {
  margin-bottom: 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.page-heading-sticky p {
  display: none;
}

.button-back {
  margin-bottom: 0.9rem;
  padding: 0.5rem 0.85rem;
  min-height: 36px;
  font-size: 0.8rem;
}

.page-heading-sticky .button-back {
  margin-bottom: 0;
}

.page-heading h1 {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.7rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 5vw, 4rem);
  font-weight: 500;
  letter-spacing: -0.045em;
}

.page-heading-icon,
.conversation-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--teal);
  color: white;
}

.page-heading-icon {
  width: 44px;
  height: 44px;
}

.conversation-icon {
  width: 34px;
  height: 34px;
}

.page-heading > div > p:last-child {
  max-width: 650px;
  margin-bottom: 0;
}

.onboarding-card,
.family-card,
.activity-card,
.form-card,
.account-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  box-shadow: 0 12px 35px rgba(38, 55, 60, 0.055);
}

.onboarding-card {
  position: relative;
  display: grid;
  min-height: 310px;
  align-items: center;
  overflow: hidden;
  padding: clamp(1.5rem, 4vw, 3.5rem);
  grid-template-columns: auto minmax(0, 1fr) minmax(230px, 0.7fr);
}

.step-badge {
  display: grid;
  width: 46px;
  height: 46px;
  align-self: start;
  margin-right: 1.4rem;
  place-items: center;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  font-weight: 850;
}

.onboarding-copy {
  max-width: 500px;
}

.onboarding-copy h2,
.family-card h2,
.activity-card h2,
.empty-state h2 {
  margin-bottom: 0.8rem;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
}

.onboarding-copy > p:not(.eyebrow) {
  margin-bottom: 1.5rem;
  color: var(--ink-soft);
}

.onboarding-preview {
  position: relative;
  height: 200px;
  margin-left: 2rem;
}

.onboarding-preview::before,
.onboarding-preview::after,
.onboarding-preview span {
  position: absolute;
  display: block;
  border-radius: 12px;
  background: var(--sage);
  content: "";
}

.onboarding-preview::before {
  inset: 10px 10px 0 45px;
  border: 1px solid var(--sage-deep);
  background: #edf4ef;
  transform: rotate(4deg);
}

.onboarding-preview::after {
  inset: 22px 35px 12px 17px;
  border: 1px solid var(--line);
  background: white;
  box-shadow: var(--shadow);
  transform: rotate(-4deg);
}

.onboarding-preview span {
  z-index: 2;
  left: 54px;
  width: 120px;
  height: 10px;
}

.onboarding-preview span:nth-child(1) { top: 67px; width: 64px; background: var(--navy); }
.onboarding-preview span:nth-child(2) { top: 100px; }
.onboarding-preview span:nth-child(3) { top: 126px; width: 90px; }

.quiet-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
  grid-template-columns: repeat(3, 1fr);
}

.quiet-grid article {
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 249, 0.62);
}

.quiet-grid h3 {
  margin: 0.8rem 0 0.4rem;
  font-size: 1rem;
}

.quiet-grid p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.quiet-icon {
  color: var(--teal);
  font-size: 1.25rem;
}

.family-list {
  display: grid;
  gap: 1rem;
}

.family-card {
  padding: clamp(1.3rem, 4vw, 2.2rem);
}

.family-card-top {
  display: grid;
  align-items: center;
  grid-template-columns: auto 1fr auto;
}

.family-monogram {
  width: 52px;
  height: 52px;
  margin-right: 1rem;
}

.family-card .eyebrow {
  margin-bottom: 0.25rem;
}

.family-card h2 {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.34rem 0.65rem;
  border: 1px solid #b9d7c1;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 850;
}

.status-pill::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.metric-grid {
  display: grid;
  margin: 1.8rem 0;
  border-block: 1px solid var(--line);
  grid-template-columns: repeat(4, 1fr);
}

.metric-tile {
  display: grid;
  gap: 0.1rem;
  padding: 1.2rem 0;
  color: inherit;
  text-decoration: none;
  transition: opacity 130ms ease;
}

.metric-tile:hover {
  opacity: 0.7;
}

.metric-tile:hover strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.metric-tile + .metric-tile {
  padding-left: 1.4rem;
  border-left: 1px solid var(--line);
}

.metric-grid strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.metric-grid span,
.family-actions span {
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.family-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.activity-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 1rem;
  padding: 1.6rem 2rem;
}

.activity-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.activity-card > p {
  max-width: 410px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.form-card,
.account-card {
  padding: clamp(1.4rem, 4vw, 2.5rem);
}

.narrow-card {
  max-width: 650px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 0.5rem;
}

.empty-state {
  display: grid;
  min-height: 390px;
  place-items: center;
  align-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}

.empty-state > p:not(.eyebrow) {
  max-width: 480px;
  color: var(--ink-soft);
}

.empty-illustration {
  position: relative;
  width: 88px;
  height: 68px;
  margin-bottom: 1.4rem;
}

.empty-illustration span {
  position: absolute;
  width: 55px;
  height: 40px;
  border: 2px solid var(--teal);
  border-radius: 14px;
  background: var(--sage);
}

.empty-illustration span::after {
  position: absolute;
  right: 8px;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--teal);
  background: var(--sage);
  content: "";
  transform: skewY(38deg);
}

.empty-illustration span + span {
  right: 0;
  bottom: 0;
  border-color: var(--navy);
  background: white;
}

.account-card {
  display: grid;
  max-width: 760px;
  align-items: start;
  gap: 2rem;
  grid-template-columns: auto 1fr;
}

.account-avatar {
  width: 76px;
  height: 76px;
  font-size: 1.5rem;
}

.account-card dl {
  margin: 0;
}

.account-card dl > div {
  display: grid;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  grid-template-columns: 140px 1fr;
}

.account-card dt {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 750;
}

.account-card dd {
  margin: 0;
  font-weight: 700;
}

.standalone-state {
  display: grid;
  min-height: 100vh;
  place-items: center;
  align-content: center;
  padding: 2rem;
  text-align: center;
}

.standalone-state h1 {
  margin-bottom: 0.6rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  font-weight: 500;
}

.standalone-state > p:not(.eyebrow) {
  color: var(--ink-soft);
}

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-aside {
    min-height: 290px;
    padding: 2rem;
  }

  .auth-message {
    padding: 3.5rem 0 1.5rem;
  }

  .auth-message h1 {
    max-width: 14ch;
    font-size: clamp(2.4rem, 10vw, 4.5rem);
  }

  .auth-message > p:last-child,
  .auth-footnote {
    display: none;
  }

  .auth-main {
    min-height: auto;
  }

  .app-header {
    grid-template-columns: 1fr auto;
  }

  .desktop-nav,
  .user-name {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    z-index: 20;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    height: 60px;
    padding: 0.45rem 1rem;
    border-top: 1px solid var(--line);
    background: rgba(255, 253, 249, 0.97);
    grid-template-columns: repeat(4, 1fr);
  }

  .mobile-nav a {
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 0.72rem;
    text-decoration: none;
  }

  .mobile-nav a.is-active {
    background: var(--sage);
    color: var(--ink);
  }

  .app-main {
    padding-bottom: 6rem;
  }

  .onboarding-card {
    grid-template-columns: auto 1fr;
  }

  .onboarding-preview {
    display: none;
  }
}

@media (max-width: 620px) {
  .auth-aside {
    min-height: 230px;
  }

  .auth-message {
    padding-top: 2.5rem;
  }

  .auth-message h1 {
    margin-bottom: 0;
    font-size: 2.55rem;
  }

  .auth-message > p:last-child,
  .auth-message .eyebrow {
    display: none;
  }

  .auth-main {
    display: block;
    padding: 1rem;
  }

  .auth-card {
    margin-top: -2rem;
    padding: 1.5rem;
  }

  .field-grid,
  .name-grid,
  .quiet-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    padding: 0 1rem;
  }

  .brand-compact > span:last-child {
    display: none;
  }

  .app-main {
    width: min(100% - 1.4rem, 1120px);
  }

  .page-heading {
    margin-bottom: 1.5rem;
  }

  .onboarding-card {
    display: block;
  }

  .step-badge {
    width: 38px;
    height: 38px;
    margin: 0 0 1.2rem;
  }

  .quiet-grid article {
    display: grid;
    column-gap: 0.8rem;
    grid-template-columns: auto 1fr;
  }

  .quiet-grid h3 {
    margin-top: 0;
  }

  .quiet-grid p {
    grid-column: 2;
  }

  .family-card-top {
    grid-template-columns: auto 1fr;
  }

  .family-card-top .status-pill {
    display: none;
  }

  .metric-tile,
  .metric-tile + .metric-tile {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.75rem 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-tile:last-child {
    border-bottom: 0;
  }

  .family-actions,
  .activity-card {
    align-items: stretch;
    flex-direction: column;
  }

  .family-actions .button {
    width: 100%;
  }

  .account-card {
    grid-template-columns: 1fr;
  }

  .account-card dl > div {
    gap: 0.3rem;
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
