/* ── Reset & Base ─────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Header ──────────────────────────────── */
header {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    color: #fff;
    padding: 24px 32px;
    position: relative;
}
header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
header .subtitle {
    font-size: 0.82rem;
    opacity: 0.6;
    margin-top: 2px;
}
header .header-link {
    position: absolute;
    right: 32px;
    top: 50%;
    transform: translateY(-50%);
    color: #9bb5e8;
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}
header .header-link:hover { color: #fff; }

/* ── Container ───────────────────────────── */
.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

/* ── Search Card ─────────────────────────── */
.search-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.search-query-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.search-query-row textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #d0d5dd;
    border-radius: 8px;
    font-size: 0.92rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    min-height: 48px;
}
.search-query-row textarea:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.12);
}

#btn-search {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 22px;
    background: linear-gradient(135deg, #1a1a2e, #2a3a5e);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    white-space: nowrap;
}
#btn-search:hover {
    box-shadow: 0 4px 14px rgba(26,26,46,0.3);
    transform: translateY(-1px);
}
#btn-search:active { transform: translateY(0); }
#btn-search svg { flex-shrink: 0; }

/* ── Search Options Row ──────────────────── */
.search-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #eef0f4;
}

.method-toggle {
    display: flex;
    background: #f0f2f6;
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}
.method-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #666;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.method-btn.active {
    background: #fff;
    color: #1a1a2e;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    font-weight: 600;
}
.method-btn:hover:not(.active) { color: #333; }

.reset-btn {
    padding: 5px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #666;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}
.reset-btn:hover {
    background: #f5f5f5;
    color: #333;
}

/* ── Filter Row ──────────────────────────── */
.filter-row {
    display: flex;
    gap: 14px;
    margin-top: 14px;
}
.filter-field { flex: 1; }
.filter-field label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
    letter-spacing: 0.01em;
}
.filter-field input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #d0d5dd;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-field input:focus {
    outline: none;
    border-color: #4a6fa5;
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.12);
}

/* ── Results Area ────────────────────────── */
.results-area {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: #fafbfc;
    border-bottom: 1px solid #eef0f4;
}
.results-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #1a1a2e;
}
.results-method {
    font-size: 0.78rem;
    padding: 3px 10px;
    border-radius: 20px;
    background: #e8edf5;
    color: #4a6fa5;
    font-weight: 500;
}

#results-list { padding: 8px 24px 16px; }

/* ── Result Card ─────────────────────────── */
.result-card {
    border: 1px solid #eef0f4;
    border-radius: 10px;
    padding: 16px 18px;
    margin-top: 12px;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.result-card:hover {
    border-color: #c8d0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}
.result-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1a1a2e;
    line-height: 1.4;
    flex: 1;
}
.result-score {
    flex-shrink: 0;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    color: #2e7d32;
}

.result-meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.result-meta strong {
    color: #555;
    font-weight: 600;
    min-width: 60px;
}
.result-meta a {
    color: #4a6fa5;
    text-decoration: none;
    transition: color 0.15s;
}
.result-meta a:hover { color: #1a1a2e; text-decoration: underline; }

.site-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    background: #eef0f4;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.site-badge.ja { background: #fce4ec; color: #c62828; }
.site-badge.en { background: #e3f2fd; color: #1565c0; }

/* ── Chunks Toggle ───────────────────────── */
.chunks-toggle {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: #4a6fa5;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}
.chunks-toggle:hover { color: #1a1a2e; }
.chunks-toggle .arrow {
    display: inline-block;
    transition: transform 0.25s;
    font-size: 0.7rem;
}
.chunks-toggle.open .arrow { transform: rotate(180deg); }

/* ── Chunk Cards ─────────────────────────── */
.chunks-area {
    margin-top: 10px;
    display: none;
}
.chunks-area.open { display: block; }

.chunk-card {
    background: #f8f9fb;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    transition: background 0.15s;
}
.chunk-card:hover { background: #f0f2f6; }

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.chunk-type {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
}
.chunk-type.press_release { background: #e3f2fd; color: #1565c0; }
.chunk-type.abstract { background: #fff3e0; color: #e65100; }

.chunk-score {
    font-size: 0.75rem;
    color: #999;
    font-family: "SF Mono", "Fira Code", monospace;
}

.chunk-text {
    color: #555;
    white-space: pre-wrap;
    max-height: 90px;
    overflow-y: auto;
    line-height: 1.5;
    font-size: 0.8rem;
}

/* ── Paper Info ───────────────────────────── */
.paper-info {
    background: #fafbfc;
    border: 1px solid #eef0f4;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 8px;
    margin-bottom: 4px;
}
.paper-info .paper-row {
    font-size: 0.8rem;
    color: #666;
    display: flex;
    gap: 6px;
    margin-bottom: 2px;
}
.paper-info .paper-row strong {
    color: #444;
    min-width: 70px;
    font-weight: 600;
}
.paper-info .paper-row a {
    color: #4a6fa5;
    text-decoration: none;
}
.paper-info .paper-row a:hover { text-decoration: underline; }

/* ── Pagination ──────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-top: 1px solid #eef0f4;
    font-size: 0.85rem;
}

.page-info { color: #888; font-size: 0.82rem; }

.page-btns { display: flex; gap: 6px; }
.page-btn {
    padding: 5px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.page-btn:hover:not(:disabled) {
    background: #f5f7fa;
    border-color: #b0b8c8;
}
.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ── Loading & Empty ─────────────────────── */
.loading {
    text-align: center;
    padding: 40px 24px;
    color: #888;
    font-size: 0.9rem;
}
.loading::before {
    content: "";
    display: block;
    width: 28px;
    height: 28px;
    border: 3px solid #e0e4ec;
    border-top-color: #4a6fa5;
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.no-results {
    padding: 40px 24px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

.error-msg {
    padding: 16px 24px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 0.85rem;
    margin: 12px 24px;
}

/* ── Responsive ──────────────────────────── */
@media (max-width: 640px) {
    header { padding: 18px 16px; }
    header .header-link { position: static; margin-top: 6px; display: block; }
    .container { padding: 16px 12px 40px; }
    .search-card { padding: 16px; }
    .search-query-row { flex-direction: column; }
    #btn-search { width: 100%; justify-content: center; padding: 12px; }
    .filter-row { flex-direction: column; }
    .search-options { flex-wrap: wrap; gap: 8px; }
    #results-list { padding: 8px 16px 16px; }
    .result-card { padding: 12px; }
    .pagination { padding: 12px 16px; }
}
