* {
  box-sizing: border-box;
}

/* --- Inline styles moved from index.html ---
	 These are prepended so existing rules in this file (below) take precedence.
*/
:root {
  --brand: #0b5fff;
  --brand-dark: #0b66ff;
  --brand-darker: #0b4ed6;
  --muted: #666666;
  --text-strong: #0b1220;
  --panel-bg: rgba(255, 255, 255, 0.98);
  --input-border: #cbd5e1;
  --placeholder: #6b7280;
  --shadow-soft: 0 0.25rem 0.75rem rgba(158, 207, 255, 0.3);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.12);
  --focus-color: rgba(11, 95, 255, 0.22);

  /* Brand gradient stops / color tokens */
  --brand-50: #b5deff;
  --brand-100: #9ecfff;
  --brand-200: #89bfff;
  --brand-300: #1a56db;
  --brand-400: #3d7fd9;
  --focus-ring-color: rgba(181, 222, 255, 0.2);

  /* Accent pinks */
  --accent-pink-100: #ffb5e8;
  --accent-pink-200: #ff9ecd;
  --accent-pink-gradient: linear-gradient(
    135deg,
    var(--accent-pink-100),
    var(--accent-pink-200)
  );
  --accent-pink-radial: radial-gradient(
    circle,
    var(--accent-pink-200) 0%,
    transparent 70%
  );

  /* Body and banner gradients */
  /* Body background stops centralized */
  --body-bg-stop-1: #ffe5e5;
  --body-bg-stop-2: #fff0e5;
  --body-bg-stop-3: #ffffe5;
  --body-bg-stop-4: #e5ffe5;
  --body-bg-stop-5: #e5f0ff;
  --body-bg-stop-6: #f0e5ff;
  --body-bg: linear-gradient(
    135deg,
    var(--body-bg-stop-1) 0%,
    var(--body-bg-stop-2) 20%,
    var(--body-bg-stop-3) 40%,
    var(--body-bg-stop-4) 60%,
    var(--body-bg-stop-5) 80%,
    var(--body-bg-stop-6) 100%
  );
  --banner-100: #fff7e6;
  --banner-200: #fff3cc;
  --banner-grad: linear-gradient(90deg, var(--banner-100), var(--banner-200));
  --banner-warn-100: #fff0f0;
  --banner-warn-200: #ffe5e5;
  --banner-warn-grad: linear-gradient(
    90deg,
    var(--banner-warn-100),
    var(--banner-warn-200)
  );

  /* Danger / delete colors */
  --danger-100: #ff6464;
  --danger-200: #ff4444;
  --danger-300: #ff2222;

  /* Text and muted tokens */
  --text-default: #2d2d2d;
  --muted-100: #e6e6e6;
  --social-x: #117ab0;
  --social-x-hover: #0e5f89;
  --separator: #6b7280;
  --note-color: #374151;
  --panel-contrast: #ffffff;
  --error-red: #b91c1c;

  /* Progress bar */
  --model-progress-grad: linear-gradient(
    90deg,
    var(--brand-dark),
    var(--brand-300)
  );

  /* Button / element shadow tokens */
  --shadow-panel: 0 6px 18px rgba(0, 0, 0, 0.6);
  --shadow-card: 0 0.5rem 2rem rgba(0, 0, 0, 0.1);
  --shadow-card-strong: 0 0.5rem 2rem rgba(0, 0, 0, 0.25);
  --shadow-inset-small: inset 0 0.125rem 0.5rem rgba(0, 0, 0, 0.5);
  --shadow-ring: 0 0 0 0.1875rem rgba(181, 222, 255, 0.2);

  /* Button-specific */
  --shadow-btn: 0 0.125rem 0.375rem rgba(158, 207, 255, 0.3);
  --shadow-btn-hover: 0 0.25rem 0.5rem rgba(158, 207, 255, 0.4);
  --shadow-btn-active: 0 0.0625rem 0.25rem rgba(158, 207, 255, 0.3);

  /* Accent / brand shadows */
  --shadow-accent-strong: 0 0.125rem 0.375rem rgba(11, 95, 255, 0.8);

  /* Danger (delete) */
  --shadow-danger: 0 0.125rem 0.25rem rgba(255, 100, 100, 0.2);
  --shadow-danger-hover: 0 0.25rem 0.375rem rgba(255, 100, 100, 0.4);
  --shadow-danger-active: 0 0.0625rem 0.125rem rgba(255, 100, 100, 0.3);

  /* small neutral shadows */
  --shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
  --shadow-popup: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);

  /* Transitions */
  --trans-fast: all 0.12s ease;
  --trans-medium: all 0.16s ease;
  --trans-default: all 0.2s ease;
  --trans-slow: all 0.3s ease;

  /* Background opacity tokens */
  --bg-95: rgba(255, 255, 255, 0.95);
  --bg-90: rgba(255, 255, 255, 0.9);
  --bg-85: rgba(255, 255, 255, 0.85);
  --bg-80: rgba(255, 255, 255, 0.8);
  --bg-60: rgba(255, 255, 255, 0.6);
  --bg-70: rgba(255, 255, 255, 0.7);
  --bg-50: rgba(255, 255, 255, 0.5);

  /* Muted border / panel accents */
  --muted-border: rgba(200, 200, 255, 0.3);

  /* Panel border and message background tokens (centralize repeated rgba stops) */
  --border-panel: rgba(255, 255, 255, 0.6);
  --message-bg-gradient: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.5)
  );
  /* Common gradients centralized for reuse */
  --brand-gradient-strong: linear-gradient(
    135deg,
    rgba(11, 95, 255, 0.8),
    rgba(91, 156, 255, 0.4)
  );
  --brand-gradient-soft: linear-gradient(
    135deg,
    rgba(11, 95, 255, 0.12),
    rgba(91, 156, 255, 0.8)
  );
  /* Code block / inline code background token */
  --code-bg: rgba(0, 0, 0, 0.5);

  /* Additional centralized tokens discovered during sweep */
  --white: #ffffff;
  --timestamp-color: #888888; /* used for small timestamps */
  --overlay-bg: rgba(0, 0, 0, 0.5);
  --panel-border-dark: rgba(0, 0, 0, 0.6);
  --panel-border-strong: rgba(0, 0, 0, 0.8);
  --table-border: rgba(0, 0, 0, 0.1);
  --blockquote-border: rgba(181, 222, 255, 0.5);

  /* Danger / delete rgba variants */
  --danger-bg-1: rgba(255, 100, 100, 0.1);
  /* small neutral grey variants */
  --muted-grey-1: rgba(200, 200, 200, 0.3);
  --muted-grey-2: rgba(200, 200, 200, 0.5);
  --muted-grey-3: rgba(200, 200, 200, 0.6);
  --danger-bg-2: rgba(255, 100, 100, 0.2);
  --danger-bg-3: rgba(255, 100, 100, 0.3);
  --danger-border-weak: rgba(255, 100, 100, 0.3);
  --danger-border: rgba(255, 100, 100, 0.4);

  /* More small tokens */
  --brand-hover-bg: rgba(91, 156, 255, 0.1);
  --progress-bg: rgba(0, 0, 0, 0.6);
  --text-strong-opacity: rgba(27, 27, 27, 0.85);
  --table-header-bg: rgba(181, 222, 255, 0.2);
  --brand-hover-gradient: linear-gradient(
    135deg,
    var(--brand-100),
    var(--brand-200)
  );

  /* Border radius tokens to reduce specific values */
  --radius-lg: 0.75rem; /* 12px */
  --radius-md: 0.5rem; /* 8px */
  --radius-sm: 0.25rem; /* 4px */
  --radius-pill: 9999px;
  /* Spacing tokens */
  --pad-sm: 0.5rem;
  --pad-md: 0.75rem;
  --pad-lg: 1rem;
  --pad-xl: 1.25rem;
}
html,
body {
  height: 100%;
  min-width: 20rem;
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    "Helvetica Neue",
    Arial;
}
header.site {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
header.site h1 {
  z-index: 10;
  margin: 0;
  font-size: 1.25rem;
}
/* Make H1 link look like plain header text but remain keyboard accessible */
.site-title-link {
  color: inherit;
  text-decoration: none;
}

/* Nav toggle (hamburger) focus/active states */
.nav-toggle:focus-visible {
  outline: 4px solid var(--brand-300);
  outline-offset: 4px;
  border-radius: 8px;
}
.nav-toggle:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Nav links clearer focus and hover */
.site-nav a:focus-visible, .site-nav a:active, .site-nav a:hover,
.nav-panel a:focus-visible, .nav-panel a:active, .nav-panel a:hover {
  border-radius: 6px;
  background: var(--brand-gradient-strong);
}
.site-nav a:focus-visible, 
.nav-panel a:focus-visible {
  outline: 4px solid var(--brand-300);
  outline-offset: 4px;
}
.site-nav a:active,
.nav-panel a:active {
  transform: translateY(1px);
}

/* Shared button base: layout & interaction defaults for buttons across the site. */
.btn,
button,
.new-chat-button,
.delete-chat-button,
.delete-confirm-yes,
.delete-confirm-no,
.feature-banner .dismiss {
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-weight: 600;
  cursor: pointer;
  /* transition centralized in grouped controls rule */
  text-decoration: none;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Grouped transitions for interactive controls to avoid repeating the same property */
.btn,
.control,
.social-btn,
.new-chat-button,
.delete-chat-button,
.delete-confirm-yes,
.delete-confirm-no {
  transition: var(--trans-default);
}

/* Focus and active states for buttons and button-like controls */
.btn:focus-visible,
button:focus-visible,
.new-chat-button:focus-visible,
.delete-chat-button:focus-visible,
.delete-confirm-yes:focus-visible,
.delete-confirm-no:focus-visible,
.feature-banner .dismiss:focus-visible {
  outline: 4px solid var(--brand-300);
  outline-offset: 4px;
}

.btn:active,
button:active,
.new-chat-button:active,
.delete-chat-button:active,
.delete-confirm-yes:active,
.delete-confirm-no:active,
.feature-banner .dismiss:active {
  transform: translateY(1px);
}

/* Responsive navigation */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 8px;
  border: 1px solid var(--muted-100);
}
/* Hide the inline nav on small screens; show the mobile panel instead */
nav.site-nav {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}
nav.site-nav a {
  color: inherit;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}
.nav-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}
.nav-panel {
  display: none;
  position: absolute;
  top: 2.75rem;
  right: 0;
  width: 9rem;
  background: var(--panel-contrast);
  border: 1px solid var(--muted-100);
  border-radius: var(--radius-md);
  padding: var(--pad-sm);
  box-shadow: var(--shadow-panel);
  z-index: 60;
}
.nav-panel a {
  display: block;
  padding: 0.5rem 0.75rem;
}
/* Visual indicator for the current page link (accessible via aria-current="page") */
.site-nav a[aria-current="page"],
.nav-panel a[aria-current="page"] {
  background: var(--brand-gradient-soft);
  color: var(--brand);
  font-weight: 700;
  box-shadow: var(--shadow-accent-strong);
}
@media (min-width: 720px) {
  .nav-toggle {
    display: none;
  }
  .nav-panel {
    display: none !important;
  }
  nav.site-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
  }
}

.btn {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: var(--white);
  transition: var(--trans-default);
  box-shadow: var(--shadow-btn);
}

.btn:hover {
  background: var(--brand-hover-gradient);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-0.0625rem);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn-active);
}

footer {
  display: flex;
  gap: 2rem;
  justify-content: center;
  padding: var(--pad-lg);
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}
footer a {
  color: var(--brand);
  text-decoration: none;
}
footer a:hover,
footer a:focus,
footer a:active {
  text-decoration: underline;
}

/* --- end moved styles --- */

html,
body {
  height: 100%;
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    Roboto,
    "Segoe UI",
    "Helvetica Neue",
    Arial;
  color: var(--text-default);
  background: var(--body-bg);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

/* Group default text color applied to multiple interactive components to reduce duplicated rules */

/* loading-panel color provided by grouped defaults above */

/* Default body layout for static/content pages: normal flow, scrollable */
body {
  min-height: 100vh;
  padding: 1rem;
  overflow: scroll;
}

/* Group near-black text color used across panels and form labels */
.feature-banner,
.new-chat-button,
.chat-link-current,
.delete-confirm-text,
.delete-confirm-no,
#model-progress-text,
.loading-panel,
.social-btn,
label {
  color: var(--text-strong);
}

/* Chat page keeps the previous full-screen centered/grid layout */
body.chat-page {
  height: 100vh;
  display: grid;
  grid-template-rows: 5rem 1fr 2rem;
  overflow: hidden;
}

header h1 {
  z-index: 10;
}

/* background silhouettes */
body::before,
body::after {
  content: "";
  position: fixed;
  opacity: 0.8;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 25rem;
  height: 25rem;
  background: var(--accent-pink-radial);
  border-radius: 40% 60% 70% 30% / 60% 30% 70% 40%;
  top: -6.25rem;
  left: -6.25rem;
  animation: float 20s ease-in-out infinite;
}

body::after {
  width: 31.25rem;
  height: 31.25rem;
  background: radial-gradient(circle, var(--brand-100) 0%, transparent 70%);
  border-radius: 60% 40% 30% 70% / 40% 70% 30% 60%;
  bottom: -9.375rem;
  right: -9.375rem;
  animation: float 25s ease-in-out infinite reverse;
}

@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(3.125rem, 3.125rem) rotate(5deg);
  }
  50% {
    transform: translate(1.25rem, 6.25rem) rotate(-5deg);
  }
  75% {
    transform: translate(-1.875rem, 3.125rem) rotate(3deg);
  }
}

.container {
  width: 100%;
  padding: 1rem 1.5rem;
  background: var(--bg-85);
  backdrop-filter: blur(0.625rem);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: none;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.cta {
  text-align: center;
  width: 100%;
  padding: 2rem;
}
.cta .btn {
  width: 100%;
}

#chat {
  display: flex;
  flex-direction: column;
  flex: auto;
  justify-content: space-between;
  gap: 1rem;
  height: 100%;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
  max-height: 100%;
  padding: 1rem;
  background: var(--bg-60);
  backdrop-filter: blur(0.3125rem);
  border-radius: var(--radius-md);
  overflow-y: auto;
  border: 0.0625rem solid var(--muted-border);
  box-shadow: var(--shadow-inset-small);
}

.message {
  padding: 0.625rem 0.75rem;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.message .role {
  font-weight: 700;
  margin-right: 0.5rem;
  padding: 0.125rem 0.5rem;
  border-radius: 0.5rem;
  display: inline-block;
  background: var(--accent-pink-gradient);
}
.message .role-assistant {
  background: var(--brand-300);
}

.message .timestamp {
  font-size: 0.75rem;
  color: var(--timestamp-color);
  font-weight: 500;
}

.message-content {
  display: block;
  line-height: 1.5;
}

/* Markdown styling for assistant messages */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  line-height: 1.3;
}

.message-content h1 {
  font-size: 1.5rem;
}
.message-content h2 {
  font-size: 1.3rem;
}
.message-content h3 {
  font-size: 1.1rem;
}
.message-content h4 {
  font-size: 1rem;
}

.message-content p {
  margin: 0.5rem 0;
}

.message-content code {
  background: var(--code-bg);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: "Courier New", monospace;
  font-size: 0.875em;
}

.message-content pre {
  background: var(--code-bg);
  padding: 0.75rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.message-content pre code {
  background: none;
  padding: 0;
}

.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.message-content li {
  margin: 0.25rem 0;
}

.message-content blockquote {
  border-left: 0.25rem solid var(--blockquote-border);
  padding-left: 1rem;
  margin: 0.75rem 0;
  color: var(--text-strong-opacity);
  font-style: italic;
}

.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
}

.message-content th,
.message-content td {
  border: 0.0625rem solid var(--table-border);
  padding: 0.5rem;
  text-align: left;
}

.message-content th {
  background: var(--table-header-bg);
  font-weight: 600;
}

.message-content a {
  text-decoration: underline;
}

.message-content hr {
  border: none;
  border-top: 0.0625rem solid var(--table-border);
  margin: 1rem 0;
}

.message-content strong {
  font-weight: 600;
}

.message-content em {
  font-style: italic;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: end;
}

textarea {
  padding: 0.75rem;
  border: 0.125rem solid var(--muted-border);
  border-radius: var(--radius-lg);
  background: var(--bg-80);
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: var(--brand-50);
  box-shadow: var(--shadow-ring);
  background: var(--bg-95);
}

input[type="file"] {
  padding: 0.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-70);
  border: 0.0625rem solid var(--muted-border);
}

button {
  padding: 0.75rem 1rem;
  border: none;
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-200));
  color: var(--white);
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: var(--trans-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover {
  background: var(--brand-hover-gradient);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-0.0625rem);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn-active);
}

.thinking {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 0.25rem;
  align-items: center;
  padding: 0.25rem 0;
}

.thinking .dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--accent-pink-gradient);
  border-radius: 50%;
  opacity: 0.3;
  animation: blink 1s infinite;
}

.thinking .dot:nth-child(2) {
  animation-delay: 0.15s;
}
.thinking .dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes blink {
  0% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
}

/* Main content area - Grid layout */
.main-content {
  display: grid;
  grid-template-columns: 14rem 1fr;
  gap: 1rem;
  height: 100%;
  overflow: hidden;
  flex: auto;
}

/* Sidebar container */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem; /* 0.5rem in total for visile items */
  padding-top: 0.5rem;;
  background: var(--bg-50);
  backdrop-filter: blur(0.3125rem);
  border-radius: var(--radius-md);
  border: 0.0625rem solid var(--muted-border);
  overflow: hidden;
}

/* Sidebar title */
.sidebar-title {
  font-weight: 600;
  margin: 0.25rem; /* Note the .sidebar padding adds to this */
}

/* New Chat Button */
.new-chat-button {
  display: block;
  width: auto;
  margin: 0.25rem; /* Note the .sidebar padding adds to this */
  background: linear-gradient(135deg, var(--brand-dark), var(--brand-100));
  font-size: 1rem;
}

.new-chat-button:hover {
  background: linear-gradient(135deg, var(--brand-100), var(--brand-200));
  transform: translateY(-0.0625rem);
}

.new-chat-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn-active);
}


/* Accessible visually-hidden helper */
.visually-hidden {
  position: absolute !important;
  height: 1px;
  width: 1px;
  overflow: hidden;
  clip: rect(1px, 1px, 1px, 1px);
  white-space: nowrap; /* added line */
}

/* No-JS / No-WASM banners */
.feature-banner {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11000;
  max-width: min(90%, 60rem);
  background: var(--banner-grad);
  border: 1px solid var(--panel-border-strong);
  box-shadow: var(--shadow-strong);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.feature-banner p {
  margin: 0;
  font-weight: 600;
}
.feature-banner a {
  color: var(--brand-dark);
  text-decoration: underline;
  font-weight: 700;
}
.feature-banner .dismiss {
  margin-left: auto;
  background: transparent;
  border: none;
  font-weight: 700;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
/* Error style for more urgent banner (no wasm) */
.feature-banner.warning {
  background: var(--banner-warn-grad);
  border-color: var(--danger-border);
}

/* Utility: hide elements */
.hidden {
  display: none;
}

/* Spinner */
.spinner {
  width: 3rem;
  height: 3rem;
  margin: 0.5rem auto 1rem auto;
  border-radius: 50%;
  border: 0.375rem solid var(--panel-border-strong);
  border-top-color: var(--brand-dark); /* accessible blue accent */
  animation: spinner 1s linear infinite;
}
@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Chat list styles */
.chat-list {
  /* this needs to scroll if too tall */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  flex: auto;
  padding: 0.25rem; /* Note .sidebar padding adds to this */
}

/* Chat item container with link and delete button */
.chat-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}

/* Chat link */

.chat-link {
  display: block;
  text-decoration: none;
  padding: 0.375rem 0.5rem;
  border-radius: 0.375rem;
  transition: var(--trans-default);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-link:hover {
  background: var(--brand-hover-bg);
  text-decoration: underline;
}

/* Grouped link color rules to reduce duplicated declarations */
.message-content a,
.chat-link {
  color: var(--brand-300);
}

.message-content a:hover,
.chat-link:hover {
  color: var(--brand-400);
}

/* Current/active chat link */
.chat-link-current {
  background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
  font-weight: 600;
}

.chat-link-current:hover {
  background: linear-gradient(135deg, var(--brand-100), var(--brand-200));
  text-decoration: none;
}

/* Grouped box-shadow for primary hover/active link/button states */
.new-chat-button:hover,
button:hover,
.chat-link-current,
.chat-link-current:hover {
  box-shadow: var(--shadow-btn-hover);
}

/* Animated placeholder for chat being generated */
.chat-link.chat-placeholder {
  animation: pulse-dots 1.5s ease-in-out infinite;
}

@keyframes pulse-dots {
  0%,
  100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Delete container with button and popup */
.delete-container {
  position: relative;
}

/* Delete chat button */
.delete-chat-button {
  padding: 0.25rem 0.5rem;
  background: var(--danger-bg-1);
  color: var(--danger-100) !important;
  border: 0.0625rem solid var(--danger-border-weak);
  border-radius: 0.25rem;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: var(--trans-default);
}

.delete-chat-button:hover {
  background: var(--danger-bg-2);
  border-color: var(--danger-border);
  box-shadow: var(--shadow-danger);
  transform: translateY(0);
}

.delete-chat-button:active {
  background: var(--danger-bg-3);
  transform: scale(0.95);
}

/* Delete confirmation popup */
.delete-confirm-popup {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 0.25rem;
  background: var(--panel-contrast);
  border: 0.0625rem solid var(--danger-border);
  border-radius: 0.5rem;
  padding: 0.75rem;
  box-shadow: var(--shadow-popup);
  min-width: 10rem;
  animation: popupFadeIn 0.2s ease;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.delete-confirm-text {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.delete-confirm-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.delete-confirm-yes,
.delete-confirm-no {
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans-default);
  border: none;
}

.delete-confirm-yes {
  background: linear-gradient(135deg, var(--danger-100), var(--danger-200));
  box-shadow: var(--shadow-danger);
}

.delete-confirm-yes:hover {
  background: linear-gradient(135deg, var(--danger-200), var(--danger-300));
  box-shadow: var(--shadow-danger-hover);
  transform: translateY(-0.0625rem);
}

.delete-confirm-yes:active {
  transform: translateY(0);
  box-shadow: var(--shadow-danger-active);
}

/* Grouped danger color rules for delete controls */
.delete-chat-button,
.delete-confirm-yes {
  color: var(--danger-100);
}

.delete-chat-button:hover,
.delete-confirm-yes:hover {
  color: var(--danger-200);
}

.delete-confirm-no {
  background: var(--note-color);
}

/* Grouped box-shadow helpers for delete controls to reduce duplicated single-property rules */
.delete-chat-button,
.delete-chat-button:active,
.delete-confirm-no {
  box-shadow: none;
}

.delete-chat-button:hover,
.delete-confirm-yes {
  box-shadow: var(--shadow-danger);
}

/* delete-confirm-no color provided by grouped defaults above */
.delete-confirm-no:hover {
  background: var(--muted-grey-2);
  box-shadow: var(--shadow-sm);
}

.delete-confirm-no:active {
  background: var(--muted-grey-3);
  transform: scale(0.98);
}

/* Mobile responsive adjustments */
@media (max-width: 48rem) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}

/* Login page specific styles */
/* Two-column layout for login on wider screens */
.login-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: start;
}
.social-column {
  text-align: left;
}
.form-column {
  text-align: left;
}

@media (min-width: 720px) {
  .login-layout {
    padding: 2rem 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
    text-align: left;
  }
  .social-column .lead {
    margin-bottom: 0.5rem;
  }
  .email-form {
    margin-top: 0;
  }
  .login-box .small-note {
    margin-top: 1rem;
  }
}

.social-buttons {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
}

.social-btn {
  /* Expanded from .control to remain compatible with plain CSS (no @apply available) */
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans-default);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  border: 1px solid var(--panel-border-strong);
  background: var(--note-color);
  text-decoration: none;
  width: 100%;
}

.social-btn:hover {
  background: var(--brand-dark);
}

/* Ensure inline SVG icons inside social buttons inherit the button's text color */
.social-btn svg {
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  fill: currentColor;
}

.or-separator {
  margin: 1rem 0;
  color: var(--separator);
}

.small-note {
  font-size: 0.9rem;
  color: var(--note-color);
  margin-top: 1rem;
}

#email-form {
  margin-top: 0.75rem;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--input-border); /* darker border for contrast */
  color: var(--text-strong); /* dark input text */
  background: var(--panel-contrast);
  margin-top: 0.5rem;
}

.email-form .form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Shared white text for primary/contrast controls */
nav.site-nav a.primary,
.btn,
.social-btn {
  color: var(--white);
}

#email-error {
  color: var(--error-red);
  margin-top: 0.5rem;
  display: none;
}

/* Visible labels and form field layout */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}
label {
  font-weight: 700;
  color: var(--text-strong);
  font-size: 0.95rem;
}
input::placeholder {
  color: var(--placeholder);
}

/* Utility helpers for small inline content previously in HTML */
.lead-center {
  text-align: center;
  margin-bottom: 0.5rem;
}
.centered-note {
  grid-column: 1 / -1;
  margin-top: 1rem;
  text-align: center;
}

/* Consolidated focus states for form controls and interactive elements on the login page */
input[type="email"]:focus,
input[type="password"]:focus,
.social-btn:focus-visible,
#email-submit:focus-visible,
button:focus-visible {
  outline: 4px solid var(--brand-300);
  outline-offset: 4px;
  box-shadow: var(--shadow-ring);
  border-color: var(--brand-50);
}

/* Model Download Dialog Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-bg);
  backdrop-filter: blur(0.2rem);
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-dialog {
  position: relative;
  max-width: 42rem;
  width: calc(100% - 2rem);
  background: var(--panel-contrast);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-strong);
  border: 1px solid var(--panel-border-dark);
  padding: 1.5rem;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(2rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-dialog h2 {
  margin: 0 0 1rem 0;
  color: var(--text-strong);
  font-size: 1.5rem;
}

.model-info {
  margin-bottom: 1rem;
  color: var(--text-strong-opacity);
}

.model-info p {
  margin: 0;
}

.checking-dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 3rem 2rem;
  min-height: 20rem;
}

.checking-dialog h2 {
  margin: 0;
  color: var(--text-strong);
  font-size: 1.5rem;
}

.checking-dialog p {
  margin: 0;
  color: var(--text-strong-opacity);
  font-size: 1rem;
}

.spinner-large {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  border: 0.4rem solid var(--panel-border-strong);
  border-top-color: var(--brand-dark);
  border-right-color: var(--brand-100);
  animation: spinner 1s linear infinite;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.file-item {
  padding: 1rem;
  background: var(--bg-70);
  border-radius: var(--radius-md);
  border: 1px solid var(--muted-border);
  transition: var(--trans-default);
}

.file-item.downloading {
  border-color: var(--brand-100);
  background: var(--bg-80);
}

.file-item.complete,
.file-item.cached {
  border-color: var(--brand-200);
  background: linear-gradient(135deg, var(--brand-50), var(--brand-100));
}

.file-item.error {
  border-color: var(--danger-border);
  background: var(--danger-bg-1);
}

.file-name {
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.5rem;
}

.file-status {
  min-height: 1.5rem;
}

.status-text {
  font-size: 0.875rem;
  color: var(--text-strong-opacity);
}

.status-complete,
.status-cached {
  color: var(--brand-dark);
  font-weight: 600;
}

.status-error {
  color: var(--danger-100);
  font-weight: 600;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-bar {
  width: 100%;
  height: 0.75rem;
  background: var(--progress-bg);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--model-progress-grad);
  border-radius: var(--radius-pill);
  transition: width 0.3s ease;
}

.progress-fill.progress-complete {
  background: linear-gradient(90deg, var(--brand-200), var(--brand-300));
}

.progress-fill.progress-cached {
  background: linear-gradient(90deg, var(--brand-100), var(--brand-200));
}

.progress-bar.indeterminate .progress-fill {
  width: 30%;
  animation: indeterminateProgress 1.5s ease-in-out infinite;
}

@keyframes indeterminateProgress {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(350%);
  }
  100% {
    transform: translateX(-100%);
  }
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-strong);
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.dialog-actions .btn {
  padding: 0.75rem 1.5rem;
}

.dialog-actions .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dialog-actions .btn:disabled:hover {
  transform: none;
  box-shadow: var(--shadow-btn);
}

.storage-info {
  text-align: center;
  color: var(--muted);
}

.storage-info small {
  font-size: 0.8rem;
}

.error-message {
  padding: 0.75rem;
  margin-bottom: 1rem;
  background: var(--danger-bg-2);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  color: var(--danger-100);
  font-weight: 600;
}

/* Responsive adjustments for modal */
@media (max-width: 48rem) {
  .modal-dialog {
    padding: 1rem;
  }

  .modal-dialog h2 {
    font-size: 1.25rem;
  }

  .file-item {
    padding: 0.75rem;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .dialog-actions .btn {
    width: 100%;
  }
}

/* ===== PROFILE PAGE STYLES ===== */

.profile-card {
  background: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 2rem;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--muted-border);
}

.profile-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--muted-border);
}

.profile-avatar {
  flex-shrink: 0;
}

.profile-avatar img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--brand);
  box-shadow: var(--shadow-card);
}

.profile-info h2 {
  margin: 0 0 0.5rem 0;
  color: var(--text-strong);
  font-size: 1.75rem;
}

.profile-email {
  color: var(--muted);
  margin: 0 0 0.5rem 0;
  font-size: 0.95rem;
}

.profile-meta {
  color: var(--note-color);
  margin: 0;
  font-size: 0.9rem;
  font-style: italic;
}

.profile-section {
  margin-bottom: 2rem;
}

.profile-section h3 {
  margin: 0 0 1rem 0;
  color: var(--text-strong);
  font-size: 1.25rem;
  border-bottom: 2px solid var(--brand-50);
  padding-bottom: 0.75rem;
}

.profile-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}

.profile-fields .field {
  background: rgba(255, 255, 255, 0.5);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--muted-border);
}

.profile-fields .field label {
  display: block;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-fields .field p {
  margin: 0;
  color: var(--text-default);
  font-size: 1rem;
}

.security-settings,
.settings-list,
.data-management {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setting-item,
.data-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: var(--radius-md);
  border: 1px solid var(--muted-border);
}

.setting-label,
.data-info {
  flex: 1;
}

.setting-label h4,
.data-info h4 {
  margin: 0 0 0.25rem 0;
  color: var(--text-strong);
  font-size: 1rem;
}

.setting-label .small-note,
.data-info .small-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.setting-item input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--brand);
}

.data-item .btn {
  white-space: nowrap;
}

.btn-danger {
  background-color: var(--danger-200);
  color: var(--white);
  border: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans-default);
  box-shadow: var(--shadow-danger);
}

.btn-danger:hover {
  background-color: var(--danger-300);
  box-shadow: var(--shadow-danger-hover);
  transform: translateY(-0.0625rem);
}

.btn-danger:active {
  background-color: var(--danger-100);
  box-shadow: var(--shadow-danger-active);
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--note-color);
  color: var(--white);
  border: 1px solid var(--panel-border-strong);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans-default);
  box-shadow: var(--shadow-btn);
}

.btn-secondary:hover {
  background-color: var(--brand-dark);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-0.0625rem);
}

.btn-secondary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-btn-active);
}

.activity-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}


.profile-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--muted-border);
  flex-wrap: wrap;
}

/* Responsive adjustments for profile page */
@media (max-width: 48rem) {
  .profile-card {
    padding: 1.5rem;
  }

  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
  }

  .profile-avatar img {
    width: 100px;
    height: 100px;
  }

  .profile-info h2 {
    font-size: 1.5rem;
  }

  .profile-fields {
    grid-template-columns: 1fr;
  }

  .setting-item,
  .data-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .setting-item input[type="checkbox"] {
    align-self: flex-end;
  }

  .activity-info {
    grid-template-columns: 1fr;
  }

  .profile-actions {
    flex-direction: column;
  }

  .profile-actions .btn {
    width: 100%;
  }
}

/* Consent Dialog Styles */
.consent-overlay {
  /* Prevent scrolling when consent dialog is shown */
  backdrop-filter: blur(0.2rem);
}

.consent-dialog {
  max-width: 28rem;
  width: calc(100% - 2rem);
  text-align: center;
}

.consent-dialog h2 {
  margin: 0 0 1.5rem 0;
  color: var(--text-strong);
  font-size: 1.5rem;
}

.consent-content {
  margin-bottom: 1.5rem;
  text-align: left;
}

.consent-content p {
  margin: 0 0 1.5rem 0;
  color: var(--text-strong-opacity);
  line-height: 1.6;
}

.consent-links {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.consent-actions {
  display: flex;
  justify-content: center;
}

/* Responsive adjustments for consent dialog */
@media (max-width: 32rem) {
  .consent-dialog {
    width: calc(100% - 1rem);
    padding: 1.5rem;
  }

  .consent-dialog h2 {
    font-size: 1.25rem;
  }

  .consent-content p {
    font-size: 0.95rem;
  }
}
