* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  color-scheme: dark;
  background-color: var(--bg); 
  color: var(--ink); 
  font-family: var(--font-ui); 
  min-height: 100vh; 
  display: flex; 
  flex-direction: column; 
  position: relative;
  overflow-x: hidden;
}

body.light {
  color-scheme: light;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}





/* Header */
header.top { 
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px var(--space-5); 
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}
header.top .brand { display: flex; align-items: center; gap: var(--space-3); margin-inline-end: auto; }
.logo { width: 28px; height: 28px; object-fit: contain; }
.logo-light { display: none; }
.logo-dark { display: block; }
body.light .logo-dark { display: none; }
body.light .logo-light { display: block; }
header.top h1 { font-family: var(--font-logo); font-size: 1.2rem; font-weight: normal; letter-spacing: 0.5px; }
header.top p.muted { color: color-mix(in srgb, var(--ink) 60%, transparent); font-size: 0.8rem; font-weight: 400; margin-top: 2px; white-space: nowrap; overflow: hidden;}

header.top .controls { display: flex; align-items: center; gap: var(--space-3); }
header.top .controls button.new-chat {
  height: 36px;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 600;
  gap: 6px;
}

/* Buttons & Inputs in header */
.custom-select {
  position: relative;
  user-select: none;
}

.custom-select, button.new-chat, button.access-btn, button.theme-toggle {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 40px;
  padding: 0 16px;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: normal;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: none;
  white-space: nowrap;
}
.custom-select .select-selected:hover, button.stop:hover, button.new-chat:hover, button.access-btn:hover, button.theme-toggle:hover {
  opacity: 0.7;
}
.custom-select .select-selected:active, button.stop:active, button.new-chat:active, button.access-btn:active, button.theme-toggle:active {
  opacity: 0.4;
}
.custom-select .select-selected:disabled, button.stop:disabled, button.new-chat:disabled, button.access-btn:disabled, button.theme-toggle:disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

.select-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 100%;
}

.select-items {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  min-width: 220px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 99;
  padding: 6px;
}

.select-hide {
  display: none;
}

.select-items div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: normal;
  transition: background 0.1s ease;
}

.select-items div::before {
  content: "";
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  background-image: url(/assets/favicon.svg);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.same-as-selected::after {
  content: "✓";
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--deep-gold);
}

.same-as-selected {
  background-color: var(--deep-gold-muted);
  color: var(--ink);
}

.select-items div:hover:not(.same-as-selected) {
  background-color: var(--surface);
  filter: brightness(1.2);
}

body.light .same-as-selected {
  color: var(--ink);
}

button.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
}

/* Main Chat Area */
main.chat { 
  width: 100%; 
  max-width: 48rem; 
  margin: 0 auto; 
  display: flex; 
  flex-direction: column; 
  gap: var(--space-5); 
  padding: calc(var(--space-5) * 2) var(--space-5) 240px; 
  flex-grow: 1; 
}

/* Hero Section */
.hero { display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 10vh; gap: var(--space-4); animation: fadeUp 0.8s ease-out forwards; }
.hero[hidden] { display: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.logo-wrapper { position: relative; display: flex; justify-content: center; align-items: center; margin-bottom: var(--space-3); }
.hero-logo { width: 80px; height: 80px; position: relative; z-index: 1; object-fit: contain; }
.hero .greeting { font-family: var(--font-display); font-size: 2.5rem; font-weight: 700; letter-spacing: -0.02em; text-transform: lowercase; }
.hero .muted { font-family: var(--font-ui); font-size: 1.1rem; color: color-mix(in srgb, var(--ink) 60%, transparent); max-width: 400px; line-height: 1.5; text-transform: lowercase; }

/* Starters */
.starters { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-3); margin-top: var(--space-4); }
.starter { 
  background: color-mix(in srgb, var(--bg) 94%, var(--ink)); 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  height: 40px;
  padding: 0 20px; 
  font-size: 0.9rem; 
  font-family: inherit; 
  font-weight: normal;
  color: var(--ink); 
  cursor: pointer; 
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  box-shadow: none;
  white-space: nowrap;
}
.starter:hover { 
  background: color-mix(in srgb, var(--bg) 88%, var(--ink));
}
.starter:active {
  background: color-mix(in srgb, var(--bg) 82%, var(--ink));
}
.starter:disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}

/* Chat Messages */
.msg-user, .msg-assistant {
  animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
  transform: translateY(10px);
}
@keyframes slideIn { to { opacity: 1; transform: translateY(0); } }

.msg-user { 
  align-self: flex-end; 
  max-width: 75%; 
  background: var(--invert-bg); 
  color: var(--invert-ink); 
  padding: 14px 20px;
  border-radius: var(--radius-card);
  font-size: 16px;
  line-height: 1.5;
  box-shadow: none;
  font-family: var(--font-ui);
}

.msg-assistant { 
  align-self: flex-start;
  font-family: var(--font-ui); 
  font-size: 16px; 
  line-height: 1.7; 
  max-width: 85%; 
  padding: 10px 0;
}
.msg-assistant p { margin-bottom: var(--space-3); white-space: pre-wrap; line-height: 1.7; max-width: 66ch; }
.msg-assistant p:last-child { margin-bottom: 0; }

.byline { color: var(--accent-gap); font-size: 0.75rem; margin-bottom: var(--space-2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; font-family: var(--font-heading); }

.punt {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  margin-top: var(--space-4);
  color: var(--ink);
  max-width: 400px;
  transition: all 0.2s ease;
}
.punt:hover {
  opacity: 0.7;
}
.punt:active {
  opacity: 0.4;
}
.punt:disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}
.punt h3 {
  color: var(--accent-gap);
  margin-bottom: var(--space-2);
  font-family: var(--font-heading);
  font-weight: 400;
}
.punt p {
  font-size: 0.9rem;
  opacity: 0.9;
}

.tb-header strong {
  font-family: var(--font-heading);
  color: var(--accent-gap);
  font-weight: 600;
}

.thinking {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: var(--space-5);
  gap: var(--space-3);
}

.braille-spinner {
  display: inline-flex;
  flex-shrink: 0;
  width: 16px;
}

.braille-spinner::before {
  content: "⠋";
  animation: braille 1s steps(10, end) infinite, spinner-colors 3s ease-in-out infinite;
  display: inline-block;
  width: 16px;
}

@keyframes spinner-colors {
  0% { color: color-mix(in srgb, var(--ink) 55%, transparent); }
  50% { color: #3186FF; }
  100% { color: color-mix(in srgb, var(--ink) 55%, transparent); }
}

@keyframes braille {
  0% { content: "⠋"; }
  10% { content: "⠙"; }
  20% { content: "⠹"; }
  30% { content: "⠸"; }
  40% { content: "⠼"; }
  50% { content: "⠴"; }
  60% { content: "⠦"; }
  70% { content: "⠧"; }
  80% { content: "⠇"; }
  90% { content: "⠏"; }
  100% { content: "⠋"; }
}

.thinking-text {
  font-family: var(--font-shine);
  font-weight: normal;
  font-size: 0.85rem;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  
  background: linear-gradient(
    120deg,
    color-mix(in srgb, var(--ink) 45%, transparent) 0%,
    color-mix(in srgb, var(--ink) 45%, transparent) 35%,
    #3186FF 50%,
    color-mix(in srgb, var(--ink) 45%, transparent) 65%,
    color-mix(in srgb, var(--ink) 45%, transparent) 100%
  );
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: text-shine 4.5s ease-in-out infinite alternate;
}

@keyframes text-shine {
  0% {
    background-position: 200% center;
  }
  100% {
    background-position: -200% center;
  }
}

/* Floating Composer (Lumo / Modern UI style) */
footer.composer {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px var(--space-4) 30px var(--space-4);
  background: var(--bg);
  z-index: 100;
}
.composer-inner {
  width: 100%;
  max-width: 48rem;
  border-radius: var(--radius-card);
  padding: 8px 12px;
}
.composer-inner form {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  padding: var(--space-3);
  transition: all 0.2s ease;
  position: relative;
  min-height: 108px;
}
.composer-inner form:focus-within {
  border-color: color-mix(in srgb, var(--ink) 50%, transparent);
}
.composer-inner form:hover {
  opacity: 1;
}
.composer-inner form:active {
  opacity: 1;
}
.composer-inner form:disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: not-allowed;
}
footer.composer textarea {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-weight: 400;
  font-size: 16px;
  outline: none;
  caret-shape: block;
  caret-color: var(--ink);
  resize: vertical;
  min-height: 24px;
  field-sizing: content;
  flex-grow: 1;
  margin-bottom: var(--space-2, 8px);
}
footer.composer textarea::placeholder { color: color-mix(in srgb, var(--ink) 60%, transparent); }
.composer-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-top: 14px;
  padding-bottom: 2px;
  margin-top: auto;
}

.composer-strip-left,
.composer-strip-right {
  display: flex;
  align-items: center;
  gap: var(--space-2, 8px);
}

/* Overriding Composer Buttons to be Transparent */
footer.composer button:not(.btn-upgrade):not(.menu-option):not(.answer-mode-card) {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  color: var(--ink, #f3f4f6);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
  width: 32px !important;
  height: 32px !important;
}

footer.composer button:not(.btn-upgrade):not(.menu-option):not(.answer-mode-card):hover {
  opacity: 0.8;
  background: transparent !important;
}

footer.composer button:not(.btn-upgrade):not(.menu-option):not(.answer-mode-card):active {
  opacity: 0.5;
}

footer.composer button svg {
  width: 18px;
  height: 18px;
}

/* Model Select Wrapper Override */
#modeSelect {
  position: relative;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  height: 32px !important;
  padding: 0 !important;
  color: var(--ink, #f3f4f6) !important;
  font-family: var(--font-ui, "Nunito", -apple-system, BlinkMacSystemFont, sans-serif) !important;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

#modeSelect .select-selected:hover {
  opacity: 0.8;
}

#modeSelect .select-selected:active {
  opacity: 0.5;
}

#modeSelect .select-selected {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  font-weight: 500;
  font-size: 0.85rem;
}

/* Dropdown Menu Panel */
#modeSelect .select-items {
  position: absolute;
  bottom: calc(100% + 8px);
  right: -8px;
  left: auto;
  width: 280px;
  max-width: calc(100vw - var(--space-4, 16px) * 2);
  background-color: var(--bg, #111827);
  border: 1px solid var(--border, #374151);
  border-radius: var(--radius-md, 12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 200;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: default;
  transition: opacity 0.15s ease, transform 0.15s ease;
  opacity: 1 !important; /* Force solid menu */
}

#modeSelect .select-items.select-hide {
  display: none;
}

/* Menu Headers */
.menu-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.menu-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink, #f3f4f6);
  opacity: 0.7;
  text-transform: none;
  margin-bottom: 2px;
}

/* Radio List of Models */
.menu-options-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.menu-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: background 0.15s ease;
  border: 1px solid transparent;
}

.menu-option:hover {
  background: var(--surface, rgba(255, 255, 255, 0.05));
}

.menu-option.active {
  background: color-mix(in srgb, var(--deep-gold, #BAA56F) 22%, transparent);
  border-color: var(--deep-gold, #BAA56F);
  box-shadow: inset 0 0 0 1px var(--deep-gold, #BAA56F);
}
.menu-option.active .option-title {
  color: var(--deep-gold, #BAA56F);
}

/* Custom Model Icons */
.model-icon-wrapper {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  flex-shrink: 0;
  color: var(--ink, #f3f4f6);
  opacity: 0.5;
  transition: all 0.15s ease;
}

.menu-option.active .model-icon-wrapper {
  opacity: 1;
  color: var(--deep-gold, #BAA56F);
}

/* Details text inside options */
.option-details {
  display: flex;
  flex-direction: column;
  gap: 1px;
  text-align: left;
}

.option-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink, #f3f4f6);
}

.option-desc {
  font-size: 0.68rem;
  color: color-mix(in srgb, var(--ink, #f3f4f6) 60%, transparent);
  line-height: 1.25;
}

/* Divider */
.menu-divider {
  border: none;
  border-top: 1px solid var(--border, #374151);
  margin: 2px 0;
  width: 100%;
}

/* Answer Modes side-by-side cards */
.answer-modes-container {
  display: flex;
  gap: 8px;
}

.answer-mode-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  border: 1px solid var(--border, #374151);
  border-radius: var(--radius-sm, 4px);
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  text-align: left;
  font-family: inherit;
  color: inherit;
  outline: none;
}

.answer-mode-card:hover {
  background: var(--surface, rgba(255, 255, 255, 0.05));
}

.answer-mode-card.active {
  background: color-mix(in srgb, var(--deep-gold, #BAA56F) 22%, transparent);
  border-color: var(--deep-gold, #BAA56F);
  box-shadow: inset 0 0 0 1px var(--deep-gold, #BAA56F);
}
.answer-mode-card.active .mode-title {
  color: var(--deep-gold, #BAA56F);
}

.answer-mode-card.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.answer-mode-card .mode-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink, #f3f4f6);
}

.answer-mode-card .mode-desc {
  font-size: 0.65rem;
  color: color-mix(in srgb, var(--ink, #f3f4f6) 55%, transparent);
  line-height: 1.25;
}



/* sources block */
details.sources { margin: var(--space-3) 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); transition: all 0.2s ease; }
details.sources:hover { opacity: 0.7; }
details.sources:active { opacity: 0.4; }
details.sources:disabled { opacity: 0.4; pointer-events: none; cursor: not-allowed; }
details.sources summary { font-size: 0.85rem; font-weight: 500; color: var(--ink); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.sources summary::-webkit-details-marker { display: none; }
details.sources summary::before { content: "›"; display: inline-block; font-size: 1.2em; transition: transform 0.2s ease; font-family: monospace; }
details.sources[open] summary::before { transform: rotate(90deg); }
details.sources ul { margin-top: 12px; padding-left: 20px; list-style: none; }
details.sources li { font-size: 0.8rem; color: var(--deep-gold); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
details.sources li::before { content: "•"; color: var(--accent-grounded); }

/* reasoning block */
details.reasoning { margin: var(--space-2) 0; border: none; padding: 4px 0; background: transparent; transition: all 0.2s ease; display: flex; flex-direction: column-reverse; }
details.reasoning:first-child { margin-top: 0; }
details.reasoning summary { font-size: 0.85rem; font-weight: 700; color: var(--muted); cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; width: 100%; font-family: var(--font-display); }
details.reasoning summary::-webkit-details-marker { display: none; }
details.reasoning summary::after { content: "›"; display: inline-block; font-size: 1.2em; transition: transform 0.2s ease; font-family: monospace; }
details.reasoning[open] summary::after { transform: rotate(90deg); }
details.reasoning .unified-reasoning-content {
    margin-bottom: 8px;
  max-height: 3.6em;
  overflow-y: auto;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
  font-family: var(--font-ui);
  mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 100%);
  scrollbar-width: none; /* Hide scrollbar in Firefox */
  -ms-overflow-style: none; /* Hide scrollbar in IE/Edge */
}
details.reasoning .unified-reasoning-content::-webkit-scrollbar {
  display: none; /* Hide scrollbar in Chrome/Safari/Webkit */
}
details.reasoning .reasoning-content {
  white-space: pre-wrap;
}

.composer-inner {
  background: var(--surface);
}

@keyframes driftBg {
  0% { transform: translateX(0); }
  50% { transform: translateX(-1.5%); }
  100% { transform: translateX(0); }
}

body.busy .app-background {
  animation: driftBg 15s ease-in-out infinite;
}

@media (prefers-reduced-motion) {
  body.busy .app-background {
    animation: none;
  }
}

/* history sidebar */
.history {
  position: fixed;
  right: 0;
  left: auto;
  top: 0;
  height: 100vh;
  width: 260px;
  background: var(--bg, #111827);
  border-left: 1px solid var(--border, #374151);
  border-right: none;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}

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

.history-head {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  height: 57px; /* Align divider perfectly with header.top */
  padding: 0 16px;
  border-bottom: 1px solid var(--border, #374151);
}

.history-controls,
.history-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2, 8px);
  padding: var(--space-3, 12px) var(--space-4, 16px);
}

.history-controls {
  border-bottom: 1px solid var(--border, #374151);
}

.history-footer {
  margin-top: auto; /* Push footer containing Login and Theme Toggle to bottom of panel */
  border-top: 1px solid var(--border, #374151);
}

.history-controls button,
.history-footer button {
  width: 100%;
  height: 38px;
  border-radius: var(--radius, 8px);
  background: var(--surface, rgba(255, 255, 255, 0.05));
  color: var(--ink, #f3f4f6);
  border: 1px solid var(--border, #374151);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-controls button:hover,
.history-footer button:hover {
  background: color-mix(in srgb, var(--surface, rgba(255, 255, 255, 0.05)) 80%, var(--ink, #f3f4f6) 10%);
}

.history-controls button:active,
.history-footer button:active {
  opacity: 0.7;
}

.history-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 8px;
  gap: 4px;
}

/* Sidebar history item layout with delete button */
.history-item-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.history-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: var(--radius, 8px);
  padding: 8px 32px 8px 10px; /* Leave padding on the right for the delete button */
  font-size: 0.8rem;
  color: var(--ink, #f3f4f6);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item:hover {
  background: color-mix(in srgb, var(--surface, rgba(255, 255, 255, 0.05)), var(--ink, #f3f4f6) 8%);
}

.btn-delete-chat {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent !important;
  border: none !important;
  color: var(--ink, #f3f4f6) !important;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease, background-color 0.2s ease;
  padding: 4px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px !important;
  width: 22px !important;
  height: 22px !important;
}

.history-item-wrapper:hover .btn-delete-chat {
  opacity: 0.5;
}

.btn-delete-chat:hover {
  opacity: 1 !important;
  color: var(--accent-gap, #E45572) !important;
  background: var(--surface, rgba(255, 255, 255, 0.05)) !important;
}

/* For hoverless touch screens, make it always semi-visible */
@media (hover: none) {
  .btn-delete-chat {
    opacity: 0.4;
  }
}

#historyClose, #historyToggle {
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
}

#historyClose:hover, #historyToggle:hover {
  opacity: 0.7;
}

  /* Empty state: hero centred, composer sits in the flow beneath it */
  body.empty main.chat {
    flex: 1 1 auto;
    overflow: visible;
  }

  body.empty .hero {
    margin-block: auto;
  }

  body.empty footer.composer {
    position: static;
  }

  /* Grounding note under the composer */
  .composer-note {
    text-align: center;
    font-size: 0.78rem;
    color: color-mix(in srgb, var(--ink) 55%, transparent);
    margin-top: var(--space-3);
    padding: 0 var(--space-4);
  }

  /* Footer links, empty state only */
  .page-links {
    display: none;
  }

  body.empty .page-links {
    display: flex;
    justify-content: center;
    gap: var(--space-5);
    margin-top: var(--space-5);
    padding-bottom: var(--space-4);
  }  .page-links a {
    font-size: 0.8rem;
    text-decoration: none;
    color: color-mix(in srgb, var(--ink) 55%, transparent);
    transition: color 0.2s ease;
  }

  .page-links a:hover {
    color: var(--ink);
  }

  /* Honeycomb field. Cells light up around the cursor. */
  .glow {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    --mx: 50%;
    --my: 40%;
    opacity: 0;
    transition: opacity 0.9s ease;
  }
  .glow.lit {
    opacity: 1;
  }

  body:not(.empty) .glow {
    display: none !important;
  }

  .glow::before,
  .glow::after {
    content: "";
    position: absolute;
    inset: 0;
    mask-image: url(/assets/honeycomb.svg);
    mask-size: 66px 38.11px;
    mask-repeat: repeat;
    -webkit-mask-image: url(/assets/honeycomb.svg);
    -webkit-mask-size: 66px 38.11px;
    -webkit-mask-repeat: repeat;
  }

  .glow::before {
    background: var(--deep-gold);
    opacity: 0;
  }  .glow::after {
    background: radial-gradient(
      circle 260px at var(--mx) var(--my),
      var(--deep-gold) 0%,
      var(--accent-gap) 65%,
      transparent 100%
    );
    mask-image:
      url(/assets/honeycomb.svg),
      radial-gradient(circle 260px at var(--mx) var(--my), #000 0%, transparent 72%);
    mask-size: 66px 38.11px, 100% 100%;
    mask-repeat: repeat, no-repeat;
    mask-composite: intersect;
    -webkit-mask-image:
      url(/assets/honeycomb.svg),
      radial-gradient(circle 260px at var(--mx) var(--my), #000 0%, transparent 72%);
    -webkit-mask-size: 66px 38.11px, 100% 100%;
    -webkit-mask-repeat: repeat, no-repeat;
    -webkit-mask-composite: source-in;
    opacity: 0.55;
    transition: opacity 0.4s ease;
  }

  body.light .glow::before {
    opacity: 0;
  }

  body.light .glow::after {
    opacity: 0.4;
  }

  .hero .logo-wrapper,
  .hero .hero-logo,
  .hero .greeting,
  .hero .starters {
    position: relative;
    z-index: 1;
  }

  /* No cursor: the field breathes on its own */
  @media (hover: none) {
    .glow {
      opacity: 1;
    }
    .glow::after {
      animation: hive-breathe 7s ease-in-out infinite alternate;
    }
  }  @media (prefers-reduced-motion: reduce) {
    .glow::after {
      transition: none;
      animation: none;
    }
  }

  @keyframes hive-breathe {
    from { opacity: 0.3; }
    to   { opacity: 0.6; }
  }

@media (max-width: 760px) {
  header.top p.muted {
    display: none;
  }
}

@media (max-width: 480px) {
  header.top .controls button.new-chat span {
    display: none;
  }
  header.top .controls button.new-chat {
    padding: 0;
    width: 36px;
    justify-content: center;
    gap: 0;
  }
}

/* Attachments Styling */
.attachments-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 8px);
  padding-bottom: 12px;
  width: 100%;
}

.attachments-container.select-hide {
  display: none;
}

.attachment-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, #374151);
  padding: 4px 8px;
  border-radius: var(--radius-sm, 4px);
  font-size: 0.75rem;
  color: var(--ink, #f3f4f6);
}

.attachment-badge .btn-remove-attachment {
  background: transparent !important;
  border: none !important;
  color: color-mix(in srgb, var(--ink, #f3f4f6) 60%, transparent) !important;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px !important;
  height: 14px !important;
  padding: 0 !important;
  font-size: 0.85rem;
}

.attachment-badge .btn-remove-attachment:hover {
  color: var(--accent-gap, #E45572) !important;
}

/* Sidebar Search Styling */
.search-wrapper {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

.search-wrapper .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink, #f3f4f6);
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.search-wrapper input {
  width: 100%;
  height: 34px;
  border-radius: var(--radius-sm, 6px);
  background: var(--surface, rgba(255, 255, 255, 0.05));
  color: var(--ink, #f3f4f6);
  border: 1px solid var(--border, #374151);
  padding: 0 10px 0 32px;
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.search-wrapper input:focus {
  border-color: color-mix(in srgb, var(--border, #374151) 30%, var(--ink, #f3f4f6) 70%);
  background: color-mix(in srgb, var(--surface, rgba(255, 255, 255, 0.05)) 90%, var(--ink, #f3f4f6) 5%);
}

.search-wrapper input:focus + .search-icon,
.search-wrapper input:not(:placeholder-shown) + .search-icon {
  opacity: 0.85;
}

.compacting-live {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--muted);
  margin: var(--space-5) 0;
}

.compacting-live .bar {
  position: relative;
  height: 4px;
  max-width: 240px;
  width: 100%;
  border-radius: 2px;
  background: var(--surface);
  overflow: hidden;
}

.compacting-live .bar::after {
  content: "";
  position: absolute;
  top: 0;
  height: 100%;
  width: 40%;
  border-radius: 2px;
  background: var(--deep-gold);
  animation: compactSlide 1.1s ease-in-out infinite;
}

@keyframes compactSlide {
  from { left: -40%; }
  to { left: 100%; }
}

:lang(ar) {
  font-family: "Readex Pro", var(--font-ui);
  text-align: right;
}

[dir="rtl"] {
  font-family: "Readex Pro", var(--font-ui);
  text-align: right;
}

footer.composer textarea[dir="rtl"],
footer.composer textarea:dir(rtl) {
  text-align: right;
  font-family: "Readex Pro", var(--font-ui);
}

.fg-langwrap {
  position: relative;
}

.fg-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.fg-langmenu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.fg-langmenu[data-open="false"] {
  display: none;
}

.fg-langmenu[data-open="true"] {
  display: flex;
}

.fg-langopt {
  text-align: left;
  background: none;
  border: none;
  color: var(--ink);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.fg-langopt:hover {
  background: var(--surface);
}

[dir="rtl"] header.top .brand {
  margin-right: 0;
  margin-left: auto;
}

[dir="rtl"] header.top .controls {
  flex-direction: row;
  gap: var(--space-3);
}

[dir="rtl"] header.top .controls button.new-chat {
  flex-direction: row-reverse;
}

