:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-color: #333333;
    --border-color: #dee2e6;
    --hover-color: #f1f3f5;
    --link-hover: #2980b9;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.site-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    padding: 0.3rem;
    background: #fff;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.site-logo-link:hover {
    background: rgba(255, 255, 255, 0.582);
    transform: translateY(-1px);
}

.site-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    display: block;
}

.header-intro {
    flex: 1;
    min-width: 260px;
}

.github-link {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.github-link:hover {
    opacity: 0.75;
}

header h1 {
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Main */
main {
    padding: 2rem 0;
}

section {
    background: var(--card-background);
    margin-bottom: 2rem;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.6rem;
    border-bottom: 3px solid var(--secondary-color);
    padding-bottom: 0.5rem;
}

section p {
    margin-bottom: 0.75rem;
}

.note {
    background-color: #e92300;
    color: #ffffff;
    font-size: 0.8rem;
    padding: 1rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.stats {
    padding: 0.75rem;
    background-color: var(--hover-color);
    border-radius: 4px;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Table */
.table-container {
    overflow-x: auto;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    background-color: white;
}

thead {
    background-color: var(--primary-color);
    color: white;
}

th {
    padding: 1rem 0.75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 0.75rem;
    vertical-align: middle;
    border-right: 1px solid var(--border-color);
}

td:last-child {
    border-right: none;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

tbody tr:hover {
    background-color: #e3f2fd;
}

tbody tr:nth-child(even) {
    background-color: #fafafa;
}

tbody tr:nth-child(even):hover {
    background-color: #e3f2fd;
}

.bone-name {
    font-weight: 600;
    color: var(--primary-color);
}

/* Links & buttons */
a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.3s;
}

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

.btn-link {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background-color: var(--secondary-color);
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.btn-link:hover {
    background-color: var(--link-hover);
    color: white;
    text-decoration: none;
}

.unavailable {
    color: #999;
}

[hidden] {
    display: none !important;
}

.loading,
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.error-state {
    padding: 1rem;
    background-color: #f8d7da;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
    color: #842029;
}

/* Download: toolbar and body-part groups */
.atlas-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.atlas-toolbar input[type="search"] {
    flex: 1 1 240px;
    min-width: 0;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font: inherit;
    font-size: 0.95rem;
}

.atlas-toolbar button,
.viewer-toolbar button {
    padding: 0.4rem 0.9rem;
    background-color: var(--secondary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.3s;
}

.atlas-toolbar button:hover,
.viewer-toolbar button:hover {
    background-color: var(--link-hover);
}

.region {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.6rem;
    background-color: #fff;
}

.region > summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--primary-color);
    border-radius: 6px;
}

.region > summary::-webkit-details-marker {
    display: none;
}

.region > summary::before {
    content: "\25B8";
    color: var(--secondary-color);
    transition: transform 0.2s;
}

.region[open] > summary::before {
    transform: rotate(90deg);
}

.region > summary:hover {
    background-color: var(--hover-color);
}

.region-title {
    flex: 1;
}

.region-count {
    font-size: 0.85rem;
    font-weight: 400;
    color: #666;
}

.region-body {
    padding: 0 1rem 1rem;
}

.region-browse {
    font-size: 0.85rem;
    color: #666;
}

th.subject-head {
    text-align: center;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
}

th.format-head {
    padding-top: 0.3rem;
    padding-bottom: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    opacity: 0.9;
}

th.format-head:nth-child(3n + 1) {
    border-left: 1px solid rgba(255, 255, 255, 0.35);
}

th.bone-head {
    vertical-align: bottom;
}

td.dl-cell {
    text-align: center;
    padding: 0.4rem;
}

.bone-name {
    white-space: nowrap;
}

.btn-link .btn-size {
    display: block;
    font-size: 0.7rem;
    opacity: 0.85;
}

.region-body .table-container {
    box-shadow: none;
    border-width: 1px;
}

/* 3D Viewer */
.viewer-layout {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    align-items: stretch;
}

.viewer-sidebar {
    flex: 0 0 280px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.viewer-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: var(--hover-color);
    border-radius: 4px;
    font-size: 0.9rem;
}

.viewer-toolbar label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.viewer-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.viewer-card + .viewer-card {
    margin-top: 2rem;
}

.viewer-card h3 {
    color: var(--primary-color);
    font-size: 1.2rem;
}

.viewer-meta {
    font-size: 0.9rem;
    font-weight: 400;
    color: #666;
}

.viewer-list {
    list-style: none;
    margin: 0;
    padding: 0.25rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow-y: auto;
    height: 0;
    flex: 1 1 auto;
}

.viewer-list ul {
    list-style: none;
    margin: 0 0 0.25rem 1.6rem;
    padding: 0;
}

.viewer-list ul li {
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
}

.viewer-list ul li:hover {
    background-color: #e3f2fd;
}

.viewer-group-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.4rem;
    border-radius: 3px;
}

.viewer-group-head:hover {
    background-color: var(--hover-color);
}

.viewer-group-toggle {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.viewer-group-toggle::after {
    content: "\25B8";
    color: #888;
    transition: transform 0.2s;
}

.viewer-group-toggle[aria-expanded="true"]::after {
    transform: rotate(90deg);
}

.viewer-group-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewer-group-count {
    font-size: 0.75rem;
    color: #888;
}

.viewer-list label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.viewer-list-empty {
    color: #666;
    font-size: 0.9rem;
}

.viewer-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.viewer-canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 600px;
    background-color: #1b2733;
    border-radius: 6px;
    overflow: hidden;
}

.viewer-canvas canvas {
    display: block;
}

.viewer-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #e3f2fd;
    font-size: 0.95rem;
    text-align: center;
    padding: 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.35);
    border-radius: 4px;
    pointer-events: none;
}

/* Name of the bone under the cursor. */
.viewer-tooltip {
    position: absolute;
    z-index: 2;
    padding: 0.25rem 0.6rem;
    background-color: rgba(12, 20, 28, 0.92);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    font-size: 0.85rem;
    white-space: nowrap;
    pointer-events: none;
}

@media (max-width: 768px) {
    .viewer-layout {
        flex-direction: column;
    }

    .viewer-sidebar {
        flex-basis: auto;
    }

    .viewer-list {
        height: 220px;
        flex: none;
    }

    .viewer-canvas {
        height: 420px;
    }
}

/* Citation */
.cite-ref {
    padding-left: 1rem;
    border-left: 3px solid var(--border-color);
    color: #444;
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: white;
    padding: 2rem 0;
    margin-top: 2rem;
}

footer a {
    color: #85c1e9;
}

footer a:hover {
    color: white;
}

.disclaimer {
    font-size: 0.9rem;
    opacity: 0.9;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.9rem;
    }

    section {
        padding: 1.5rem;
    }

    table {
        font-size: 0.85rem;
    }

    th,
    td {
        padding: 0.5rem;
    }
}
