:root {
  --bg: #ffffff;
  --bg-elevated: #f0f4f9;
  --bg-input: #f0f4f9;
  --border: #dadce0;
  --text: #1f1f1f;
  --text-dim: #5f6368;
  --accent: #0b57d0;
  --accent-strong: #0b57d0;
  --accent-text: #ffffff;
  --bubble-user: #e9eef6;
  --error: #d93025;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Google Sans", "Segoe UI", Roboto, Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 28px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.top-nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

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

.top-nav-link.active {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--accent-strong);
}

.consultant-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
  font-size: 14px;
}

.consultant-badge-emoji {
  display: inline-flex;
  line-height: 1;
  font-size: 14px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
}

.reset-btn {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.reset-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.chat-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  justify-content: center;
}

.messages {
  width: 100%;
  max-width: 760px;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40vh;
  text-align: center;
}

.empty-title {
  font-size: 56px;
  opacity: 0.5;
}

.empty-subtitle {
  color: var(--text-dim);
  font-size: 15px;
}

.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

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

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.msg-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

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

.msg.model .avatar {
  background: linear-gradient(135deg, #4285f4, #9b72cb, #d96570);
  color: white;
}

.msg.user .avatar {
  background: var(--bubble-user);
  color: var(--text);
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  line-height: 1.55;
  font-size: 15px;
  word-wrap: break-word;
  max-width: 100%;
}

.msg.user .bubble {
  background: var(--bubble-user);
  border-top-right-radius: 4px;
  white-space: pre-wrap;
}

.msg.model .bubble {
  background: transparent;
  padding-left: 0;
  border-top-left-radius: 4px;
}

.bubble > *:first-child { margin-top: 0; }
.bubble > *:last-child { margin-bottom: 0; }

.bubble p {
  margin: 0 0 12px;
}

.bubble ul,
.bubble ol {
  margin: 0 0 12px;
  padding-left: 24px;
}

.bubble li {
  margin: 4px 0;
}

.bubble a {
  color: var(--accent);
  text-decoration: underline;
}

.bubble strong {
  font-weight: 600;
}

.bubble blockquote {
  margin: 0 0 12px;
  padding: 0 0 0 12px;
  border-left: 3px solid var(--border);
  color: var(--text-dim);
}

.bubble code {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.bubble pre {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin: 0 0 12px;
  overflow-x: auto;
}

.bubble pre code {
  background: none !important;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.5;
}

.copy-code-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}

.bubble pre:hover .copy-code-btn {
  opacity: 1;
}

.copy-code-btn:hover {
  background: var(--border);
  color: var(--text);
}

.bubble table {
  display: block;
  overflow-x: auto;
  max-width: 100%;
  border-collapse: collapse;
  margin: 0 0 12px;
}

.bubble th,
.bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  white-space: nowrap;
}

.bubble h1, .bubble h2, .bubble h3 {
  margin: 16px 0 8px;
  font-weight: 600;
}
.bubble h1:first-child, .bubble h2:first-child, .bubble h3:first-child {
  margin-top: 0;
}

.cursor {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--accent);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.thinking-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}

.thinking-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

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

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

@keyframes thinking-bounce {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.error-text {
  color: var(--error);
}

/* Виджет Google Search Suggestions приезжает со своим <style>, но его вырезает
   санитайзер (DOMPurify не пропускает тег style), поэтому стилизуем сами. */
.search-suggestions {
  margin-top: 16px;
  margin-bottom: 24px;
  max-width: 100%;
}

.search-suggestions .container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-suggestions .headline {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.search-suggestions .headline svg {
  width: 16px;
  height: 16px;
}

.search-suggestions .logo-dark {
  display: none;
}

.search-suggestions .gradient-container {
  display: none;
}

.search-suggestions .carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.search-suggestions .carousel::-webkit-scrollbar {
  display: none;
}

.search-suggestions .chip {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}

.search-suggestions .chip:hover {
  background: var(--border);
  border-color: var(--accent-strong);
}

.retry-status {
  color: var(--text-dim);
  font-size: 14px;
  font-style: italic;
}

.retry-status:empty {
  display: none;
}

.composer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px 18px;
}

/* Инструмент генерации картинок */

.aspect-picker {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.aspect-option {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.aspect-option:hover {
  border-color: var(--accent-strong);
  color: var(--text);
}

.aspect-option.active {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-text);
}

.image-bubble {
  padding: 0 0 24px;
  background: transparent;
}

.generated-image {
  display: block;
  max-width: 100%;
  max-height: 480px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.image-actions {
  margin-top: 8px;
}

.image-actions .image-download-btn {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.image-actions .image-download-btn:hover {
  background: var(--border);
}

.composer {
  width: 100%;
  max-width: 760px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 10px 10px 10px 20px;
}

.composer textarea {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 200px;
  padding: 6px 0;
}

.composer textarea::placeholder {
  color: var(--text-dim);
}

.composer button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-strong);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
}

.composer button:disabled {
  opacity: 0.35;
  cursor: default;
}

.composer button:not(:disabled):active {
  transform: scale(0.92);
}

.composer .attach-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.composer .attach-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--accent-strong);
}

.attach-chips {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attach-chips:not(:empty) {
  margin-bottom: 8px;
}

.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 5px 8px 5px 12px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text);
}

.attach-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-chip-remove {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  padding: 0;
}

.attach-chip-remove:hover {
  background: var(--border);
  color: var(--text);
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 5px 10px;
  border-radius: 14px;
  background: var(--bubble-user);
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer.drag-over {
  border-color: var(--accent-strong);
  background: var(--bg-elevated);
}

.hint {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 10px;
  text-align: center;
}

.messages::-webkit-scrollbar,
.chat-wrap::-webkit-scrollbar {
  width: 8px;
}
.chat-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Layout консультанта: сайдбар + чат */

.app-shell {
  flex: 1;
  display: flex;
  min-height: 0;
  width: 100%;
}

.sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.sidebar .brand,
.mobile-menu .brand {
  margin-bottom: 18px;
}

.new-chat-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  margin-bottom: 12px;
  transition: background 0.15s, border-color 0.15s;
}

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

.tools-nav-link,
.consultants-nav-link {
  margin-bottom: 10px;
}

.sidebar-section-title {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 4px 0 8px;
}

.consultant-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
  max-height: 140px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.nav-item.active {
  background: var(--bg-elevated);
  color: var(--text);
  font-weight: 500;
}

.nav-emoji {
  display: inline-flex;
  font-size: 14px;
}

.history-item {
  min-height: 34px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
}

.consultant-nav::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
  width: 6px;
}
.consultant-nav::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.history-item {
  background: none;
  border: none;
  text-align: left;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: inherit;
}

.history-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.history-item.active {
  background: var(--bg-elevated);
  color: var(--text);
}

.history-empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 10px;
}

.main-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.page-intro h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.page-intro p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

/* Главная страница */

.home-wrap {
  flex: 1;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.hero {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 48px;
}

.hero h1 {
  font-size: 34px;
  font-weight: 600;
  margin: 0 0 16px;
  line-height: 1.25;
}

@media (max-width: 600px) {
  .hero h1 {
    font-size: 26px;
    line-height: 1.15;
  }
}

.hero p {
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 8px;
}

.consultant-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

/* Ховер только там, где есть настоящая мышь — на тач-экранах он не нужен
   (палец не "наводит", а тап по ссылке уже сразу переход). */
@media (hover: hover) and (pointer: fine) {
  .consultant-card:hover {
    border-color: var(--accent-strong);
    transform: translateY(-2px);
  }
}

.card-emoji {
  font-size: 32px;
  margin-bottom: 4px;
}

.card-name {
  font-size: 18px;
  font-weight: 600;
}

.card-tagline {
  color: var(--accent);
  font-size: 13px;
}

.card-description {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 12px;
  flex: 1;
}

.card-cta {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 500;
}

.home-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  padding: 20px 24px 32px;
}

/* Мобильная версия: сайдбар превращается в выезжающую панель */

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: 260px;
  z-index: 100;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.mobile-menu.open {
  transform: translateX(0);
}

@media (max-width: 860px) {
  .menu-toggle {
    display: flex;
  }

  .top-nav {
    display: none;
  }

  .topbar {
    justify-content: flex-start;
    gap: 12px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    background: var(--bg);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

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

  .sidebar-backdrop.open {
    display: block;
  }
}

/* Аккаунт и вход по коду */

.account-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-area-mobile {
  display: none;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.account-area-mobile .account-info {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.account-area-mobile .account-email {
  max-width: 100%;
}

.account-area-mobile .login-btn {
  width: 100%;
}

.login-btn {
  background: var(--accent-strong);
  color: var(--accent-text);
  border: none;
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.account-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.account-email {
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.logout-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.auth-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.auth-modal-backdrop.open {
  display: flex;
}

.auth-modal {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px 24px;
}

.auth-modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.auth-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 16px;
  line-height: 1.5;
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.auth-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 12px;
}

.auth-input:focus {
  outline: none;
  border-color: var(--accent-strong);
}

.auth-code-input {
  letter-spacing: 6px;
  font-size: 20px;
  text-align: center;
}

.auth-submit-btn {
  width: 100%;
  background: var(--accent-strong);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.auth-submit-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.auth-link-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  margin-top: 14px;
  cursor: pointer;
  text-align: center;
}

.auth-link-btn:disabled {
  color: var(--text-dim);
  cursor: default;
}

.auth-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 10px;
  min-height: 1em;
}

.auth-hidden {
  display: none;
}

@media (max-width: 860px) {
  .account-area {
    display: none;
  }

  .account-area-mobile {
    display: block;
  }
}

/* vendor/highlight-theme.min.css грузится для тёмной темы (atom-one-dark) —
   перекрываем её цветами под светлый фон, чтобы код в ответах был читаемым. */
.hljs {
  color: var(--text);
  background: none;
}
.hljs-comment, .hljs-quote { color: var(--text-dim); }
.hljs-doctag, .hljs-formula, .hljs-keyword { color: #a626a4; }
.hljs-deletion, .hljs-name, .hljs-section, .hljs-selector-tag, .hljs-subst { color: #e45649; }
.hljs-literal { color: #0184bc; }
.hljs-addition, .hljs-attribute, .hljs-meta .hljs-string, .hljs-regexp, .hljs-string { color: #50a14f; }
.hljs-attr, .hljs-number, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-pseudo, .hljs-template-variable, .hljs-type, .hljs-variable { color: #986801; }
.hljs-bullet, .hljs-link, .hljs-meta, .hljs-selector-id, .hljs-symbol, .hljs-title { color: #4078f2; }
.hljs-built_in, .hljs-class .hljs-title, .hljs-title.class_ { color: #c18401; }

/* --- Блог --- */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 8px;
}

.blog-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}

@media (hover: hover) and (pointer: fine) {
  .blog-card:hover {
    border-color: var(--accent-strong);
    transform: translateY(-2px);
  }
}

.blog-card-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-input);
}

.blog-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 18px 20px 20px;
  gap: 6px;
}

.blog-card-date {
  color: var(--text-dim);
  font-size: 12px;
}

.blog-card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
}

.blog-card-excerpt {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  flex: 1;
}

.blog-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
}

.breadcrumbs {
  max-width: 760px;
  margin: 0 auto 24px;
  font-size: 13px;
  color: var(--text-dim);
}

.breadcrumbs a {
  color: var(--text-dim);
  text-decoration: none;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.article {
  max-width: 760px;
  margin: 0 auto;
}

.article-cover {
  width: 100%;
  border-radius: 16px;
  margin-bottom: 24px;
  display: block;
}

.article-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 12px;
}

.article-date {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 32px;
}

.article-body {
  font-size: 16px;
  line-height: 1.7;
}

.article-body h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 32px 0 12px;
}

.article-body p {
  margin: 0 0 16px;
}

.article-body ul,
.article-body ol {
  margin: 0 0 16px;
  padding-left: 24px;
}

.article-body li {
  margin: 4px 0;
}

.article-body a {
  color: var(--accent);
}

.article-tags {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
}

.related-posts {
  max-width: 760px;
  margin: 56px auto 0;
}

.related-posts h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

/* --- Админка блога --- */

.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

.admin-login-wrap {
  max-width: 360px;
  margin: 96px auto;
  padding: 0 24px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  margin-bottom: 32px;
}

.admin-form label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.admin-form label:not(:first-child) {
  margin-top: 10px;
}

.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="password"],
.admin-form textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}

.admin-form select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
}

.admin-form button {
  margin-top: 8px;
}

.admin-form button,
.btn-primary {
  background: var(--accent-strong);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-start;
}

.admin-flash {
  background: var(--bubble-user);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 14px;
}

.admin-post {
  display: flex;
  gap: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  align-items: flex-start;
}

.admin-post-cover {
  width: 120px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--bg-input);
}

.admin-post-body {
  flex: 1;
  min-width: 0;
}

.admin-post-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.admin-post-meta {
  color: var(--text-dim);
  font-size: 12px;
  margin-bottom: 8px;
}

.admin-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.admin-status.draft {
  background: #fef7e0;
  color: #a15c00;
}

.admin-status.published {
  background: #e6f4ea;
  color: #137333;
}

.admin-post-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn-danger {
  background: none;
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.generate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.generate-overlay[hidden] {
  display: none;
}

.generate-overlay-box {
  background: var(--bg);
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 340px;
}

.generate-overlay-box p {
  margin: 16px 0 0;
  color: var(--text);
}

.generate-overlay-hint {
  font-size: 13px;
  color: var(--text-dim) !important;
  margin-top: 8px !important;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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