/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --site-container: 1200px;
}

body {
  font-family: system-ui, sans-serif;
  margin: 0 2rem;
}

form {
  display: grid;
  gap: 0.75rem;
  max-width: 24rem;
}

label {
  font-weight: 600;
}

input[type="submit"],
button {
  width: fit-content;
}

.admin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.admin-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.admin-header form {
  display: block;
  max-width: none;
  margin-left: 0;
}

.impersonation-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin: -2rem -2rem 2rem;
  padding: 12px 24px;
  background: #f08129;
  color: #242221;
}

.impersonation-banner p {
  margin: 0;
}

.impersonation-banner form {
  display: block;
  max-width: none;
  margin: 0 0 0 auto;
}

.admin-users {
  box-sizing: border-box;
  width: min(var(--site-container), calc(100% - 48px));
  margin: 0 auto;
  padding: 24px 0;
}

.admin-users h1 {
  margin: 0 0 16px;
}

.chats-table form {
  display: block;
  max-width: none;
  margin: 0;
}

.flash-alert,
.flash-notice {
  width: min(var(--site-container), calc(100% - 48px));
  margin: 16px auto;
}

.flash-alert {
  color: #9f1239;
}

.flash-notice {
  color: #166534;
}

.header-profile {
  margin-left: auto;
}

form.chat-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  max-width: none;
  margin-bottom: 16px;
}

.chats-count {
  margin: 0 0 16px;
}

.chats-table {
  width: 100%;
  border-collapse: collapse;
}

.chats-table th,
.chats-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #e4e4e7;
}

.chats-table tbody tr {
  cursor: pointer;
}

.chats-table tbody tr:hover,
.chats-table tbody tr:focus {
  background: #f4f4f5;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.empty {
  color: #3f3f46;
}

.error {
  color: #b91c1c;
}

.chat-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 24px;
}

.chat-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.chat-dialog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.chat-dialog-toolbar h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.chat-summary {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.chat-summary p {
  margin: 0;
}

.thread {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.chat-photos {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.chat-photo {
  margin: 0;
}

.message .chat-photo {
  margin-top: 8px;
}

.chat-photo-image {
  display: block;
  max-width: 240px;
  max-height: 240px;
  width: auto;
  height: auto;
  border-radius: 12px;
  background: #f7f5f2;
}

.chat-photo-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message {
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 36rem;
}

.message p {
  margin: 0;
}

.message-meta {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 4px;
}

.message-user {
  background: #dbeafe;
}

.message-assistant,
.message-agent {
  background: #f4f4f5;
  margin-left: auto;
}

.message-system,
.message-unknown {
  background: #fef3c7;
}

pre.json {
  margin-top: 16px;
  padding: 16px;
  overflow: auto;
  border-radius: 8px;
  background: #f4f4f5;
  color: #18181b;
  white-space: pre-wrap;
}

.json-key {
  color: #1d4ed8;
}

.json-string {
  color: #047857;
}

.json-number {
  color: #b45309;
}

.json-literal {
  color: #7c3aed;
}

body:has(.auth-page) {
  margin: 0;
}

.auth-page {
  display: flex;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 64px 24px;
  color: #242221;
  background:
    radial-gradient(640px 280px at 50% 0%, rgba(240, 129, 41, 0.2), transparent 70%),
    #f1efec;
}

.auth-card {
  width: min(400px, 100%);
  margin: auto;
  padding: 32px 24px;
  background: #ffffff;
  border: 1px solid rgba(36, 34, 33, 0.08);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(36, 34, 33, 0.08);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  margin-bottom: 24px;
  color: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
}

.auth-brand::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  background: #f08129;
  border-radius: 2px;
}

.auth-card h1 {
  margin: 0 0 24px;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.auth-flash {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.auth-flash-alert {
  color: #b91c1c;
}

.auth-flash-notice {
  color: #047857;
}

.auth-form {
  display: grid;
  gap: 16px;
  max-width: none;
  margin: 0;
}

.auth-field {
  display: grid;
  gap: 4px;
}

.auth-field label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.auth-field input {
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid rgba(36, 34, 33, 0.12);
  border-radius: 12px;
  background: #f7f5f2;
  color: #242221;
  font: 400 16px/1.5 system-ui, sans-serif;
}

.auth-field input::placeholder {
  color: #9a958f;
}

.auth-field input:focus {
  border-color: #f08129;
  outline: 4px solid rgba(240, 129, 41, 0.28);
  outline-offset: 0;
}

.auth-form input[type="submit"] {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  background: #f08129;
  color: #ffffff;
  font: 600 16px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.auth-form input[type="submit"]:hover {
  background: #d9731f;
}

.auth-form input[type="submit"]:focus {
  outline: 4px solid rgba(240, 129, 41, 0.45);
  outline-offset: 4px;
}

.auth-forgot {
  display: block;
  margin-top: 16px;
  color: #5c5854;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

.auth-forgot:hover {
  color: #242221;
}

html:has(.demo-page) {
  height: 100%;
  overflow: hidden;
}

body:has(.demo-page) {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  background: #f1efec;
  color: #242221;
}

body:has(.demo-page) .impersonation-banner {
  flex: none;
  margin: 0;
}

.demo-page {
  display: flex;
  flex: 1;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 0;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.demo-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #f1efec;
}

.demo-columns {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
}

.demo-panel {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  border-bottom: 1px solid rgba(36, 34, 33, 0.08);
}

.demo-answer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}

.demo-crm-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.demo-crm-bar .demo-scheme-button {
  justify-self: start;
}

.demo-crm-title {
  margin: 0;
  justify-self: center;
  text-align: center;
  color: #242221;
  font: 700 13px/1 system-ui, sans-serif;
  letter-spacing: 0.14em;
}

.demo-crm-logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 4px 5px;
  min-width: 0;
}

.demo-crm-logo {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.demo-crm-mark {
  width: 20px;
  height: 20px;
  flex: none;
}

.demo-crm-word {
  font: 700 13px/1 system-ui, sans-serif;
}

.demo-crm-word-amo {
  color: #339dc7;
}

.demo-crm-amo {
  color: #7f98a4;
  font-weight: 600;
  font-style: italic;
}

.demo-crm-word-bitrix {
  color: #1d4e89;
}

.demo-crm-24 {
  color: #2fc6f6;
}

.demo-crm-word-telegram {
  color: #2aabee;
}

.demo-answer-stage {
  display: flex;
  /*flex: 1;*/
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
}

.demo-manager {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  align-self: center;
  gap: 8px;
  color: #c2410c;
  text-align: center;
}

.demo-manager[hidden] {
  display: none;
}

.demo-manager-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #f08129;
  color: #ffffff;
}

.demo-manager-icon svg {
  width: 28px;
  height: 28px;
}

.demo-manager-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 2px solid rgba(240, 129, 41, 0.45);
  border-radius: 50%;
  animation: demo-manager-pulse 1.4s ease-out infinite;
}

.demo-manager-label {
  font: 600 12px/1.25 system-ui, sans-serif;
}

@keyframes demo-manager-pulse {
  from {
    transform: scale(0.92);
    opacity: 0.8;
  }

  to {
    transform: scale(1.15);
    opacity: 0;
  }
}

.demo-answer-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.demo-cards {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: minmax(min-content, 1fr);
  gap: 24px;
  min-width: 0;
  min-height: 0;
  margin: 20px;
}

.demo-card {
  width: 100%;
  height: 100%;
  min-width: 0;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 20px;
  background: #e8e5e5;
  overflow: hidden;
  color: #242221;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.demo-card th,
.demo-card td {
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  border-top: 1px solid #efece8;
  overflow-wrap: anywhere;
}

.demo-card tr:first-child th,
.demo-card tr:first-child td {
  border-top: 0;
}

.demo-card th {
  width: 42%;
  color: #5c5854;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.demo-card td {
  color: #242221;
  font-size: 16px;
  font-weight: 500;
}

.demo-scheme-button,
.demo-scheme-toolbar button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(36, 34, 33, 0.16);
  border-radius: 999px;
  background: #ffffff;
  color: #242221;
  font: 600 14px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.demo-scheme-button {
  background-color: #ffa50073;
}

.demo-scheme {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  overflow: auto;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  color: #242221;
}

.demo-scheme::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.demo-scheme-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.demo-scheme .mermaid svg {
  max-width: 100%;
  height: auto;
}

.demo-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 16px;
  background: #f7f5f2;
}

.demo-thread {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: auto;
}

.demo-bubble {
  box-sizing: border-box;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
}

.demo-bubble p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.demo-bubble img {
  display: block;
  max-width: 160px;
  max-height: 160px;
  margin-top: 6px;
  border-radius: 10px;
}

.demo-bubble img:first-child {
  margin-top: 0;
}

.demo-bubble-user {
  align-self: flex-end;
  background: #007aff;
  color: #ffffff;
  border-bottom-right-radius: 6px;
}

.demo-bubble-agent {
  align-self: flex-start;
  background: #e5e5ea;
  color: #242221;
  border-bottom-left-radius: 6px;
}

.demo-loading {
  display: flex;
  align-items: center;
  width: fit-content;
  min-height: 36px;
}

.demo-spinner {
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(36, 34, 33, 0.22);
  border-top-color: #242221;
  border-radius: 50%;
  animation: demo-spin 0.7s linear infinite;
}

@keyframes demo-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo-spinner {
    animation: none;
    border-color: #242221;
  }

  .demo-manager-icon::after {
    animation: none;
  }
}

.demo-chat-error {
  min-height: 1.2em;
  margin: 0;
  color: #b91c1c;
}

.demo-meta-empty {
  margin: 0;
  color: #5c5854;
}

.demo-composer-stack {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.demo-new-dialog {
  margin: 0;
}

.demo-new-dialog button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(36, 34, 33, 0.16);
  border-radius: 999px;
  background: #ffffff;
  color: #242221;
  font: 600 14px/1.2 system-ui, sans-serif;
  cursor: pointer;
  margin-bottom: 15px;
}

.demo-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: stretch;
}

.demo-previews:empty {
  display: none;
}

.demo-preview {
  position: relative;
  width: 48px;
  height: 48px;
}

.demo-preview img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.demo-preview button {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #242221;
  color: #ffffff;
  font: 600 12px/18px system-ui, sans-serif;
  cursor: pointer;
}

.demo-composer {
  display: flex;
  align-self: stretch;
  gap: 8px;
  max-width: none;
  margin: 0;
}

.demo-composer-field {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  box-sizing: border-box;
  height: 34px;
  padding: 0 10px 0 4px;
  border: 1px solid rgba(36, 34, 33, 0.12);
  border-radius: 999px;
  background: #ffffff;
}

.demo-composer-field:focus-within {
  border-color: #007aff;
}

.demo-attach {
  position: relative;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  overflow: hidden;
  color: #5c5854;
  cursor: pointer;
}

.demo-clip {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.demo-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.demo-message {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: #242221;
  font: 400 16px/1.4 system-ui, sans-serif;
}

.demo-message:focus {
  outline: none;
}

.demo-send {
  box-sizing: border-box;
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #007aff;
  color: #ffffff;
  font: 600 16px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.demo-send:disabled {
  opacity: 0.6;
  cursor: default;
}

.test-case-generate-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 0;
  border-radius: 24px;
  padding: 24px;
  background: #ffffff;
  color: #242221;
}

.test-case-generate-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.test-case-generate-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.test-case-generate-toolbar h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.test-case-select {
  width: 1%;
  white-space: nowrap;
  text-align: center;
}

.test-case-select label {
  font-size: 12px;
  font-weight: 600;
}

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

.test-case-dialog {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.dialog-role {
  font-weight: 700;
  font-style: italic;
}

.dialog-roles {
  position: relative;
}

.dialog-roles-input {
  box-sizing: border-box;
  width: 100%;
  min-height: 140px;
  padding: 12px 16px;
  border: 1px solid rgba(36, 34, 33, 0.12);
  border-radius: 12px;
  background: #f7f5f2;
  color: #242221;
  font: 400 16px/1.5 system-ui, sans-serif;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}

.dialog-roles-input:focus {
  border-color: #f08129;
  outline: 4px solid rgba(240, 129, 41, 0.28);
  outline-offset: 0;
}

textarea.dialog-roles-source {
  display: none !important;
}

.test-case-actions {
  white-space: nowrap;
}

.test-case-actions form {
  display: inline-flex;
  max-width: none;
  margin: 0 0 0 12px;
}

form.test-case-selected {
  display: inline-flex;
  max-width: none;
  margin: 0 0 12px;
}

.test-run-details {
  display: grid;
  gap: 16px;
  margin: 0;
}

.test-run-details > div {
  display: grid;
  gap: 4px;
}

.test-run-details dt {
  margin: 0;
  color: #5c5854;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.test-run-details dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

main.profile {
  width: min(var(--site-container), calc(100% - 48px));
  margin: 0 auto;
  padding: 8px 0 64px;
}

.profile-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.profile-hero form.profile-picker {
  flex: 0 1 280px;
  width: 280px;
  max-width: 100%;
  margin: 0 0 0 auto;
}

.profile-picker-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-left: auto;
}

.profile-picker-actions form.profile-picker {
  margin: 0;
}

.profile-kicker,
.profile-mermaid-caption,
.profile-facts dt {
  margin: 0 0 8px;
  color: #5c5854;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.profile-hero-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.profile-hero-copy .profile-kicker,
.profile-hero-copy .profile-lead {
  margin: 0;
}

.profile-hero h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.profile-lead {
  margin: 8px 0 0;
  color: #5c5854;
  font-size: 16px;
}

.profile-name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.profile-name-line .profile-field {
  flex: 1 1 240px;
}

.profile-boards {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.profile-boards > .profile-card {
  margin-top: 0;
}

.profile-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-board h2,
.profile-danger h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.profile-board-note,
.profile-danger p {
  margin: 0;
  color: #5c5854;
  font-size: 14px;
  line-height: 1.45;
}

.profile-board .profile-stats,
.profile-board .profile-links {
  margin: 0;
}

.profile-board .profile-links {
  margin-top: auto;
}

.profile-board .profile-stat {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.profile-board-metrics {
  display: grid;
  gap: 16px;
}

.profile-pass {
  display: grid;
  gap: 8px;
  align-content: end;
}

.profile-pass-label {
  margin: 0;
  color: #5c5854;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

.profile-stats-pass .profile-stat-value {
  font-size: 22px;
}

.profile-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-chip-list li {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f7f5f2;
  color: #5c5854;
  font-size: 13px;
  font-weight: 600;
}

.profile-danger {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding: 20px 24px;
  border: 1px solid rgba(185, 28, 28, 0.28);
  border-radius: 24px;
  background: #fff7f7;
}

.profile-danger-copy {
  flex: 1 1 280px;
  display: grid;
  gap: 4px;
}

.profile-danger p {
  max-width: 62ch;
}

.profile-danger form.profile-delete {
  margin: 0;
}

.profile-link-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.profile-link-group + .profile-link-group {
  margin-left: 8px;
  padding-left: 20px;
  border-left: 1px solid rgba(36, 34, 33, 0.12);
}

.test-case-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px 32px;
}

.test-case-tools > form {
  flex: 1 1 280px;
  max-width: 420px;
  margin: 0;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.profile-stat {
  padding: 16px;
  background: #ffffff;
  border: 1px solid rgba(36, 34, 33, 0.08);
  border-radius: 16px;
}

.profile-stat-value {
  margin: 0;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.1;
}

.profile-stat-label {
  margin: 4px 0 0;
  color: #5c5854;
  font-size: 13px;
}

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

.settings-versions li {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.test-case-photo-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
}

.profile-card {
  margin-top: 16px;
  padding: 24px;
  background: #ffffff;
  border: 1px solid rgba(36, 34, 33, 0.08);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(36, 34, 33, 0.06);
}

.profile-facts {
  display: grid;
  gap: 20px;
  margin: 0;
}

.profile-facts > div {
  display: grid;
  gap: 8px;
}

.profile-facts > div.profile-token {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.profile-facts dd {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
}

.profile-facts dt label {
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.profile-facts .profile-token dt,
.profile-facts .profile-token dt label,
.landing.profile-dark .profile-facts .profile-token dt,
.landing.profile-dark .profile-facts .profile-token dt label {
  margin: 0;
  color: inherit;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: normal;
  line-height: 1.4;
  text-transform: none;
}

.profile-token-controls {
  display: flex;
  flex: 1 1 280px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.profile-token-quoted {
  display: flex;
  flex: 1 1 220px;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.profile-token-quote {
  font: 500 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.profile-token-controls input {
  flex: 1 1 auto;
  box-sizing: border-box;
  min-width: 0;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid rgba(36, 34, 33, 0.12);
  border-radius: 12px;
  background: #f7f5f2;
  color: #242221;
  font: 500 15px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.profile-token-controls input.is-masked {
  -webkit-text-security: disc;
}

.profile-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(36, 34, 33, 0.14);
  border-radius: 999px;
  background: #ffffff;
  color: #242221;
  font: 600 14px/1.2 system-ui, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.profile-button:hover {
  background: #f7f5f2;
}

.profile-button-primary {
  border-color: transparent;
  background: #f08129;
  color: #ffffff;
}

.profile-button-primary:hover {
  background: #d9731f;
}

.profile-button-danger {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #ffffff;
}

.profile-button-danger:hover {
  background: #991b1b;
}

form.profile-delete,
form.profile-sign-out {
  display: block;
  max-width: none;
  margin: 24px 0 0;
}

.profile-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
}

.profile-links form,
.profile-links .test-case-generate-open {
  display: inline-flex;
  align-items: center;
  max-width: none;
  margin: 0;
}

form.profile-image-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 24px;
}

form.profile-image-upload label {
  font-weight: 600;
}

form.profile-image-upload input[type="file"] {
  flex: 1 1 220px;
  min-width: 0;
}

.profile-image-name {
  margin: 0;
  font-weight: 600;
}

.profile-image-list {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-image-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.profile-image-open {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.profile-image-photo {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: cover;
  border-radius: 12px;
  background: #f7f5f2;
}

.profile-image-dialog {
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 0;
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
}

.profile-image-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.profile-image-close {
  display: block;
  margin: 0 0 12px auto;
}

.profile-image-full {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 120px);
  width: auto;
  height: auto;
  margin: 0 auto;
}

.profile-image-details {
  flex: 1 1 220px;
  display: grid;
  gap: 8px;
  min-width: 0;
}

form.profile-image-delete {
  display: block;
  max-width: none;
  margin: 0;
}

.profile-image-date {
  margin: 0;
  color: #5c5854;
  font-size: 14px;
}

.profile-image-text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.profile-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
}

form.profile-picker {
  flex: 1 1 280px;
  max-width: none;
  margin: 0;
}

form.profile-picker select,
form.profile-form textarea,
form.profile-form input[type="text"],
form.profile-form input[type="number"],
form.profile-form select {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid rgba(36, 34, 33, 0.12);
  border-radius: 12px;
  background: #f7f5f2;
  color: #242221;
  font: 400 16px/1.5 system-ui, sans-serif;
}

form.profile-picker select {
  min-height: 48px;
  padding: 12px 16px;
}

form.profile-create {
  display: block;
  max-width: none;
  margin: 0;
}

.profile-chats h2,
.profile-editor h2 {
  margin: 0 0 16px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.profile-table-scroll {
  overflow-x: auto;
}

table.profile-chats-table {
  min-width: 720px;
}

table.profile-chats-table th {
  color: #5c5854;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

table.profile-chats-table tbody tr {
  cursor: pointer;
}

table.profile-chats-table tbody tr:hover,
table.profile-chats-table tbody tr:focus {
  background: #f7f5f2;
}

.profile .error {
  margin: 0 0 16px;
  padding: 12px 16px 12px 32px;
  border-radius: 12px;
  background: #fff1f2;
}

form.profile-form {
  max-width: none;
  gap: 20px;
}

.profile-field {
  display: grid;
  gap: 8px;
}

.profile-demo-link {
  color: #c2410c;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.profile-mermaid .profile-field {
  grid-template-rows: auto minmax(280px, 1fr);
}

form.profile-form .profile-mermaid textarea {
  height: 100%;
  min-height: 280px;
}

.profile-demo label,
form.profile-form label,
form.profile-picker label {
  font-size: 14px;
}

form.profile-form textarea,
form.profile-form input[type="text"],
form.profile-form input[type="number"],
form.profile-form select {
  padding: 12px 16px;
}

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

form.profile-picker select:focus,
form.profile-form textarea:focus,
form.profile-form input[type="text"]:focus,
form.profile-form input[type="number"]:focus,
form.profile-form select:focus,
.profile-token-controls input:focus {
  border-color: #f08129;
  outline: 4px solid rgba(240, 129, 41, 0.28);
  outline-offset: 0;
}

.profile-mermaid {
  display: grid;
  gap: 16px;
}

.profile-mermaid-preview {
  min-height: 280px;
  padding: 16px;
  overflow: auto;
  border: 1px solid rgba(36, 34, 33, 0.08);
  border-radius: 16px;
  background: #f7f5f2;
}

.profile-mermaid-preview .mermaid {
  min-height: 220px;
  color: #5c5854;
}

.profile-mermaid-preview .mermaid svg {
  max-width: 100%;
  height: auto;
}

form.profile-theme {
  display: block;
  max-width: none;
  margin: 0;
}

.theme-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
}

.theme-switch input {
  position: absolute;
  z-index: 1;
  width: 44px;
  height: 26px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.theme-switch-track {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d6d3d1;
}

.theme-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
}

.theme-switch input:checked + .theme-switch-track {
  background: #f08129;
}

.theme-switch input:checked + .theme-switch-track::after {
  transform: translateX(18px);
}

.theme-switch input:focus-visible + .theme-switch-track {
  outline: 4px solid rgba(240, 129, 41, 0.28);
  outline-offset: 2px;
}

body:has(.profile-dark) {
  background: #171513;
}

.landing.profile-dark {
  color: #f4f1ec;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(240, 129, 41, 0.22), transparent 60%),
    #171513;
}

.landing.profile-dark .site-header {
  background: rgba(23, 21, 19, 0.92);
}

.landing.profile-dark .header-user,
.landing.profile-dark .header-wrench {
  background: rgba(255, 255, 255, 0.08);
  color: #f4f1ec;
}

.landing.profile-dark .header-user:hover,
.landing.profile-dark .header-wrench:hover {
  background: rgba(255, 255, 255, 0.16);
}

.landing.profile-dark .site-header button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: #242220;
  color: #f4f1ec;
  font: 600 14px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.landing.profile-dark .profile-kicker,
.landing.profile-dark .profile-lead,
.landing.profile-dark .profile-board-note,
.landing.profile-dark .profile-pass-label,
.landing.profile-dark .profile-danger p,
.landing.profile-dark .profile-facts dt,
.landing.profile-dark .test-run-details dt,
.landing.profile-dark table.profile-chats-table th,
.landing.profile-dark .empty,
.landing.profile-dark .profile-image-date {
  color: #a8a29e;
}

.landing.profile-dark form.profile-image-upload input[type="file"] {
  color: #f4f1ec;
}

.landing.profile-dark .profile-demo-link {
  color: #fdba74;
}

.landing.profile-dark .profile-card,
.landing.profile-dark .profile-stat {
  background: #242220;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

.landing.profile-dark .profile-board .profile-stat {
  background: transparent;
  border-color: transparent;
}

.landing.profile-dark .profile-chip-list li {
  background: #171513;
  color: #d6d3d1;
}

.landing.profile-dark .profile-danger {
  background: #2a1616;
  border-color: rgba(248, 113, 113, 0.35);
}

.landing.profile-dark .profile-link-group + .profile-link-group {
  border-left-color: rgba(255, 255, 255, 0.14);
}

.landing.profile-dark .profile-stat-label {
  color: #a8a29e;
}

.landing.profile-dark .profile-token-controls input,
.landing.profile-dark form.profile-picker select,
.landing.profile-dark form.profile-form textarea,
.landing.profile-dark form.profile-form input[type="text"],
.landing.profile-dark form.profile-form input[type="number"],
.landing.profile-dark form.profile-form select,
.landing.profile-dark .dialog-roles-input {
  border-color: rgba(255, 255, 255, 0.14);
  background: #171513;
  color: #f4f1ec;
}

.landing.profile-dark .profile-button {
  border-color: rgba(255, 255, 255, 0.14);
  background: #171513;
  color: #f4f1ec;
}

.landing.profile-dark .profile-button:hover {
  background: #322f2c;
}

.landing.profile-dark .profile-button-primary,
.landing.profile-dark .profile-button-primary:hover {
  border-color: transparent;
  color: #ffffff;
}

.landing.profile-dark .profile-button-primary {
  background: #f08129;
}

.landing.profile-dark .profile-button-primary:hover {
  background: #d9731f;
}

.landing.profile-dark .profile-button-danger,
.landing.profile-dark .profile-button-danger:hover {
  border-color: #b91c1c;
  color: #ffffff;
}

.landing.profile-dark .profile-button-danger {
  background: #b91c1c;
}

.landing.profile-dark .profile-button-danger:hover {
  background: #991b1b;
}

.landing.profile-dark table.profile-chats-table th,
.landing.profile-dark table.profile-chats-table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.landing.profile-dark table.profile-chats-table tbody tr:hover,
.landing.profile-dark table.profile-chats-table tbody tr:focus {
  background: #322f2c;
}

.landing.profile-dark .chat-dialog,
.landing.profile-dark .profile-image-dialog,
.landing.profile-dark .test-case-generate-dialog {
  border-color: rgba(255, 255, 255, 0.14);
  background: #242220;
  color: #f4f1ec;
}

.landing.profile-dark .chat-dialog .message-user {
  background: #1e3a5f;
  color: #f4f1ec;
}

.landing.profile-dark .chat-dialog .message-assistant,
.landing.profile-dark .chat-dialog .message-agent,
.landing.profile-dark .chat-dialog .message-system,
.landing.profile-dark .chat-dialog .message-unknown {
  background: #3f3a36;
  color: #f4f1ec;
}

.landing.profile-dark .chat-dialog .empty {
  color: #a8a29e;
}

.landing.profile-dark .pagination a {
  color: #f4b27a;
}

.landing.profile-dark .flash-notice {
  color: #86efac;
}

.landing.profile-dark .flash-alert {
  color: #fda4af;
}

.landing.profile-dark .profile .error {
  background: #3f1d24;
  color: #fecdd3;
}

.landing.profile-dark .profile-mermaid-preview {
  border-color: transparent;
  background: #f7f5f2;
  color: #242221;
}

.landing.profile-dark .profile-mermaid-preview .profile-mermaid-caption,
.landing.profile-dark .profile-mermaid-preview .mermaid {
  color: #5c5854;
}

form.test-case-form,
form.test-case-run-form {
  max-width: none;
}

form.test-case-form textarea,
form.test-case-form input[type="text"],
form.test-case-form input[type="number"],
form.test-case-form select {
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 900px) {
  .profile-mermaid {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr);
    align-items: stretch;
  }

  .profile-boards {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  }

  .profile-board-tests {
    grid-column: 1 / -1;
  }

  .profile-board-metrics {
    grid-template-columns: minmax(180px, 0.7fr) minmax(0, 1.3fr);
    align-items: end;
  }
}

.test-case-photos-field {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.test-case-photos-field legend {
  font-weight: 600;
  margin-bottom: 8px;
}

.test-case-photos {
  display: grid;
  gap: 8px;
}

.test-case-photos[hidden] {
  display: none;
}

.test-case-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.test-case-check label {
  font-weight: 600;
}

@media (min-width: 900px) {
  .demo-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }

  .demo-panel {
    border-bottom: 0;
    border-right: 1px solid rgba(36, 34, 33, 0.08);
  }

  .demo-panel:last-child {
    border-right: 0;
  }

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