/* Google Fonts moved to index.html for performance */

:root {
  --bg: #111212;
  --text: #DFE1E2;
  --dim: #acacac;
  --accent: #cbcbcb;
  --border: #222;
  --input-bg: #303030;
  --font: 'Gowun Batang', serif;

  /* Safe Spaces for Floating UI */
  --safe-top: 140px;
  --safe-bottom: 120px;
}
/* ── Mobile & Responsive ── */
@media (max-width: 600px) {
  .code-copy-btn {
    opacity: 1;
    background: rgba(40, 40, 40, 0.8);
  }

  .container {
    padding-inline: 1.5rem;
  }

  .input-wrapper {
    border-radius: 24px;
  }

  .modal-container {
    padding: 1.5rem;
    max-width: 95%;
  }

  .modal-container.modal-container-popover {
    width: min(520px, calc(100vw - 1.2rem));
    border-radius: 18px;
    padding: 1.1rem;
  }

  .custom-model-row {
    flex-direction: column;
  }

  #btn-save-custom-model {
    width: 100%;
  }

  .model-picker-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 420px);
    max-height: 70vh;
  }

  /* Quick picker popover: keep the panel inside the popover (no full-screen takeover). */
  .modal-container.modal-container-popover .model-picker-panel {
    position: static;
    left: auto;
    top: auto;
    width: 100%;
    transform: none;
    max-height: 62vh;
  }

  .model-picker-list {
    max-height: 50vh;
  }

  .summary-confirm-actions {
    grid-template-columns: 1fr;
  }

  .utility-panel-actions {
    grid-template-columns: 1fr;
  }
}
/* ── Sidebar Menu ── */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-menu {
  position: fixed;
  top: 75px;
  left: 50%;
  width: 90%;
  max-width: 400px;
  height: auto;
  max-height: 80vh;

  padding: 1rem;
  gap: 1rem;

  background: rgba(17, 18, 18, 0.85);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;

  z-index: 999;
  display: flex;
  flex-direction: column;
  min-height: 0;

  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-10px) scale(0.95);
  transition:
    opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0.3s;

  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.sidebar-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0) scale(1);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-content {
  flex-grow: 1;
  overflow-y: auto;
  min-height: 0;
  /* critical: without this, overflow-y can fail inside flex */
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: none;
  /* Hide scrollbar for sidebar */
  -ms-overflow-style: none;
  overscroll-behavior: contain;
}

.sidebar-content::-webkit-scrollbar {
  display: none;
}

.sidebar-brand {
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.sidebar-brand:hover {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}

.sidebar-brand-mark {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-balance {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.4rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: help;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar-balance .balance-icon svg {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

.sidebar-balance.pulse-update {
  animation: balancePulse 1.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.sidebar-brand-name {
  font-size: 1.2rem;
}

.sidebar-btn {
  width: 100%;
  padding: 0.8rem 1.2rem;
  border-radius: 8px;
  border: 1px solid #333;
  background: var(--input-bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar-btn:hover {
  background: #444;
  border-color: var(--accent);
}

.sidebar-btn.primary {
  background: #2a2b2b;
  border-color: #444;
}

.sidebar-btn.danger {
  color: #ff6b6b;
  border-color: #442222;
}

.sidebar-btn.danger:hover {
  background: #442222;
}

.sidebar-btn.tertiary {
  background: transparent;
  border-color: #333;
  margin-top: 0;
}

.sidebar-btn.tertiary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--accent);
}

/* ── Sidebar Sections (Collapsables) ── */
.sidebar-section {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.section-trigger {
  width: 100%;
  padding: 0.8rem 1rem;
  background: transparent;
  border: none;
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Sections are always open by default; keep header non-interactive for now. */
  cursor: default;
  transition: color 0.2s;
}

.section-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  opacity: 0.9;
}

.section-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.section-icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0.35rem;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  /* better tap target on mobile */
}

.section-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.section-icon-btn:active {
  transform: translateY(1px);
}

.section-icon svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: linear-gradient(to top, rgba(17, 18, 18, 0.85), rgba(17, 18, 18, 0.25));
}

.section-trigger:hover {
  color: var(--text);
}

.section-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  padding: 0 0.5rem;
  scrollbar-width: none;
}

.section-content::-webkit-scrollbar {
  display: none;
}

.sidebar-section.active .section-content {
  max-height: 300px;
  /* Limit height per section in popup */
  overflow-y: auto;
  padding-bottom: 0.8rem;
}

/* Default visible list size */
#history-section.active .section-content {
  max-height: 25vh;
}

.sidebar-item-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.history-item {
  flex-grow: 1;
  padding: 0.6rem 0.8rem;
  padding-right: 2.75rem;
  font-size: 0.85rem;
  color: var(--dim);
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.2s;
}

.history-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.item-menu-btn {
  position: absolute;
  right: 0.5rem;
  background: transparent;
  border: none;
  color: var(--dim);
  cursor: pointer;
  /* Bigger tap target for mobile */
  min-width: 40px;
  min-height: 40px;
  padding: 8px;
  border-radius: 4px;
  opacity: 0.7;
  /* Always partially visible */
  transition: all 0.2s;
  touch-action: manipulation;
}

.sidebar-item-wrapper:hover .item-menu-btn {
  opacity: 1;
}

.item-menu-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.empty-text {
  padding: 1rem;
  font-size: 0.8rem;
  color: var(--dim);
}

/* ── Top Bar ── */
.top-bar {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 2rem);
  max-width: 700px;
  height: 2.8rem;
  border-radius: 1.2rem;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: none;
  box-shadow: none;
  display: flex;
  justify-content: space-between;
  /* padding: 0 0rem; */
  z-index: 900;
  transition: transform 0.3s ease, top 0.3s ease, width 0.3s ease;
  align-items: baseline;
  flex-direction: row;
}

/* Layer 1: The Blur */
.top-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: -1;
  border-radius: inherit;
}

/* Layer 2: The Surface (Texture, Gradient, Border) */
.top-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
}

/* Offline Mode - Soft Pastel Red Topbar */
.top-bar.offline::after {
  background: linear-gradient(180deg, rgba(255, 180, 180, 0.25) 0%, rgba(255, 150, 150, 0.15) 100%);
  border: 1px solid rgba(255, 100, 100, 0.2);
  box-shadow:
    0 8px 32px rgba(255, 100, 100, 0.25),
    inset 0 1px 0 0 rgba(255, 200, 200, 0.15);
}

.top-bar.offline {
  animation: topbar-pulse 3s ease-in-out infinite;
}

@keyframes topbar-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.chat-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  position: relative;
  z-index: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.chat-title.visible {
  opacity: 1;
}

.chat-title.pulse-update {
  animation: titlePulse 1.5s ease-out;
}

@keyframes titlePulse {
  0% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    color: var(--text);
  }

  30% {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    color: #fff;
    transform: scale(1.02);
  }

  100% {
    text-shadow: 0 0 0 rgba(255, 255, 255, 0);
    color: var(--text);
    transform: scale(1);
  }
}

/* ── Notifications (Toast) ── */

/* ── Animation Prototypes (User Test) ── */

/* 1. Arctic Glow */
.top-bar.anim-glow {
  animation: navbarGlow 1.5s ease-out;
}

@keyframes navbarGlow {
  0% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.05);
  }

  30% {
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.15), 0 0 50px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
  }

  100% {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.05);
  }
}

/* 2. Energy Shimmer (Simulated via overlay gradient moving) */
.top-bar.anim-shimmer::before {
  /* We use before filter, let's pulse brightness */
  animation: navbarShimmerFilter 0.8s ease-out;
}

.top-bar.anim-shimmer {
  border-color: rgba(255, 255, 255, 0.6);
  transition: border-color 0.2s;
}

@keyframes navbarShimmerFilter {
  0% {
    backdrop-filter: blur(12px) brightness(1);
  }

  50% {
    backdrop-filter: blur(12px) brightness(1.8);
  }

  100% {
    backdrop-filter: blur(12px) brightness(1);
  }
}

/* 3. Glass Breath */
.top-bar.anim-breath {
  animation: navbarBreath 2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes navbarBreath {
  0% {
    background-color: transparent;
    transform: translateX(-50%) scale(1);
  }

  50% {
    background-color: rgba(255, 255, 255, 0.12);
    transform: translateX(-50%) scale(1.02);
    border-color: rgba(255, 255, 255, 0.2);
  }

  100% {
    background-color: transparent;
    transform: translateX(-50%) scale(1);
  }
}

/* 4. ULTIMATE (Combined) */
.top-bar.anim-ultimate {
  animation: navbarUltimate 2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes navbarUltimate {
  0% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px) brightness(1);
  }

  20% {
    /* Fast attack: Glow & Scale */
    transform: translateX(-50%) scale(1.025);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2), 0 0 60px rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
  }

  50% {
    /* Sustain: Shimmer/Brightness peak */
    backdrop-filter: blur(12px) brightness(1.6);
    background-color: rgba(255, 255, 255, 0.08);
  }

  100% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    border-color: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px) brightness(1);
    background-color: transparent;
  }
}



.menu-toggle {
  position: absolute;
  top: 50%;
  left: 0.35rem;
  transform: translateY(-50%);
  z-index: 901;
  background: transparent;
  /* Cleaner look inside pill */
  border: none;
  color: var(--text);
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.5rem;
  transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
  padding-left: 2px;
  /* Optical adjustment (match send button) */
  box-shadow: none;
}

.menu-toggle .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: inherit;
  pointer-events: none;
}

.menu-toggle:hover {
  transform: translateY(-50%) scale(1.05);
  background: transparent !important;
}

.container {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  padding-top: var(--safe-top) !important;
  padding-bottom: var(--safe-bottom) !important;
  scroll-padding-top: var(--safe-top);
  scroll-padding-bottom: var(--safe-bottom);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

html {
  scroll-padding-top: var(--safe-top);
  scroll-padding-bottom: var(--safe-bottom);
}

/* ── Fader Overlays (Behind UI) ── */
.fader-overlay {
  position: fixed;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 850;
  /* Above content (0), below navbar (900) and composer (800+auto) */
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  /* The blur needs a background to "bite", otherwise it just blurs without dimming much. 
     User requested "box hitam opacity 25%". */
}

.fader-overlay.top {
  top: 0;
  height: 6rem;
  /* Covers top bar + extra */
  background: linear-gradient(to bottom, rgba(17, 18, 18, 0.25) 0%, rgba(17, 18, 18, 0.1) 60%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.fader-overlay.bottom {
  bottom: 0;
  height: 8rem;
  /* Covers composer area */
  background: linear-gradient(to top, rgba(17, 18, 18, 0.25) 0%, rgba(17, 18, 18, 0.1) 60%, transparent 100%);
  mask-image: linear-gradient(to top, black 40%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 40%, transparent 100%);
}

/* ── Greeting Placeholder ── */
.greeting-placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.greeting-placeholder.visible {
  display: flex;
  animation: fadeInGreeting 0.8s ease forwards;
  pointer-events: auto;
}

@keyframes fadeInGreeting {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.greeting-placeholder h1 {
  font-size: 3rem;
  line-height: 4rem;
  margin-bottom: 0.5rem;
}

.greeting-placeholder h1 span {
  font-size: 4rem;
}

#greeting-transcendent-line {
  display: inline-block;
}
@font-face {
    font-family: 'Gowun Batang';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../lib/vendor/fonts/gowun-batang-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Gowun Batang';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../lib/vendor/fonts/gowun-batang-700.woff2') format('woff2');
}
/* ── Settings Modal System ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  position: relative;
  background: transparent !important;
  border: none !important;
  border-radius: 20px;
  width: 90%;
  max-width: 500px;
  padding: 2.2rem;
  transform: translateY(30px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  z-index: 1;
}

/* Layer 1: The Blur */
.modal-container::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  z-index: -1;
  border-radius: inherit;
}

/* Layer 2: The Surface & Shadow */
.modal-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.05);
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
}

.modal-container.modal-container-popover {
  position: fixed;
  width: min(460px, calc(100vw - 1.4rem));
  max-width: none;
  padding: 1.25rem;
  border-radius: 18px;
  align-items: stretch;
  transform: none;
}

.modal-container.modal-container-popover .settings-content h2 {
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
}

.modal-container.modal-container-popover .settings-group {
  margin-bottom: 0;
}

.modal-container.modal-container-popover .settings-item {
  margin-bottom: 0.9rem;
}

.modal-container.modal-container-popover .model-picker-trigger {
  display: none;
}

.modal-container.modal-container-popover .model-picker-panel {
  position: static;
  transform: none;
  width: 100%;
  max-height: min(62vh, 520px);
  box-shadow: none;
}

.modal-container.modal-container-modelpicker {
  width: min(560px, calc(100vw - 2rem));
  max-width: none;
  padding: 1.25rem;
  border-radius: 18px;
  align-items: stretch;
}

.modal-container.modal-container-modelpicker .model-picker-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.modal-container.modal-container-modelpicker .model-picker-toolbar .model-picker-refresh-btn {
  width: auto;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  border-radius: 12px;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0;
}

.modal-container.modal-container-modelpicker .model-picker-toolbar .model-picker-refresh-btn:hover {
  transform: scale(1.03);
  border-color: var(--text);
}

.modal-container.modal-container-modelpicker .model-picker-refresh-status {
  font-size: 0.9rem;
  opacity: 0.8;
  white-space: nowrap;
}

.modal-container.modal-container-modelpicker .model-picker-search {
  margin-bottom: 0.75rem;
}

.modal-container.modal-container-modelpicker .model-picker-list {
  max-height: min(58vh, 520px);
  padding-right: 0.2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) rgba(255, 255, 255, 0.04);
}

.modal-container.modal-container-modelpicker .model-picker-list::-webkit-scrollbar {
  width: 10px;
}

.modal-container.modal-container-modelpicker .model-picker-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.modal-container.modal-container-modelpicker .model-picker-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.0);
  background-clip: padding-box;
}

.modal-container.modal-container-modelpicker .model-picker-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
  background-clip: padding-box;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-container>.settings-content,
.modal-container>.modal-header,
.modal-container>.modal-body,
.modal-container>.modal-footer {
  width: 100%;
}

.modal-footer {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.settings-content h2 {
  margin-bottom: 2rem;
  font-size: 1.6rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.settings-group {
  margin-bottom: 1.8rem;
}

.settings-group h3 {
  font-size: 0.85rem;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 1rem;
}

.settings-item {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.settings-item label {
  font-size: 0.95rem;
  font-weight: 700;
}

.settings-select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #444;
  color: var(--text);
  padding: 0.8rem;
  border-radius: 10px;
  font-family: var(--font);
  outline: none;
  font-size: 1rem;
  transition: border-color 0.2s;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  appearance: none;
}

.settings-select:focus {
  border-color: var(--accent);
}

.model-picker {
  position: relative;
  width: 100%;
}

.model-picker-trigger {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #444;
  color: var(--text);
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.98rem;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.model-picker-trigger:hover,
.model-picker.open .model-picker-trigger {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.42);
}

#model-picker-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-picker-caret {
  color: var(--dim);
  font-size: 0.9rem;
}

.model-picker-panel {
  display: none;
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  width: 100%;
  background: rgba(24, 24, 24, 0.96);
  border: 1px solid #3b3b3b;
  border-radius: 12px;
  padding: 0.6rem;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
  z-index: 3800;
}

.model-picker.open .model-picker-panel {
  display: block;
}

.model-picker-search {
  margin-bottom: 0.55rem;
}

.model-quick-panel {
  width: 100%;
}

.model-picker-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.model-picker-option {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  min-width: 0;
}

.model-picker-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.model-picker-option.active {
  border-color: #4f4f4f;
  background: rgba(255, 255, 255, 0.08);
}

.model-option-label {
  display: block;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-option-id {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-picker-empty {
  color: var(--dim);
  font-size: 0.9rem;
  padding: 0.55rem 0.45rem;
}

#btn-refresh-models .refresh-models-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.refresh-models-indicator {
  position: relative;
  width: 1rem;
  height: 1rem;
  flex: 0 0 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.refresh-models-ring {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.68);
  opacity: 0;
}

.refresh-models-dot {
  position: absolute;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #8d8d8d;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#btn-refresh-models[data-state="idle"] .refresh-models-dot {
  background: #8d8d8d;
  box-shadow: none;
}

#btn-refresh-models[data-state="loading"] {
  cursor: wait;
}

#btn-refresh-models[data-state="loading"] .refresh-models-ring {
  opacity: 1;
  animation: refreshSpin 0.85s linear infinite;
}

#btn-refresh-models[data-state="loading"] .refresh-models-dot {
  background: #f2c871;
  animation: refreshDotPulse 1s ease-in-out infinite;
}

#btn-refresh-models[data-state="success"] .refresh-models-dot {
  background: #6ed89a;
  box-shadow: 0 0 0 3px rgba(110, 216, 154, 0.2);
}

#btn-refresh-models[data-state="error"] .refresh-models-dot {
  background: #ff7f7f;
  box-shadow: 0 0 0 3px rgba(255, 127, 127, 0.2);
}

@keyframes refreshSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes refreshDotPulse {
  0% {
    transform: scale(0.95);
    opacity: 0.65;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }

  100% {
    transform: scale(0.95);
    opacity: 0.65;
  }
}

.modal-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid #444;
  color: var(--text);
  padding: 0.8rem 0.9rem;
  border-radius: 10px;
  font-family: var(--font);
  outline: none;
  font-size: 0.98rem;
  transition: border-color 0.2s, background 0.2s;
}

.modal-input:focus {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.42);
}

.modal-btn {
  border: 1px solid #333;
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: var(--input-bg);
  color: var(--text);
  transition: all 0.2s;
}

.modal-btn:hover {
  background: #444;
  border-color: var(--accent);
}

.modal-btn.primary {
  background: #2a2b2b;
  border-color: #444;
}

.modal-btn.danger {
  color: #ff6b6b;
  border-color: #442222;
}

.modal-btn.danger:hover {
  background: #442222;
}

.modal-btn.cancel {
  background: transparent;
}

.custom-model-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

#custom-model-input {
  flex: 1;
  min-width: 0;
}

#btn-save-custom-model {
  min-width: 86px;
  white-space: nowrap;
}

.settings-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.settings-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-close-btn {
  margin-top: 2.5rem;
}

.modal-close-icon {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: none;
  border: none;
  color: var(--dim);
  font-size: 1.8rem;
  cursor: pointer;
  transition: color 0.2s;
  padding: 0.5rem;
  line-height: 1;
}

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

.summary-confirm-panel h2 {
  margin-bottom: 1rem;
  font-size: 1.4rem;
}

.summary-confirm-text {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 0.8rem;
}

.summary-confirm-warning {
  color: #ff8d8d;
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

.summary-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.utility-panel h2 {
  margin-bottom: 0.9rem;
  font-size: 1.35rem;
}

.utility-panel-text {
  color: var(--text);
  line-height: 1.65;
  margin-bottom: 0.85rem;
}

.utility-panel-warning {
  color: #ff8d8d;
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

.utility-panel-status {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.utility-panel-status.success {
  color: #93dfa7;
}

.utility-panel-status.error {
  color: #ff8d8d;
}

.utility-panel-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}

.utility-panel-processing {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--dim);
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.utility-panel-processing .compacting-dots {
  margin-top: 0;
}

.message.assistant.compacting-temp .response-content {
  border-left: 3px solid #555;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.8rem 1rem;
  border-radius: 6px;
}

.message.assistant.compacting-error .response-content {
  border-left: 3px solid #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  padding: 0.8rem 1rem;
  border-radius: 6px;
}

.compacting-subtext {
  color: var(--dim);
  font-size: 0.92rem;
}

.compacting-dots {
  display: inline-flex;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.compacting-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--dim);
  opacity: 0.35;
  animation: compactingPulse 1.1s ease-in-out infinite;
}

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

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

@keyframes compactingPulse {
  0% {
    opacity: 0.25;
    transform: translateY(0);
  }

  50% {
    opacity: 0.95;
    transform: translateY(-1px);
  }

  100% {
    opacity: 0.25;
    transform: translateY(0);
  }
}

/* ── API Settings Styling (90/10) ── */
.sidebar-api-row {
  display: flex;
  width: 100%;
  align-items: center;
  padding: 0.5rem;
  gap: 0.3rem;
}

.sidebar-api-row .modal-input {
  flex: 80;
  min-width: 0;
  height: 38px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  padding: 0 0.75rem;
  border-radius: 0.3rem;
}

.sidebar-api-row .section-icon-btn {
  flex: 20;
  min-width: 0;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.4rem;
}

textarea:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
/* ── Chat Area ── */
#chat-history {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 1.05rem;
  width: 100%;
  flex-grow: 1;
  padding: 0 0.2rem;
}

.message {
  /* Don't rely on animation to become visible (some mobile/UA settings may skip animations). */
  opacity: 1;
  animation: fadein 0.25s ease;
  width: 100%;
  text-align: left;
  /* Ensure left alignment from the start */
  scroll-margin-bottom: calc(var(--composer-offset, 140px) + 12px);
}

.message.user {
  text-align: left;
  color: var(--dim);
}

.message.user .user-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.message.assistant {
  text-align: left;
  color: var(--text);
  white-space: normal;
}

.message .response-content,
.message.assistant .response-content,
.message.assistant p,
.message.assistant li,
.message.assistant blockquote {
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

#chat-history a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.reasoning-content {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message.assistant p {
  margin-bottom: 1em;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
  font-size: 1.1rem;
  color: var(--text);
  font-weight: normal;
}

.message.assistant h1:first-child,
.message.assistant h2:first-child,
.message.assistant h3:first-child {
  margin-top: 0;
}

.message .message-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  opacity: 0.8;
  /* Always visible but subtle */
  transition: opacity 0.2s ease;
  padding: 2px 0;
}

.message .message-actions:hover {
  opacity: 1;
}

.message .action-btn {
  background: transparent;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  position: relative;
}

.message .action-btn.is-disabled,
.message .action-btn:disabled {
  opacity: 0.45;
  cursor: default;
  filter: grayscale(1);
}

.message .action-btn.is-disabled:hover,
.message .action-btn:disabled:hover {
  background: transparent;
  color: var(--dim);
}

.message .action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  /* No transform/movement here */
}

.message .action-metric {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--dim);
  opacity: 0.9;
  user-select: none;
}

.message .action-metric:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.message .action-metric svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message .action-metric-text {
  font-size: 0.85rem;
  line-height: 1;
}

/* Tooltip for Copy */
.copy-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  animation: fadein 0.2s forwards;
  margin-bottom: 4px;
}

.message .action-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}



#chat-history a {
  color: var(--dim);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s;
}

#chat-history a:hover {
  color: var(--text);
}

.message.assistant pre {
  padding: 1.2rem;
  overflow-x: auto;
  border-radius: 8px;
  margin: 1rem 0 1.2rem;
  border: 1px solid #333;
  /* Remove hardcoded background to let hljs theme take over */
  background: #1e1e1e;
  width: 100%;
  box-sizing: border-box;
}

/* ── Scrollbar: Code Blocks + Reasoning (Dark Thin) ── */
.message.assistant pre,
.reasoning-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) rgba(255, 255, 255, 0.04);
}

.message.assistant pre::-webkit-scrollbar,
.reasoning-content::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.message.assistant pre::-webkit-scrollbar-button,
.reasoning-content::-webkit-scrollbar-button {
  display: none;
}

.message.assistant pre::-webkit-scrollbar-track,
.reasoning-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.message.assistant pre::-webkit-scrollbar-thumb,
.reasoning-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0);
  background-clip: padding-box;
}

.message.assistant pre::-webkit-scrollbar-thumb:hover,
.reasoning-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
  background-clip: padding-box;
}

.message.assistant code {
  font-family: monospace;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  /* Subtle background for inline code */
}

/* Ensure pre code doesn't have the inline background */
.message.assistant pre code {
  padding: 0;
  background: transparent !important;
  font-size: 0.85rem;
  display: block;
  padding-bottom: 1rem;
}

/* ── Lists (Bullet & Numbering) ── */
.message.assistant ul,
.message.assistant ol {
  margin-bottom: 1em;
  padding-left: 1.2em;
  list-style-position: outside;
}

.message.assistant ul {
  list-style-type: disc;
}

.message.assistant ol {
  list-style-type: decimal;
}

.message.assistant li {
  margin-bottom: 0.5em;
  padding-left: 0;
}

.message.assistant li::marker {
  font-size: 0.8em;
  color: var(--dim);
}

.message.assistant li:last-child {
  margin-bottom: 0;
}

/* ── Blockquote ── */
.message.assistant blockquote {
  border-left: 3px solid #444;
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--dim);
  font-style: italic;
}

/* ── Reasoning Block (Details/Summary) ── */
.reasoning-details {
  border-left: 2px solid #555;
  margin-bottom: 1.2rem;
  border-radius: 4px;
  overflow: hidden;
}


.reasoning-details summary {
  padding: 0.6rem 1rem;
  font-size: 1rem;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.reasoning-details summary.show-thought {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.reasoning-details summary.show-thought .show-thought-emoji picture,
.reasoning-details summary.show-thought .show-thought-emoji img {
  display: block;
}

.reasoning-details summary.show-thought .show-thought-text {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  text-decoration-color: var(--dim);
}

.reasoning-details summary.show-thought:hover .show-thought-text {
  text-decoration-color: var(--text);
}

.reasoning-details summary:hover {
  color: var(--text);
}

.reasoning-content {
  padding: 1rem;
  font-size: 0.95rem;
  color: var(--dim);
  white-space: pre-wrap;
  line-height: 1.6;
}

/* ── Input Area (Gemini-like) ── */
.input-area {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 0rem 1rem calc(0.9rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  z-index: 910;
  /* Must be > fader-overlay (850) and top-bar (900) to remain sharp */
  pointer-events: none;
  /* Let clicks pass through the empty areas */
}

.input-wrapper {
  max-width: 700px;
  width: 100%;
  transition: all 0.3s ease;
}

.composer-shell {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: auto;
}

.composer-icon-btn {
  background: transparent;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 0.25rem 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  line-height: 1;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.composer-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  transform: translateY(-1px);
}

.composer-icon-btn .icon {
  pointer-events: none;
}

.composer-main {
  min-width: 0;
  border-radius: 18px;
  position: relative;
  /* Reset old glass props */
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
  padding: 0.6rem 0.8rem;
  z-index: 1;
  /* Context for children */
}

/* Layer 1: The Blur */
.composer-main::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 18px;
  z-index: -1;
}

/* Layer 2: The Surface */
.composer-main::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  z-index: 0;
  pointer-events: none;
}

/* Ensure content sits above valid glass layers */
.composer-top,
.composer-bottom {
  position: relative;
  z-index: 1;
}

.composer-top {
  width: 100%;
}

.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.composer-btn {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--input-bg);
  border: 1px solid #444;
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
  padding-left: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 1.5rem;
}

.composer-btn:hover {
  transform: scale(1.05);
  background: #444;
  border-color: var(--text);
}

.composer-btn .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: inherit;
  pointer-events: none;
}

#message-input {
  width: 100%;
  background: transparent;
  border: none !important;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.3rem 0.2rem;
  resize: none;
  outline: none;
  height: auto;
  min-height: 2.2rem;
  /* base; JS controls max lines */
  max-height: none;
  /* handled by JS */
  overflow-y: hidden;
  /* Default hidden */
  line-height: 1.45;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

#message-input::-webkit-scrollbar {
  display: none;
}

.send-btn {
  width: 1.875rem;
  /* 75% of 2.5rem */
  height: 1.875rem;
  background: var(--input-bg);
  /* Match new chat btn */
  border: 1px solid #444;
  /* Match new chat btn */
  border-radius: 50%;
  color: var(--text);
  /* Match new chat btn */
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
  padding-left: 0;
  /* Optical adjustment */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
}

.send-btn[data-state="disabled"] {
  opacity: 0.45;
  filter: grayscale(1);
  cursor: default;
}

.send-btn[data-state="ready"] {
  opacity: 1;
  filter: none;
}

.send-disabled {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(0.85);
}

.send-btn[data-state="disabled"][data-mode="send"] .send-disabled {
  opacity: 1;
  transform: scale(1);
}

.send-btn[data-state="disabled"][data-mode="send"] .send-fire,
.send-btn[data-state="disabled"][data-mode="send"] .send-stop {
  opacity: 0;
  transform: scale(0.85);
}

.send-btn[data-mode="stop"] {
  /* Keep the same “fire” vibe but make it clearly interactive for stopping. */
  opacity: 1;
  filter: none;
}

.send-btn:not([data-state="disabled"]):hover {
  transform: scale(1.05);
  background: #444;
  border-color: var(--text);
}

.send-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: opacity 160ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform, opacity;
}

.send-fire picture,
.send-fire img {
  display: block;
}

.send-btn[data-state="disabled"] .send-fire {
  filter: grayscale(1);
}

.send-stop {
  position: absolute;
  inset: 0;
  font-size: 1.05rem;
  color: var(--text);
  opacity: 0;
  transform: scale(0.75) rotate(-10deg);
}

.send-btn[data-mode="stop"] .send-fire {
  opacity: 0;
  transform: scale(0.75) rotate(10deg);
}

.send-btn[data-mode="stop"] .send-disabled {
  opacity: 0;
  transform: scale(0.85);
}

.send-btn[data-mode="stop"] .send-stop {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.model-text-btn {
  background: transparent;
  border: none;
  color: var(--dim);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  max-width: min(62vw, 460px);
  padding: 0.25rem 0.35rem;
  border-radius: 10px;
  transition: background 0.2s, color 0.2s;
}

.model-text-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.model-text-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.model-text-caret {
  opacity: 0.8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.model-text-caret svg {
  width: 16px;
  height: 16px;
  display: block;
}

.attachment-preview:empty {
  display: none;
}

.edit-preview:empty {
  display: none;
}

.edit-preview {
  padding: 0 0.2rem;
}

.edit-banner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 14px;
  background: rgba(17, 18, 18, 0.75);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: var(--dim);
}

.edit-banner strong {
  color: var(--text);
}

.edit-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.edit-banner-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  cursor: pointer;
}

.edit-banner-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.composer-icon-btn.is-disabled {
  opacity: 0.45;
  cursor: default;
  filter: grayscale(1);
}

.attachment-preview {
  padding: 0 0.2rem;
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  color: var(--dim);
  overflow: hidden;
}

.attachment-thumb {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 auto;
}

.attachment-kind {
  font-size: 0.8rem;
  color: var(--dim);
}

.attachment-name {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.attachment-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.attachment-remove:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.send-btn .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: inherit;
  pointer-events: none;
}

.send-btn:hover {
  transform: scale(1.05);
  background: #444;
  border-color: var(--text);
}

.new-chat-btn:hover {
  transform: scale(1.05);
  background: #444;
  border-color: var(--text);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  background: #222;
  color: #555;
  border-color: #333;
}

.message.user.command-message {
  opacity: 0.6;
  padding-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  border-left: 3px solid var(--accent);
  background: rgba(0, 0, 0, 0.2);
}

@keyframes fadein {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* ── Thinking Animation ── */
.thinking-dots::after {
  content: ' .';
  animation: dots 1.5s steps(5, end) infinite;
}

.thinking-preview {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  border: none;
  background: transparent;
  color: var(--dim);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.2rem 0;
  cursor: pointer;
  text-align: left;
}

.thinking-preview:hover {
  color: var(--text);
}

/* Inline reasoning: summary looks like raw "Processing..." text, details opens on click */
.reasoning-details.thinking-inline {
  border: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin-bottom: 1rem !important;
  box-shadow: none !important;
}

.reasoning-details.thinking-inline summary {
  list-style: none;
  cursor: pointer;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  padding: 0.2rem 0;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 24px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

.reasoning-details.thinking-inline summary.show-thought {
  color: var(--text);
  text-decoration: none;
}

.reasoning-details.thinking-inline summary.show-thought:hover {
  color: var(--text);
  text-decoration: none;
}

.reasoning-details.thinking-inline summary::-webkit-details-marker {
  display: none;
}

.reasoning-details.thinking-inline[open] summary {
  color: var(--text);
}

.reasoning-details.thinking-inline summary:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.reasoning-details.thinking-inline summary.show-thought .show-thought-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}

.reasoning-details.thinking-inline summary.show-thought .show-thought-emoji img,
.reasoning-details.thinking-inline summary.show-thought .show-thought-emoji picture {
  width: 20px;
  height: 20px;
  display: block;
}

.reasoning-details.thinking-inline summary.show-thought .show-thought-text {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--dim);
}

.reasoning-details.thinking-inline summary.show-thought:hover .show-thought-text {
  text-decoration-color: var(--text);
}

.reasoning-details.thinking-inline .reasoning-content {
  margin-top: 0.5rem;
  background: transparent !important;
  border: none !important;
  padding: 0 1.5rem !important;

  /* Tambahkan ini agar posisi garis terkunci di sini */
  position: relative;
  padding-bottom: 0.25rem !important;
  /* Ruang untuk garis di bawah teks */
}

.thinking-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.thinking-emoji img {
  display: block;
}

.thinking-text {
  display: inline;
  white-space: nowrap;
}

/* Status (S:) prefix emoji */
.status-emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.status-emoji img {
  display: block;
}

.status-text {
  display: inline;
}

/* Status-only processing uses inline dots on the status text (not the whole container). */
.status-message .thinking-dots::after {
  content: ' .';
  animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {

  0%,
  20% {
    content: ' .';
  }

  40% {
    content: ' . .';
  }

  60% {
    content: ' . . .';
  }

  80%,
  100% {
    content: ' . . . .';
  }
}

/* ── Code Copy Button ── */
.code-wrapper {
  position: relative;
  width: 100%;
  margin: 1rem 0 1.2rem;
}

.code-wrapper pre {
  margin: 0;
  width: 100%;
}

/* Full-width code blocks even inside list indentation */
.message.assistant li>.code-wrapper,
.message.assistant li>pre {
  margin-left: -1.5em;
  width: calc(100% + 1.5em);
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 5;
  background: rgba(48, 48, 48, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #a8a8a8;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.code-wrapper:hover .code-copy-btn {
  opacity: 1;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.code-copy-btn.copied {
  border-color: #4ade80 !important;
  color: #4ade80 !important;
}

/* ── Notification Toast (Android Glass Style) ── */
.notification-toast-container {
  position: fixed;
  top: 4.5rem;
  /* Below navbar gap */
  top: 4.5rem;
  /* Exactly below the 2.8rem + 1rem navbar */
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: calc(100% - 2rem);
  max-width: 700px;
}

.notification-toast {
  background: rgba(28, 28, 30, 0.85);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  display: flex;
  align-items: center;
  overflow: hidden;
  pointer-events: auto;

  /* Initial state: Hidden & Mini */
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  padding: 0;

  transition:
    opacity 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1),
    max-width 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform, opacity, max-width;
}

.notification-toast.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.notification-toast.is-expanded {
  width: fit-content;
  max-width: 100%;
  /* Limited by container's 700px */
  padding: 0 1.2rem 0 0.2rem;
}

.notification-toast-icon {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.notification-toast-content {
  color: var(--text);
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-10px);
  transition: opacity 0.3s ease 0.2s, transform 0.3s ease 0.2s;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notification-toast.is-expanded .notification-toast-content {
  opacity: 1;
  transform: translateX(0);
}

.notification-toast-content em {
  color: var(--accent);
  font-style: normal;
  font-weight: 500;
  margin-left: 0.2rem;
}
/* ── KaTeX LaTeX Styling ── */
.katex-display {
  margin: 1.5rem 0 !important;
  padding: 0.8rem !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border-radius: 8px !important;
}

.katex-block-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;
  scroll-behavior: auto;
  scroll-snap-type: none;
  padding: 0;
  /* keep scrollbar close to the formula */
  margin: 0.8rem 0 1.2rem;
}

.katex-block-wrapper>.katex-display {
  margin: 0 !important;
  /* Keep visual padding on the formula itself, not on the scroller. */
  padding: 0.85rem 0.9rem !important;
}

.katex {
  font-size: 1.1em !important;
}

.katex-block-wrapper::-webkit-scrollbar {
  height: 10px;
}

.katex-block-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.katex-block-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.katex-block-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

.katex-block-wrapper {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.06);
}

.response-content {
  overflow-wrap: break-word;
}

/* ── Markdown Tables ── */
.response-content table {
  /* Shrink-to-fit when table is small; scroll only when it exceeds the container. */
  width: fit-content;
  max-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.8rem 0 1.2rem;
  font-size: 0.95em;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  overflow: hidden;
  display: block;
  /* enables horizontal scroll on narrow screens */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.response-content table thead {
  background: rgba(255, 255, 255, 0.04);
}

.response-content table tr {
  width: 100%;
}

.response-content table th,
.response-content table td {
  padding: 0.65rem 0.8rem;
  vertical-align: top;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  /* keep columns readable; table scrolls on mobile */
}

.response-content table td {
  white-space: normal;
  /* allow wrapping in body cells */
}

.response-content table th {
  text-align: left;
  color: var(--text);
  font-weight: 600;
}

.response-content table tbody tr:nth-child(odd) {
  background: rgba(255, 255, 255, 0.015);
}

.response-content table tbody tr:last-child td {
  border-bottom: none;
}

.response-content table::-webkit-scrollbar {
  height: 10px;
}

.response-content table::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}

.response-content table::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

.response-content table::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

hr {
  display: none;
}

/* ── Small Tooltips (Buttons) ── */
.tooltip-target {
  position: relative;
}

.tooltip-target::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 5000;
  backdrop-filter: blur(10px);
}

.tooltip-target:hover::after,
.tooltip-target:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

/* ── Top Bar Tooltips (Show Below) ── */
.top-bar .tooltip-target::after {
  bottom: auto !important;
  top: calc(100% + 15px) !important;
  transform: translateX(-50%) translateY(0) !important;
}

.top-bar .tooltip-target:hover::after,
.top-bar .tooltip-target:focus-visible::after {
  opacity: 1 !important;
  transform: translateX(-50%) translateY(5px) !important;
}

@media (pointer: coarse) {

  /* Avoid noisy hover tooltips on mobile; rely on long-press default behaviors. */
  .tooltip-target::after {
    display: none;
  }
}

/* ── Custom Context Menu ── */
.context-menu {
  position: fixed;
  z-index: 4000;
  min-width: 180px;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.6rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
}

.context-menu.context-menu-centered {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
}

.context-menu-item {
  padding: 0.8rem 1.2rem;
  font-size: 0.95rem;
  color: var(--text);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
}

.context-menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.context-menu-item.delete {
  color: #ff5555;
}

.context-menu-item.delete:hover {
  background: rgba(255, 85, 85, 0.15);
}

.settings-select option {
  background-color: var(--bg);
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  /* Prevent layout "drift" when vertical scrollbar appears/disappears (e.g. opening Show Thought). */
  /* Prevent layout "drift" when vertical scrollbar appears/disappears (e.g. opening Show Thought). 
     Using overflow-y: scroll to ensure scrollbar track is always present, preventing 100% width elements from being cut off. */
  overflow-y: scroll;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Form controls often don't inherit font-family by default (mobile browsers love Arial).
   Enforce the project's primary font everywhere. */
button,
input,
textarea,
select {
  font-family: var(--font);
}