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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f8f9fa;
  color: #212529;
  line-height: 1.6;
}

header {
  background: #fff;
  border-bottom: 2px solid #dee2e6;
  padding: 14px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-spacer { flex: 1; }

.header-actions { flex: 1; display: flex; justify-content: flex-end; }

.ask-btn {
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.ask-btn:hover { background: #a93226; }

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.modal-overlay.active { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  width: 100%;
  max-width: 680px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-title { font-size: 1.2rem; color: #1a1a2e; margin-bottom: 6px; }
.modal-hint  { font-size: 0.83rem; color: #868e96; margin-bottom: 14px; }

.modal-textarea {
  width: 100%;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.modal-textarea:focus { border-color: #e2c07c; }

.modal-actions { display: flex; gap: 10px; margin-top: 12px; }
.modal-submit {
  background: #1a1a2e;
  color: #e2c07c;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.modal-submit:disabled { opacity: 0.6; cursor: default; }
.modal-submit:not(:disabled):hover { background: #2d2d4e; }
.modal-cancel {
  background: none;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  color: #495057;
}
.modal-cancel:hover { background: #f8f9fa; }

.modal-result {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.7;
}
.modal-result--loading { background: #f8f9fa; color: #868e96; font-style: italic; }
.modal-result--error   { background: #fff3f3; color: #c0392b; }
.modal-result--ok      { background: #f8f9fa; color: #212529; }

.site-title {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 14px;
  /* центрирование поверх flex-пространства */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.site-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: #1a1a2e;
  letter-spacing: 1.5px;
}

.site-logo { height: 48px; width: auto; border-radius: 4px; }

main { max-width: 1200px; margin: 0 auto; padding: 32px 16px; }

/* Category bar */
.cat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0;
  margin-bottom: 20px;
  border-bottom: 1px solid #dee2e6;
}
.cat-pill {
  background: #f1f3f5;
  color: #495057;
  border-radius: 16px;
  padding: 4px 14px;
  font-size: 0.82rem;
  text-decoration: none;
  white-space: nowrap;
}
.cat-pill:hover { background: #e2c07c; color: #1a1a2e; }
.cat-pill--active { background: #1a1a2e; color: #e2c07c; }

/* Page layout: content + sidebar */
.page-layout {
  display: flex;
  gap: 32px;
  align-items: flex-start;
}
.catalog { flex: 1; min-width: 0; }

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.sidebar-block { margin-bottom: 24px; }
.sidebar-block h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #868e96;
  margin-bottom: 8px;
}
.sidebar-link {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.85rem;
  color: #495057;
  text-decoration: none;
}
.sidebar-link:hover { color: #e2c07c; }
.sidebar-count {
  color: #adb5bd;
  font-size: 0.78rem;
}
.sidebar-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Author grouping within category */
.author-group { margin-bottom: 24px; }
.author-heading {
  font-size: 0.95rem;
  color: #1a1a2e;
  margin-bottom: 10px;
  padding-left: 4px;
  border-left: 3px solid #e2c07c;
  padding-left: 10px;
}
.author-heading a { color: inherit; text-decoration: none; }
.author-heading a:hover { color: #e2c07c; }

@media (max-width: 768px) {
  .page-layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; }
}

footer {
  text-align: center;
  padding: 24px;
  color: #868e96;
  font-size: 0.85rem;
  margin-top: 48px;
  border-top: 1px solid #dee2e6;
}

/* Catalog */
.category { margin-bottom: 40px; }
.category h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 2px solid #e2c07c;
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.category h2 a { color: inherit; text-decoration: none; }
.category h2 a:hover { color: #e2c07c; }

.article-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid #e9ecef;
  transition: box-shadow 0.15s;
}

.article-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.article-header { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.article-title { font-size: 1rem; font-weight: 600; color: #1a1a2e; text-decoration: none; }
.article-title:hover { color: #e2c07c; }
.article-source { font-size: 0.8rem; color: #868e96; text-decoration: none; }
.article-source:hover { color: #e2c07c; }

.tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  background: #f1f3f5;
  color: #495057;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.78rem;
  text-decoration: none;
}
.tag:hover { background: #e2c07c; color: #1a1a2e; }

details.summary { margin-top: 10px; font-size: 0.9rem; color: #495057; }
details.summary summary {
  cursor: pointer;
  color: #868e96;
  font-size: 0.82rem;
  list-style: none;
}
details.summary summary::-webkit-details-marker { display: none; }
details.summary summary::before { content: "▸ "; }
details[open].summary summary::before { content: "▾ "; }
details.summary p { margin-top: 8px; }
.key-ideas { margin-top: 6px; }

.empty { color: #868e96; text-align: center; margin-top: 60px; font-size: 1.1rem; }

/* Article full */
.article-full { background: #fff; border-radius: 8px; padding: 32px; border: 1px solid #e9ecef; }
.article-full-header { background: transparent; padding: 0; position: static; }
.article-full-header h1 { font-size: 1.6rem; line-height: 1.3; color: #1a1a2e; }
.meta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.category-badge {
  background: #1a1a2e;
  color: #e2c07c;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.article-body { margin-top: 32px; }
.article-body h1, .article-body h2, .article-body h3 { margin: 24px 0 12px; color: #1a1a2e; }
.article-body p { margin-bottom: 16px; }
.article-body img { max-width: 100%; border-radius: 6px; margin: 16px 0; }
.article-body a { color: #e2c07c; }
.article-body blockquote {
  border-left: 3px solid #e2c07c;
  padding-left: 16px;
  color: #495057;
  margin: 16px 0;
}
.article-body code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
}
.article-body pre {
  background: #f1f3f5;
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
}

.back { margin-top: 32px; padding-top: 16px; border-top: 1px solid #e9ecef; }
.back a { color: #868e96; text-decoration: none; font-size: 0.9rem; }
.back a:hover { color: #e2c07c; }

.article-author {
  font-size: 0.75rem;
  color: #fff;
  padding: 2px 10px;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 500;
}

.author-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

.sidebar-author-name {
  display: flex;
  align-items: center;
}
.article-date { font-size: 0.8rem; color: #868e96; }

@media (max-width: 600px) {
  header { padding: 10px 16px; justify-content: space-between; }
  .header-spacer { display: none; }
  .header-actions { flex: 0; }
  .ask-btn { padding: 8px 10px; }
  .ask-btn-text { display: none; }
  .ask-btn::before { content: '💬'; font-size: 1.3rem; }
}
