* {
    box-sizing: border-box;
}

body {
    font-family: "Lucida Grande", "Trebuchet MS", "Verdana", "Helvetica", "Arial", sans-serif;
    margin: 0;
    padding: 24px 16px;
    background-color: #f8fafc;
    color: #0f172a;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.search-app {
    max-width: 1120px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
    padding: 28px 32px 36px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-logo {
    height: 25px;
    padding-top: 1px;
    width: auto;
    flex: 0 0 auto;
    display: block;
}

.app-header h1 {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.02;
    color: #0f172a;
}

.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
    margin: 0;
}

.search-form .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}

.search-form .field-query {
    flex: 1 1 520px;
    min-width: 240px;
}

.search-form .field-mode {
    flex: 0 0 180px;
}

.search-form span {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.search-form input,
.search-form select {
    padding: 9px 12px;
    border: 1px solid #cbd5f5;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-form select {
    padding-right: 36px;
    background-color: #ffffff;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #2563eb 50%), linear-gradient(135deg, #2563eb 50%, transparent 50%), linear-gradient(to right, #cbd5f5, #cbd5f5);
    background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px), calc(100% - 2.5em) 50%;
    background-size: 6px 6px, 6px 6px, 1px 2.5em;
    background-repeat: no-repeat;
}

.search-form input:focus,
.search-form select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.search-form button {
    padding: 11px 22px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.search-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.25);
}

.message {
    min-height: 22px;
    font-size: 0.95rem;
    color: #0f172a;
}

.results-panel {
    background: #f9fbff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.15rem;
    color: #0f172a;
}

.panel-summary {
    font-size: 0.85rem;
    color: #64748b;
}

.results-spinner {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.results-spinner:not([hidden]) {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 3px solid rgba(37, 99, 235, 0.25);
    border-top-color: #2563eb;
    animation: spinner-rotate 0.75s linear infinite;
}

@keyframes spinner-rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.result-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.result-card {
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.05);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.result-heading {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.result-heading h3 {
    margin: 0;
    font-size: 1.05rem;
    color: #0f172a;
    word-break: break-word;
}

.result-heading h3 a {
    color: #1d4ed8;
    text-decoration: none;
}

.result-heading h3 a:hover,
.result-heading h3 a:focus {
    text-decoration: underline;
}

.result-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.85rem;
    color: #2563eb;
}

.result-footer a {
    color: inherit;
    text-decoration: none;
}

.result-footer a:hover {
    text-decoration: underline;
}

.result-footer-link {
    flex: 1 1 auto;
    min-width: 0;
}

.result-footer-score {
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
    color: #94a3b8;
}

.content-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.content-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.content-column-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.content-preview {
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
    font-size: 0.92rem;
    line-height: 1.4;
    color: #1e293b;
    white-space: pre-wrap;
}

.content-preview-overflow {
    background: none;
    border: none;
    padding: 0;
    display: block;
    font: inherit;
    margin-top: 6px;
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: right;
    cursor: pointer;
}

.content-preview-overflow:hover {
    color: #64748b;
    text-decoration: underline;
}

.content-preview-overflow:focus {
    color: #64748b;
    text-decoration: underline;
    outline: 2px solid #cbd5f5;
    outline-offset: 2px;
}

body.content-modal-open {
    overflow: hidden;
}

.content-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}

.content-modal-backdrop[hidden] {
    display: none !important;
}

.content-modal {
    width: min(640px, 100%);
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px 0;
}

.content-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.content-modal-close {
    border: 1px solid #cbd5f5;
    background: #eff4ff;
    color: #1d4ed8;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.content-modal-close:hover {
    border-color: #1d4ed8;
}

.content-modal-text {
    margin: 0;
    padding: 16px 20px 20px;
    font-family: inherit;
    font-size: 0.92rem;
    line-height: 1.45;
    color: #1e293b;
    white-space: pre-wrap;
    overflow: auto;
    flex: 1 1 auto;
    background: #f8fafc;
}

.metadata-note {
    font-size: 0.8rem;
    color: #64748b;
}

.summary-columns .content-preview {
    background: #fff8ed;
    border: 1px solid #fed7aa;
    color: #7c2d12;
}

.summary-columns .content-column-title {
    color: #c2410c;
}

.empty {
    margin: 0;
    font-size: 0.9rem;
    font-style: italic;
    color: #94a3b8;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.9rem;
    color: #475569;
}

.pagination button {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #cbd5f5;
    background: #ffffff;
    color: #1d4ed8;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    border-color: #1d4ed8;
}

.pagination button:disabled {
    cursor: default;
    opacity: 0.5;
}

@media (max-width: 900px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .search-app {
        padding: 20px;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form .field,
    .search-form .field-mode,
    .search-form .field-query {
        width: 100%;
        max-width: none;
    }

    .search-form button {
        width: 100%;
    }

    .pagination {
        justify-content: center;
    }
}
