/* ai.kogni.pro. kogni's tool-first system (App/docs/REDESIGN_PLAN_TOOL_FIRST.md section 6, Website/docs/DESIGN_MANUAL.md):
   --tool-* tokens, flat surfaces, one outer border with internal separators, 4px radius, no gradients, blur, glow
   or shadows. Orange is only the action, the focus and the selection. Motion only on menus and dialogs. */

:root {
  --tool-bg: #0a0b0d;
  --tool-surface: #111316;
  --tool-surface-raised: #1c1b18;
  --tool-line: #2e2d2b;
  --tool-line-strong: #55524c;
  /* Control outlines: 3:1 or more on every ground (WCAG 1.4.11). */
  --tool-control-line: #6b665e;
  --tool-ink: #f7edd9;
  --tool-muted: #a39d91;
  --tool-subtle: #8a857b;
  --tool-accent: #ff9737;
  --tool-accent-dark: #1b1007;
  --tool-accent-ground: #23170c;
  --tool-positive: #68d4a5;
  --tool-negative: #ff7676;
  --tool-radius: 4px;

  --font-ui: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Arial Narrow", "Roboto Condensed", "Segoe UI", sans-serif;
  --font-mono: Consolas, "SFMono-Regular", ui-monospace, "Liberation Mono", monospace;

  --topbar-h: 56px;
  --sidebar-w: 272px;
  --column-w: 820px;
  --motion: 160ms;

  color-scheme: dark;
}

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

html {
  background: var(--tool-bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--tool-bg);
  color: var(--tool-ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
}

html.drawer-open,
html.drawer-open body {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

img,
svg {
  display: block;
}

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

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

:focus {
  outline: none;
}

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

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

.label {
  margin: 0;
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-transform: uppercase;
}

.text-link {
  color: var(--tool-ink);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-link:hover {
  color: var(--tool-accent);
}

.text-button {
  display: inline;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tool-ink);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.text-button:hover {
  color: var(--tool-accent);
}

/* ---------------------------------------------------------------------------------------------------- controls */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--tool-control-line);
  border-radius: var(--tool-radius);
  background: var(--tool-bg);
  color: var(--tool-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.button:hover:not(:disabled, [aria-disabled="true"]) {
  border-color: var(--tool-accent);
  background: var(--tool-accent-ground);
  color: var(--tool-accent);
}

.button:disabled,
.button[aria-disabled="true"] {
  border-color: var(--tool-line-strong);
  color: var(--tool-subtle);
  cursor: default;
}

.button.primary {
  border-color: var(--tool-accent);
  background: var(--tool-accent);
  color: var(--tool-accent-dark);
}

.button.primary:hover:not(:disabled) {
  background: var(--tool-accent);
  color: var(--tool-accent-dark);
}

.button.primary:disabled {
  border-color: var(--tool-line-strong);
  background: var(--tool-surface-raised);
  color: var(--tool-subtle);
}

.button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--tool-muted);
}

.button.ghost:hover:not(:disabled) {
  border-color: var(--tool-control-line);
  background: transparent;
  color: var(--tool-ink);
}

.button.danger {
  border-color: var(--tool-negative);
  background: var(--tool-bg);
  color: var(--tool-negative);
}

.button.danger:hover:not(:disabled) {
  border-color: var(--tool-negative);
  background: #2a1214;
  color: var(--tool-negative);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--tool-radius);
  background: transparent;
  color: var(--tool-muted);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--tool-control-line);
  color: var(--tool-ink);
}

.input,
.select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--tool-control-line);
  border-radius: var(--tool-radius);
  background: var(--tool-bg);
  color: var(--tool-ink);
  font-size: 14px;
}

.input {
  padding: 8px 12px;
}

.input[aria-invalid="true"] {
  border-color: var(--tool-negative);
}

.select {
  padding: 0 32px 0 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5 6 7.5 9 4.5' fill='none' stroke='%23a39d91' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 12px 12px;
  text-overflow: ellipsis;
  cursor: pointer;
}

.select:disabled {
  color: var(--tool-subtle);
  cursor: default;
}

.select option:disabled {
  color: var(--tool-subtle);
}

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

.field-label {
  color: var(--tool-muted);
  font-size: 13px;
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  color: var(--tool-muted);
  font-size: 13px;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--tool-accent);
}

/* ---------------------------------------------------------------------------------------------------- brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--tool-ink);
  text-decoration: none;
}

.brand-mark {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-tag {
  padding: 1px 6px;
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
  color: var(--tool-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* ----------------------------------------------------------------------------------------------- boot, sign-in */

.boot {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  text-align: center;
}

.boot-mark {
  width: 40px;
  height: 40px;
}

.boot-text {
  margin: 0;
  color: var(--tool-muted);
}

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

.signin-panel {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
  background: var(--tool-surface);
}

.signin-panel .brand-mark {
  width: 32px;
  height: 32px;
}

.signin-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}

.signin-lead {
  margin: 0;
  color: var(--tool-muted);
  font-size: 14px;
}

.signin-form {
  display: grid;
  gap: 14px;
}

.signin-providers {
  display: grid;
  gap: 8px;
}

.provider-button {
  width: 100%;
  min-height: 44px;
}

.provider-icon {
  flex: none;
}

.provider-icon--discord {
  color: #5865f2;
}

.provider-button:hover:not(:disabled) .provider-icon--discord {
  color: currentColor;
}

/* A rule with the label in the middle, drawn by two hairline pseudo-elements. */
.signin-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--tool-subtle);
  font-size: 12px;
}

.signin-divider::before,
.signin-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--tool-line);
}

.password-control {
  display: flex;
  gap: 6px;
}

.password-toggle {
  min-width: 64px;
}

.form-error {
  margin: 0;
  color: var(--tool-negative);
  font-size: 13px;
}

.form-error:empty {
  display: none;
}

.signin-submit {
  width: 100%;
  min-height: 44px;
}

.signin-alt {
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--tool-line);
  color: var(--tool-muted);
  font-size: 13px;
}

/* ------------------------------------------------------------------------------------------------------ shell */

.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: var(--tool-radius);
  background: var(--tool-accent);
  color: var(--tool-accent-dark);
  font-weight: 600;
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--tool-line);
  background: var(--tool-bg);
}

.menu-button,
.drawer-close {
  display: none;
}

.mock-badge {
  padding: 2px 8px;
  border: 1px dashed var(--tool-control-line);
  border-radius: var(--tool-radius);
  color: var(--tool-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
}

.account {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  margin: 0;
  font-size: 13px;
}

.account-name {
  overflow: hidden;
  color: var(--tool-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-plan {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------------------------------- sidebar */

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--tool-line);
  background: var(--tool-surface);
}

.sidebar-head {
  display: flex;
  gap: 8px;
  padding: 12px;
}

.new-chat {
  flex: 1;
  justify-content: flex-start;
}

.sidebar-title {
  padding: 8px 16px 6px;
}

.chat-state-text {
  margin: 0;
  padding: 6px 16px 10px;
  color: var(--tool-muted);
  font-size: 13px;
}

.chat-state-text.is-error {
  color: var(--tool-negative);
}

.chat-list {
  margin: 0;
  padding: 0 0 16px;
  list-style: none;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px 0 0;
  border-top: 1px solid var(--tool-line);
  box-shadow: inset 2px 0 0 transparent;
}

.chat-item:last-child {
  border-bottom: 1px solid var(--tool-line);
}

.chat-item:hover {
  background: var(--tool-surface-raised);
}

.chat-item.is-active {
  background: var(--tool-surface-raised);
  box-shadow: inset 2px 0 0 var(--tool-accent);
}

.chat-link {
  display: grid;
  flex: 1;
  gap: 2px;
  min-width: 0;
  min-height: 52px;
  padding: 8px 8px 8px 16px;
  color: var(--tool-ink);
  text-decoration: none;
}

.chat-link:focus-visible {
  outline-offset: -2px;
}

.chat-title {
  overflow: hidden;
  font-size: 13px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-meta {
  overflow: hidden;
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-delete {
  color: var(--tool-subtle);
}

.chat-delete:hover {
  border-color: var(--tool-negative);
  color: var(--tool-negative);
}

.scrim {
  display: none;
}

/* ------------------------------------------------------------------------------------------------------ main */

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: calc(100vh - var(--topbar-h));
  min-height: calc(100dvh - var(--topbar-h));
}

.thread-wrap {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: min(100%, var(--column-w));
  margin: 0 auto;
  padding: 28px 24px 12px;
}

.main.is-empty .thread-wrap {
  justify-content: center;
}

.empty {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 0 8px;
  text-align: center;
}

.empty-mark {
  width: 48px;
  height: 48px;
}

.empty-title {
  max-width: 26ch;
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 38px);
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
}

.empty-lead {
  max-width: 54ch;
  margin: 0;
  color: var(--tool-muted);
  font-size: 14px;
}

.examples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 100%;
  max-width: 680px;
  margin: 14px 0 0;
  padding: 0;
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
  list-style: none;
  overflow: hidden;
}

.examples li + li {
  border-left: 1px solid var(--tool-line);
}

.examples li:nth-child(3) {
  border-left: 0;
}

.examples li:nth-child(n + 3) {
  border-top: 1px solid var(--tool-line);
}

.example {
  display: grid;
  gap: 4px;
  width: 100%;
  height: 100%;
  min-height: 76px;
  padding: 12px 14px;
  border: 0;
  background: transparent;
  color: var(--tool-ink);
  text-align: left;
  cursor: pointer;
}

.example:hover {
  background: var(--tool-surface-raised);
}

.example:focus-visible {
  outline-offset: -2px;
}

.example-tag {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.example-text {
  font-size: 14px;
  line-height: 1.45;
}

.thread-state {
  margin: 0;
  color: var(--tool-muted);
  font-size: 14px;
}

.thread-state:empty {
  display: none;
}

/* ---------------------------------------------------------------------------------------------------- messages */

.thread {
  display: grid;
  gap: 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.thread:empty {
  display: none;
}

.msg {
  min-width: 0;
  scroll-margin-top: calc(var(--topbar-h) + 16px);
}

.msg--user {
  display: grid;
  justify-items: end;
  gap: 4px;
  justify-self: end;
  max-width: min(84%, 620px);
}

.msg-user-text {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
  background: var(--tool-surface-raised);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg--user.is-failed .msg-user-text {
  border-color: var(--tool-line-strong);
  color: var(--tool-muted);
}

.msg-state {
  margin: 0;
  color: var(--tool-negative);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.msg--assistant {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
}

.msg-body {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding-top: 2px;
}

.md {
  display: grid;
  gap: 10px;
  overflow-wrap: anywhere;
}

.md p,
.md ul,
.md ol,
.md h4 {
  margin: 0;
}

.md h4 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.md ul,
.md ol {
  display: grid;
  gap: 4px;
  padding-left: 22px;
}

.md li::marker {
  color: var(--tool-subtle);
}

.md strong {
  font-weight: 700;
}

.md code {
  padding: 1px 5px;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
  background: var(--tool-surface);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

.md a:not(.cite) {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.md a:not(.cite):hover {
  color: var(--tool-accent);
}

.cite {
  display: inline-block;
  min-width: 24px;
  margin: 0 1px;
  padding: 0 4px;
  border: 1px solid var(--tool-control-line);
  border-radius: var(--tool-radius);
  color: var(--tool-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  text-decoration: none;
  vertical-align: 1px;
}

.cite:hover {
  border-color: var(--tool-accent);
  color: var(--tool-accent);
}

.msg-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 0;
  color: var(--tool-muted);
  font-size: 13px;
}

.evidence {
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
}

.evidence-title {
  padding: 8px 12px;
  border-bottom: 1px solid var(--tool-line);
}

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

.evidence-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  box-shadow: inset 2px 0 0 transparent;
}

.evidence-item + .evidence-item {
  border-top: 1px solid var(--tool-line);
}

.evidence-item:focus {
  background: var(--tool-surface-raised);
}

.evidence-item:focus-visible {
  outline-offset: -2px;
}

.ev-id {
  color: var(--tool-ink);
  font-family: var(--font-mono);
  font-size: 12px;
}

.ev-label {
  color: var(--tool-ink);
  overflow-wrap: anywhere;
}

.ev-kind {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
}

.msg-meta {
  margin: 0;
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
}

.msg-meta:empty {
  display: none;
}

.progress {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 0;
  color: var(--tool-muted);
  font-size: 14px;
}

.progress-time {
  font-family: var(--font-mono);
  font-size: 12px;
}

.dots {
  display: inline-flex;
  gap: 4px;
}

.dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--tool-muted);
  animation: pulse 1.2s ease-in-out infinite;
}

.dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes pulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }

  40% {
    opacity: 1;
  }
}

.msg-error-text {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--tool-line-strong);
  border-left: 2px solid var(--tool-negative);
  border-radius: var(--tool-radius);
  color: var(--tool-ink);
  font-size: 14px;
}

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

/* -------------------------------------------------------------------------------------------------- board card */

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

.board-card {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
}

.board-card-preview {
  padding: 12px;
  border-right: 1px solid var(--tool-line);
}

.board-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
  background: var(--tool-surface);
  cursor: zoom-in;
}

.board-thumb:hover:not(:disabled) {
  border-color: var(--tool-accent);
}

.board-thumb:disabled {
  cursor: default;
}

.board-thumb-frame {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--tool-radius);
}

.board-thumb-frame svg {
  width: 100%;
  height: 100%;
}

.board-thumb-empty {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
}

.board-thumb-caption {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--tool-radius);
  background: var(--tool-bg);
  color: var(--tool-ink);
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
}

.board-thumb:disabled .board-thumb-caption {
  display: none;
}

.board-card-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-width: 0;
  padding: 12px 14px;
}

.board-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.board-source {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  margin: 0;
  color: var(--tool-muted);
  font-size: 13px;
}

.source-kind {
  color: var(--tool-ink);
  font-weight: 600;
}

.board-state,
.board-note,
.board-save-none {
  margin: 0;
  color: var(--tool-muted);
  font-size: 13px;
}

.board-state:empty {
  display: none;
}

.board-save {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--tool-line);
}

.board-save-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
}

.field--inline {
  flex: 1 1 180px;
  min-width: 0;
}

.field--inline .field-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tool-subtle);
}

.board-save-status {
  margin: 0;
  color: var(--tool-positive);
  font-size: 13px;
}

.board-save-status.is-error {
  color: var(--tool-negative);
}

.board-save-status:empty {
  display: none;
}

/* ---------------------------------------------------------------------------------------------- board preview */

.board-svg .bd-ground {
  fill: var(--tool-surface-raised);
}

.board-svg .bd-arrow {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.board-svg .bd-arrow--dashed {
  stroke-dasharray: 14 10;
}

.bd-team--ally {
  --team: var(--tool-positive);
}

.bd-team--enemy {
  --team: var(--tool-negative);
}

.bd-team--neutral {
  --team: var(--tool-ink);
}

.board-svg .bd-arrow,
.board-svg .bd-ring,
.board-svg .bd-ability-ring {
  stroke: var(--team);
}

.board-svg .bd-head--ally {
  fill: var(--tool-positive);
}

.board-svg .bd-head--neutral {
  fill: var(--tool-ink);
}

/* An enemy arrowhead is hollow, so a path's team does not rest on colour alone. */
.board-svg .bd-head--enemy {
  fill: var(--tool-bg);
  stroke: var(--tool-negative);
  stroke-width: 1.4;
}

.board-svg .bd-agent-bg {
  fill: var(--tool-bg);
}

.board-svg .bd-initials {
  fill: var(--tool-ink);
  font-family: var(--font-mono);
  font-weight: 700;
}

.board-svg .bd-ring {
  fill: none;
  stroke-width: 5;
}

.board-svg .bd-team--enemy .bd-ring {
  stroke-dasharray: 9 5;
}

.board-svg .bd-ability-bg {
  fill: var(--tool-bg);
}

.board-svg .bd-ability-ring {
  fill: none;
  stroke-width: 3.5;
}

.board-svg .bd-team--enemy .bd-ability-ring {
  stroke-dasharray: 6 4;
}

.board-svg .bd-tag-bg {
  fill: var(--tool-bg);
  fill-opacity: 0.9;
  stroke: var(--tool-line-strong);
  stroke-width: 1;
}

.board-svg .bd-tag-text {
  fill: var(--tool-ink);
  font-family: var(--font-mono);
}

.board-svg .bd-tag--note .bd-tag-bg {
  stroke: var(--tool-control-line);
}

.board-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
  list-style: none;
  color: var(--tool-ink);
  font-size: 13px;
}

.board-legend li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.lg-note {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
}

.lg-swatch {
  flex: none;
}

.lg-ring {
  fill: var(--tool-bg);
  stroke: var(--team);
  stroke-width: 2.5;
}

.lg-ring--dashed {
  stroke-dasharray: 4 2.5;
}

.lg-square {
  fill: var(--tool-bg);
  stroke: var(--tool-ink);
  stroke-width: 1.6;
}

.lg-path {
  fill: none;
  stroke: var(--tool-ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------------------------------------------------- dock */

.dock {
  position: sticky;
  bottom: 0;
  z-index: 10;
  width: min(100%, calc(var(--column-w)));
  margin: 0 auto;
  padding: 10px 24px max(14px, env(safe-area-inset-bottom));
  background: var(--tool-bg);
}

.composer {
  display: grid;
  border: 1px solid var(--tool-control-line);
  border-radius: var(--tool-radius);
  background: var(--tool-surface);
}

.composer:has(.composer-input:focus-visible) {
  outline: 2px solid var(--tool-accent);
  outline-offset: 2px;
}

.composer-input {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 240px;
  padding: 14px 16px 6px;
  border: 0;
  background: transparent;
  color: var(--tool-ink);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
}

.main.is-empty .composer-input {
  min-height: 76px;
}

.composer-input:focus-visible {
  outline: none;
}

.composer-input::placeholder {
  color: var(--tool-subtle);
  opacity: 1;
}

.composer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 8px;
}

.pickers {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.picker {
  display: flex;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--tool-control-line);
  border-radius: var(--tool-radius);
  background: var(--tool-bg);
}

.picker-label {
  padding: 0 0 0 10px;
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.picker .select {
  min-width: 0;
  max-width: 240px;
  border: 0;
  background-color: transparent;
  font-size: 13px;
}

.picker .select:focus-visible {
  outline-offset: 1px;
}

.count {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.count.is-limit {
  color: var(--tool-negative);
}

.send {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--tool-accent);
  color: var(--tool-accent-dark);
  cursor: pointer;
}

.send:disabled {
  background: var(--tool-surface-raised);
  color: var(--tool-subtle);
  cursor: default;
}

.send.is-busy {
  cursor: progress;
}

.dock-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px 16px;
  padding-top: 8px;
}

.sinaps {
  display: flex;
  flex: 1 1 320px;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.sinaps-bar {
  position: relative;
  flex: none;
  width: 56px;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--tool-line);
  transform: translateY(-2px);
}

.sinaps-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  background: var(--tool-muted);
}

.sinaps.is-low .sinaps-fill,
.sinaps.is-empty .sinaps-fill {
  background: var(--tool-negative);
}

.sinaps-text {
  margin: 0;
  color: var(--tool-subtle);
  font-size: 12px;
  line-height: 1.5;
}

.sinaps-text strong {
  color: var(--tool-ink);
  font-weight: 600;
}

.sinaps.is-empty .sinaps-text strong {
  color: var(--tool-negative);
}

.keys {
  margin: 0;
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
}

/* ---------------------------------------------------------------------------------------------------- dialogs */

.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--tool-line-strong);
  border-radius: var(--tool-radius);
  background: var(--tool-surface);
  color: var(--tool-ink);
}

.dialog[open] {
  animation: dialog-in var(--motion) ease-out;
}

.dialog.is-closing {
  animation: dialog-out 140ms ease-in forwards;
}

.dialog::backdrop {
  background: rgba(5, 6, 7, 0.82);
}

@keyframes dialog-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes dialog-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

.dialog-frame {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 20px;
}

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

.dialog-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.15;
}

.dialog-text {
  margin: 0;
  color: var(--tool-muted);
  font-size: 14px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 6px;
}

.dialog--board {
  width: min(1100px, calc(100vw - 32px));
}

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

.board-figure {
  display: grid;
  gap: 8px;
  margin: 0;
}

.board-figure svg {
  width: 100%;
  max-height: calc(100dvh - 140px);
  aspect-ratio: 1;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
}

.board-details {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.facts {
  display: grid;
  margin: 0;
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
}

.facts > div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 12px;
}

.facts > div + div {
  border-top: 1px solid var(--tool-line);
}

.facts dt {
  color: var(--tool-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.9;
  text-transform: uppercase;
}

.facts dd {
  margin: 0;
  font-size: 13px;
}

.board-notes {
  margin: 0;
  color: var(--tool-muted);
  font-size: 13px;
}

.board-objects {
  border: 1px solid var(--tool-line);
  border-radius: var(--tool-radius);
}

.board-objects summary {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: var(--tool-ink);
  font-size: 13px;
  cursor: pointer;
}

.board-objects summary:focus-visible {
  outline-offset: -2px;
}

.board-objects ul {
  max-height: 260px;
  margin: 0;
  padding: 4px 12px 10px 30px;
  overflow-y: auto;
  border-top: 1px solid var(--tool-line);
  color: var(--tool-muted);
  font-size: 13px;
}

/* ------------------------------------------------------------------------------------------------ responsive */

@media (max-width: 1020px) {
  .dialog-board {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-figure svg {
    max-height: none;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-h: 52px;
  }

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

  .topbar {
    gap: 6px;
    padding: 0 8px;
  }

  .menu-button,
  .drawer-close {
    display: inline-grid;
  }

  .account {
    display: none;
  }

  .mock-badge {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(86vw, 320px);
    height: 100%;
    border-right: 1px solid var(--tool-line-strong);
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform var(--motion) ease, visibility 0s linear var(--motion);
  }

  .sidebar.is-open {
    visibility: visible;
    transform: none;
    transition: transform var(--motion) ease, visibility 0s linear 0s;
  }

  .scrim {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    background: rgba(5, 6, 7, 0.82);
  }

  .thread-wrap {
    padding: 20px 16px 8px;
  }

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

  .examples li + li {
    border-left: 0;
    border-top: 1px solid var(--tool-line);
  }

  .example {
    min-height: 64px;
  }

  .msg--user {
    max-width: 92%;
  }

  .msg--assistant {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .msg-avatar {
    width: 22px;
    height: 22px;
  }

  .board-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .board-card-preview {
    padding: 12px 12px 0;
    border-right: 0;
  }

  .board-thumb {
    max-width: 280px;
  }

  .board-legend {
    grid-template-columns: minmax(0, 1fr);
  }

  .dock {
    padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  }

  .main.is-empty .composer-input {
    min-height: 60px;
  }

  /* The send button sits beside the text; the two pickers share the row under it. */
  .composer {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "input send"
      "pickers pickers"
      "count count";
  }

  .count:empty {
    display: none;
  }

  .composer-input {
    grid-area: input;
    max-height: 160px;
    padding: 12px 12px 4px;
  }

  .composer-bar {
    display: contents;
  }

  .send {
    grid-area: send;
    align-self: end;
    margin: 0 6px 4px 0;
  }

  .pickers {
    display: grid;
    grid-area: pickers;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 6px;
  }

  .picker .select {
    flex: 1;
    max-width: none;
  }

  .count {
    grid-area: count;
    justify-self: end;
    padding: 0 10px 6px;
  }

  .keys {
    display: none;
  }

  .dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .dialog-frame {
    padding: 14px;
  }

  .dialog-actions .button {
    flex: 1;
  }
}

/* Phones: the picker values speak for themselves; their labels stay for assistive technology. */
@media (max-width: 430px) {
  .picker-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dots span {
    animation: none;
    opacity: 0.6;
  }

  .dialog[open],
  .dialog.is-closing {
    animation: none;
  }

  .sidebar,
  .sidebar.is-open {
    transition: none;
  }
}
