:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #627d98;
  --line: #d9e2ec;
  --paper: #f7f5ef;
  --card: #fffefa;
  --pending: #c2410c;
  --progress: #0369a1;
  --done: #3f6212;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-bottom: 164px;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(249, 115, 22, 0.1), transparent 24rem),
    linear-gradient(180deg, #f2efe6 0, var(--paper) 22rem);
}

.topbar,
main,
footer {
  width: min(1480px, calc(100% - 48px));
  margin-inline: auto;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 54px 0 32px;
  border-bottom: 1px solid rgba(16, 42, 67, 0.18);
}

.eyebrow,
.lane-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.95;
}

.subtitle {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 12px;
}

.identity-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
}

.identity-control button {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.identity-control button:hover,
.identity-control button:focus-visible {
  border-color: var(--ink);
}

.push-control {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.push-toggle {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 750;
}

.push-toggle[data-state="subscribed"] {
  border-color: #4d7c0f;
  background: #4d7c0f;
}

.push-toggle:disabled {
  border-color: #9fb3c8;
  background: #9fb3c8;
  cursor: not-allowed;
}

.push-toggle:focus-visible {
  outline: 3px solid rgba(3, 105, 161, 0.32);
  outline-offset: 3px;
}

.push-status {
  max-width: 290px;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.35;
  text-align: right;
}

.push-help {
  max-width: 320px;
  padding: 9px 11px;
  border: 1px solid #fdba74;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: left;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
}

.connection-dot[data-state="online"] {
  background: #65a30d;
  box-shadow: 0 0 0 4px rgba(101, 163, 13, 0.15);
}

.connection-dot[data-state="retrying"] {
  background: #f59e0b;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.summary div {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 14px 18px;
  border-right: 1px solid var(--line);
}

.summary div:last-child {
  border-right: 0;
}

.summary strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
}

.summary span {
  color: var(--muted);
  font-size: 0.8rem;
}

.page-error {
  margin-bottom: 20px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  border-radius: 10px;
  background: #fff1f2;
  color: #9f1239;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.conversation {
  margin-top: 42px;
  padding-top: 24px;
  border-top: 1px solid rgba(16, 42, 67, 0.18);
}

.conversation-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.conversation-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 500;
}

.conversation-header p:last-child {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.chat-list {
  display: flex;
  max-height: min(60vh, 680px);
  min-height: 220px;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-message {
  width: fit-content;
  max-width: min(78%, 760px);
  padding: 12px 14px;
  border: 1px solid rgba(16, 42, 67, 0.13);
  border-radius: 16px 16px 16px 5px;
  background: var(--card);
  box-shadow: 0 3px 12px rgba(16, 42, 67, 0.05);
}

.chat-message[data-role="user"] {
  margin-left: auto;
  border-color: #1e3a5f;
  border-radius: 16px 16px 5px 16px;
  background: #173b5f;
  color: #fff;
}

.chat-message[data-role="system"] {
  align-self: center;
  border-style: dashed;
  background: #f0f4f8;
}

.chat-metadata {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.68rem;
}

.chat-message[data-role="user"] .chat-metadata {
  color: #d9eaf7;
}

.chat-body {
  margin: 7px 0 0;
  font-size: 0.91rem;
  line-height: 1.58;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-delivery {
  display: block;
  margin-top: 7px;
  color: #d9eaf7;
  font-size: 0.66rem;
  text-align: right;
}

.chat-delivery[data-state="failed"] {
  color: #fecaca;
  font-weight: 750;
}

.lane {
  min-width: 0;
  border-top: 4px solid;
}

.lane-pending {
  border-color: var(--pending);
}

.lane-progress {
  border-color: var(--progress);
}

.lane-done {
  border-color: var(--done);
}

.lane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 3px 14px;
}

.lane-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  font-weight: 500;
}

.lane-count {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-card {
  padding: 18px;
  border: 1px solid rgba(16, 42, 67, 0.14);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 5px 18px rgba(16, 42, 67, 0.06);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-header h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.priority {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 4px;
  color: #52606d;
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.priority[data-priority="P0"] {
  color: #be123c;
}

.priority[data-priority="P1"] {
  color: #c2410c;
}

.priority[data-priority="P2"] {
  color: #0369a1;
}

.priority[data-priority="done"] {
  color: var(--done);
}

.message-body {
  margin: 14px 0;
  color: #334e68;
  font-size: 0.9rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.metadata {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid #e8e3d9;
  color: var(--muted);
  font-size: 0.72rem;
}

.metadata span {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.source-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.empty-state {
  margin: 0;
  padding: 28px 18px;
  border: 1px dashed #bcccdc;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 36px 0 28px;
  color: var(--muted);
  font-size: 0.72rem;
}

.phase-note {
  text-align: right;
}

.composer-shell {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 14px 24px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(16, 42, 67, 0.2);
  background: rgba(247, 245, 239, 0.94);
  box-shadow: 0 -10px 28px rgba(16, 42, 67, 0.09);
  backdrop-filter: blur(14px);
}

.chat-form {
  display: grid;
  width: min(1180px, 100%);
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 8px 10px;
  margin-inline: auto;
}

.message-field {
  min-width: 0;
}

.message-field textarea {
  width: 100%;
  border: 1px solid #9fb3c8;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.message-field textarea {
  min-height: 66px;
  max-height: 150px;
  padding: 11px 12px;
  line-height: 1.42;
  resize: vertical;
}

.message-field textarea:focus {
  border-color: var(--progress);
  outline: 3px solid rgba(3, 105, 161, 0.18);
}

.chat-send {
  min-width: 86px;
  align-self: end;
  min-height: 66px;
  padding: 12px 18px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.chat-send:disabled {
  border-color: #9fb3c8;
  background: #9fb3c8;
  cursor: wait;
}

.chat-status {
  grid-column: 1 / 3;
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.login-page {
  display: grid;
  min-height: 100vh;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  place-items: center;
}

.login-shell {
  width: min(100%, 520px);
  margin: 0;
}

.login-card {
  padding: clamp(28px, 7vw, 54px);
  border: 1px solid rgba(16, 42, 67, 0.16);
  border-radius: 24px;
  background: rgba(255, 254, 250, 0.92);
  box-shadow: 0 28px 80px rgba(16, 42, 67, 0.14);
  backdrop-filter: blur(18px);
}

.login-card h1 {
  font-size: clamp(2.7rem, 11vw, 4.6rem);
}

.login-subtitle {
  margin: 18px 0 30px;
  color: var(--muted);
  line-height: 1.65;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.login-form textarea {
  width: 100%;
  min-height: 76px;
  padding: 14px;
  border: 1px solid #9fb3c8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 500 0.9rem/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  resize: vertical;
}

.login-form textarea:focus {
  border-color: var(--progress);
  outline: 3px solid rgba(3, 105, 161, 0.18);
}

.login-privacy {
  margin: -2px 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.login-form button {
  min-height: 50px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.login-form button:disabled {
  border-color: #9fb3c8;
  background: #9fb3c8;
  cursor: wait;
}

.login-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
}

.login-status[data-state="error"] {
  color: #be123c;
  font-weight: 750;
}

.login-status[data-state="success"] {
  color: var(--done);
  font-weight: 750;
}

.login-help {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.login-help summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

.chat-status[data-state="sent"] {
  color: var(--done);
}

.chat-status[data-state="error"] {
  color: #be123c;
  font-weight: 750;
}

.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;
}

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

@media (max-width: 640px) {
  body {
    padding-bottom: 180px;
  }

  .topbar,
  main,
  footer {
    width: min(100% - 28px, 1480px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding-top: 32px;
  }

  .header-actions,
  .push-control {
    align-items: flex-start;
    width: 100%;
  }

  .identity-control {
    justify-content: space-between;
    width: 100%;
  }

  .push-status {
    max-width: none;
    text-align: left;
  }

  .push-help {
    max-width: none;
  }

  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary div:nth-child(2) {
    border-right: 0;
  }

  .summary div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .message-card {
    padding: 16px;
  }

  .conversation-header h2 {
    font-size: 1.65rem;
  }

  .chat-list {
    min-height: 190px;
    padding: 12px;
  }

  .chat-message {
    max-width: 92%;
  }

  .composer-shell {
    padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  }

  .chat-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px 8px;
  }

  .message-field {
    grid-column: 1;
  }

  .message-field textarea,
  .chat-send {
    min-height: 58px;
  }

  .chat-send {
    grid-column: 2;
    min-width: 72px;
    padding-inline: 13px;
  }

  .chat-status {
    grid-column: 1 / 3;
  }

  footer {
    flex-direction: column;
  }

  .phase-note {
    text-align: left;
  }
}
