@import url("confirmation-dialog.css?v=1");
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --primary: #5b5ceb;
  --primary-hover: #4c4ddc;
  --secondary: #eef2ff;
  --bg: #f7f8fc;
  --surface: #ffffff;
  --border: #e7eaf3;
  --text: #1e293b;
  --text-secondary: #64748b;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --sidebar-w: 280px;
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 2px 4px rgba(15, 23, 42, 0.05), 0 12px 28px rgba(15, 23, 42, 0.06);
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: 150ms ease-in-out;
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --secondary: #1e1b4b;
  --bg: #0f1117;
  --surface: #171a22;
  --border: #2a2f3a;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.25);
}

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

html {
  overflow-x: clip;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--primary);
}

.is-hidden,
.d-none {
  display: none !important;
}

/* —— Shell —— */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  z-index: 40;
  transition: transform var(--ease);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sidebar-cta {
  margin: 0 8px 16px;
  width: calc(100% - 16px);
  justify-content: center;
  text-decoration: none;
}

.sidebar-brand {
  padding: 0 8px 16px;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px;
  margin: 0;
  border: none;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  min-width: 0;
  cursor: pointer;
  transition: background-color var(--ease), color var(--ease);
}

.sidebar-brand-link:hover {
  background: var(--surface-muted, rgba(99, 102, 241, 0.08));
}

.sidebar-brand-link:hover .brand-text strong {
  color: var(--primary);
}

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

.sidebar-nav-section-label {
  margin: 12px 0 4px;
  padding: 0 14px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--secondary);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 700;
}

.brand-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar .nav-item,
.sidebar a.nav-item-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--ease), color var(--ease);
  text-decoration: none;
  font: inherit;
  font-size: 14px;
  line-height: 1.35;
}

.sidebar .nav-item svg,
.sidebar a.nav-item-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 2px;
}

.sidebar .nav-item:hover,
.sidebar .nav-item.is-active,
.sidebar a.nav-item-link:hover,
.sidebar a.nav-item-link.is-active {
  background: var(--secondary);
  color: var(--primary);
}

.sidebar .nav-item.is-active,
.sidebar a.nav-item-link.is-active {
  font-weight: 600;
}

/* —— Navegação da gravação (sidebar) —— */
.meeting-nav-block {
  margin-top: auto;
  flex-shrink: 0;
  padding: 14px 4px 8px;
  border-top: 1px solid var(--border);
  max-height: min(360px, 42vh);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.meeting-nav-label {
  margin: 0 10px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.meeting-job-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 4px 4px;
}

.meeting-job-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--ease), color var(--ease);
  min-width: 0;
}

.meeting-job-nav-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-job-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.meeting-job-nav-item:hover {
  background: var(--secondary);
  color: var(--text);
}

.meeting-job-nav-item.is-active {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 16px;
}

.plan-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.plan-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.plan-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  background: var(--secondary);
  padding: 4px 8px;
  border-radius: 999px;
}

.plan-usage {
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-hint {
  margin: 8px 0 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.plan-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.plan-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.plan-cta {
  width: 100%;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: background var(--ease);
}

.user-chip:hover {
  background: var(--secondary);
}

.user-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  overflow: hidden;
  flex-shrink: 0;
}

.user-avatar-lg {
  width: 72px;
  height: 72px;
  font-size: 22px;
}

.user-avatar.has-photo {
  background: var(--border);
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-profile-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-top: 4px;
  padding-bottom: 20px;
}

.user-profile-section {
  padding: 20px 0;
}

.user-profile-section:first-child {
  padding-top: 0;
}

.user-profile-section--avatar {
  padding-bottom: 16px;
}

.user-profile-section--password {
  margin: 0 -24px;
  padding: 20px 24px;
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
  border-top: 1px solid var(--border);
}

.user-profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.user-profile-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  flex: 1;
  min-width: 160px;
}

.user-profile-form .field {
  margin-bottom: 16px;
}

.user-profile-form .field:last-of-type {
  margin-bottom: 20px;
}

.user-profile-form .field-hint {
  margin: 6px 0 0;
  line-height: 1.45;
}

.user-profile-section-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.user-profile-password-hint {
  margin: 0 0 16px;
  line-height: 1.45;
}

.user-profile-save-btn,
.user-profile-password-btn {
  width: 100%;
  justify-content: center;
}

.user-profile-feedback {
  margin: 0;
  min-height: 1.25em;
  flex: 1;
  line-height: 1.45;
}

.user-profile-modal-footer {
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 16px 24px 20px;
}

.user-profile-logout {
  margin-left: auto;
  flex-shrink: 0;
}

.modal-dialog-profile {
  width: min(100%, 520px);
}

#user-profile-modal .modal-content.user-profile-modal-content {
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
}

#user-profile-modal .modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-dialog-narrow {
  max-width: 440px;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-meta strong {
  font-size: 13px;
}

.user-meta span {
  font-size: 12px;
  color: var(--text-secondary);
}

.sidebar-backdrop {
  display: none;
}

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
}

.topbar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 32px 40px 8px;
  flex-wrap: wrap;
  max-width: 100%;
}

.topbar-copy {
  flex: 1;
  min-width: 0;
}

.topbar-copy h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.topbar-copy p {
  margin: 8px 0 0;
  font-size: 16px;
  color: var(--text-secondary);
}

.app-breadcrumbs {
  margin: 0 0 6px;
}

.app-breadcrumbs__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.35;
}

.app-breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  color: var(--text-secondary);
}

.app-breadcrumbs__item:not(:last-child)::after {
  content: "/";
  margin: 0 8px;
  color: var(--muted);
  font-weight: 400;
  pointer-events: none;
}

.app-breadcrumbs__link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-breadcrumbs__link:hover {
  text-decoration: underline;
}

.app-breadcrumbs__current {
  color: var(--text);
  font-weight: 600;
  max-width: min(280px, 40vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-title-block .app-breadcrumbs {
  margin-bottom: 4px;
}

.topbar-copy .app-breadcrumbs + h1 {
  margin-top: 2px;
}

.topbar-copy--center .app-breadcrumbs__list {
  justify-content: center;
}

.chat-topbar .app-breadcrumbs {
  margin-bottom: 4px;
}

.kg-app-topbar .app-breadcrumbs {
  flex: 1;
  min-width: 0;
  margin: 0 8px 0 0;
}

.timeline-page-topbar .app-breadcrumbs,
.mindmap-page-topbar .app-breadcrumbs {
  flex: 1;
  min-width: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
}

.hero-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--secondary), #f5f3ff);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.hero-badge-btn {
  cursor: pointer;
  font: inherit;
  transition: background var(--ease), box-shadow var(--ease), transform var(--ease);
}

.hero-badge-btn:hover {
  background: linear-gradient(135deg, #e0e7ff, #ede9fe);
  box-shadow: var(--shadow);
}

.hero-badge-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[data-theme="dark"] .hero-badge {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #e0e7ff;
  border-color: rgba(129, 140, 248, 0.45);
}

[data-theme="dark"] .hero-badge svg {
  color: currentColor;
}

[data-theme="dark"] .hero-badge-btn:hover {
  background: linear-gradient(135deg, #312e81 0%, #4338ca 100%);
  color: #f5f3ff;
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.25);
}

.topbar-dropdown-wrap {
  position: relative;
}

.topbar-notifications-btn {
  position: relative;
}

.topbar-notifications-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.topbar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-hover);
  z-index: 120;
  overflow: hidden;
}

.topbar-dropdown-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.topbar-dropdown-head strong {
  font-size: 14px;
}

.topbar-dropdown-body {
  max-height: min(360px, 50vh);
  overflow-y: auto;
}

.topbar-dropdown-empty {
  margin: 0;
  padding: 20px 14px;
  text-align: center;
}

.topbar-notification-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background var(--ease);
}

.topbar-notification-item:last-child {
  border-bottom: none;
}

.topbar-notification-item:hover {
  background: var(--bg);
}

.topbar-notification-item.is-unread {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.topbar-notification-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.topbar-notification-icon--completed {
  background: color-mix(in srgb, var(--success) 14%, transparent);
  color: var(--success);
}

.topbar-notification-icon--failed {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.topbar-notification-icon svg {
  width: 16px;
  height: 16px;
}

.topbar-notification-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-notification-copy strong {
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-notification-time {
  flex-shrink: 0;
  font-size: 11px;
}

.notifications-backdrop {
  display: none;
}

@media (max-width: 768px) {
  .notifications-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(15, 23, 42, 0.4);
    -webkit-tap-highlight-color: transparent;
  }

  body.notifications-panel-open {
    overflow: hidden;
  }

  .topbar-notifications-panel:not(.is-hidden) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    max-width: none;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: none;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
    z-index: 160;
    max-height: min(75vh, 520px);
    animation: notifications-sheet-in 0.22s ease-out;
  }

  @keyframes notifications-sheet-in {
    from {
      transform: translateY(100%);
      opacity: 0.6;
    }

    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-dropdown-body {
    max-height: min(55vh, 420px);
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-dropdown-head {
    padding: 14px 16px;
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-dropdown-head strong {
    font-size: 15px;
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-notification-item {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 8px 10px;
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-notification-copy strong {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .topbar-notifications-panel:not(.is-hidden) .topbar-notification-time {
    flex-basis: 100%;
    padding-left: 42px;
    margin-top: -2px;
    color: var(--text-secondary);
  }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .topbar-notifications-panel:not(.is-hidden) {
    animation: none;
  }
}

.topbar-ia-links {
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.topbar-ia-link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: background var(--ease);
}

.topbar-ia-link:hover {
  background: var(--bg);
}

.topbar-ia-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--primary);
}

.topbar-ia-link span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.topbar-ia-link strong {
  font-size: 13px;
}

.topbar-ia-link small {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.hero-badge svg {
  width: 16px;
  height: 16px;
}

.sidebar-toggle {
  display: grid;
  flex-shrink: 0;
}

@media (min-width: 901px) {
  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  body.sidebar-collapsed .main-area {
    margin-left: 0;
  }
}

.content {
  padding: 24px 40px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}

#section-history {
  width: 100%;
}

#section-history .table-wrap {
  width: 100%;
}

/* —— Cards —— */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--ease), transform var(--ease);
  min-width: 0;
  max-width: 100%;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.card-head.tight {
  margin-bottom: 12px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.section-label {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
  background: transparent;
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: #d5dae8;
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg);
  color: var(--text);
}

.btn-ghost.is-danger {
  color: var(--danger);
}

.btn-ghost.is-danger:hover:not(:disabled) {
  background: #fef2f2;
  color: #b91c1c;
}

.btn-danger {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 14px 22px;
  min-width: 220px;
  font-size: 15px;
  font-weight: 600;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--ease), color var(--ease);
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* —— Forms —— */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.form-grid .field-full {
  grid-column: 1 / -1;
}

/* Campos de texto / select (design system) */
.input-field,
select.input-field,
textarea.input-field {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.35;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

select.input-field {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
  text-overflow: ellipsis;
}

.input-field::placeholder {
  color: var(--text-secondary);
  opacity: 0.85;
}

.input-field:hover:not(:disabled):not(:focus) {
  border-color: #d5dae8;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 92, 235, 0.14);
}

.input-field:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg);
}

.input-field-sm {
  padding: 7px 10px;
  font-size: 13px;
  min-width: 0;
  max-width: 100%;
  border-radius: 10px;
}

select.input-field-sm {
  padding-right: 30px;
  background-position: right 8px center;
}

.input-field-sm:focus {
  box-shadow: 0 0 0 2px rgba(91, 92, 235, 0.12);
}

#history-table .job-work-category-select,
#history-table .job-project-input,
#history-table .job-meeting-title-input {
  background: var(--bg);
}

#history-table .job-work-category-select:hover,
#history-table .job-project-input:hover,
#history-table .job-meeting-title-input:hover {
  background: var(--surface);
}

/* —— Trabalhos (modal + lista) —— */
.modal-dialog-work {
  width: min(100%, 480px);
}

.modal-work .modal-header {
  align-items: flex-start;
}

.modal-work .modal-body {
  padding: 4px 24px 20px;
}

.modal-work .modal-footer {
  padding: 16px 24px;
  background: var(--bg);
}

.work-categories-empty {
  margin: 0 0 16px;
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  list-style: none;
}

.work-categories-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(40vh, 320px);
  overflow-y: auto;
}

.work-categories-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.work-categories-list-item:hover {
  border-color: #d5dae8;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.work-category-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border);
}

.work-category-name {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-categories-add {
  display: flex;
  gap: 10px;
  align-items: stretch;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.work-categories-add .input-field {
  flex: 1 1 160px;
  min-width: 0;
  margin: 0;
}

.work-categories-add .btn {
  flex-shrink: 0;
  align-self: stretch;
}

.icon-btn-sm {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
}

.icon-btn-danger {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}

.icon-btn-danger:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.work-category-delete {
  margin-left: auto;
}

.col-work-category,
.col-project-name {
  min-width: 0;
}

.job-project-input {
  width: 100%;
  max-width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.field input[type="text"],
.field input[type="date"],
.chat-composer textarea {
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  background: var(--surface);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.field input:focus,
.chat-composer textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 92, 235, 0.15);
}

.dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--secondary);
}

.dropzone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--primary);
}

.dropzone-icon svg {
  width: 26px;
  height: 26px;
}

.dropzone-title {
  margin: 0;
  font-weight: 600;
  font-size: 15px;
}

.dropzone-hint,
.dropzone-file {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.dropzone-file {
  color: var(--primary);
  font-weight: 500;
}

/* —— Table —— */
.table-wrap {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.table-wrap--fit {
  overflow-x: hidden;
  overflow-y: visible;
  container-type: inline-size;
  container-name: history-table-wrap;
}

.table-wrap--fit:focus-within {
  outline: none;
}

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

.history-table {
  table-layout: fixed;
  min-width: 0;
}

.history-col-file {
  width: 30%;
}

.history-col-work {
  width: 14%;
}

.history-col-project {
  width: 14%;
}

.history-col-status {
  width: 10%;
}

.history-col-date {
  width: 12%;
}

.history-col-actions {
  width: 20%;
}

@container history-table-wrap (max-width: 720px) {
  .table-wrap--fit {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

#history-table th,
#history-table td {
  padding: 10px 8px;
  overflow: hidden;
}

#history-table .col-date {
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

#history-table .input-field-sm,
#history-table .job-project-input,
#history-table .job-meeting-title-input {
  min-width: 0;
  max-width: none;
  width: 100%;
}

#history-table .badge {
  font-size: 11px;
  padding: 3px 7px;
}

/* Histórico: colunas e densidade conforme largura do card (não só viewport) */
@container history-table-wrap (max-width: 980px) {
  .history-col-project,
  .history-th-project,
  .history-cell-project {
    display: none;
  }

  .history-col-file {
    width: 34%;
  }

  .history-col-work {
    width: 16%;
  }

  .history-col-actions {
    width: 22%;
  }
}

@container history-table-wrap (max-width: 820px) {
  .history-col-work,
  .history-th-work,
  .history-cell-work {
    display: none;
  }

  .history-col-file {
    width: 36%;
  }

  .history-col-status {
    width: 14%;
  }

  .history-col-date {
    width: 16%;
  }

  .history-col-actions {
    width: 24%;
  }
}

@container history-table-wrap (max-width: 640px) {
  .history-table {
    min-width: 0;
    table-layout: auto;
  }

  .history-table colgroup {
    display: none;
  }

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

  .history-table tbody tr {
    display: block;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
  }

  .history-table tbody tr:hover {
    background: var(--surface);
    box-shadow: var(--shadow-hover);
  }

  .history-table tbody td {
    display: grid !important;
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 6px 12px;
    align-items: center;
    padding: 10px 14px;
    overflow: visible;
    border-bottom: 1px solid var(--border);
  }

  .history-table tbody td:last-child {
    border-bottom: none;
  }

  .history-table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
  }

  .history-table tbody td.history-cell-file {
    display: block !important;
    padding: 14px 14px 10px;
    border-bottom: 1px solid var(--border);
  }

  .history-table tbody td.history-cell-file::before {
    display: none;
  }

  .history-table tbody td.history-cell-actions {
    text-align: left;
  }

  .history-table tbody td.history-cell-actions::before {
    align-self: start;
    padding-top: 6px;
  }

  #history-table .history-row-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  #history-table .col-date {
    white-space: normal;
  }

  .history-mobile-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    margin-left: auto;
    align-self: flex-start;
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 10px;
    background: #fef2f2;
    color: var(--danger);
    cursor: pointer;
  }

  .history-mobile-delete-btn svg {
    width: 18px;
    height: 18px;
  }

  .history-mobile-delete-bar {
    display: block;
    width: 100%;
  }

  .history-mobile-delete-full {
    width: 100%;
    justify-content: center;
    gap: 8px;
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.35);
    background: #fef2f2;
  }

  #history-table .history-cell-actions,
  #history-table td.col-actions {
    overflow: visible;
  }

  #history-table .history-row-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  #history-table .history-action-group {
    width: 100%;
    justify-content: space-between;
  }

  #history-table .history-action-icon.history-action-delete {
    display: none;
  }
}

@container history-table-wrap (max-width: 420px) {
  #history-table th,
  #history-table td {
    padding: 8px 10px;
  }

  .history-table tbody td {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  #history-table .file-icon {
    width: 28px;
    height: 28px;
  }
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 14px;
}

.data-table tbody tr {
  transition: background var(--ease);
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.data-table tbody tr.is-active {
  background: var(--secondary);
}

.data-table tbody tr.history-row-openable {
  cursor: pointer;
}

.data-table tbody tr.history-row-openable:focus-visible {
  outline: 2px solid rgba(91, 92, 235, 0.45);
  outline-offset: -2px;
}

.file-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--secondary);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.file-icon svg {
  width: 18px;
  height: 18px;
}

.file-cell-text {
  min-width: 0;
  flex: 1;
}

.file-cell-text .job-meeting-title-input {
  font-weight: 500;
  margin-bottom: 2px;
}

.file-cell .sub {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.col-actions {
  text-align: right;
  vertical-align: middle;
  width: 1%;
  white-space: nowrap;
  min-width: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.history-row-actions {
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  max-width: 100%;
}

.history-action-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 1;
  min-width: 0;
}

.history-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.history-action-icon svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.history-action-icon:hover {
  background: var(--surface);
  color: var(--text);
}

.history-action-icon.is-mindmap:hover {
  color: var(--primary);
}

.history-action-icon.is-workspace:hover {
  color: #0284c7;
}

.history-action-icon.is-danger {
  color: var(--danger);
}

.history-action-icon.is-danger:hover {
  background: #fef2f2;
  color: #b91c1c;
}

.history-action-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

.history-action-delete {
  padding: 0;
}

#history-table .history-action-icon {
  position: relative;
  width: 32px;
  height: 32px;
  padding: 0;
  flex-shrink: 0;
}

.history-floating-tooltip {
  position: fixed;
  z-index: 10000;
  padding: 6px 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  max-width: min(280px, 92vw);
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 4px));
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s;
}

.history-floating-tooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

.history-floating-tooltip.is-below {
  transform: translate(-50%, 4px);
}

#history-table .history-action-icon.history-action-delete {
  padding: 0;
}

#history-table .history-action-group {
  padding: 2px;
  gap: 0;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
}

#history-table .history-action-divider {
  display: none;
}

#history-table .history-cell-actions,
#history-table td.col-actions {
  overflow: hidden;
  min-width: 0;
}

#history-table th.col-actions {
  width: auto;
  white-space: nowrap;
}

#history-table .history-row-actions {
  flex-wrap: wrap;
  gap: 4px 6px;
  justify-content: flex-end;
  max-width: 100%;
}

#history-table .file-icon {
  width: 32px;
  height: 32px;
}

#history-table .file-cell {
  gap: 8px;
}

.history-mobile-delete-btn,
.history-mobile-delete-bar {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .history-floating-tooltip {
    transition: none;
  }
}

@media (max-width: 1440px) {
  .input-field-sm {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 1440px) and (min-width: 901px) {
  .topbar {
    flex-wrap: wrap;
    padding-left: 24px;
    padding-right: 24px;
  }

  .topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .content {
    padding-left: 24px;
    padding-right: 24px;
  }

  .card {
    padding: 20px;
  }
}

/* Painel de resultado (home) — atalhos com mesma linguagem visual */
.btn-action-mindmap {
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--primary);
}

.btn-action-mindmap:hover {
  background: rgba(99, 102, 241, 0.08);
  border-color: var(--primary);
}

.btn-action-workspace {
  border-color: rgba(14, 165, 233, 0.35);
  color: #0284c7;
}

.btn-action-workspace:hover {
  background: rgba(14, 165, 233, 0.08);
  border-color: #0284c7;
}

/* —— Badges —— */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-info {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-muted {
  background: var(--bg);
  color: var(--text-secondary);
}

.badge-muted::before {
  display: none;
}

[data-theme="dark"] .badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

[data-theme="dark"] .badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

[data-theme="dark"] .badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* —— Progress —— */
.progress {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.muted {
  color: var(--text-secondary);
}

.small {
  font-size: 13px;
}

.text-success {
  color: var(--success) !important;
}

/* —— Alerts —— */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

/* —— Result layout —— */
.result-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-utilities {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-utilities:has(.alert:not(.is-hidden)),
.result-utilities:has(#retry-chunks-btn:not(.is-hidden)) {
  margin-bottom: 16px;
}

.result-utilities #retry-chunks-btn:not(.is-hidden) {
  align-self: flex-start;
}

.download-tab-card {
  padding-bottom: 8px;
}

.export-group,
.toolbar-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.download-format-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.download-format-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
  white-space: nowrap;
}

.download-format-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text);
}

.download-format-btn:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: var(--bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.download-format-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.download-format-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.download-tab-hint {
  margin: 16px 0 0;
  line-height: 1.5;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.result-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.meta-list {
  margin: 0;
  display: grid;
  gap: 12px;
}

.meta-list > div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px;
  font-size: 14px;
}

.meta-list dt {
  color: var(--text-secondary);
  font-weight: 500;
}

.meta-list dd {
  margin: 0;
}

.prose-block {
  white-space: normal;
  word-break: break-word;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  max-height: 360px;
  overflow-y: auto;
  padding: 4px 2px;
}

.markdown-body ul,
.markdown-body .md-list {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.35rem;
  list-style-type: disc;
}

.markdown-body li {
  margin-bottom: 0.55rem;
  line-height: 1.55;
}

.markdown-body li::marker {
  color: var(--primary);
}

.markdown-body strong {
  font-weight: 600;
  color: var(--text);
}

.markdown-body p {
  margin: 0 0 0.65rem;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}

.future-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.future-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px dashed var(--border);
  color: var(--text-secondary);
}

.future-chip span {
  opacity: 0.7;
  margin-left: 4px;
}

.transcript-block {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  max-height: 280px;
  overflow-y: auto;
}

.transcript-block.is-expanded {
  max-height: 640px;
}

/* —— KPIs —— */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.kpi strong {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* —— Chat panel —— */
.chat-panel-card {
  display: flex;
  flex-direction: column;
  min-height: 480px;
  max-height: 720px;
}

.chat-job-label {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-toolbar {
  display: flex;
  gap: 4px;
  align-items: center;
}

.chat-window-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-welcome.is-hidden {
  display: none;
}

.chat-empty-state {
  padding: 0 16px 16px;
}

.chat-empty-state.is-hidden {
  display: none;
}

.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-suggestion {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--primary);
  text-align: left;
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease);
}

.chat-suggestion:hover {
  background: var(--secondary);
  border-color: #c7c9f5;
}

.chat-row {
  display: flex;
  gap: 10px;
  max-width: 95%;
  border-radius: 8px;
  transition: background 0.3s ease;
}

.chat-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-row.assistant {
  align-self: flex-start;
}

.chat-row-highlight {
  background: rgba(91, 92, 235, 0.1);
}

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.chat-row.user .chat-msg-avatar {
  display: none;
}

.chat-msg-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-row.assistant .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.chat-row.user .chat-bubble {
  background: var(--primary);
  color: #fff;
  border-top-right-radius: 4px;
}

.chat-bubble.is-error {
  background: #fef2f2 !important;
  border-color: #fecaca !important;
  color: #991b1b !important;
}

.chat-bubble--md p {
  margin: 0 0 0.4rem;
}

.chat-bubble--md p:last-child {
  margin-bottom: 0;
}

.chat-bubble--md ul {
  margin: 0.2rem 0 0.4rem;
  padding-left: 1.1rem;
}

.chat-bubble--md li {
  margin-bottom: 0.3rem;
}

.chat-bubble--md strong {
  font-weight: 600;
}

.chat-bubble-footer {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-typing .chat-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  min-width: 52px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: typing 1.2s infinite ease-in-out;
}

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

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

@keyframes typing {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.chat-composer textarea {
  flex: 1;
  height: auto;
  min-height: 48px;
  max-height: 120px;
  resize: none;
  padding: 12px 14px;
  line-height: 1.4;
}

.chat-memory-panel {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow: hidden;
}

.chat-memory-panel.is-open {
  display: flex;
}

.chat-memory-panel-head {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.chat-memory-count {
  color: var(--text-secondary);
  font-size: 12px;
}

.chat-memory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.chat-memory-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  color: var(--text);
}

.chat-memory-item:hover {
  color: var(--primary);
}

.chat-memory-item time {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
}

.chat-memory-empty {
  margin: 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.chat-memory-empty.is-hidden {
  display: none;
}

/* —— Skeleton / empty —— */
.skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.skeleton-row {
  height: 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--border), var(--bg), var(--border));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

.skeleton-row.short {
  width: 60%;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.empty-state {
  margin: 0;
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.settings-row p {
  margin: 4px 0 0;
}

.settings-row-stack {
  flex-direction: column;
  align-items: stretch;
}

.settings-row-main {
  width: 100%;
  min-width: 0;
}

.settings-api-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
}

.settings-api-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-api-hint {
  margin: 8px 0 0;
  line-height: 1.45;
}

.settings-password-form {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
}

.settings-password-form .field {
  margin: 0;
}

.settings-password-feedback {
  margin: 0;
  min-height: 1.25em;
}

.settings-pwa-desc {
  margin: 8px 0 10px;
  line-height: 1.45;
}

.settings-pwa-feedback {
  margin: 0 0 10px;
  min-height: 1.25em;
}

.settings-api-form.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

/* —— Modal —— */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
}

.modal-dialog {
  position: relative;
  width: min(100%, 440px);
  z-index: 1;
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 0 24px 8px;
}

.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

.modal-dialog-wide {
  width: min(100%, 640px);
}

.modal-header-sub {
  margin: 4px 0 0;
}

.modal-tabs {
  margin: 0 24px 0;
  padding-top: 4px;
}

.modal-body-tabs {
  padding-top: 16px;
  padding-bottom: 20px;
}

.modal-body-tabs .result-tab-panel {
  min-height: 200px;
}

.modal-footer-split {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.modal-footer-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-left: auto;
}

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

.result-tab-panel-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.result-tab-panel.is-panel-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 500;
  margin: 0;
  padding: 16px 20px 28px;
  background: var(--bg);
  overflow: auto;
}

.result-tab-panel.is-panel-fullscreen > .card,
.result-tab-panel.is-panel-fullscreen > .result-tab-panel-toolbar + .card {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.result-tab-panel.is-panel-fullscreen .panel-fullscreen-bar {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.panel-fullscreen-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

body.has-panel-fullscreen {
  overflow: hidden;
}

.empty-state .empty-cta {
  display: inline-flex;
  margin-top: 12px;
}

.topbar-new-meeting {
  display: none;
}

@media (min-width: 768px) {
  .topbar-new-meeting {
    display: inline-flex;
  }
}

.result-tabs .result-tab i,
.result-tabs .result-tab svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}

.radio-row:last-child {
  border-bottom: none;
}

/* —— Responsive —— */
@media (max-width: 1100px) {
  .result-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  #section-history .card-head-actions {
    width: 100%;
  }

  #section-history .card-head-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 35;
  }

  .main-area {
    margin-left: 0;
  }

  body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
  }

  .sidebar-toggle {
    display: grid;
  }

  .topbar,
  .content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .topbar-copy h1 {
    font-size: 24px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .btn-lg {
    width: 100%;
  }

  .hero-badge span {
    display: none;
  }
}

@media (max-width: 560px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .meta-list > div {
    grid-template-columns: 1fr;
  }
}

/* Result tabs + mind map */
.result-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.result-tab {
  flex: 1;
  min-width: 100px;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.result-tab i,
.result-tab svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.result-tab:hover {
  background: var(--secondary);
  color: var(--primary);
}

.result-tab.is-active {
  background: var(--primary);
  color: #fff;
}

a.result-tab.result-tab-link {
  text-decoration: none;
  align-items: center;
}

.result-tab-panel.is-hidden {
  display: none;
}

.result-tab-text--short {
  display: none;
}

.result-mobile-bar {
  display: block;
}

.result-mobile-header {
  display: none;
}

/* Desktop: só abas completas */
@media (min-width: 901px) {
  .result-tabs-shell {
    display: block;
  }

  .job-mobile-nav {
    display: none !important;
  }
}

/* Mobile: só nav compacta + Mais */
@media (max-width: 900px) {
  .result-tabs-shell {
    display: none !important;
  }

  .job-mobile-nav {
    display: flex;
  }
}

@media (max-width: 900px) {
  body.job-result-open #section-history .card-head,
  body.job-result-open #section-history .card-subtitle,
  body.job-result-open #section-history .table-wrap,
  body.job-result-open #section-history #history-empty,
  body.job-result-open #section-history #history-skeleton {
    display: none;
  }

  body.job-result-open #section-history {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    box-shadow: none;
  }

  /* Com gravação aberta, o hero do topbar some — o cabeçalho fica no painel da gravação */
  body.job-result-open .topbar {
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 0;
    align-items: center;
    gap: 8px;
  }

  body.job-result-open .topbar-copy {
    display: none;
  }

  body.job-result-open .topbar-actions {
    margin-left: auto;
    flex-wrap: nowrap;
  }

  body.job-result-open .content {
    padding-top: 8px;
  }

  #result-panel:not(.is-hidden) .result-mobile-bar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 45;
    margin: 0 -20px 12px;
    padding: 0 20px 8px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }

  .result-mobile-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 6px 0 10px;
  }

  .result-mobile-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    align-self: flex-start;
    padding: 6px 10px 6px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  .result-mobile-back svg {
    width: 16px;
    height: 16px;
  }

  .result-mobile-title {
    flex: none;
    width: 100%;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
  }

  /* Mobile: nav compacta substitui abas desktop (regra duplicada removida abaixo) */

  .job-mobile-nav {
    flex-wrap: nowrap;
    gap: 4px;
    padding: 2px 0 0;
  }

  .job-mobile-nav-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    padding: 7px 4px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .job-mobile-nav-item svg,
  .job-mobile-nav-item i {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .job-mobile-nav-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .job-mobile-nav-item.is-active {
    background: var(--secondary);
    color: var(--primary);
  }

  .job-mobile-nav-more {
    position: relative;
  }

  .job-mobile-nav-more.is-active::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 18px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
  }

  .result-main {
    gap: 16px;
  }

  .result-tab-panel .card {
    padding: 16px;
  }

  .result-tab-panel .card-head.tight {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .result-tab-panel .card-head-actions,
  .result-tab-panel .timeline-toolbar-inline,
  .result-tab-panel .mindmap-toolbar-inline {
    width: 100%;
    flex-wrap: wrap;
  }

  .prose-block {
    max-height: none;
  }

  .transcript-block {
    max-height: none;
    padding: 14px;
    font-size: 12px;
  }

  .transcript-block.is-expanded {
    max-height: none;
  }

  .chat-panel-card--tab {
    min-height: min(70vh, 560px);
    max-height: none;
  }

  .chat-panel-card--tab .chat-window-body {
    min-height: min(52vh, 420px);
    max-height: none;
  }

  .chat-job-label {
    max-width: none;
    white-space: normal;
  }

  .download-format-grid {
    grid-template-columns: 1fr 1fr;
  }

  .meta-list > div {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .mindmap-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .mindmap-toolbar-actions .btn-primary,
  .mindmap-toolbar-actions [id$="mindmap-ai-workspace-btn"],
  .mindmap-toolbar-actions [id$="mindmap-send-workspace-btn"] {
    grid-column: 1 / -1;
  }

  .mindmap-toolbar-actions .btn {
    justify-content: center;
    font-size: 12px;
    padding: 8px 10px;
  }

  .mindmap-toolbar-hint {
    font-size: 11px;
  }

  .mindmap-viewport {
    height: min(50vh, 440px);
    min-height: 220px;
  }
}

.mindmap-card {
  overflow: hidden;
}

.mindmap-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.mindmap-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mindmap-toolbar-hint {
  margin: 0;
  width: 100%;
  line-height: 1.4;
  font-size: 12px;
}

.mindmap-select-mode .mindmap-toolbar-hint::after {
  content: " Modo seleção: clique nos nós para marcar.";
  font-weight: 600;
  color: var(--primary);
}

.mindmap-select-mode-btn.is-active {
  background: rgba(91, 92, 235, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}

.mindmap-status {
  min-height: 1.25rem;
  margin-bottom: 8px;
  font-size: 13px;
}

.mindmap-status--error {
  color: var(--danger);
}

.mindmap-viewport {
  position: relative;
  height: min(520px, 60vh);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bg) 0%, var(--secondary) 100%);
  cursor: grab;
  touch-action: none;
}

.mindmap-zoom-controls {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mindmap-zoom-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.mindmap-zoom-btn svg {
  width: 16px;
  height: 16px;
}

.mindmap-zoom-btn:active {
  background: var(--secondary);
}

.mindmap-viewport.is-dragging {
  cursor: grabbing;
}

.mindmap-viewport.is-generating {
  cursor: wait;
}

.mindmap-viewport.is-generating .mindmap-canvas {
  opacity: 0.35;
  filter: blur(1px);
  pointer-events: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.mindmap-generating-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(248, 249, 255, 0.72);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.mindmap-viewport.is-generating .mindmap-generating-overlay {
  opacity: 1;
  visibility: visible;
}

.mindmap-generating-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 320px;
  text-align: center;
}

.mindmap-generating-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(91, 92, 235, 0.18);
  border-top-color: var(--primary);
  animation: mindmap-spin 0.85s linear infinite;
}

.mindmap-generating-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.mindmap-generating-sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.mindmap-generating-dots::after {
  content: "";
  animation: mindmap-dots 1.4s steps(4, end) infinite;
}

.mindmap-btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(91, 92, 235, 0.25);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: mindmap-spin 0.75s linear infinite;
  vertical-align: -2px;
  margin-right: 2px;
}

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

@keyframes mindmap-dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.mindmap-canvas {
  transform-origin: 0 0;
  padding: 32px 48px;
  min-width: max-content;
}

.mindmap-tree {
  display: flex;
  justify-content: center;
}

.mindmap-root-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.mindmap-branches {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 32px;
  justify-content: center;
  max-width: 900px;
}

.mindmap-branch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.mindmap-children {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.mindmap-branch.is-collapsed .mindmap-children {
  display: none;
}

.mindmap-root-wrap.is-collapsed .mindmap-root-children {
  display: none;
}

.mindmap-node-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.mindmap-node-row .mindmap-node-pill {
  flex: 1;
  min-width: 0;
}

.mindmap-node-remove {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.mindmap-node-row:hover .mindmap-node-remove,
.mindmap-node-remove:focus-visible {
  opacity: 1;
}

.mindmap-node-remove:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.mindmap-node-remove svg {
  width: 16px;
  height: 16px;
}

.mindmap-node--level-0 .mindmap-node-remove {
  display: none;
}

.mindmap-node-toggle {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mindmap-node-toggle svg {
  width: 14px;
  height: 14px;
}

.mindmap-branch.is-collapsed .mindmap-node-toggle svg {
  transform: rotate(-90deg);
}

.mindmap-node-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  max-width: 220px;
  line-height: 1.3;
}

.mindmap-node-pill--open:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.mindmap-node--level-0 .mindmap-node-pill {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-size: 15px;
  max-width: 280px;
}

.mindmap-node-pill--branch {
  cursor: pointer;
}

.mindmap-node-pill--branch:hover {
  border-color: var(--primary);
}

.mindmap-node-pill.is-selected {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.chat-panel-card--tab .chat-window-body {
  min-height: 320px;
  max-height: 420px;
}

/* —— Mobile bottom navigation —— */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    align-items: flex-end;
    justify-content: space-around;
    gap: 2px;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
  }

  body:has(.mobile-bottom-nav) .content,
  body:has(.mobile-bottom-nav) .workspace-layout,
  body:has(.mobile-bottom-nav) .mindmap-page-workspace,
  body:has(.mobile-bottom-nav) .timeline-page-workspace,
  body:has(.mobile-bottom-nav) .kg-main-area,
  body:has(.mobile-bottom-nav) .chat-shell .main-area.chat-main,
  body:has(.mobile-bottom-nav) .knowledge-shell .main-area.knowledge-main-area {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }

  body:has(.mobile-bottom-nav) .knowledge-shell .main-area.knowledge-main-area,
  body:has(.mobile-bottom-nav) .chat-shell .main-area.chat-main {
    height: calc(100dvh - 56px - env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  body:has(.mobile-bottom-nav) .pwa-toast-root {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body:has(.mobile-bottom-nav) .pwa-install-banner {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }

  body.has-panel-fullscreen .mobile-bottom-nav,
  body.notifications-panel-open .mobile-bottom-nav,
  body.bottom-sheet-open .mobile-bottom-nav {
    display: none;
  }
}

.mobile-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  min-height: 48px;
  padding: 4px 4px 2px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s ease;
}

.mobile-bottom-nav__item svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.mobile-bottom-nav__item.is-active {
  color: var(--primary);
}

.mobile-bottom-nav__item--primary {
  flex: 0 0 auto;
  min-width: 64px;
  margin-top: -14px;
  color: var(--primary);
}

.mobile-bottom-nav__fab {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px rgba(91, 92, 235, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-bottom-nav__item--primary.is-active .mobile-bottom-nav__fab,
.mobile-bottom-nav__item--primary:active .mobile-bottom-nav__fab {
  transform: scale(0.96);
}

.mobile-bottom-nav__item--primary .mobile-bottom-nav__fab svg {
  width: 24px;
  height: 24px;
}

.mobile-bottom-nav__item:not(.mobile-bottom-nav__item--primary):active {
  color: var(--primary);
}

/* —— Bottom Sheet (generic, reusable) —— */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 220;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

body.bottom-sheet-open {
  overflow: hidden;
}

body.bottom-sheet-open .bottom-sheet-backdrop {
  pointer-events: auto;
}

body.bottom-sheet-visible .bottom-sheet-backdrop {
  opacity: 1;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 230;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  max-height: min(82vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.22);
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  visibility: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.bottom-sheet-open .bottom-sheet {
  visibility: visible;
}

body.bottom-sheet-visible .bottom-sheet {
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .bottom-sheet,
  .bottom-sheet-backdrop {
    transition: none;
  }
}

.bottom-sheet-grabber {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  margin: 10px auto 2px;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
}

.bottom-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 20px 12px;
  flex-shrink: 0;
}

.bottom-sheet-head-text {
  min-width: 0;
}

.bottom-sheet-head-text h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.bottom-sheet-head-text p {
  margin: 4px 0 0;
}

.bottom-sheet-close {
  flex-shrink: 0;
}

.bottom-sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 12px;
  -webkit-overflow-scrolling: touch;
}

.bottom-sheet-footer {
  padding: 8px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.bottom-sheet-footer .btn {
  width: 100%;
  justify-content: center;
}

@media (min-width: 901px) {
  .bottom-sheet,
  .bottom-sheet-backdrop {
    display: none;
  }
}

.bottom-sheet-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 6px;
}

.bottom-sheet-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 52px;
  padding: 10px 12px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bottom-sheet-menu-item:hover,
.bottom-sheet-menu-item:active {
  background: var(--bg);
}

.bottom-sheet-menu-item.is-active {
  background: var(--secondary);
  color: var(--primary);
  font-weight: 600;
}

.bottom-sheet-menu-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--bg);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.bottom-sheet-menu-item.is-active .bottom-sheet-menu-icon {
  background: var(--surface);
  color: var(--primary);
}

.bottom-sheet-menu-icon svg {
  width: 18px;
  height: 18px;
}

.bottom-sheet-menu-label {
  flex: 1;
  min-width: 0;
}

.bottom-sheet-menu-divider {
  height: 1px;
  margin: 8px 4px;
  background: var(--border);
}

.bottom-sheet-menu-item--danger {
  color: var(--danger);
}

.bottom-sheet-menu-item--danger .bottom-sheet-menu-icon {
  background: #fef2f2;
  color: var(--danger);
}

[data-theme="dark"] .history-mobile-delete-btn,
[data-theme="dark"] .history-mobile-delete-full {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}

[data-theme="dark"] .bottom-sheet-menu-item--danger .bottom-sheet-menu-icon {
  background: rgba(220, 38, 38, 0.15);
}

/* —— PWA: safe areas & standalone —— */
body {
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.sidebar {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.topbar,
.timeline-page-topbar {
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

@media (display-mode: standalone) {
  body {
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-cta {
    font-size: 15px;
    padding: 12px 16px;
  }
}

/* —— PWA: install banner —— */
.pwa-install-banner {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  width: min(420px, calc(100vw - 24px));
  transform: translateX(-50%) translateY(calc(100% + 32px));
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s ease, opacity 0.32s ease;
}

.pwa-install-banner.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.pwa-install-banner__card {
  position: relative;
  padding: 14px 14px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.14);
}

.pwa-install-banner__close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pwa-install-banner__close:hover {
  background: var(--bg);
  color: var(--text);
}

.pwa-install-banner__close svg {
  width: 16px;
  height: 16px;
}

.pwa-install-banner__main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding-right: 24px;
  margin-bottom: 12px;
}

.pwa-install-banner__icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(91, 92, 235, 0.2);
}

.pwa-install-banner__copy {
  min-width: 0;
}

.pwa-install-banner__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 4px;
}

.pwa-install-banner__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.pwa-install-banner__desc strong {
  color: var(--text);
  font-weight: 600;
}

.pwa-install-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pwa-install-banner__actions .btn-primary {
  flex: 1 1 auto;
  min-width: 0;
  justify-content: center;
}

.pwa-install-banner__actions .btn-ghost {
  flex: 0 0 auto;
  color: var(--text-secondary);
}

.pwa-install-banner__install[hidden] {
  display: none;
}

.pwa-install-banner__install:not([hidden]) + .pwa-install-banner__dismiss {
  flex: 0 0 auto;
}

.pwa-install-banner__install[hidden] + .pwa-install-banner__dismiss {
  flex: 1 1 auto;
  justify-content: center;
}

@media (max-width: 380px) {
  .pwa-install-banner__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .pwa-install-banner__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* —— PWA: toast/banner —— */
.pwa-toast-root {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  z-index: 9999;
  max-width: min(420px, calc(100vw - 32px));
  width: 100%;
  pointer-events: none;
  transition: transform 0.3s ease;
}

.pwa-toast-root.is-visible {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.pwa-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
}

.pwa-toast__message {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  margin: 0;
}

.pwa-toast__actions {
  flex-shrink: 0;
}

.pwa-toast__btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pwa-toast__btn:hover {
  background: var(--primary-hover);
}

@media (max-width: 900px) {
  .sidebar-cta {
    font-size: 15px;
    min-height: 44px;
  }

  .nav-item,
  .nav-item-link {
    min-height: 44px;
  }
}
