:root {
  color-scheme: light;
  --md-primary: #2196f3;
  --md-primary-dark: #1976d2;
  --md-primary-light: #bbdefb;
  --md-on-primary: #ffffff;
  --md-primary-container: #e3f2fd;
  --md-on-primary-container: #0d47a1;
  --md-surface: #ffffff;
  --md-surface-container-low: #f7fbff;
  --md-surface-container: #eef6ff;
  --md-surface-container-high: #e8f2fd;
  --md-background: #f5f9ff;
  --md-outline: #d4e3f4;
  --md-outline-variant: #e3edf9;
  --md-text: #172033;
  --md-muted: #607089;
  --md-error: #b3261e;
  --md-error-container: #ffdad6;
  --md-success: #146c2e;
  --md-success-container: #dcf5df;
  --md-shadow: 0 18px 46px rgba(25, 118, 210, 0.14);
  --md-shadow-soft: 0 8px 24px rgba(25, 118, 210, 0.10);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 34px;
  --sidebar-width: 420px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--md-background);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: Roboto, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 0%, rgba(187, 222, 251, 0.9), transparent 30rem),
    linear-gradient(180deg, #ffffff 0%, var(--md-background) 42%, #eef6ff 100%);
  color: var(--md-text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 88% 4%, rgba(33, 150, 243, 0.20), transparent 24rem),
    radial-gradient(circle at 80% 96%, rgba(187, 222, 251, 0.48), transparent 28rem);
}

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

.app-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
  border-right: 1px solid rgba(212, 227, 244, 0.9);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(22px);
  z-index: 10;
}

.brand {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border-radius: var(--radius-lg);
  color: var(--md-on-primary);
  background:
    linear-gradient(135deg, var(--md-primary-dark), var(--md-primary)),
    var(--md-primary);
  box-shadow: var(--md-shadow);
}

.brand::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  right: -80px;
  top: -92px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.brand-title {
  position: relative;
  display: block;
  color: var(--md-on-primary);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  position: relative;
  margin-top: 8px;
  max-width: 15rem;
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.86);
  line-height: 1.4;
}

.search-box {
  position: relative;
  margin: 18px 0 14px;
}

.search-box input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--md-outline);
  border-radius: 999px;
  padding: 0 46px 0 46px;
  outline: none;
  background: var(--md-surface-container-low);
  color: var(--md-text);
  font-size: 0.96rem;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* Hide the native search "x" so we can use our own consistent one. */
.search-box input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--md-surface-container-high);
  color: var(--md-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.search-clear:hover {
  background: var(--md-primary-container);
  color: var(--md-primary-dark);
}

.search-clear[hidden] {
  display: none;
}

.search-box::before {
  content: "⌕";
  position: absolute;
  left: 17px;
  top: 10px;
  z-index: 1;
  color: var(--md-primary-dark);
  font-size: 1.25rem;
  line-height: 1;
}

.search-box input:focus {
  border-color: var(--md-primary);
  background: var(--md-surface);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.13);
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  z-index: 20;
  padding: 8px;
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  box-shadow: var(--md-shadow);
}

.search-result,
.search-empty {
  display: block;
  padding: 11px 12px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--md-text);
  font-size: 0.92rem;
}

.search-result:hover {
  background: var(--md-primary-container);
}

.menu {
  margin-top: 4px;
}

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

.menu > ul {
  display: grid;
  gap: 6px;
}

.folder {
  padding-top: 10px;
}

.folder details {
  border: none;
}

.folder details summary {
  cursor: pointer;
  list-style: none;
}

.folder details summary::-webkit-details-marker {
  display: none;
}

.folder details summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 140ms ease;
}

.folder details[open] summary::before {
  transform: rotate(90deg);
}

.folder-title {
  margin: 10px 0 6px;
  padding: 0 12px;
  color: var(--md-muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.folder ul {
  margin-left: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--md-outline-variant);
}

.doc-link {
  position: relative;
  display: block;
  margin: 3px 0;
  padding: 11px 13px 11px 38px;
  border-radius: 999px;
  color: #24364f;
  text-decoration: none;
  font-size: 0.94rem;
  line-height: 1.25;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.doc-link::before {
  content: "";
  position: absolute;
  left: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--md-primary-light);
}

.doc-link:hover {
  background: var(--md-primary-container);
}

.doc-link.active {
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  box-shadow: 0 10px 26px rgba(25, 118, 210, 0.25);
}

.doc-link.active::before {
  background: var(--md-on-primary);
}

.sync-card {
  margin-top: 20px;
  padding: 14px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-md);
  background: var(--md-surface-container-low);
  font-size: 0.82rem;
}

.sync-label {
  color: var(--md-muted);
  font-weight: 700;
}

.sync-status {
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: var(--md-primary-dark);
  font-weight: 800;
  text-transform: capitalize;
}

.status-error {
  color: var(--md-error);
  background: var(--md-error-container);
}

.status-ok {
  color: var(--md-success);
  background: var(--md-success-container);
}

.status-syncing,
.status-never_synced {
  color: var(--md-on-primary-container);
  background: var(--md-primary-container);
}

.sync-time,
.sync-error {
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--md-muted);
}

.sync-error {
  color: var(--md-error);
}

.content {
  position: relative;
  min-width: 0;
  padding: clamp(22px, 4vw, 58px);
}

.doc-page,
.empty-state {
  max-width: 1120px;
  margin: 0 auto;
  border: 1px solid rgba(212, 227, 244, 0.9);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--md-shadow);
}

.doc-page {
  overflow: hidden;
}

.doc-header {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 36px 40px;
  border-bottom: 1px solid var(--md-outline-variant);
  background:
    linear-gradient(135deg, rgba(227, 242, 253, 0.92), rgba(255, 255, 255, 0.96)),
    var(--md-surface);
}

.doc-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3.4vw, 3.15rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 1.04;
  color: #102033;
}

.doc-header p {
  margin: 12px 0 0;
  color: var(--md-muted);
}

/* Tag chips */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--md-outline);
  background: var(--md-surface-container);
  color: var(--md-primary-dark);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.tag-chip::before {
  content: "#";
  opacity: 0.55;
}

.tag-chip:hover {
  background: var(--md-primary-dark);
  border-color: var(--md-primary-dark);
  color: var(--md-on-primary);
}

.tag-chip:hover::before {
  opacity: 0.8;
}

.tag-chip-lg {
  padding: 8px 16px;
  font-size: 0.92rem;
}

.tag-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  font-size: 0.74rem;
  font-weight: 800;
}

.tag-chip:hover .tag-count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--md-on-primary);
}

/* Tags index + detail pages */
.tags-index,
.tag-doc-list {
  padding: 40px;
}

.tags-empty {
  color: var(--md-muted);
}

.tag-eyebrow {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tag-eyebrow a {
  color: var(--md-muted);
  text-decoration: none;
}

.tag-eyebrow a:hover {
  color: var(--md-primary-dark);
}

.tag-doc-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.tag-doc-list li a {
  display: block;
  padding: 14px 18px;
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--radius-md);
  background: var(--md-surface-container-low);
  color: var(--md-text);
  text-decoration: none;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.tag-doc-list li a:hover {
  background: var(--md-primary-container);
  border-color: var(--md-primary-light);
  box-shadow: var(--md-shadow-soft);
}

/* Sidebar tags nav */
.tags-nav {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--md-outline-variant);
}

.tags-nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 999px;
  color: var(--md-primary-dark);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 800;
  transition: background 140ms ease;
}

.tags-nav-link:hover {
  background: var(--md-primary-container);
}

.open-drive,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  white-space: nowrap;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  color: var(--md-on-primary);
  text-decoration: none;
  background: var(--md-primary-dark);
  box-shadow: var(--md-shadow-soft);
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
}

.open-drive:hover,
.menu-toggle:hover {
  background: var(--md-primary);
}

.google-doc-content {
  padding: 40px;
  font-size: 1.02rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.google-doc-content > *:first-child {
  margin-top: 0 !important;
}

.google-doc-content h1,
.google-doc-content h2,
.google-doc-content h3,
.google-doc-content h4,
.google-doc-content h5,
.google-doc-content h6 {
  margin: 1.45em 0 0.55em;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: #102033;
}

.google-doc-content h1 {
  font-size: 2rem;
}

.google-doc-content h2 {
  font-size: 1.55rem;
}

.google-doc-content h3 {
  font-size: 1.28rem;
}

.google-doc-content p {
  margin: 0 0 1.1em;
}

.google-doc-content a {
  font-weight: 700;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.google-doc-content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 24px auto;
  border-radius: 22px;
  box-shadow: 0 16px 38px rgba(25, 118, 210, 0.16);
}

.google-doc-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 26px 0;
  overflow: hidden;
  border: 1px solid var(--md-outline-variant);
  border-radius: 18px;
  background: var(--md-surface);
}

.google-doc-content th,
.google-doc-content td {
  padding: 12px 14px;
  border-right: 1px solid var(--md-outline-variant);
  border-bottom: 1px solid var(--md-outline-variant);
  vertical-align: top;
}

.google-doc-content tr > *:last-child {
  border-right: 0;
}

.google-doc-content tr:last-child > * {
  border-bottom: 0;
}

.google-doc-content th {
  background: var(--md-primary-container);
  color: var(--md-on-primary-container);
  text-align: left;
  font-weight: 800;
}

.google-doc-content blockquote {
  margin: 24px 0;
  padding: 16px 20px;
  border-left: 5px solid var(--md-primary);
  border-radius: 16px;
  background: var(--md-primary-container);
  color: #20334c;
}

.google-doc-content pre,
.google-doc-content code {
  border-radius: 12px;
  background: #101827;
  color: #f8fafc;
}

.google-doc-content code {
  padding: 0.16em 0.38em;
}

.google-doc-content pre {
  padding: 18px;
  overflow: auto;
}

.video-embed {
  position: relative;
  width: 100%;
  margin: 30px 0;
  overflow: hidden;
  border-radius: 24px;
  background: #0b1020;
  box-shadow: 0 18px 46px rgba(25, 118, 210, 0.22);
}

.video-embed::before {
  content: "";
  display: block;
  padding-top: 56.25%;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.alert {
  margin: 38px;
  padding: 18px;
  border: 1px solid rgba(179, 38, 30, 0.24);
  border-radius: 20px;
  background: var(--md-error-container);
  color: #601410;
}

.alert pre,
.empty-state pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 44px;
}

.empty-state h1 {
  margin-top: 0;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.menu-toggle {
  display: none;
  margin-bottom: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar .menu-toggle {
  margin-bottom: 0;
}

.ticket-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  margin-left: auto;
  border: 0;
  border-radius: 999px;
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  box-shadow: var(--md-shadow-soft);
  font-weight: 800;
  font-size: 0.94rem;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.ticket-button:hover {
  background: var(--md-primary);
  box-shadow: var(--md-shadow);
}

/* Ticket modal */
.ticket-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ticket-modal[hidden] {
  display: none;
}

.ticket-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 51, 0.45);
  backdrop-filter: blur(3px);
}

.ticket-modal-dialog {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--md-surface);
  box-shadow: var(--md-shadow);
}

.ticket-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.ticket-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #102033;
}

.ticket-modal-subtitle {
  margin: 6px 0 0;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--md-muted);
}

.ticket-modal-close {
  border: 0;
  background: transparent;
  font-size: 1.8rem;
  line-height: 1;
  color: var(--md-muted);
  cursor: pointer;
  padding: 0 6px;
}

.ticket-modal-close:hover {
  color: var(--md-text);
}

.ticket-form {
  display: grid;
  gap: 16px;
}

.ticket-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ticket-field {
  display: grid;
  gap: 7px;
}

.ticket-field-label {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--md-text);
}

.ticket-form .required {
  color: var(--md-error);
  font-weight: 800;
}

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

.ticket-form input,
.ticket-form textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--md-outline);
  border-radius: var(--radius-sm);
  background: var(--md-surface-container-low);
  color: var(--md-text);
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.5;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.ticket-form input::placeholder,
.ticket-form textarea::placeholder {
  color: var(--md-muted);
  opacity: 0.6;
}

.ticket-form input:focus,
.ticket-form textarea:focus {
  border-color: var(--md-primary);
  background: var(--md-surface);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.13);
}

.ticket-form textarea {
  resize: vertical;
  min-height: 120px;
}

.ticket-form-message {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
}

.ticket-form-message.is-error {
  color: var(--md-error);
  background: var(--md-error-container);
}

.ticket-form-message.is-success {
  color: var(--md-success);
  background: var(--md-success-container);
}

.ticket-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--md-outline-variant);
}

.ticket-cancel,
.ticket-submit {
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.ticket-cancel {
  border: 1px solid var(--md-outline);
  background: var(--md-surface);
  color: var(--md-text);
}

.ticket-cancel:hover {
  background: var(--md-surface-container);
}

.ticket-submit {
  border: 0;
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  box-shadow: var(--md-shadow-soft);
}

.ticket-submit:hover {
  background: var(--md-primary);
}

.ticket-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Sidebar close button — only shown when the drawer is open (mobile only, since
   the sidebar never gets the 'open' class on desktop). Tied to state rather than
   a viewport media query so it works regardless of exact device width. */
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--md-text);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--md-shadow-soft);
}

.sidebar.open .sidebar-close {
  display: inline-flex;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(88vw, var(--sidebar-width));
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 40px rgba(23, 32, 51, 0.12);
    z-index: 1100;
  }

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

  /* Dimmed backdrop behind the open sidebar. */
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(16, 32, 51, 0.45);
    backdrop-filter: blur(2px);
  }

  .content {
    padding: 18px;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .doc-page,
  .empty-state {
    border-radius: 24px;
  }

  .doc-header {
    display: block;
    padding: 26px;
  }

  .open-drive {
    margin-top: 18px;
  }

  .google-doc-content {
    padding: 26px;
  }
}

/* Documentation chatbot */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  box-shadow: var(--md-shadow);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 140ms ease, transform 140ms ease;
}

.chat-fab:hover {
  background: var(--md-primary);
  transform: translateY(-1px);
}

.chat-fab-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.chat-panel {
  position: fixed;
  right: 24px;
  bottom: 88px;
  z-index: 901;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  border-radius: var(--radius-lg);
  background: var(--md-surface);
  box-shadow: var(--md-shadow);
  overflow: hidden;
}

.chat-panel[hidden] {
  display: none;
}

.chat-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  color: var(--md-on-primary);
  background: linear-gradient(135deg, var(--md-primary-dark), var(--md-primary));
}

.chat-panel-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.chat-panel-header p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
}

.chat-close {
  border: 0;
  background: transparent;
  color: var(--md-on-primary);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--md-surface-container-low);
}

.chat-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chat-msg-user {
  align-self: flex-end;
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  border-bottom-right-radius: 4px;
}

.chat-msg-bot {
  align-self: flex-start;
  color: var(--md-text);
  background: var(--md-surface);
  border: 1px solid var(--md-outline-variant);
  border-bottom-left-radius: 4px;
}

.chat-msg-thinking {
  opacity: 0.7;
  font-style: italic;
}

/* Rendered Markdown inside chat answers */
.chat-md > *:first-child {
  margin-top: 0;
}

.chat-md > *:last-child {
  margin-bottom: 0;
}

.chat-md p {
  margin: 0 0 0.6em;
}

.chat-md ul,
.chat-md ol {
  margin: 0.4em 0 0.7em;
  padding-left: 1.4em;
}

.chat-md li {
  margin: 0.2em 0;
}

.chat-md h3,
.chat-md h4,
.chat-md h5 {
  margin: 0.8em 0 0.4em;
  font-size: 1rem;
  font-weight: 800;
  color: #102033;
}

.chat-md code {
  padding: 0.12em 0.36em;
  border-radius: 6px;
  background: rgba(16, 24, 39, 0.08);
  font-size: 0.86em;
}

.chat-md pre {
  margin: 0.5em 0;
  padding: 12px;
  border-radius: 10px;
  background: #101827;
  color: #f8fafc;
  overflow-x: auto;
}

.chat-md pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.chat-md blockquote {
  margin: 0.5em 0;
  padding: 4px 12px;
  border-left: 3px solid var(--md-primary);
  color: var(--md-muted);
}

.chat-md a {
  color: var(--md-primary-dark);
  font-weight: 700;
}

.chat-md table {
  width: 100%;
  margin: 0.5em 0;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.chat-md th,
.chat-md td {
  padding: 6px 8px;
  border: 1px solid var(--md-outline-variant);
  text-align: left;
}

.chat-sources {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--md-outline-variant);
  font-size: 0.78rem;
  color: var(--md-muted);
}

.chat-sources a {
  color: var(--md-primary-dark);
  font-weight: 700;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--md-outline-variant);
  background: var(--md-surface);
}

.chat-input-row input {
  flex: 1;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--md-outline);
  border-radius: 999px;
  background: var(--md-surface-container-low);
  color: var(--md-text);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--md-primary);
  background: var(--md-surface);
  box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.13);
}

.chat-input-row button {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: var(--md-on-primary);
  background: var(--md-primary-dark);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}

.chat-input-row button:disabled {
  opacity: 0.6;
  cursor: default;
}

@media (max-width: 560px) {
  .chat-panel {
    right: 8px;
    left: 8px;
    width: auto;
    bottom: 84px;
  }
}
