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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
    font-size: 1rem;
    background: #17171B;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Все заголовки одного размера, но жирные */
h1, h2, h3, h4, h5, h6 {
    font-size: 1rem;
    font-weight: bold;
}

.container {
    max-width: 100%;
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 16px 20px; /* Уменьшено на 20% (было 20px) */
    background: #17171B;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Область для центрированного контента при начальном состоянии */
.center-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: 10px; /* Отступ сверху для фиксированной панели */
}

.container.has-results .center-content {
    display: none;
}

/* Начальное состояние - центрированный поиск */
.container.initial-state .main-layout {
    display: none;
}

.container.initial-state .search-box {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.container.initial-state .header {
    margin-bottom: 40px;
}

/* Состояние после запроса */
.container.has-results {
    padding-top: 64px; /* Отступ для фиксированной панели (уменьшен на 20%) */
}

.container.has-results .main-layout {
    display: flex;
}

.content-wrapper {
    flex: 1;
    display: none;
    flex-direction: column;
    padding: 0;
    min-height: 0;
    position: relative;
}

.container.has-results .content-wrapper {
    display: flex;
}

.content-wrapper .search-box {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #17171B;
    padding: 20px;
    z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 0;
    max-width: 100%;
}

.content-wrapper .main-layout {
    margin-bottom: 100px; /* Отступ снизу для фиксированной поисковой строки */
    padding-bottom: 20px;
}

/* Основной layout с двумя колонками */
.main-layout {
    display: none;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    gap: 0;
    align-items: stretch;
    background: #FFFFFF;
    border-radius: 0;
    padding: 20px;
    width: 100%;
}

/* Левая панель навигации */
.navigation-panel {
    width: 20%;
    min-width: 200px;
    max-width: 50%;
    background: transparent;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Разделитель между панелями */
.resizer {
    width: 4px;
    background: #ddd;
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    transition: background 0.2s;
}

.resizer:hover {
    background: #999;
}

.resizer::before {
    content: '';
    position: absolute;
    left: -2px;
    right: -2px;
    top: 0;
    bottom: 0;
    cursor: col-resize;
}

.resizer.resizing {
    background: #666;
}

.navigation-panel h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: bold;
    border-bottom: 2px solid #000;
    padding-bottom: 8px;
}

.chapter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-item {
    margin-bottom: 8px;
}

.chapter-link {
    color: #000;
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 9px;
    transition: all 0.2s;
    font-size: 1rem;
}

.chapter-link:hover {
    background: #f0f0f0;
    text-decoration: underline;
}

.chapter-link.active {
    background: #000;
    color: white;
}

/* Правая панель контента */
.content-panel {
    flex: 1;
    min-width: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    margin-left: 20px;
}


.top-bar-logo {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
    height: 100%;
    line-height: 1.2;
    vertical-align: middle;
}

.top-bar-logo .logo-number-1 {
    color: #F7D046;
}

.top-bar-logo .logo-number-2 {
    color: #DFA539;
}

.top-bar-logo .logo-text {
    color: #FFFFFF;
}

.top-bar-links {
    display: flex;
    gap: 24px;
    align-items: center;
    height: 100%;
}

.top-bar-button {
    border: none;
    background: transparent;
    color: white;
    font-size: 1rem;
    font-weight: 400;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    text-decoration: none;
}

.top-bar-button:hover {
    color: #999999;
}

.top-bar-button.active {
    color: #F7D046;
}

.header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1rem;
    opacity: 0.9;
}

.search-box {
    background: transparent;
    border-radius: 0;
    padding: 20px 0;
    box-shadow: none;
    margin-bottom: 10px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.container.has-results .search-box {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 15px;
}

#queryInput, #queryInputTop {
    flex: 1;
    padding: 18px 26px;
    font-size: 1rem;
    font-weight: 200; /* Thin weight - лучше поддерживается системными шрифтами */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: 0.01em; /* Небольшой межбуквенный интервал для более тонкого вида */
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50px;
    outline: none;
    transition: all 0.3s;
    background: #1F1F24;
    color: #FFFFFF;
}

#queryInput::placeholder, #queryInputTop::placeholder {
    color: rgba(255,255,255,0.7);
}

#queryInput:focus, #queryInputTop:focus {
    border-color: #F7D046;
    box-shadow: 0 0 0 3px rgba(247, 208, 70, 0.25);
}

.btn {
    padding: 16px 40px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #F7D046;
    color: #000000;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(247, 208, 70, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.loading {
    text-align: center;
    padding: 40px;
    color: white;
    font-size: 1rem;
}

.spinner {
    border: 4px solid rgba(255,255,255,0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.result-container {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    margin-bottom: 20px;
}

.answer {
    margin-bottom: 40px;
}

.answer h2 {
    color: #000000;
    margin-bottom: 15px;
    font-size: 1rem;
    font-weight: bold;
}

.answer-content {
    background: transparent;
    padding: 0;
    border-radius: 0;
    border-left: none;
    line-height: 1.5; /* unified */
    font-size: 1rem;
}

.answer-content strong {
    font-weight: bold;
}

.answer-content h1, .answer-content h2, .answer-content h3, 
.answer-content h4, .answer-content h5, .answer-content h6 {
    font-size: 1rem;
    font-weight: bold;
}

/* Tables in answer content */
.answer-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 1rem;
    background: white;
}

.answer-content table th,
.answer-content table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #ddd;
    vertical-align: top;
    font-size: 1rem;
}

.answer-content table th {
    background: #f5f5f5;
    font-weight: bold;
    color: #000;
}

.answer-content table td {
    background: white;
}

.answer-list {
    margin: 8px 0 8px 20px;
    padding-left: 20px;
    line-height: 1.3;
}

.answer-list li {
    margin: 4px 0;
}

.citations {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid #000000;
}

.citations h3 {
    color: #000;
    margin-bottom: 10px;
    font-size: 1rem;
    font-weight: bold;
}

.citation-card {
    background: transparent;
    border-radius: 0;
    padding: 0 0 24px 0;
    margin-bottom: 24px;
    border-bottom: 1px solid #f0f0f0;
}

.citation-card:last-child {
    border-bottom: none;
}

.citation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.citation-title {
    font-weight: 600;
    color: #000;
    font-size: 1rem;
    flex: 1;
    text-align: left;
}

.citation-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;
    justify-content: flex-end;
}

.page-icon-button {
    border: none;
    background: #000000;
    color: #FFFFFF;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 300;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'SF Pro', system-ui, sans-serif;
    transition: opacity 0.2s;
}

.page-icon-button:hover {
    opacity: 0.8;
}

.page-icon-button:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
}

.citation-quote {
    background: transparent;
    padding: 0;
    border-radius: 0;
    border-left: none;
    margin-top: 10px;
    font-size: 1rem;
    max-width: 75ch; /* approximate words-per-line like PDF */
}

.citation-quote strong {
    font-weight: bold;
}

.citation-quote h1, .citation-quote h2, .citation-quote h3,
.citation-quote h4, .citation-quote h5, .citation-quote h6 {
    font-size: 1rem;
    font-weight: bold;
}

.citation-quote .quote-paragraph {
    line-height: 1.3; /* unified */
    margin: 0 0 8px 0;
    text-align: left;
    word-wrap: break-word;
}

.citation-quote .quote-paragraph:last-child {
    margin-bottom: 0;
}

/* Indented paragraphs (as in PDF) */
.citation-quote .quote-paragraph.indented {
    margin-left: 20px;
    padding-left: 10px;
}

.citation-quote .quote-paragraph.double-indented {
    margin-left: 40px;
    padding-left: 10px;
}

/* Bullet points and lists */
.citation-quote .quote-list {
    margin: 8px 0;
    padding-left: 20px;
    list-style: none;
}

.citation-quote .quote-list-item {
    margin: 4px 0;
    padding-left: 20px;
    position: relative;
    line-height: 1.3; /* unified */
}

.citation-quote .quote-list-item::before {
    content: "•";
    position: absolute;
    left: 0;
    color: #000000;
    font-weight: bold;
    font-size: 1rem;
}

.citation-quote .quote-list-item.indented {
    margin-left: 20px;
}

.citation-quote .quote-list-item.double-indented {
    margin-left: 40px;
}

.citation-quote .quote-numbered-item {
    margin: 4px 0;
    padding-left: 25px;
    position: relative;
    line-height: 1.3; /* unified */
}

.citation-quote .quote-numbered-item::before {
    content: attr(data-number) ".";
    position: absolute;
    left: 0;
    color: #000000;
    font-weight: bold;
}

.citation-quote {
    counter-reset: list-counter;
}

.citation-quote ul.quote-list {
    margin: 8px 0;
    padding-left: 25px;
    list-style: none;
}

.citation-quote ul.quote-list li {
    margin: 4px 0;
    line-height: 1.7;
}

.citation-quote .quote-heading {
    display: block;
    font-size: 1rem;
    font-weight: bold;
    color: #000000; /* black */
    margin: 12px 0 8px 0;
    text-transform: none;
}

.citation-quote .quote-heading:first-child {
    margin-top: 0;
}

/* Markdown tables */
.citation-quote table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 1rem;
    background: white;
}

.citation-quote table th,
.citation-quote table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #ddd;
    vertical-align: top;
    font-size: 1rem;
}

.citation-quote table th {
    background: #f5f5f5;
    font-weight: bold;
    color: #000;
}

/* Убираем различие между th и td - все ячейки одинаковые */
.citation-quote table td {
    background: white;
}

.citation-quote table tr:first-child td {
    background: #f5f5f5;
    font-weight: bold;
}

.citation-quote table tr:nth-child(even) {
    background: #fafafa;
}

.citation-quote table tr:hover {
    background: #f0f0f0;
}

.citation-image {
    margin-top: 15px;
    padding: 10px;
    background: white;
    border-radius: 9px;
    text-align: center;
}

.citation-image img {
    max-width: 100%;
    height: auto;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.3s;
}

.citation-image img:hover {
    transform: scale(1.02);
}

.image-link {
    color: #000000;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    margin-top: 10px;
}

.image-link:hover {
    text-decoration: underline;
}

.error {
    background: #fee;
    color: #c33;
    padding: 20px;
    border-radius: 9px;
    border-left: 4px solid #c33;
    margin-bottom: 20px;
}