/* DBLU Business — layout inspired by app-to-web-studio / OSX chrome */
:root {
  --radius: 14px;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui,
    sans-serif;
  --background: #fafbfc;
  --foreground: #0f172a;
  --card: #ffffff;
  --muted: #64748b;
  --border: #e8eaef;
  --primary: #2563eb;
  --primary-fg: #ffffff;
  --surface: #f4f6f9;
  --badge-personal: #2563eb;
  --badge-company: #7c3aed;
  --destructive: #dc2626;
  --accent: #eff6ff;
  /* Header, main column, and bottom nav share one width */
  --app-max-width: 1400px;
}

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

/* Same idea as doubleu-api static/avatar/css/avatar.css (visitor /a/{slug} chat) — light theme */
html {
  min-height: 100%;
  background-color: var(--background);
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -30%, rgba(37, 99, 235, 0.09), transparent 50%),
    radial-gradient(ellipse 55% 50% at 100% 0%, rgba(37, 99, 235, 0.055), transparent 48%),
    radial-gradient(ellipse 50% 45% at 0% 100%, rgba(37, 99, 235, 0.065), transparent 46%),
    repeating-linear-gradient(
      105deg,
      rgba(232, 234, 239, 0.95) 0 1px,
      transparent 1px 48px
    ),
    repeating-linear-gradient(
      -105deg,
      rgba(232, 234, 239, 0.75) 0 1px,
      transparent 1px 60px
    ),
    radial-gradient(circle at 1px 1px, rgba(15, 23, 42, 0.045) 1px, transparent 0);
  background-size:
    auto,
    auto,
    auto,
    auto,
    auto,
    22px 22px;
  background-attachment: fixed;
}

html,
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--foreground);
}

body {
  min-height: 100%;
  background: transparent;
}

@media (prefers-reduced-motion: reduce) {
  html {
    background-attachment: scroll;
  }
}

/* Login: only the blue procedural canvas (not stacked on the default html pattern) */
html:has(.login-page) {
  background-color: #e8f0fe;
  background-image: none;
  background-attachment: scroll;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--app-max-width);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--app-max-width);
  margin-inline: auto;
  box-sizing: border-box;
  height: 56px;
  padding: 0 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 0;
}
.brand-link:hover {
  text-decoration: none;
  opacity: 0.92;
}
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  border-radius: 6px;
}

.login-brand-logo {
  display: block;
  max-width: min(220px, 100%);
  width: 100%;
  height: auto;
  margin: 0 auto 1.25rem;
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(37, 99, 235, 0.18);
}

.profile-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}
.profile-link:hover {
  background: var(--accent);
  color: var(--foreground);
  text-decoration: none;
}

.app-main {
  flex: 1;
  overflow: auto;
  width: 100%;
  max-width: var(--app-max-width);
  margin-inline: auto;
  box-sizing: border-box;
  padding-bottom: 72px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  /* Opaque so the page pattern does not show through (header/footer read as solid chrome) */
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 40;
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0 1.25rem;
  box-sizing: border-box;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.35rem 0.75rem;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.bottom-nav a:hover {
  color: var(--foreground);
}
.bottom-nav a.active {
  color: var(--primary);
}
.bottom-nav svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
}

.flash-stack {
  width: 100%;
  max-width: var(--app-max-width);
  margin-inline: auto;
  box-sizing: border-box;
  padding: 0.75rem 1.25rem 0;
}
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}
.flash-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.flash-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.split {
  display: flex;
  min-height: calc(100vh - 56px - 64px);
}
.split-sidebar {
  width: 100%;
  max-width: 320px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.split-main {
  flex: 1;
  background: var(--card);
  min-width: 0;
}

@media (max-width: 768px) {
  .split {
    flex-direction: column;
  }
  .split-sidebar {
    max-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
    overflow: auto;
  }
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 1.125rem;
  font-family: var(--font-display);
}
.icon-btn {
  border: none;
  background: transparent;
  padding: 0.35rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}
.icon-btn:hover {
  background: var(--accent);
  color: var(--foreground);
}

.double-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.75rem;
  margin: 0 0.5rem 2px;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.double-row:hover {
  background: rgba(37, 99, 235, 0.06);
}
.double-row.active {
  background: rgba(37, 99, 235, 0.1);
}
.double-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 1.1rem;
}
.double-avatar.personal {
  background: var(--badge-personal);
}
.double-avatar.company {
  background: var(--badge-company);
}
.double-avatar.fictional {
  background: #9333ea;
}
.badge-pill {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
}
.badge-pill.personal {
  background: var(--badge-personal);
}
.badge-pill.company {
  background: var(--badge-company);
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--border);
}
.status-dot.on {
  background: var(--destructive);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}
.empty-state h2 {
  margin: 0.75rem 0 0.25rem;
  color: var(--foreground);
  font-size: 1.125rem;
  font-weight: 600;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tabs a {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}
.tabs a:hover {
  background: var(--surface);
  color: var(--foreground);
}
.tabs a.active {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.tabs-double {
  margin: 0.5rem 1rem 0;
  padding: 3px;
  gap: 2px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  background: var(--surface);
  border-bottom: 1px solid rgba(15, 23, 42, 0.12);
}
.tabs-double a {
  flex: 1;
  text-align: center;
  min-width: 0;
  font-size: 0.78rem;
  padding: 0.45rem 0.25rem;
  border-radius: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tabs-double a.active {
  font-weight: 600;
}

.btn-outline-danger {
  background: transparent;
  color: var(--destructive);
  border-color: rgba(220, 38, 38, 0.45);
}
.btn-outline-danger:hover {
  background: #fef2f2;
}

/* Doubles (PersonaDetailView / BundlesView parity) */
.doubles-sidebar-head h2 {
  font-family: var(--font-display);
}
.doubles-sidebar-tools {
  display: flex;
  gap: 2px;
  align-items: flex-start;
}
.doubles-sidebar-list {
  padding: 0 0 1rem;
}
.double-row {
  align-items: center;
  gap: 0.65rem;
}
.double-row-body {
  min-width: 0;
  flex: 1;
}
.double-row-name {
  font-weight: 600;
  font-size: 0.875rem;
}
.double-row-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.double-type-pill {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  text-transform: none;
}
.double-type-pill.personal {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}
.double-type-pill.company {
  background: rgba(99, 102, 241, 0.14);
  color: #4338ca;
}
.double-type-pill.fictional {
  background: rgba(147, 51, 234, 0.12);
  color: #7e22ce;
}
.double-row-role {
  font-size: 0.72rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.double-privacy-icon {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  align-self: center;
}
.double-privacy-maximum {
  background: #16a34a;
}
.double-privacy-balanced {
  background: #ea580c;
}
.double-privacy-convenience {
  background: #dc2626;
}
.double-privacy-other {
  background: #94a3b8;
}

.doubles-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.doubles-empty-main .doubles-empty-icon {
  font-size: 2.75rem;
  opacity: 0.35;
}
.doubles-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.doubles-detail-title {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--font-display);
  font-weight: 600;
}
.doubles-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.doubles-brain-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(147, 51, 234, 0.1);
  color: #6b21a8;
  font-variant-numeric: tabular-nums;
}
.doubles-rename-link {
  text-decoration: none;
}
.doubles-delete-form {
  margin: 0;
}
.doubles-panel {
  flex: 1;
  min-height: 0;
}
.doubles-section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 0.25rem;
}
.doubles-section-toolbar-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.doubles-toolbar-icon {
  font-size: 1rem;
  opacity: 0.85;
}
.doubles-toolbar-refresh {
  text-decoration: none;
}
.doubles-bundle-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
}
.doubles-bundle-details + .doubles-bundle-details {
  border-top: 1px solid var(--border);
}
.doubles-bundle-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  font-weight: 600;
}
.doubles-bundle-summary::-webkit-details-marker {
  display: none;
}
.doubles-bundle-summary:hover {
  background: rgba(15, 23, 42, 0.03);
}
.doubles-bundle-folder {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}
.doubles-bundle-summary-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
}
.doubles-bundle-name {
  font-size: 0.9rem;
}
.doubles-bundle-sub {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.doubles-bundle-attrcount {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
}
.doubles-bundle-type-pill {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}
.doubles-bundle-type-pill.predefined {
  background: rgba(234, 179, 8, 0.2);
  color: #a16207;
}
.doubles-bundle-type-pill.custom {
  background: rgba(37, 99, 235, 0.12);
  color: var(--primary);
}
.doubles-bundle-chevron {
  font-size: 1.1rem;
  color: var(--muted);
  font-weight: 300;
  transition: transform 0.15s ease;
}
.doubles-bundle-details[open] .doubles-bundle-chevron {
  transform: rotate(90deg);
}
.doubles-bundle-expanded {
  padding: 0 0.85rem 0.85rem 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.doubles-bundle-total {
  text-align: center;
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
}
.doubles-empty-tab {
  padding: 1.5rem 0;
}
.doubles-card-heading {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
}
.doubles-settings-card .doubles-inline-form {
  display: inline-block;
  margin-top: 0.5rem;
}
.doubles-settings-actions {
  margin-top: 0.65rem;
}
.doubles-toggle-line {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.875rem;
}
.doubles-system-prompt-details {
  margin-bottom: 0.75rem;
}
.doubles-summary-like {
  cursor: pointer;
  margin-bottom: 0.35rem;
}
.doubles-system-prompt-ta {
  margin-top: 0.35rem;
}
.doubles-danger-card {
  margin-top: 1rem;
  border-color: #fecaca;
  background: #fffafa;
}
.doubles-danger-heading {
  color: #991b1b;
}
.doubles-danger-copy {
  margin: 0 0 0.75rem;
  max-width: 48rem;
  line-height: 1.45;
}
.doubles-rename-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.doubles-rename-form input[type="text"] {
  margin-bottom: 0;
  max-width: 280px;
}
.doubles-scrape-form .field {
  margin-top: 0.5rem;
}
.doubles-kb-status {
  margin: 0 0 0.35rem;
}
.doubles-kb-url {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.doubles-material-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}
.doubles-material-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}
.doubles-material-list .doubles-material-item:last-child {
  border-bottom: none;
}
.doubles-material-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.doubles-material-meta {
  min-width: 0;
}
.doubles-material-preview {
  margin: 0.15rem 0 0;
}
.doubles-material-preview > summary {
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  list-style: none;
  user-select: none;
}
.doubles-material-preview > summary::-webkit-details-marker {
  display: none;
}
.doubles-material-preview > summary::before {
  content: "▸ ";
  display: inline-block;
  transition: transform 0.12s ease;
}
.doubles-material-preview[open] > summary::before {
  transform: rotate(90deg);
}
.doubles-material-text {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  max-height: 280px;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--foreground);
}
.doubles-material-no-text {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
}
.doubles-inline-form {
  display: inline;
  margin: 0;
}
.doubles-selfai-chat-body {
  position: relative;
  margin-top: 0.75rem;
  min-height: 220px;
}
.selfai-chat-loading {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 25;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card) 82%, transparent);
  backdrop-filter: blur(3px);
}
.selfai-chat-loading.is-active {
  display: flex;
}
.selfai-chat-loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}
.selfai-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: selfai-spin 0.75s linear infinite;
}
@keyframes selfai-spin {
  to {
    transform: rotate(360deg);
  }
}
.selfai-loading-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
}

.doubles-selfai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.doubles-selfai-head .doubles-card-heading {
  margin-bottom: 0;
}
.doubles-selfai-clear-form {
  margin: 0;
}
.doubles-selfai-card .doubles-selfai-chat-body .doubles-chat-log {
  margin-top: 0;
}
.doubles-selfai-card textarea {
  max-width: 100%;
}

.doubles-selfai-assistant-block {
  position: relative;
  margin-bottom: 0.85rem;
}
.doubles-selfai-assistant-block:has(.doubles-selfai-correction[open]) {
  /* Reserve space so the floating correction panel does not cover the next bubbles */
  margin-bottom: 11rem;
}
.doubles-selfai-feedback {
  margin: 0.25rem 0 0 0.15rem;
}
.doubles-selfai-thumbs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.15rem;
}
.doubles-selfai-feedback-form {
  display: block;
  margin: 0;
}
/* Matched pill controls for 👍 submit and 👎 disclosure (same size, border, fill). */
.doubles-selfai-thumb-pill {
  box-sizing: border-box;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  margin: 0;
  font-size: 1.125rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 400;
  color: inherit;
  box-shadow: none;
}
button.doubles-selfai-thumb-pill {
  list-style: none;
  -webkit-appearance: none;
  appearance: none;
}
.doubles-selfai-correction > summary.doubles-selfai-thumb-pill {
  list-style: none;
}
.doubles-selfai-correction > summary.doubles-selfai-thumb-pill::-webkit-details-marker {
  display: none;
}
.doubles-selfai-correction > summary.doubles-selfai-thumb-pill:focus {
  outline: none;
}
.doubles-selfai-correction > summary.doubles-selfai-thumb-pill:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.doubles-selfai-correction[open] > summary.doubles-selfai-thumb-pill {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}
.doubles-selfai-thumb-pill:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.doubles-selfai-thumb-pill:active {
  transform: scale(0.97);
}
.doubles-selfai-feedback-done {
  font-size: 0.8125rem;
}
.doubles-selfai-correction {
  flex: 0 0 auto;
  margin: 0;
}
/* Popover below the message row: does not reflow 👍/👎 (they stay on one line). */
.doubles-selfai-correction-drop {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 0.4rem;
  z-index: 8;
}
.doubles-selfai-correction[open] > .doubles-selfai-correction-drop {
  display: block;
}
.doubles-selfai-correction-form {
  margin-top: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-sizing: border-box;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12);
}
.doubles-selfai-correction-form textarea {
  width: 100%;
  margin: 0.35rem 0 0.5rem;
  box-sizing: border-box;
}

.panel {
  padding: 1rem 1.25rem 2rem;
}

/* Home: same horizontal rhythm as header (no extra narrow column) */
.home-page {
  padding-top: 1.5rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
}
.btn-danger {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}
.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8125rem;
}

label.field {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea,
select {
  width: 100%;
  max-width: 520px;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  margin-bottom: 0.75rem;
}
textarea {
  min-height: 100px;
  max-width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
table.data th,
table.data td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.35rem;
  text-align: left;
}

/* Same procedural stack as `html` (app shell), blue-forward for sign-in */
.login-page {
  min-height: 100vh;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-color: #e8f0fe;
  background-image:
    radial-gradient(ellipse 100% 70% at 50% -30%, rgba(37, 99, 235, 0.22), transparent 52%),
    radial-gradient(ellipse 55% 50% at 100% 0%, rgba(37, 99, 235, 0.14), transparent 48%),
    radial-gradient(ellipse 50% 45% at 0% 100%, rgba(59, 130, 246, 0.16), transparent 46%),
    repeating-linear-gradient(
      105deg,
      rgba(37, 99, 235, 0.16) 0 1px,
      transparent 1px 48px
    ),
    repeating-linear-gradient(
      -105deg,
      rgba(37, 99, 235, 0.12) 0 1px,
      transparent 1px 60px
    ),
    radial-gradient(circle at 1px 1px, rgba(37, 99, 235, 0.08) 1px, transparent 0);
  background-size:
    auto,
    auto,
    auto,
    auto,
    auto,
    22px 22px;
  background-attachment: fixed;
}

@media (prefers-reduced-motion: reduce) {
  .login-page {
    background-attachment: scroll;
  }
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 24px;
  padding: 2rem;
  color: var(--foreground);
  box-shadow: 0 16px 48px rgba(37, 99, 235, 0.12);
}
.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  font-family: var(--font-display);
  color: var(--foreground);
}
.login-card .btn-primary {
  width: 100%;
  max-width: none;
  margin-top: 0.5rem;
}
.login-card input[type="email"],
.login-card input[type="password"] {
  max-width: none;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.tile {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  text-align: center;
  background: var(--card);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease;
}
.tile:hover {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}
.tile-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.chat-log {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 160px;
  max-height: 320px;
  overflow: auto;
  background: var(--surface);
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.chat-bubble {
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  max-width: 95%;
}
.chat-bubble.user {
  background: rgba(37, 99, 235, 0.12);
  margin-left: auto;
}
.chat-bubble.assistant {
  background: #fff;
  border: 1px solid var(--border);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.subtle {
  font-size: 0.875rem;
  color: var(--muted);
}

.voice-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.sample-list,
.video-msg-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.sample-list li,
.video-msg-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}
.sample-list li:last-child,
.video-msg-list li:last-child {
  border-bottom: none;
}

.video-status {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.45rem;
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}
.video-status-completed {
  background: #dcfce7;
  color: #166534;
}
.video-status-pending,
.video-status-generating-audio,
.video-status-generating-video {
  background: #ffedd5;
  color: #9a3412;
}
.video-status-failed,
.video-status-error {
  background: #fee2e2;
  color: #991b1b;
}

.governance-split .gov-sidebar {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px - 64px);
  max-height: calc(100vh - 56px - 64px);
}
.governance-split .gov-sidebar > div:nth-child(2) {
  flex: 1;
  overflow-y: auto;
}

.gov-pkg-row {
  display: block;
  padding: 0.55rem 0.75rem;
  margin: 0 0 2px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
}
.gov-pkg-row:hover {
  background: rgba(37, 99, 235, 0.06);
  text-decoration: none;
}
.gov-pkg-row.active {
  background: rgba(15, 23, 42, 0.06);
}

.gov-main {
  padding: 0;
}
.gov-detail-inner {
  max-width: 560px;
  padding: 1.25rem 1.5rem 2rem;
}
.gov-detail-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.gov-detail-title {
  margin: 0;
  font-size: 1.35rem;
  font-family: var(--font-display);
  font-weight: 700;
}

.perm-row {
  display: grid;
  grid-template-columns: 1fr minmax(140px, 160px) auto;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.perm-row input,
.perm-row select {
  margin-bottom: 0;
  max-width: none;
}

.btn-add-row {
  margin-top: 0.65rem;
  padding: 0.25rem 0;
  border: none;
  background: none;
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-add-row:hover {
  text-decoration: underline;
}

/* Actors / Convo Bot list + sheets */
.actors-page {
  max-width: 1100px;
  margin: 0 auto;
}
.actors-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.actors-header-text {
  min-width: 0;
  flex: 1;
}
.actors-subtitle {
  margin: 0;
  max-width: 42rem;
  font-size: 0.8125rem;
  line-height: 1.4;
}
.actors-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.actors-add-btn {
  min-width: 2.25rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
  font-size: 1.1rem;
  line-height: 1;
}
.actors-refresh-btn {
  text-decoration: none;
}
.actors-refresh-btn:hover {
  text-decoration: none;
}
.actors-sheet-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.actors-sheet-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.actors-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--card);
  margin-top: 0.5rem;
}
.actors-empty-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.actors-table-wrap {
  margin-top: 0.5rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}
table.data.actors-table {
  margin: 0;
  font-size: 0.8125rem;
}
.actors-table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.5rem;
}
.actors-table td {
  vertical-align: middle;
  padding: 0.65rem 0.5rem;
}
.actors-th-name,
.actors-col-name {
  min-width: 120px;
}
.actors-th-chip,
.actors-col-chip {
  width: 1%;
  white-space: nowrap;
  min-width: 148px;
}
.actors-th-actions,
.actors-col-actions {
  width: 112px;
  text-align: right;
}
.actor-cell-form {
  display: inline-block;
  margin: 0;
}
.actor-cell-form select {
  margin-bottom: 0;
}
.actor-chip-select {
  appearance: none;
  -webkit-appearance: none;
  max-width: 220px;
  width: auto;
  min-width: 118px;
  padding: 0.5rem 2rem 0.5rem 0.85rem;
  border: none;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  line-height: 1.25;
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 10px 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='white' stroke-width='1.2' stroke-linecap='round' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
}
.actor-chip-double {
  background-color: #176edd;
}
.actor-chip-avatar {
  background-color: #2670e8;
}
.actor-chip-governance {
  background-color: #3861d6;
}
.actors-col-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.actor-delete-form {
  display: inline-flex;
  margin: 0;
  vertical-align: middle;
}
.actor-trash-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
  cursor: pointer;
  overflow: visible;
  flex-shrink: 0;
}
.actor-trash-btn:hover {
  background: rgba(220, 38, 38, 0.16);
}
.actor-trash-icon {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
  overflow: visible;
}
.actor-menu {
  position: relative;
}
.actor-menu-trigger {
  list-style: none;
  cursor: pointer;
  width: 40px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  user-select: none;
}
.actor-menu-trigger::-webkit-details-marker {
  display: none;
}
.actor-menu-trigger:hover {
  background: var(--surface);
  color: var(--foreground);
}
.actor-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  min-width: 140px;
  padding: 0.35rem 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}
.actor-menu-panel a {
  display: block;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  text-decoration: none;
}
.actor-menu-panel a:hover {
  background: var(--surface);
  text-decoration: none;
}

/* Convo Bot grid (web home → list) */
.convo-bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.75rem;
}
.convo-bot-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
  overflow: hidden;
  min-height: 200px;
}
.convo-bot-card-body {
  padding: 1rem 1rem 0.75rem;
  flex: 1;
}
.convo-bot-card-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.convo-bot-card-meta {
  margin: 0;
  font-size: 0.8125rem;
}
.convo-bot-meta-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0;
  border-top: 1px solid var(--border);
}
.convo-bot-meta-row:first-of-type {
  border-top: none;
  padding-top: 0;
}
.convo-bot-meta-row dt {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.convo-bot-meta-row dd {
  margin: 0;
  color: var(--foreground);
  font-weight: 500;
  line-height: 1.35;
  word-break: break-word;
}
.convo-bot-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.convo-bot-card-actions .btn {
  text-decoration: none;
}
.convo-bot-card-actions .btn:hover {
  text-decoration: none;
}
.convo-bot-card-actions .actor-delete-form {
  margin-left: auto;
}
.convo-bot-share-btn {
  text-decoration: none;
}
.convo-bot-share-btn:hover {
  text-decoration: none;
}
.convo-bot-share-btn--disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--muted);
  border-color: var(--border);
  background: var(--surface);
}

/* Convo Bot wizard (per-bot shell, macOS-style) */
.wizard-page {
  max-width: 720px;
  margin: 0 auto;
}
.wizard-topbar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.wizard-back,
.wizard-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  text-decoration: none;
}
.wizard-back:hover,
.wizard-close:hover {
  background: var(--surface);
  color: var(--foreground);
  text-decoration: none;
}
.wizard-topbar-text {
  flex: 1;
  min-width: 0;
}
.wizard-title {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
  font-family: var(--font-display);
  font-weight: 700;
}
.wizard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.wizard-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.2);
}
.wizard-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.wizard-system-bubble {
  padding: 1rem 1.1rem;
  border-radius: 12px;
  background: #f5f0e8;
  border: 1px solid #e8dfd0;
}
.wizard-bubble-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #3d3429;
}
.wizard-bubble-text a {
  word-break: break-all;
}
.wizard-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.wizard-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #1e3a5f;
  background: #dbeafe;
  border: 1px solid rgba(37, 99, 235, 0.22);
  text-decoration: none;
}
.wizard-pill:hover {
  background: #cfe2fd;
  text-decoration: none;
}
.wizard-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
}
.wizard-chat-frame {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
  min-height: 420px;
  flex: 1;
}
.wizard-chat-iframe {
  display: block;
  width: 100%;
  height: min(70vh, 560px);
  border: 0;
  background: #fff;
}
.wizard-iframe-foot {
  margin: 0;
  font-size: 0.75rem;
}
