:root {
    --bg: #fafafa;
    --fg: #0a0a0a;
    --muted: #737373;
    --border: #e5e5e5;
    --accent: #0a0a0a;
}

[data-theme="dark"] {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a3a3a3;
    --border: #262626;
    --accent: #fafafa;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--fg);
    transition: background 200ms, color 200ms;
}

/* Remove scrollbars from all iframes */
iframe {
    overflow: hidden;
}

/* HEADER */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 15px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
}

.logo a {
    display: flex;
    align-items: center;
}

.logo img {
    height: 24px;
}

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

.header-nav a {
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 150ms;
}

.header-nav a:hover {
    color: var(--fg);
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
    position: relative;
}

/* FAVORITES BUTTON */
.favorites-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: all 150ms;
    padding: 0;
    position: relative;
}

.favorites-btn:hover {
    color: var(--fg);
}

.favorites-btn.has-favorites {
    color: var(--fg);
}

.favorites-btn svg {
    width: 20px;
    height: 20px;
}

/* FAVORITES COUNTER BADGE */
.favorites-counter {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #e63946 0%, #f72585 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    transition: all 200ms ease;
}

.favorites-counter.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.favorites-counter.pulse {
    animation: pulse-badge 400ms ease;
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* FAVORITES FLYOUT */
.favorites-flyout {
    position: absolute;
    top: 100%;
    right: -8px;
    width: 380px;
    max-height: 520px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 200ms, transform 200ms, visibility 200ms;
    z-index: 200;
    margin-top: 8px;
}

.favorites-flyout.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.favorites-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.favorites-title {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.favorites-count {
    font-size: 13px;
    color: var(--muted);
}

.favorites-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 8px;
}

.favorites-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.favorite-item {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: 2px;
    transition: background 150ms;
    cursor: pointer;
    text-decoration: none;
    color: var(--fg);
    margin-bottom: 4px;
}

.favorite-item:hover {
    background: var(--border);
}

.favorite-thumbnail {
    width: 60px;
    height: 82px;
    background: #fff;
    border-radius: 2px;
    overflow: visible;
    flex-shrink: 0;
    position: relative;
}

.favorite-thumbnail-inner {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.favorite-thumbnail-inner::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 10;
}

.favorite-thumbnail.frame-black .favorite-thumbnail-inner::before {
    background-image: url("assets/frames/black.png");
}

.favorite-thumbnail.frame-white .favorite-thumbnail-inner::before {
    background-image: url("assets/frames/white.png");
}

.favorite-thumbnail.frame-natural .favorite-thumbnail-inner::before {
    background-image: url("assets/frames/natural.png");
}

.favorite-thumbnail.frame-none .favorite-thumbnail-inner::before {
    display: none;
}

.favorite-thumbnail iframe {
    position: absolute;
    top: 2.8%;
    left: 3.9%;
    width: 93.5%;
    height: 95.5%;
    border: none;
    pointer-events: none;
}

.favorite-thumbnail.frame-none iframe {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.favorite-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.favorite-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.favorite-seed {
    font-size: 11px;
    color: var(--muted);
    font-family: 'Courier New', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.favorite-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 2px;
    transition: all 150ms;
    flex-shrink: 0;
}

.favorite-remove:hover {
    color: var(--fg);
    background: var(--border);
}

.favorite-remove svg {
    width: 16px;
    height: 16px;
}

.theme-toggle {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    border-radius: 2px;
    transition: all 150ms;
    padding: 0;
}

.theme-toggle:hover {
    color: var(--fg);
    border-color: var(--fg);
}

/* Theme icon visibility - default light mode shows moon (to switch to dark) */
.theme-icon-light {
    display: none;
}

.theme-icon-dark {
    display: block;
}

/* Dark mode shows sun (to switch to light) */
[data-theme="dark"] .theme-icon-light {
    display: block;
}

[data-theme="dark"] .theme-icon-dark {
    display: none;
}

/* Logo visibility - default light mode */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

/* Dark mode logo visibility */
[data-theme="dark"] .logo-light {
    display: none;
}

[data-theme="dark"] .logo-dark {
    display: block;
}

/* System preference dark mode (before JS loads) */
@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]) .logo-light {
        display: none;
    }

    html:not([data-theme="light"]) .logo-dark {
        display: block;
    }

    html:not([data-theme="light"]) .theme-icon-light {
        display: block;
    }

    html:not([data-theme="light"]) .theme-icon-dark {
        display: none;
    }
}

/* NEWSLETTER SECTION */
.newsletter-section {
    border-top: 1px solid var(--border);
    padding: 120px 32px;
    background: var(--fg);
}

.newsletter-inner {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.newsletter-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
    color: var(--bg);
}

.newsletter-subtitle {
    font-size: 14px;
    color: var(--bg);
    opacity: 0.7;
    line-height: 1.6;
    margin-bottom: 32px;
}

.newsletter-form {
    display: flex;
    gap: 12px;
    max-width: 480px;
    margin: 0 auto;
}

.newsletter-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: var(--bg);
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    border-radius: 2px;
    transition: border-color 150ms, background 150ms;
}

.newsletter-input:focus {
    outline: none;
    border-color: var(--bg);
    background: rgba(255,255,255,0.15);
}

.newsletter-input::placeholder {
    color: var(--bg);
    opacity: 0.6;
}

.newsletter-btn {
    padding: 12px 24px;
    background: var(--bg);
    color: var(--fg);
    border: 1px solid var(--bg);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 2px;
    transition: opacity 150ms;
    white-space: nowrap;
}

.newsletter-btn:hover {
    opacity: 0.85;
}

/* FOOTER */
footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 48px 32px;
}

.footer-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    gap: 64px;
}

.footer-section h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}

.footer-section p,
.footer-section a {
    font-size: 13px;
    color: var(--muted);
    line-height: 1.8;
    text-decoration: none;
    display: block;
}

.footer-section p {
    max-width: 280px;
}

.footer-section:nth-child(2),
.footer-section:nth-child(3) {
    text-align: right;
}

.footer-section a:hover {
    color: var(--fg);
}

.footer-bottom {
    max-width: 1600px;
    margin: 32px auto 0;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--muted);
}

.footer-bottom-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.footer-bottom a {
    color: var(--muted);
    text-decoration: none;
    transition: color 150ms;
}

.footer-bottom a:hover {
    color: var(--fg);
}

.footer-links {
    display: flex;
    gap: 20px;
}

/* RESPONSIVE */
@media (max-width: 968px) {
    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-btn {
        width: 100%;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .footer-section:nth-child(2),
    .footer-section:nth-child(3) {
        text-align: left;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .footer-bottom-left {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 640px) {
    .header-inner {
        padding: 15px 20px;
    }

    .header-nav {
        display: none;
    }

    .footer-inner,
    .footer-bottom {
        padding: 0;
    }

    .favorites-flyout {
        width: calc(100vw - 40px);
        right: -8px;
    }
}

.hidden {
    display: none;
}
