:root {
    --bg: #0b1220;
    --panel: #0f172a;
    --panel2: #111c33;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --border: rgba(255, 255, 255, 0.08);
    --accent: #60a5fa;
    --accent2: #a78bfa;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    font:
        14px/1.5 system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        Ubuntu,
        Cantarell,
        Noto Sans,
        Arial,
        sans-serif;
    color: var(--text);
    background:
        radial-gradient(
            1200px 800px at 30% 10%,
            rgba(96, 165, 250, 0.12),
            transparent 60%
        ),
        radial-gradient(
            1000px 700px at 80% 20%,
            rgba(167, 139, 250, 0.1),
            transparent 55%
        ),
        var(--bg);
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 18px 16px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    backdrop-filter: blur(8px);
}
.brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.brand .title {
    font-weight: 800;
    letter-spacing: 0.2px;
}
.brand .sub {
    color: var(--muted);
    font-size: 12px;
}

.brandlink {
    color: var(--text);
    text-decoration: none;
}
.brandlink:hover {
    text-decoration: none;
}

.brandlink-with-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.brandlogo {
    height: 24px;
    width: auto;
    display: block;
}
.brandtitle {
    line-height: 1;
}

.topsearch {
    display: flex;
    gap: 10px;
    align-items: center;
}
.topsearch input {
    width: 360px;
}
@media (max-width: 640px) {
    .topsearch {
        width: 100%;
    }
    .topsearch input {
        width: 100%;
    }
}

.layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 14px;
    margin-top: 14px;
}
@media (max-width: 960px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

.card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.card .hdr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.card .hdr h2 {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.card .body {
    padding: 14px;
}

.tabs {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
.tab {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(17, 28, 51, 0.6);
    color: var(--muted);
    cursor: pointer;
}
.tab.active {
    color: var(--text);
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}
.tab:hover {
    border-color: rgba(96, 165, 250, 0.45);
}
.tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.45);
}
.tabpanel.hidden {
    display: none;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(17, 28, 51, 0.6);
    color: var(--muted);
    font-size: 12px;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(17, 28, 51, 0.6);
    color: var(--text);
    cursor: pointer;
}
.btn:hover {
    border-color: rgba(96, 165, 250, 0.45);
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toggle buttons (e.g. decade selectors in Advanced Search) */
.btn.toggle.active {
    color: var(--text);
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
}

/* Simple result list used in Related panel */
.list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.item {
    display: block;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(17, 28, 51, 0.6);
}

.itemlink {
    color: inherit;
    text-decoration: none;
}

.itemlink:hover {
    text-decoration: none;
    border-color: rgba(96, 165, 250, 0.45);
}

.itemlink:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.12);
    border-color: rgba(96, 165, 250, 0.45);
}

.excerpt {
    font-size: 14px;
    line-height: 1.35;
    white-space: pre-wrap;
}

.meta {
    margin-top: 6px;
    font-size: 12px;
}

.refineLink {
    font-size: 12px;
    margin-left: 8px;
    opacity: 0.9;
}

input,
textarea,
select {
    width: 100%;
    padding: 10px 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(17, 28, 51, 0.6);
    color: var(--text);
}

.muted {
    color: var(--muted);
}
.mono {
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.tag {
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(17, 28, 51, 0.6);
    color: var(--muted);
    font-size: 12px;
}

.bodytext {
    white-space: pre-wrap;
}
.md {
    white-space: normal;
}
.md h1 {
    font-size: 20px;
    margin: 12px 0 8px;
}
.md h2 {
    font-size: 16px;
    margin: 12px 0 8px;
}
.md h3 {
    font-size: 14px;
    margin: 12px 0 8px;
    color: var(--text);
}
.md p {
    margin: 8px 0;
}
.md ul,
.md ol {
    margin: 8px 0 8px 18px;
    padding: 0;
}
.md li {
    margin: 4px 0;
}
.md code {
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 8px;
}
.md pre {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    overflow: auto;
}
.md pre code {
    background: transparent;
    border: none;
    padding: 0;
}
.md a {
    color: var(--accent);
}
.md hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 14px 0;
}
.md .tablewrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}
.md table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.md th,
.md td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.md th {
    text-align: left;
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}
.md tr:last-child td {
    border-bottom: none;
}

.error {
    color: #fecaca;
}

/* Download Dialog */
.download-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.download-dialog {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.download-dialog h2 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.download-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.download-info-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.download-label {
    color: var(--muted);
    font-size: 13px;
    min-width: 60px;
    font-weight: 500;
}

.download-value {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
}

.download-warning {
    margin-top: 8px;
    padding: 10px 12px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 10px;
    color: #fbbf24;
    font-size: 13px;
    line-height: 1.4;
}

.download-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.download-btn {
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(17, 28, 51, 0.6);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.download-btn:hover {
    border-color: rgba(96, 165, 250, 0.45);
}

.download-btn-cancel:hover {
    border-color: rgba(156, 163, 175, 0.4);
}

.download-btn-confirm {
    background: rgba(96, 165, 250, 0.15);
    border-color: rgba(96, 165, 250, 0.4);
    color: var(--accent);
}

.download-btn-confirm:hover {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.6);
}

/* Inline images */
.inline-image {
    width: calc(100% - 16px);
    height: auto;
    margin: 0 auto;
    cursor: pointer;
    display: block;
}
