:root {
    --logo-margin-top: 12vh;
    --search-width: min(560px, 80vw);
    --muted: #70757a;
    --accent: #1a73e8;
    --shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    font-family: "Google Sans", Roboto, Arial, Helvetica, sans-serif;
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    background: #fff;
    color: #202124;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    width: 100%;
    padding: 12px 24px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
    position: fixed;
    background: #ffff;
    z-index: 1000;
}

header #helpBtn, header #aboutBtn {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 4px;
}

header #helpBtn:hover, header #aboutBtn:hover {
    background: #f1f3f4;
    color: #202124;
}

header img {
    height: 64px;
}

header > div {
    display: flex;
    gap: 16px;
    align-items: center;
}

#debugBtn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: #333;
}

#debugBtn:hover {
    background: #f5f5f5;
}

#debugBtn.enabled {
    background: #ffc107;
    border-color: #ffb300;
    color: #000;
}

#debugBtn.enabled:hover {
    background: #ffb300;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1 0 auto;
    width: 100%;
}

.logo {
    margin-top: var(--logo-margin-top);
    margin-bottom: 18px;
}

.logo img {
    width: 360px;
    height: auto;
    max-width: 70vw;
    display: block;
}

.search-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.search-box {
    width: var(--search-width);
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 24px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
}

.search-box input {
    border: none;
    outline: none;
    flex: 1;
    font-size: 18px;
    padding: 8px;
}

.search-controls {
    margin-top: 18px;
    display: flex;
    gap: 12px;
}

button.primary,
button.ghost {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    border: none;
    cursor: pointer;
}

button.primary {
    background: #1a73e8;
    color: white;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

button.ghost {
    background: #f8f9fa;
    color: #202124;
    border: 1px solid #dadce0;
}

footer {
    margin: 36px 0 24px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
}

.modal-backdrop[aria-hidden="false"] {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
}

.modal-panel {
    max-width: 720px;
    width: min(92vw, 720px);
    background: #fff;
    color: #111;
    border-radius: 12px;
    padding: 1.25rem 1.25rem 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .5rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    appearance: none;
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.modal-body p {
    margin: .5rem 0;
}

.credits-list,
.howto-list {
    margin: .5rem 0 .75rem;
    padding-left: 1.25rem;
}

.credits-list li+li,
.howto-list li+li {
    margin-top: .25rem;
}

/* small responsive tweaks */
@media (max-width:480px) {
    .logo img {
        max-width: 240px;
    }
}

.browse-container {
    display: block;
    width: 100%;
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.browse-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    width: 100%;
}

.mesh-card {
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 8px;
    padding: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform .12s ease;
}

.mesh-card:hover {
    transform: translateY(-4px);
}

.mesh-thumb {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f7f9;
    border-radius: 6px;
    overflow: hidden;
}

.mesh-thumb .placeholder {
    color: var(--muted);
    font-size: 13px;
}

.mesh-meta {
    margin-top: 8px;
}

.mesh-title {
    font-weight: 500;
    font-size: 13px;
    color: #202124;
}

.mesh-size {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.browse-pagination {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    margin-top: 76px;
}

.browse-pagination button {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    background: white;
    cursor: pointer;
}

.browse-pagination button:disabled {
    opacity: 0.4;
    cursor: default;
}

.error {
    color: #b00020;
    text-align: center;
    margin-top: 50px;
    padding: 20px;
}

.search-info {
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    margin: 20px 0;
}

.mesh-score {
    font-size: 12px;
    color: var(--accent);
    margin-top: 4px;
}

.loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-top: 100px;
    color: var(--muted);
    font-size: 14px;
    gap: 12px;
}

.loader img {
    width: 196px;
    height: auto;
    animation: runRat 0.6s steps(6) infinite;
    image-rendering: pixelated;
}

.overlay {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 12px 14px;
    border-radius: 10px;
    font-family: ui-sans-serif, system-ui, Segoe UI, Roboto, Helvetica, Arial;
    backdrop-filter: blur(4px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    max-width: 320px;
}

.overlay h3 {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .3px;
    opacity: .9;
}

.overlay .row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 4px 0;
    font-size: 12px;
}

.overlay .controls {
    margin-top: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.overlay label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: .95;
}

.overlay .buttons {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.overlay button,
.overlay a.btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
}

.overlay button:hover,
.overlay a.btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

.overlay .muted {
    color: #c9c9c9;
    font-size: 11px;
    margin-top: 6px;
}

.overlay .top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fps {
    font-size: 11px;
    color: #90ee90;
    margin-left: 6px;
}