/* Shared base */
:root {
    --primary: #667eea;
    --primary-dark: #5568d3;
    --text: #333;
    --muted: #666;
    --card-radius: 12px;
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.2);
}

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

html {
    font-size: 16px;
}

body {
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 40px 20px;
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    display: flex;
    align-items: center;
    gap: 20px;
}

.back-btn {
    background: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
}

.back-btn:hover {
    transform: translateX(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Shared "card" look */
.tile,
.content,
.images-section,
.filter-section {
    background: white;
    border-radius: var(--card-radius);
    box-shadow: var(--shadow-md);
}

.tile:hover {
    box-shadow: var(--shadow-lg);
}

/* Index page */
.page-index .container {
    max-width: 1200px;
}

.page-index h1 {
    color: white;
    text-align: center;
    margin-bottom: 50px;
    font-size: clamp(2rem, 3.2vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.page-index .tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.page-index .tile {
    padding: 25px;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.page-index .tile:hover {
    transform: translateY(-8px);
}

.page-index .tile h3 {
    font-size: 1.2em;
    margin-bottom: 15px;
    word-wrap: break-word;
}

.page-index .tile .count {
    font-size: 0.9em;
    opacity: 0.7;
    font-weight: 500;
}

.page-index .tile:hover .count {
    opacity: 1;
}

/* Category page */
.page-category .container {
    max-width: 1200px;
}

.page-category .header {
    margin-bottom: 40px;
}

.page-category h1 {
    color: white;
    font-size: clamp(2rem, 3.2vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    flex: 1;
}

.page-category .tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.page-category .tile {
    padding: 25px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.page-category .tile:hover {
    transform: translateY(-8px);
}

.page-category .tile h3 {
    font-size: 1.3em;
    color: var(--text);
    margin-bottom: 5px;
}

.page-category .tile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.85em;
    color: var(--muted);
    margin-bottom: 10px;
}

.page-category .meta-item {
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 4px;
}

.page-category .tile-summary {
    font-size: 0.95em;
    color: #555;
    line-height: 1.5;
    flex: 1;
}

.page-category .scores {
    display: flex;
    gap: 10px;
    font-size: 0.85em;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.page-category .score {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page-category .score-label {
    color: #999;
    font-size: 0.8em;
}

.page-category .score-value {
    font-weight: 600;
    color: var(--primary);
    font-size: 1.1em;
}

.page-category .empty {
    text-align: center;
    color: white;
    padding: 40px;
    font-size: 1.2em;
}

.page-category .filter-section {
    padding: 25px;
    margin-bottom: 30px;
}

.page-category .filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    cursor: pointer;
    user-select: none;
}

.page-category .filter-header h2 {
    font-size: 1.3em;
    color: #333;
}

.page-category .toggle-icon {
    font-size: 1.5em;
    color: var(--primary);
    transition: transform 0.3s ease;
}

.page-category .toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.page-category .filter-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.page-category .filter-content.hidden {
    display: none;
}

.page-category .filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.page-category .filter-label {
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-category .range-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.page-category .range-readout {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.page-category .range-sep {
    margin: 0 6px;
    color: var(--primary);
}

.page-category .double-range {
    position: relative;
    height: 26px;
    margin-top: 8px;
}

.page-category .double-range::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
}

.source-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

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

.page-category .range-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    border-radius: 3px;
    background: var(--primary);
}

.page-category .double-range input[type="range"] {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 26px;
    margin: 0;
    background: transparent;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
}

.page-category
    .double-range
    input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
}

.page-category .double-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    pointer-events: auto;
    border: none;
    margin-top: -6px;
}

.page-category .double-range input[type="range"]::-moz-range-track {
    height: 6px;
    background: transparent;
}

.page-category .double-range input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    pointer-events: auto;
}

.page-category .double-range .range-min {
    z-index: 3;
}

.page-category .double-range .range-max {
    z-index: 4;
}

.page-category .tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
    color: var(--primary);
    font-size: 0.9em;
}

.page-category .tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.page-category .filter-range {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-category .filter-range input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.page-category .filter-range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.page-category .filter-range input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.page-category .range-values {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: #666;
    margin-top: 4px;
}

.page-category .range-value {
    font-weight: 600;
    color: var(--primary);
}

.page-category .filter-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.page-category .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    transition: all 0.3s ease;
}

.page-category .btn-primary {
    background: var(--primary);
    color: white;
}

.page-category .btn-primary:hover {
    background: var(--primary-dark);
}

.page-category .btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.page-category .btn-secondary:hover {
    background: #d0d0d0;
}

.page-category .result-count {
    text-align: center;
    color: white;
    font-size: 1.1em;
    margin-bottom: 20px;
    font-weight: 600;
}

.page-category .tile.hidden {
    display: none;
}

.page-category .keyword-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0;
}

.page-category .keyword-tag {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    background: #f0f0f0;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    user-select: none;
    line-height: 1.3;
}

.page-category .keyword-tag:hover {
    background: #e0e0ff;
    border-color: var(--primary);
}

.page-category .keyword-tag.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.page-category .keyword-tag .keyword-count {
    font-size: 0.8em;
    opacity: 0.7;
    margin-left: 4px;
}

/* Detail page */
.page-detail .container {
    max-width: 1200px;
}

.page-detail .header {
    margin-bottom: 40px;
}

.page-detail .header h1 {
    color: white;
    font-size: clamp(2rem, 3.2vw, 2.8rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    flex: 1;
}

.page-detail .content {
    padding: 32px;
    margin-bottom: 30px;
}

.page-detail .meta-header {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.page-detail .meta-item {
    background: #f8f9fa;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.95em;
}

.page-detail .meta-label {
    font-weight: 600;
    color: var(--primary);
}

.page-detail .scores-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.page-detail .score-box {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.page-detail .score-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 8px;
}

.page-detail .score-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--primary);
}

.page-detail .section {
    margin-bottom: 30px;
}

.page-detail .section h2 {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
}

.page-detail .section p {
    line-height: 1.8;
    color: #555;
    margin-bottom: 15px;
}

.page-detail .list {
    list-style: none;
    padding: 0;
}

.page-detail .list li {
    padding: 8px 0 8px 25px;
    position: relative;
    color: #555;
}

.page-detail .list li:before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2em;
}

.page-detail .images-section {
    padding: 32px;
}

.page-detail .images-section h2 {
    font-size: 1.8em;
    color: #333;
    margin-bottom: 25px;
    text-align: center;
}

.page-detail .images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.page-detail .image-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
    transition: transform 0.3s ease;
}

.page-detail .image-card:hover {
    transform: scale(1.05);
}

.page-detail .image-card img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    display: block;
}

.page-detail .image-name {
    text-align: center;
    font-size: 0.85em;
    color: #666;
    margin-top: 8px;
    word-break: break-all;
}

.page-detail .no-images {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 40px;
}

.page-detail .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.page-detail .tag {
    background: var(--primary);
    color: white;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.85em;
}

/* Legal / static pages */
.page-legal .legal-content {
    background: white;
    border-radius: var(--card-radius);
    padding: 40px;
    box-shadow: var(--shadow-md);
    margin-top: 30px;
}

.page-legal .legal-content section {
    margin-bottom: 32px;
}

.page-legal .legal-content section:last-child {
    margin-bottom: 0;
}

.page-legal .legal-content h2 {
    font-size: 1.25rem;
    color: var(--primary-dark);
    margin-bottom: 12px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.page-legal .legal-content h3 {
    font-size: 1.05rem;
    color: var(--text);
    margin-top: 20px;
    margin-bottom: 8px;
}

.page-legal .legal-content p {
    margin-bottom: 12px;
    color: var(--muted);
    line-height: 1.7;
}

.page-legal .legal-content ul {
    margin: 8px 0 12px 24px;
    color: var(--muted);
    line-height: 1.7;
}

.page-legal .legal-content a {
    color: var(--primary);
    text-decoration: none;
}

.page-legal .legal-content a:hover {
    text-decoration: underline;
}

/* Footer links for legal pages */
.legal-footer {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-top: 30px;
    padding: 20px 0;
}

.legal-footer a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.9em;
}

.legal-footer a:hover {
    color: white;
    text-decoration: underline;
}

/* Table page */
.page-table .container {
    max-width: 1600px;
}

.page-table .header {
    margin-bottom: 24px;
}

.page-table .header h1 {
    color: white;
    font-size: clamp(1.9rem, 3.1vw, 2.6rem);
    font-weight: 800;
    letter-spacing: -0.01em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    flex: 1;
}

.page-table .table-card {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(10, 14, 40, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    overflow: hidden;
}

.page-table .table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: linear-gradient(180deg, #f9faff 0%, #f4f6ff 100%);
    border-bottom: 1px solid #e7eaf8;
}

.page-table .table-toolbar-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-table .table-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-table .table-meta {
    color: #23283f;
    font-size: 0.96rem;
    font-weight: 700;
}

.page-table .table-hint {
    color: #5f6480;
    font-size: 0.84rem;
}

.page-table .search-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-table .search-box input[type="search"] {
    width: min(360px, 62vw);
    border: 1px solid #d7defc;
    border-radius: 10px;
    background: white;
    color: #222842;
    padding: 8px 10px;
    font-size: 0.9rem;
    outline: none;
}

.page-table .search-box input[type="search"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.17);
}

.page-table .toolbar-btn {
    border: 1px solid #d7defc;
    border-radius: 10px;
    background: #fff;
    color: #2a3152;
    font-size: 0.86rem;
    font-weight: 700;
    padding: 8px 12px;
    cursor: pointer;
}

.page-table .toolbar-btn:hover {
    background: #edf1ff;
    border-color: #c8d2fb;
}

.page-table .toolbar-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-table .table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    max-height: none;
}

.page-table .entries-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.page-table .entries-table th,
.page-table .entries-table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid #eceff8;
    vertical-align: top;
    font-size: 0.91rem;
    line-height: 1.45;
    color: #2d334d;
}

.page-table .entries-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: rgba(249, 250, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid #e3e8fb;
}

.page-table .entries-table tbody tr:nth-child(even) {
    background: #fcfcff;
}

.page-table .entries-table tbody tr:hover {
    background: #eef2ff;
}

.page-table .entries-table th:nth-child(1),
.page-table .entries-table td:nth-child(1),
.page-table .entries-table th:nth-child(5),
.page-table .entries-table td:nth-child(5),
.page-table .entries-table th:nth-child(8),
.page-table .entries-table td:nth-child(8),
.page-table .entries-table th:nth-child(9),
.page-table .entries-table td:nth-child(9) {
    white-space: nowrap;
}

.page-table .mono {
    font-family:
        ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    letter-spacing: 0.01em;
}

.page-table .year-cell {
    text-align: center;
}

.page-table .sort-btn {
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: #2b3150;
    font-weight: 700;
    font-size: 0.87rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    transition: all 0.18s ease;
}

.page-table .sort-btn:hover {
    color: var(--primary);
    background: #edf1ff;
    border-color: #dde4ff;
}

.page-table .sort-btn.active {
    color: white;
    background: var(--primary);
    border-color: var(--primary-dark);
}

.page-table .sort-btn.active .sort-indicator {
    opacity: 1;
}

.page-table .sort-indicator {
    font-size: 0.8rem;
    opacity: 0.72;
}

.page-table .table-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid #ccd5ff;
    background: #f5f7ff;
    padding: 4px 10px;
    transition: all 0.18s ease;
}

.page-table .table-link:hover {
    color: white;
    background: var(--primary);
    border-color: var(--primary);
    text-decoration: none;
}

.page-table .table-link--file {
    white-space: nowrap;
}

.page-table .table-link--action {
    min-width: 82px;
    font-weight: 700;
}

.page-table.dense-mode .entries-table th,
.page-table.dense-mode .entries-table td {
    padding: 7px 8px;
    font-size: 0.82rem;
    line-height: 1.28;
}

.page-table.dense-mode .sort-btn {
    font-size: 0.8rem;
    border-radius: 7px;
    padding: 3px 6px;
}

.page-table.dense-mode .table-link {
    padding: 2px 8px;
    font-size: 0.78rem;
}

.page-table.dense-mode .table-link--file {
    white-space: nowrap;
}

.page-table.dense-mode .table-wrap {
    max-height: none;
}

@media (max-width: 900px) {
    .page-table .header {
        gap: 12px;
        align-items: flex-start;
    }

    .page-table .header h1 {
        font-size: 1.6rem;
    }

    .page-table .table-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-table .table-toolbar-right {
        width: 100%;
    }

    .page-table .search-box {
        width: 100%;
    }

    .page-table .search-box input[type="search"] {
        width: 100%;
    }
}
