:root {
    color-scheme: dark;
    font-family: Inter, system-ui, sans-serif;
    background: #111827;
    color: #e5e7eb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, #1f2937, #111827 45%);
}

button,
input,
textarea {
    font: inherit;
}

button,
.secondary-button {
    cursor: pointer;
    border: 0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
}

button:hover,
.secondary-button:hover {
    background: #1d4ed8;
}

.secondary-button {
    background: #374151;
}

.secondary-button:hover {
    background: #4b5563;
}

.app {
    min-height: 100vh;
}

.topbar {
    display: flex;
    gap: 2rem;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #374151;
    background: rgba(17, 24, 39, 0.94);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 {
    margin: 0;
    font-size: 1.8rem;
}

.topbar p {
    margin: 0.25rem 0 0;
    color: #9ca3af;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.search-form {
    display: flex;
    gap: 0.75rem;
    width: min(520px, 100%);
}

.search-form input,
.chat-form textarea,
.admin-input {
    width: 100%;
    border: 1px solid #4b5563;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: #111827;
    color: #f9fafb;
}

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: calc(100vh - 98px);
}

.sidebar,
.admin-sidebar {
    padding: 1.5rem;
    border-right: 1px solid #374151;
    background: rgba(17, 24, 39, 0.76);
}

.sidebar h2,
.panel h2 {
    margin-top: 0;
}

.person-list {
    display: grid;
    gap: 0.5rem;
    margin-top: 1rem;
}

.person-button {
    width: 100%;
    text-align: left;
    background: #1f2937;
    border: 1px solid #374151;
}

.person-button:hover,
.person-button.active {
    background: #374151;
    border-color: #60a5fa;
}

.content,
.admin-main {
    padding: 1.5rem;
    display: grid;
    gap: 1.25rem;
    align-content: start;
}

.panel {
    background: rgba(31, 41, 55, 0.9);
    border: 1px solid #374151;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}

.hidden {
    display: none !important;
}

.status {
    min-height: 1.5rem;
    color: #93c5fd;
}

.error-text {
    color: #fca5a5;
}

.muted {
    color: #9ca3af;
}

.data-section {
    margin-top: 1.25rem;
}

.data-section h3 {
    margin-bottom: 0.5rem;
    color: #bfdbfe;
}

.data-section pre,
.chat-answer {
    white-space: pre-wrap;
    word-break: break-word;
    background: #111827;
    border: 1px solid #374151;
    border-radius: 10px;
    padding: 1rem;
    line-height: 1.55;
}

.chat-output {
    display: grid;
    gap: 1rem;
    margin-bottom: 1rem;
}

.chat-form,
.admin-form {
    display: grid;
    gap: 1rem;
}

.search-result {
    padding: 0.85rem 0;
    border-bottom: 1px solid #374151;
}

.search-result:last-child {
    border-bottom: 0;
}

.search-result h3 {
    margin: 0 0 0.3rem;
}

.source-list {
    margin-top: 0.75rem;
    padding-left: 1.25rem;
    color: #9ca3af;
}

.admin-login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.admin-login-card {
    width: min(440px, 100%);
}

.admin-login-card label,
.admin-form label {
    display: grid;
    gap: 0.5rem;
}

.admin-login-card input {
    width: 100%;
    border: 1px solid #4b5563;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    background: #111827;
    color: #f9fafb;
}

.error-message {
    margin: 1rem 0;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #7f1d1d;
    color: #fecaca;
}

.admin-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    min-height: calc(100vh - 98px);
}

.admin-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.admin-sidebar-header h2 {
    margin: 0;
}

.editor-heading {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(
        auto-fit,
        minmax(220px, 1fr)
    );
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

@media (max-width: 800px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .layout,
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .sidebar,
    .admin-sidebar {
        border-right: 0;
        border-bottom: 1px solid #374151;
    }
}
