:root {
  --bg: #fafbfc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #5AB9FF;
  --accent-light: #E6F4FF;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 10px 40px rgba(15,23,42,0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow-x: hidden; }
body { overflow-x: hidden; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: linear-gradient(180deg, #fafbfc 0%, #f1f5f9 100%);
  background-attachment: fixed;
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-left: 0;
  border-right: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.brand {
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, var(--accent) 0%, #3AA5F0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.actions { display: flex; align-items: center; gap: 10px; }
.upgrade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  color: #0f172a;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 8px 30px rgba(15,23,42,0.10);
}
.upgrade:hover {
  border-color: rgba(90,185,255,0.55);
  box-shadow: 0 12px 40px rgba(90,185,255,0.25);
  transform: translateY(-2px);
}
.upgrade:active {
  transform: translateY(0);
}
.icon-btn { 
  width: 32px; 
  height: 32px; 
  border-radius: 50%; 
  border: none; 
  background: transparent; 
  cursor: pointer; 
  position: relative; 
  transition: background 0.2s ease;
}
.icon-btn:hover {
  background: var(--border);
}
.icon-btn .dot { 
  width: 4px; 
  height: 4px; 
  background: var(--accent); 
  border-radius: 50%; 
  position: absolute; 
  right: 14px; 
  top: 14px; 
}

.hero {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  padding: 24px 16px 80px;
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(90, 185, 255, 0.15) 0%, transparent 70%);
  pointer-events: none;
  animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
  50% { opacity: 0.8; transform: translateX(-50%) scale(1.1); }
}
.title {
  font-size: clamp(28px, 3.5vw, 36px);
  text-align: center;
  margin: 20vh 0 32px;
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: fadeInDown 0.6s ease-out;
}

.search-wrap {
  width: min(860px, 92vw);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 22px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 8px 30px rgba(15,23,42,0.10);
  transition: all 0.3s ease;
  animation: fadeInUp 0.5s ease-out 0.2s backwards;
}
.search-wrap:focus-within {
  border-color: rgba(90,185,255,0.55);
  box-shadow: 0 12px 40px rgba(90,185,255,0.25);
  transform: translateY(-2px);
}
.add-btn {
  width: 28px; 
  height: 28px; 
  border-radius: 50%; 
  border: none; 
  background: transparent; 
  cursor: pointer; 
  font-size: 18px; 
  line-height: 1; 
  color: transparent;
  transition: all 0.2s ease;
  visibility: hidden;
}
.search-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  text-align: left;
  padding-left: 4px;
}
.search-input::placeholder {
  color: #94a3b8;
}
.search-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.controls { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
}
.control-btn { 
  width: 32px; 
  height: 32px; 
  border-radius: 50%; 
  border: 1px solid var(--border); 
  background: #fff; 
  display: grid; 
  place-items: center; 
  cursor: pointer;
  transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  will-change: box-shadow;
}
.control-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
}
.control-btn:active {
  box-shadow: 
    0 0 0 2px rgba(90, 185, 255, 0.3),
    0 4px 12px rgba(90, 185, 255, 0.2);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.control-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, var(--accent-light) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.control-btn:hover::before {
  opacity: 1;
}
.hex { width: 14px; height: 14px; background: #334155; clip-path: polygon(25% 6.7%, 75% 6.7%, 100% 50%, 75% 93.3%, 25% 93.3%, 0 50%); }
.mic { width: 8px; height: 14px; border: 2px solid #334155; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; border-top-left-radius: 8px; border-top-right-radius: 8px; position: relative; }
.mic::after { content: ""; position: absolute; bottom: -4px; left: 50%; width: 10px; height: 2px; background: #334155; transform: translateX(-50%); }
.wave { width: 14px; height: 10px; background: linear-gradient(90deg, #334155 0 30%, transparent 30% 40%, #334155 40% 70%, transparent 70% 80%, #334155 80% 100%); }

.footer { height: 40px; }

/* Glass modal */
.glass-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 1;
  transition: opacity 0.25s ease;
}
.glass-modal {
  position: fixed;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: min(560px, 92vw);
  background: radial-gradient(120% 120% at 10% 10%, rgba(255,255,255,0.35), rgba(255,255,255,0.18) 45%, rgba(255,255,255,0.14));
  border: 1px solid rgba(255,255,255,0.45);
  border-radius: 22px;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow: 0 20px 60px rgba(15,23,42,0.24), inset 0 1px 0 rgba(255,255,255,0.4);
  padding: 20px 18px 18px;
  color: #0f172a;
}
.glass-modal::before {
  content: '';
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  height: 48px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.08));
  opacity: 0.25;
  filter: blur(10px);
  pointer-events: none;
}
.glass-title { margin: 0 0 8px; font-size: 18px; }
.glass-text { margin: 0 0 8px; }
.glass-meta { margin: 8px 0 0; color: #334155; }
.glass-close {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 28px; height: 28px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,0.6);
  background: linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.14));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
}
.glass-close::before, .glass-close::after {
  content: '';
  position: absolute; left: 50%; top: 50%; width: 12px; height: 2px; background: #0f172a; border-radius: 2px; transform-origin: center;
}
.glass-close::before { transform: translate(-50%, -50%) rotate(45deg); }
.glass-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

.hidden { display: none; }

.response {
  width: min(860px, 92vw);
  margin: 6px auto 0;
  padding: 24px 26px;
  color: #0f172a;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  background: rgba(255, 255, 255, 0.30);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(15,23,42,0.12);
  border: 1px solid rgba(255, 255, 255, 0.40);
  animation: slideInFromBottom 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-height: 90px;
  position: relative;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
/* Markdown rendering inside response */
.response p { margin: 0 0 12px; }
.response p:last-child { margin-bottom: 0; }
.response strong { font-weight: 700; }
.response em { font-style: italic; }
.response h1 { margin: 0 0 12px; font-size: 20px; line-height: 1.25; }
.response h2 { margin: 0 0 10px; font-size: 18px; line-height: 1.3; }
.response h3 { margin: 8px 0 8px; font-size: 16px; line-height: 1.35; color: #1f2937; }
.response .md-note {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  border-radius: 10px;
  color: #0f172a;
}
.response .md-table-wrap { width: 100%; overflow-x: auto; margin: 12px 0; }
.response .md-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.response .md-table th, .response .md-table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.response .md-table thead th { background: #f8fafc; font-weight: 600; }
.response .md-ul, .response .md-ol { margin: 8px 0 12px 18px; }
.response .md-ol { list-style: decimal inside; counter-reset: item; }
.response .md-ul { list-style: disc; }
.response .md-code { background: #f1f5f9; padding: 1px 6px; border-radius: 6px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 0.95em; }
.response .md-pre { background: #0b1220; color: #e5e7eb; padding: 12px; border-radius: 10px; overflow: auto; font-size: 13px; }
.response .md-quote { margin: 10px 0; padding: 8px 12px; border-left: 3px solid var(--accent); background: #f8fafc; border-radius: 6px; color: #1f2937; }
.response.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  display: none;
}
.response.error { 
  color: #b91c1c; 
  background: rgba(254, 242, 242, 0.7);
  border-color: rgba(254, 202, 202, 0.9);
}
.response.loading {
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--muted);
}
.response.loading::before { display: none; content: none; }

/* Анімації */
@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInFromBottom {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }
  60% {
    opacity: 1;
    transform: translateY(-5px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 520px) {
  .hero {
    padding: 0;
    min-height: calc(100vh - 56px);
  }
  .title { 
    font-size: 28px; 
    padding: 8vh 12px 0;
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.2;
  }
  .search-wrap { 
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    border-radius: 20px; 
    padding: 10px 12px;
    gap: 8px;
    margin: 8px auto 24px;
  }
  .response {
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    padding: 20px 22px;
    font-size: 14px;
    margin: 6px auto 0;
  }
  /* Hide loading spinner to the left of the text on mobile */
  .response.loading { gap: 0; }
  .response.loading::before { display: none; content: none; }
  .topbar {
    padding: 0 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .brand {
    font-size: 16px;
  }
  .upgrade {
    font-size: 12px;
    padding: 6px 10px;
  }
  .glass-modal {
    width: calc(100vw - 24px);
    left: 12px;
    right: 12px;
    transform: translateY(-50%);
  }
}

/* Extra-small phones: make the title slightly smaller to avoid crowding */
@media (max-width: 380px) {
  .title { 
    font-size: 26px; 
    padding-top: 16vh; 
    margin-bottom: 20px;
  }
}


