/* coparent.now app shell.
   Editorial, white background, hairline borders, sparse green accent.
   Same Inter + Outfit type stack as the marketing site. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --brand: #10b981;
  --brand-dark: #047857;
  --brand-soft: rgba(16, 185, 129, 0.08);
  --ink: #0a0a0b;
  --ink-strong: #18181b;
  --ink-muted: #71717a;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --bg: #ffffff;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-strong);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

p {
  margin: 0;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 12px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 16px;
  border: 1px solid var(--ink);
  z-index: 1000;
}

.skip-link:focus {
  left: 12px;
}

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

/* === Top bar (matches marketing #main-header) === */

#main-header {
  background-color: #2563eb;
  width: 100%;
}

#main-header .topbar-inner {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

#main-header .brand {
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  font-size: 1.65rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #ffffff;
  transition: opacity 120ms ease;
}

#main-header .brand:hover {
  opacity: 0.9;
}

/* === App shell === */

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

/* === Auth panel (signed out) === */

.auth-panel {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  text-align: center;
  align-items: center;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.auth-header h1 {
  font-size: clamp(2.5rem, 6vw, 3.75rem);
  margin: 0;
}

.auth-header p {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 38ch;
  margin: 0;
}

.auth-beta {
  font-size: 0.85rem !important;
  color: var(--ink-muted);
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  margin-top: 0.5rem !important;
  max-width: 38ch;
}

.auth-panel .stack-form {
  width: 100%;
  max-width: 420px;
}

.auth-panel .turnstile-slot {
  justify-content: center;
}

.auth-note {
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.95rem;
  max-width: 420px;
}

/* === Workspace (signed in) === */

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

@media (max-width: 920px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 3rem;
  }
}

/* === Thread column === */

.thread-column {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-width: 0;
}

.thread-children {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.context-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.context-item {
  list-style: none;
}

.context-button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease;
}

.context-button:hover {
  border-color: var(--ink);
}

.context-item-active .context-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #ffffff;
}

.context-name {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}

.context-meta {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.context-item-active .context-meta {
  color: rgba(255, 255, 255, 0.72);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6rem;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-muted);
}

/* === Thread header === */

.thread-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.thread-heading h2 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
  margin-bottom: 0.5rem;
}

.thread-subtitle {
  color: var(--ink-muted);
  font-size: 0.95rem;
  max-width: 56ch;
}

.thread-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.socket-status {
  position: relative;
  padding-left: 0.85rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.socket-status::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--ink-muted);
  transform: translateY(-50%);
}

.socket-status[data-state="live"]::before,
.socket-status:not(:empty)::before {
  background: var(--brand);
}

/* === Empty state === */

.empty-state {
  padding: 3rem 0;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

.empty-state p {
  max-width: 44ch;
}

/* === Message list === */

.message-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.message-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-left: 2px solid var(--line);
  max-width: 90%;
  word-wrap: break-word;
}

.message-mine {
  border-left-color: var(--brand);
  margin-left: auto;
  text-align: right;
}

.message-theirs {
  border-left-color: var(--ink-muted);
  margin-right: auto;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}

.message-mine .message-meta {
  flex-direction: row-reverse;
}

.message-body {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink-strong);
}

.message-body em {
  color: var(--ink-muted);
  font-style: italic;
}

.message-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.message-mine .message-footer {
  flex-direction: row-reverse;
}

/* === Composer === */

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.composer textarea {
  width: 100%;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-strong);
  font-size: 1rem;
  line-height: 1.55;
  resize: vertical;
  min-height: 7rem;
  transition: border-color 120ms ease;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.composer-status {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

/* === Utility column === */

.utility-column {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.utility-block {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.utility-block h3 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.utility-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.utility-header h3 {
  font-size: 1.15rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink-strong);
  word-break: break-word;
  min-width: 0;
}

.utility-copy {
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.55;
}

.utility-note {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.utility-block--quiet {
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.utility-block--quiet h3 {
  color: var(--ink-muted);
  font-size: 0.85rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* === Forms === */

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.compact-form {
  gap: 0.65rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field span {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.field input {
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-strong);
  font-size: 1rem;
  transition: border-color 120ms ease;
}

.field input:focus {
  outline: none;
  border-color: var(--ink);
}

/* === Buttons === */

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 1.5rem;
  background: var(--ink);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background 120ms ease;
}

.primary-button:hover:not(:disabled) {
  background: #000000;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font-size: 0.82rem;
  transition: border-color 120ms ease;
}

.ghost-button:hover {
  border-color: var(--ink);
}

/* === Turnstile slot === */

.turnstile-slot {
  min-height: 65px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

/* === Toasts === */

.toast-region {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
  pointer-events: none;
  max-width: 360px;
}

.toast {
  pointer-events: auto;
  padding: 0.95rem 1.15rem;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink-strong);
  font-size: 0.88rem;
  box-shadow: 0 12px 28px rgba(15, 17, 21, 0.06);
}

.toast.is-success {
  border-color: var(--brand);
  color: var(--brand-dark);
}

.toast.is-error {
  border-color: #dc2626;
  color: #991b1b;
}

.toast.is-info {
  border-color: var(--line);
  color: var(--ink-strong);
}

/* === Mobile === */

@media (max-width: 720px) {
  .topbar {
    padding: 1rem 1.25rem;
    flex-wrap: wrap;
  }

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

  .session-status {
    width: 100%;
  }

  .app-shell {
    padding: 2.5rem 1.25rem 4rem;
  }

  .thread-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .thread-meta {
    flex-direction: row;
  }

  .auth-header h1 {
    font-size: 2.5rem;
  }
}
