@font-face { font-family: 'Thmanyah'; src: url('fonts/thmanyahsans-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Thmanyah'; src: url('fonts/thmanyahsans-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Thmanyah'; src: url('fonts/thmanyahsans-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Thmanyah Display'; src: url('fonts/thmanyahserifdisplay-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }

/* ==========================================================================
1. CSS Variables & Reset
   ========================================================================== */

:root {
  --button-ink: #fff6ee;
  /* Colors - Light Mode */
  --color-primary: #0a0e23;
  --color-primary-hover: #252d50;
  --color-primary-light: #f2d8c2;
  --color-accent: #454f79;
  --color-bg: #fae3d0;
  --color-surface: #fff6ee;
  --color-text-primary: #0a0e23;
  --color-text-secondary: #635a60;
  --color-border: #d9bfac;

  /* Shadows */
  --shadow-subtle: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-medium: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-large: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);

  /* Border Radius */
  --radius-btn: 8px;
  --radius-card: 12px;
  --radius-input: 24px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

[data-theme='dark'] {
  --color-accent: #e4c8b2;
  --button-ink: #0a0e23;
  --color-primary: #fae3d0;
  --color-primary-hover: #fff2e6;
  --color-primary-light: #1e253f;
  --color-bg: #0a0e23;
  --color-surface: #141a32;
  --color-text-primary: #fae3d0;
  --color-text-secondary: #b9bbca;
  --color-border: #343c58;
  --shadow-subtle: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-medium: 0 4px 6px -1px rgba(0,0,0,0.4);
  --shadow-large: 0 10px 15px -3px rgba(0,0,0,0.5);
}

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

html {
  direction: rtl;
  font-family: 'Thmanyah', sans-serif;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color var(--transition-fast);
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: 1rem;
}

ul {
  list-style: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-secondary);
}

/* ==========================================================================
   2. Header
   ========================================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 1000;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

@supports (backdrop-filter: blur(12px)) {
  .site-header {
    background-color: rgba(250, 227, 208, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  [data-theme='dark'] .site-header {
    background-color: rgba(10, 14, 35, 0.92);
  }
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-link {
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.25rem 0;
  position: relative;
}

.nav-link:hover {
  color: var(--color-primary);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: 0;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  transition: width var(--transition-fast);
}

.nav-link:hover::after {
  width: 100%;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--color-text-secondary);
  background-color: transparent;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* زر محادثة جديدة — مخفي افتراضياً */
.new-chat-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-btn);
  color: var(--color-text-primary);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.new-chat-btn.visible {
  display: flex;
}

.new-chat-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
}

/* ==========================================================================
   3. Main Content Area
   ========================================================================== */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 72px; /* Header height */
  position: relative;
}

/* ==========================================================================
   4. Landing Page
   ========================================================================== */

.landing {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn var(--transition-slow);
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  text-align: center;
}

.landing-description {
  color: var(--color-text-secondary);
  max-width: 600px;
  text-align: center;
  line-height: 1.8;
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

/* ==========================================================================
   5. Search Box (Landing & Chat)
   ========================================================================== */

.search-box {
  width: 100%;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 0.375rem;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-subtle);
  transition: all var(--transition-normal);
}

.search-box:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(93, 107, 154, 0.15), var(--shadow-medium);
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 0.5rem;
}

/* textarea input (both landing #search-input and chat #chat-input) */
.search-input-wrapper textarea,
.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 1rem 1.25rem;
  color: var(--color-text-primary);
  outline: none;
  resize: none;
  min-height: 52px;
  line-height: 1.5;
  overflow: hidden;
  font-size: 1rem;
}

.search-input-wrapper textarea::placeholder,
.chat-input-wrapper textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.65;
}

/* زر "اسأل" (Landing) */
.search-btn {
  background-color: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--radius-input) - 4px);
  padding: 0 2rem;
  height: 48px;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.search-btn:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.02);
}

.search-btn:active {
  transform: scale(0.98);
}

/* ==========================================================================
   6. Example Questions
   ========================================================================== */

.examples-section {
  margin-top: 3rem;
  width: 100%;
  animation: slideUp var(--transition-slow) 0.15s both;
}

.examples-title {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  margin-bottom: 1.25rem;
  text-align: center;
}

.examples-title::before,
.examples-title::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--color-border);
}

.examples-title::before {
  margin-inline-end: 1rem;
}

.examples-title::after {
  margin-inline-start: 1rem;
}

.examples-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.example-chip {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  padding: 0.7rem 1.25rem;
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.example-chip:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-subtle);
}

/* ==========================================================================
   7. Chat Interface
   ========================================================================== */

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 100px; /* مساحة لحقل الإدخال */
  animation: fadeIn var(--transition-normal);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  scroll-behavior: smooth;
}

/* ==========================================================================
   8. Messages
   ========================================================================== */

.message {
  display: flex;
  gap: 0.75rem;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.message-user {
  flex-direction: row-reverse;
}

.message-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 85%;
}

.message-user .message-content {
  align-items: flex-end;
}

.message-assistant .message-content {
  align-items: flex-start;
}

.message-bubble {
  padding: 1rem 1.25rem;
  line-height: 1.8;
  font-size: 1rem;
  word-break: break-word;
}

.message-bubble p {
  margin: 0;
}

.message-user .message-bubble {
  background-color: var(--color-primary);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
}

.message-assistant .message-bubble {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
  border-radius: 16px 16px 16px 4px;
}

/* أزرار الإجراءات (نسخ) */
.message-actions {
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity var(--transition-fast);
  padding: 0 0.25rem;
}

.message:hover .message-actions,
.message-actions:focus-within {
  opacity: 1;
}

.action-btn {
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.copy-btn span {
  font-size: 0.8125rem;
}

/* ==========================================================================
   9. Source Card
   ========================================================================== */

.source-card {
  margin-top: 0.75rem;
  background-color: var(--color-primary-light);
  border-right: 3px solid var(--color-primary);
  border-radius: var(--radius-btn);
  padding: 1rem 1.25rem;
  font-size: 0.9375rem;
  max-width: 85%;
}

.source-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.source-label {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
}

.source-title {
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  font-size: 1rem;
  line-height: 1.6;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--color-accent);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition-fast);
  padding: 0.35rem 0;
}

.source-link:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

/* ==========================================================================
   10. Loading State
   ========================================================================== */

.loading-indicator {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.loading-dots {
  display: flex;
  gap: 5px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background-color: var(--color-primary);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
  opacity: 0.6;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

.loading-text {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
}

.loading-bubble {
  background-color: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 16px 16px 16px 4px !important;
  padding: 1rem 1.25rem !important;
}

/* ==========================================================================
   11. Empty State
   ========================================================================== */

.message-bubble.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
  gap: 0.75rem;
}

.empty-icon {
  color: var(--color-text-secondary);
  opacity: 0.4;
  margin-bottom: 0.25rem;
}

.empty-state p {
  color: var(--color-text-secondary);
  margin: 0;
}

.empty-hint {
  font-size: 0.875rem !important;
  opacity: 0.7;
}

/* ==========================================================================
   12. Chat Input (Bottom bar)
   ========================================================================== */

.chat-input-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.5rem 1.25rem;
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  z-index: 100;
  display: flex;
  justify-content: center;
  transition: background-color var(--transition-normal);
}

@supports (backdrop-filter: blur(12px)) {
  .chat-input-container {
    background-color: rgba(250, 227, 208, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  [data-theme='dark'] .chat-input-container {
    background-color: rgba(10, 14, 35, 0.95);
  }
}

.chat-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 800px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 0.25rem;
  box-shadow: var(--shadow-subtle);
  transition: all var(--transition-normal);
  gap: 0.5rem;
}

.chat-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(93, 107, 154, 0.15), var(--shadow-medium);
}

.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.75rem 1rem;
  color: var(--color-text-primary);
  outline: none;
  resize: none;
  min-height: 44px;
  max-height: 150px;
  line-height: 1.5;
  overflow-y: auto;
}

.chat-input-wrapper textarea::placeholder {
  color: var(--color-text-secondary);
  opacity: 0.65;
}

/* زر إرسال (في المحادثة) */
.send-btn {
  background-color: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--radius-input) - 4px);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.send-btn:hover {
  background-color: var(--color-primary-hover);
  transform: scale(1.05);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled,
.send-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   13. Footer
   ========================================================================== */

.site-footer {
  margin-top: auto;
  padding: 2.5rem 1.5rem;
  border-top: 1px solid var(--color-border);
  text-align: center;
  background-color: var(--color-surface);
  transition: background-color var(--transition-normal);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-title {
  color: var(--color-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.footer-description {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  max-width: 400px;
  line-height: 1.6;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.footer-links a {
  color: var(--color-text-secondary);
  font-size: 0.9375rem;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-primary);
}

.footer-divider {
  color: var(--color-border);
  font-size: 0.75rem;
}

.footer-copyright {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  opacity: 0.6;
  margin-top: 0.25rem;
}

/* ==========================================================================
   14. Copy Toast
   ========================================================================== */

.copy-toast {
  position: fixed;
  bottom: 6rem;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background-color: var(--color-primary);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-btn);
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: var(--shadow-medium);
  opacity: 0;
  pointer-events: none;
  z-index: 2000;
  transition: all var(--transition-normal);
}

.copy-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   15. Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 1rem;
}

@supports (backdrop-filter: blur(4px)) {
  .modal-overlay {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background-color: var(--color-surface);
  border-radius: var(--radius-card);
  padding: 2rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-large);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
  position: relative;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-overlay.visible .modal-content {
  transform: translateY(0) scale(1);
}

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

.modal-header h2 {
  font-size: 1.375rem;
  color: var(--color-primary);
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  font-size: 1rem;
}

.modal-close:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
}

.modal-body {
  color: var(--color-text-primary);
  line-height: 1.8;
}

.modal-body p {
  margin-bottom: 1rem;
}

.modal-body h3 {
  color: var(--color-primary);
  font-size: 1.1rem;
  margin: 1.25rem 0 0.75rem;
  font-weight: 600;
}

.modal-body ul {
  padding-right: 1.25rem;
  list-style: disc;
  margin-bottom: 1rem;
}

.modal-body ul li {
  margin-bottom: 0.5rem;
  line-height: 1.7;
}

.modal-body a {
  color: var(--color-accent);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.modal-body a:hover {
  color: var(--color-primary);
  text-decoration: underline;
}

.disclaimer {
  margin-top: 1rem;
}

.disclaimer p {
  border-right: 3px solid #d4a843;
  padding-right: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   16. Animations
   ========================================================================== */

@keyframes fadeIn {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing {
  0%, 80%, 100% {
    transform: scale(0.4);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==========================================================================
   17. Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .landing-title {
    font-size: 2rem;
  }

  .landing-description {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  .search-box {
    border-radius: 16px;
  }

  .search-input-wrapper textarea {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }

  .search-btn {
    padding: 0 1.25rem;
    height: 42px;
    font-size: 0.9375rem;
  }

  .chat-messages {
    padding: 1rem;
  }

  .message-content {
    max-width: 92%;
  }

  .source-card {
    max-width: 92%;
  }

  .message-bubble {
    padding: 0.875rem 1rem;
  }

  .header-content {
    padding: 0.875rem 1rem;
  }

  .header-nav {
    gap: 0.75rem;
  }

  .nav-link {
    font-size: 0.875rem;
  }

  .new-chat-btn span {
    display: none;
  }

  .new-chat-btn {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .landing {
    padding: 1.5rem 1rem;
  }

  .landing-title {
    font-size: 1.75rem;
  }

  .example-chip {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-divider {
    display: none;
  }

  .chat-input-container {
    padding: 0.75rem 0.75rem 1rem;
  }

  .modal-content {
    padding: 1.5rem;
  }
}
/* Warm editorial layout and accessible interaction states. */
.modal-overlay:not(.visible) { visibility: hidden; }
.new-chat-btn:disabled { opacity: .5; cursor: wait; }
body { background-image: radial-gradient(ellipse at 50% 25%, var(--color-primary-light), transparent 65%); }
.header-content { max-width: 1160px; }
.header-logo { gap: 12px; line-height: 1.2; }
.header-logo small { display: block; margin-top: 5px; font-size: 10px; font-weight: 400; color: var(--color-text-secondary); }
.header-logo, .footer-title { font-family: 'Thmanyah Display', 'Thmanyah', serif; font-weight: 400; }
.header-logo { font-size: 36px; line-height: 1.4; }
.theme-toggle { border: 1px solid var(--color-border); }
main { padding-top: 90px; }
.landing { max-width: 900px; padding: 60px 24px 32px; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--color-primary); font-size: 13px; font-weight: 500; letter-spacing: .1px; margin-bottom: 24px; }
.status-dot { width: 7px; height: 7px; background: var(--color-primary); border-radius: 50%; box-shadow: 0 0 0 5px var(--color-primary-light); }
.landing-title { font-family: 'Thmanyah Display', 'Thmanyah', serif; font-weight: 400; font-size: clamp(42px, 6vw, 72px); line-height: 1.35; color: var(--color-text-primary); margin-bottom: 20px; }
.landing-title span { color: var(--color-primary); }
.landing-description { max-width: 480px; font-size: 17px; margin-bottom: 32px; }
.search-box { padding: 10px; border-radius: 20px; box-shadow: 0 12px 35px rgba(65, 53, 32, .06); }
.search-input-wrapper textarea { min-width: 0; overflow-y: auto; }
.search-btn { border-radius: 13px; height: 54px; }
.search-btn, .send-btn, .message-user .message-bubble { color: var(--button-ink); }
.search-btn span { transition: transform .2s ease; }
.search-btn:hover span { transform: translateX(-4px); }
.search-reminder { font-size: 12px; color: var(--color-text-secondary); text-align: center; margin: 13px auto 0; line-height: 1.8; }
.examples-section { margin-top: 30px; width: 100%; }
.examples-title { font-size: 12px; }
.examples-title::before, .examples-title::after { display: none; }
.examples-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.example-chip { text-align: right; border-radius: 12px; padding: 16px 18px; font-size: 14px; background: var(--color-surface); display: flex; justify-content: space-between; gap: 10px; }
.example-chip:hover { transform: translateY(-3px); box-shadow: var(--shadow-subtle); }
.journey { display: flex; gap: 32px; justify-content: center; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--color-border); width: 100%; color: var(--color-text-secondary); font-size: 12px; }
.journey b { font-weight: 400; opacity: .65; margin-left: 7px; }
.site-footer { background: transparent; padding: 24px; }
.message-bubble p { white-space: pre-line; }
.source-card { transition: border-color .2s ease, transform .2s ease; }
.source-card:hover { border-color: var(--color-primary); transform: translateY(-2px); }
.chat-input-container .search-reminder { max-width: 800px; }
.chat-container { padding-bottom: 180px; }
.notice-reminder { padding: 16px; margin: 20px 0; border-right: 3px solid var(--color-primary); background: var(--color-primary-light); border-radius: 8px; font-size: 14px; line-height: 1.9; color: var(--color-text-primary); }
.welcome-notice { position: fixed; inset: 0; margin: auto; width: min(520px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; border: 1px solid var(--color-border); border-radius: 24px; padding: 36px; background: var(--color-surface); color: var(--color-text-primary); box-shadow: 0 24px 90px rgba(0,0,0,.2); }
.welcome-notice[open] { animation: notice-enter .3s ease both; }
.welcome-notice::backdrop { background: rgba(30,26,20,.48); backdrop-filter: blur(7px); }
.notice-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--color-border); border-radius: 50%; color: var(--color-primary); margin-bottom: 22px; font-size: 23px; }
.welcome-notice .eyebrow { margin-bottom: 12px; }
.welcome-notice h2 { font-family: 'Thmanyah Display', 'Thmanyah', serif; font-weight: 400; font-size: 36px; line-height: 1.45; margin-bottom: 18px; }
.welcome-notice p { color: var(--color-text-secondary); font-size: 15px; line-height: 1.9; }
.notice-accept { width: 100%; background: var(--color-primary); color: var(--button-ink); padding: 15px 20px; border-radius: 12px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; transition: background .2s; }
.notice-accept:hover { background: var(--color-primary-hover); }
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 4px; }
@keyframes notice-enter { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .header-nav > .nav-link:first-child { display: none; }
  .header-content { padding: 12px 16px; }
  .header-nav { gap: 12px; }
  .header-logo small { display: none; }
  .brand-mark { width: 33px; height: 37px; font-size: 25px; }
  .landing { padding: 34px 18px 26px; }
  .landing-title { font-size: 44px; }
  .landing-description { font-size: 15px; }
  .search-btn { padding: 0 16px; }
  .search-input-wrapper textarea { padding: 10px 8px; font-size: 15px; }
  .example-chip { padding: 12px; font-size: 12px; }
  .journey { gap: 12px; font-size: 10px; }
  .welcome-notice { padding: 25px; }
  .welcome-notice h2 { font-size: 30px; }
  .chat-input-container { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Balanced search controls across desktop and touch screens. */
.search-box {
  max-width: 800px;
  padding: 8px;
}
.search-input-wrapper {
  min-width: 0;
  align-items: center;
  gap: 8px;
}
.search-input-wrapper textarea {
  min-height: 52px;
  max-height: 160px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.5;
}
.search-btn {
  min-width: 108px;
  min-height: 52px;
  height: 52px;
  padding: 0 20px;
}
.search-btn:disabled,
.send-btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
}
.chat-input-container {
  flex-direction: column;
  align-items: center;
  gap: 0;
}
.chat-input-wrapper {
  min-width: 0;
  align-items: flex-end;
  border-radius: 20px;
  padding: 6px;
}
.chat-input-wrapper textarea {
  min-width: 0;
  min-height: 48px;
  max-height: 160px;
  padding: 11px 14px;
  font-size: 16px;
  line-height: 1.5;
}
.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}
.chat-input-container .search-reminder {
  width: 100%;
  margin: 8px auto 0;
}
@media (max-width: 600px) {
  .search-box { padding: 8px; }
  .search-input-wrapper { flex-direction: row; align-items: center; gap: 6px; }
  .search-input-wrapper textarea { width: 0; min-height: 48px; padding: 12px 8px; }
  .search-btn { width: auto; min-width: 80px; padding: 0 12px; min-height: 48px; height: 48px; }
  .chat-input-container {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }
  .chat-input-wrapper { gap: 6px; }
  .chat-input-wrapper textarea { padding: 11px 10px; }
  .chat-input-container .search-reminder { font-size: 11px; line-height: 1.5; }
}

/* Stable conversation viewport: messages scroll, composer stays in flow. */
body { background-image: none; }
body.chat-mode { height: var(--app-height, 100dvh); min-height: 0; overflow: hidden; }
body.chat-mode .site-footer { display: none; }
body.chat-mode main { padding-top: var(--header-height, 90px); min-height: 0; overflow: hidden; }
body.chat-mode .chat-container { min-height: 0; padding-bottom: 0; overflow: hidden; animation: none; }
.chat-messages { min-height: 0; overscroll-behavior: contain; scrollbar-gutter: stable; padding-bottom: 24px; }
.chat-input-container { position: static; flex: 0 0 auto; width: 100%; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.chat-input-wrapper { max-width: 752px; }
.search-input-wrapper textarea, .chat-input-wrapper textarea { display: block; min-width: 0; max-height: 160px; box-sizing: border-box; }
.message { flex: 0 0 auto; min-width: 0; width: 100%; }
.message-user { flex-direction: row; justify-content: flex-start; }
.message-user .message-bubble { max-width: 85%; min-width: 0; border-radius: 18px 5px 18px 18px; }
.message-content { width: 100%; max-width: 100%; min-width: 0; }
.message-assistant .message-bubble { width: 100%; border-radius: 5px 18px 18px 18px; }
.message-bubble, .source-card { overflow-wrap: anywhere; }
.message-bubble p { white-space: pre-wrap; }
.source-card { width: 100%; max-width: 100%; margin-top: 4px; }
.source-scholar { font-size: 13px; color: var(--color-primary); margin-bottom: 10px; font-weight: 500; }
.source-excerpt { line-height: 1.9; margin-bottom: 10px; }
.copy-toast { color: var(--button-ink); }
@media (max-width: 600px) {
  .chat-messages { padding: 18px 12px; gap: 18px; }
  .message-user .message-bubble { max-width: 92%; }
  .message-bubble { padding: 14px 16px; }
  .message-actions { opacity: 1; }
  .chat-input-container { padding: 8px 12px max(8px, env(safe-area-inset-bottom)); }
  .header-nav { gap: 6px; }
  .chat-input-wrapper textarea { max-height: min(160px, 28dvh); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Keep additional ranked sources available without crowding the answer. */
.more-sources { width: 100%; min-width: 0; margin-top: 8px; }
.more-sources summary { cursor: pointer; width: fit-content; padding: 10px 18px; min-height: 44px; border: 1px solid var(--color-border); border-radius: 12px; color: var(--color-primary); background: var(--color-surface); font-size: 14px; }
.more-sources summary:hover { background: var(--color-primary-light); }
.more-sources summary:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
.more-sources-list { display: grid; gap: 8px; margin-top: 12px; }
.show-less-label, .more-sources[open] .show-more-label { display: none; }
.more-sources[open] .show-less-label { display: inline; }
.account-link { color: var(--color-primary); border: 1px solid var(--color-border); border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: nowrap; }
@media (max-width: 380px) { .header-nav .nav-link { font-size: 12px; } .header-nav { gap: 4px; } .account-link { padding: 8px; } .header-content { padding-inline: 12px; } }
