:root {
    --bg-color: #000000;
    --bg-elev: #050505;
    --bg-soft: #0a0a0a;
    --text-color: #f5f5f5;
    --text-muted: #b5b5b5;
    --border-color: #3a3a3a;
    --border-strong: #6d6d6d;
    --card-bg: #080808;
    --danger: #ff4d4d;
    --ok: #8cf58c;
    --warn: #ffe27a;
    --glow-soft: 0 0 10px rgba(255, 255, 255, 0.2);
    --glow-strong: 0 0 16px rgba(255, 255, 255, 0.36);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: "IBM Plex Sans", "Segoe UI", "Arial", sans-serif;
    font-size: 13px;
    line-height: 1.3;
    letter-spacing: 0.01em;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem 0.9rem;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 15;
    background: #000000;
    border-bottom: 1px solid var(--border-strong);
}

.nav-container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.58rem 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #ffffff;
    text-decoration: none;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 1rem;
}

.brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border-color);
    background: linear-gradient(180deg, #0f0f0f 0%, #060606 100%);
    padding: 0.22rem 0.52rem;
    border-radius: 0.35rem;
    text-transform: uppercase;
    font-size: 0.67rem;
    letter-spacing: 0.05em;
}

.nav-links .donate-link {
    border-color: #ffffff;
    background: linear-gradient(120deg, #ff2d55, #ff9f0a, #f5e663, #30d158, #2ea8ff, #6e5bff, #bf5af2);
    color: #000000;
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.22);
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 0.02rem;
}

.nav-links .donate-link span {
    display: inline-block;
    animation: donate-letter-bounce 0.42s ease-in-out infinite alternate;
    will-change: transform, filter;
}

.nav-links .donate-link span:nth-child(1) { animation-delay: 0ms; }
.nav-links .donate-link span:nth-child(2) { animation-delay: 55ms; }
.nav-links .donate-link span:nth-child(3) { animation-delay: 110ms; }
.nav-links .donate-link span:nth-child(4) { animation-delay: 165ms; }
.nav-links .donate-link span:nth-child(5) { animation-delay: 220ms; }
.nav-links .donate-link span:nth-child(6) { animation-delay: 275ms; }

.nav-links .donate-link span:nth-child(1) { color: #ff2d55; }
.nav-links .donate-link span:nth-child(2) { color: #ff7a00; }
.nav-links .donate-link span:nth-child(3) { color: #ffd60a; }
.nav-links .donate-link span:nth-child(4) { color: #30d158; }
.nav-links .donate-link span:nth-child(5) { color: #0abfff; }
.nav-links .donate-link span:nth-child(6) { color: #8a5cff; }

.nav-links .donate-link:hover,
.nav-links .donate-link:focus-visible {
    filter: saturate(1.18) brightness(1.05);
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.3);
}

.nav-links .donate-link:hover span,
.nav-links .donate-link:focus-visible span {
    animation-duration: 0.28s;
}

@keyframes donate-letter-bounce {
    0% {
        transform: translateY(0) rotate(0deg) scale(1);
        filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0));
    }
    100% {
        transform: translateY(-6px) rotate(-3deg) scale(1.08);
        filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.55));
    }
}

.nav-links a:hover,
.nav-links a:focus-visible {
    color: #ffffff;
    border-color: #ffffff;
    box-shadow: var(--glow-soft);
}

h1,
h2,
h3,
h4 {
    line-height: 1.15;
    margin: 0 0 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

h1 {
    font-size: clamp(1.2rem, 2.4vw, 1.8rem);
}

h2 {
    font-size: clamp(1rem, 2vw, 1.3rem);
}

h3 {
    font-size: 0.9rem;
}

h4 {
    font-size: 0.8rem;
}

p {
    margin: 0 0 0.4rem;
}

.hero {
    text-align: left;
    padding: 0.85rem 0;
}

.hero-image-first {
    padding: 0.5rem 0 0.65rem;
}

.hero-image-first h1 {
    font-size: clamp(1.4rem, 3vw, 2.2rem);
    letter-spacing: 0.06em;
}

.hero-image-first p {
    max-width: 760px;
}

.hero p {
    max-width: 820px;
    color: var(--text-muted);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.72rem;
    margin-bottom: 0.7rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.tool-shell {
    padding: 0.72rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.62rem;
}

.tool-canvas {
    display: block;
    width: 100%;
    border: 1px solid #ffffff;
    border-radius: 0;
    background: #000000;
}

.field-label {
    display: block;
    margin: 0.22rem 0 0.12rem;
    color: #dddddd;
    font-size: 0.67rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.field-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: var(--bg-soft);
    color: #ffffff;
    padding: 0.2rem 0.35rem;
    min-height: 1.55rem;
    font-size: 0.72rem;
}

.field-input:focus-visible {
    outline: 1px solid #ffffff;
    outline-offset: 0;
    box-shadow: var(--glow-soft);
}

.field-input[type='range'] {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    padding: 0;
    min-height: 0.95rem;
}

.field-input[type='range']::-webkit-slider-runnable-track {
    height: 7px;
    border: 1px solid #ffffff;
    border-radius: 0;
    background: linear-gradient(90deg, #ffffff 0%, #8f8f8f 100%);
    box-shadow: var(--glow-soft);
}

.field-input[type='range']::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -4px;
    border: 1px solid #000000;
    border-radius: 0;
    background: #ffffff;
    box-shadow: var(--glow-strong);
}

.field-input[type='range']::-moz-range-track {
    height: 7px;
    border: 1px solid #ffffff;
    border-radius: 0;
    background: linear-gradient(90deg, #ffffff 0%, #8f8f8f 100%);
    box-shadow: var(--glow-soft);
}

.field-input[type='range']::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: 1px solid #000000;
    border-radius: 0;
    background: #ffffff;
    box-shadow: var(--glow-strong);
}

.canvas-shell {
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: #000000;
    padding: 0.35rem;
    overflow: auto;
}

.tool-btn.active {
    border-color: #ffffff;
    box-shadow: var(--glow-soft);
}

.chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid #ffffff;
    border-radius: 0;
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    background: #111111;
    color: #ffffff;
    text-transform: uppercase;
}

.btn {
    border: 1px solid #ffffff;
    border-radius: 0;
    background: #0a0a0a;
    color: #ffffff;
    padding: 0.32rem 0.54rem;
    min-height: 1.62rem;
    font-size: 0.69rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    text-decoration: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.btn:hover,
.btn:focus-visible {
    background: #141414;
    box-shadow: var(--glow-soft);
}

.btn-secondary {
    border-color: #8d8d8d;
    color: #efefef;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    border-color: #ffffff;
}

.hidden {
    display: none !important;
}

.dropzone {
    border: 1px dashed #ffffff;
    border-radius: 0;
    padding: 1.2rem 0.6rem;
    text-align: center;
    background: #070707;
    cursor: pointer;
}

.dropzone.dragover,
.dropzone:hover {
    box-shadow: var(--glow-soft);
}

.site-footer {
    border-top: 1px solid var(--border-strong);
    background: #000000;
    color: var(--text-muted);
    padding: 0.52rem;
    margin-top: auto;
}

.footer-container {
    max-width: 1240px;
    margin: 0 auto;
    font-size: 0.66rem;
}

.footer-line {
    margin: 0;
}

.toast-host {
    position: fixed;
    right: 0.55rem;
    bottom: 0.55rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    z-index: 999;
}

.toast {
    background: #000000;
    border: 1px solid #ffffff;
    border-radius: 0;
    padding: 0.34rem 0.45rem;
    font-size: 0.66rem;
    box-shadow: var(--glow-soft);
}

.home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.5rem;
}

.lead {
    color: var(--text-muted);
    margin-top: 0;
}

.muted {
    color: var(--text-muted);
}

.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.scan-grid {
    display: grid;
    gap: 0.45rem;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.scan-card {
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: #050505;
    padding: 0.42rem;
}

.scan-card h4 {
    margin: 0 0 0.2rem;
    font-size: 0.72rem;
}

.scan-value {
    font-family: "Consolas", "Menlo", "Monaco", monospace;
    font-size: 0.68rem;
    color: #e9e9e9;
    word-break: break-word;
}

.code-block {
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: 0;
    background: #000000;
    color: #efefef;
    padding: 0.45rem;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.66rem;
}

.tool-link-card {
    display: block;
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.55rem;
    text-decoration: none;
    color: #ffffff;
    background: #060606;
}

.tool-link-card:hover,
.tool-link-card:focus-visible {
    border-color: #ffffff;
    box-shadow: var(--glow-soft);
}

.trust-banner {
    border: 1px solid #ffffff;
    border-radius: 0;
    padding: 0.35rem 0.45rem;
    margin: 0.45rem 0 0.55rem;
    background: #101010;
    color: #f8f8f8;
    font-size: 0.68rem;
}

.warning-box {
    border: 1px solid var(--danger);
    border-radius: 0;
    padding: 0.35rem 0.45rem;
    margin: 0.45rem 0;
    color: #ffdede;
    background: #180a0a;
}

.status-badge {
    display: inline-block;
    border: 1px solid;
    border-radius: 0;
    padding: 0.08rem 0.32rem;
    font-size: 0.61rem;
    margin-right: 0.22rem;
    margin-bottom: 0.22rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pass {
    border-color: var(--ok);
    background: rgba(140, 245, 140, 0.08);
    color: var(--ok);
}

.status-fail {
    border-color: var(--danger);
    background: rgba(255, 77, 77, 0.08);
    color: #ffb8b8;
}

.status-unsupported,
.status-unknown {
    border-color: #b5b5b5;
    background: rgba(181, 181, 181, 0.08);
    color: #dbdbdb;
}

.badge-row {
    margin-bottom: 0.45rem;
}

.result-grid {
    display: grid;
    gap: 0.52rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.52rem;
}

.explain-accordion {
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 0.32rem 0.44rem;
    margin-top: 0.45rem;
    background: #090909;
}

.explain-accordion summary {
    cursor: pointer;
    font-weight: 700;
    font-size: 0.69rem;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: 0;
    overflow: hidden;
}

.modern-table thead {
    background: #121212;
}

.modern-table th,
.modern-table td {
    padding: 0.31rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.67rem;
    text-align: left;
}

.meter-shell {
    height: 8px;
    border-radius: 0;
    border: 1px solid var(--border-color);
    background: #070707;
    overflow: hidden;
    margin-top: 0.35rem;
}

.meter-fill {
    height: 100%;
    background: #ffffff;
}

.meter-fill.meter-mid {
    background: #c7c7c7;
}

.meter-fill.meter-strong {
    background: #8b8b8b;
}

.footer-rainbow-link {
    text-decoration: none;
    margin-left: 0.2rem;
    display: inline-flex;
    gap: 0.02rem;
}

.rainbow-letter {
    display: inline-block;
    font-weight: 700;
    color: #ffffff !important;
    transition: none;
}

.image-editor-shell {
    margin-top: 0.75rem;
}

.image-lab-theme {
    border: 1px solid #3f3f3f;
    border-radius: 0.75rem;
    background: radial-gradient(circle at 80% 12%, rgba(255, 255, 255, 0.08), transparent 42%), #020202;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 16px 45px rgba(0, 0, 0, 0.45);
    font-size: 12px;
    line-height: 1.2;
}

.image-lab-compact-grid {
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.35fr);
    align-items: flex-start;
    gap: 0.75rem;
}

.image-preview-panel {
    position: sticky;
    top: 72px;
    align-self: flex-start;
    border: 1px solid #323232;
    border-radius: 0.65rem;
    background: #060606;
    padding: 0.65rem;
}

.before-after-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
}

.image-controls-panel {
    max-height: 81vh;
    overflow: auto;
    padding-right: 0.2rem;
    border: 1px solid #2f2f2f;
    border-radius: 0.65rem;
    background: linear-gradient(180deg, #0f0f0f 0%, #070707 100%);
    padding: 0.45rem;
}

.image-preset-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.25rem;
}

.image-preset-grid .btn {
    width: 100%;
    text-align: center;
    padding: 0.22rem 0.34rem;
    min-height: 1.45rem;
    font-size: 0.62rem;
}

.image-dimension-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
}

.image-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.24rem 0.32rem;
}

.image-control-row {
    border: 1px solid var(--border-color);
    border-radius: 0.45rem;
    background: linear-gradient(180deg, #121212 0%, #0a0a0a 100%);
    padding: 0.22rem 0.3rem;
}

.image-control-row-wide {
    grid-column: 1 / -1;
}

.image-label-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0;
    margin-bottom: 0.12rem;
    font-size: 0.63rem;
}

.image-value-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.45rem;
    border: 1px solid #ffffff;
    border-radius: 0.3rem;
    padding: 0 0.25rem;
    color: #ffffff;
    background: #151515;
    font-size: 0.6rem;
    line-height: 1.15;
    box-shadow: var(--glow-soft);
}

.image-user-preset-shell {
    margin-top: 0.65rem;
    border: 1px solid #2f2f2f;
    border-radius: 0.55rem;
    background: #0b0b0b;
    padding: 0.38rem;
}

.image-user-preset-shell h4 {
    margin-bottom: 0.3rem;
}

.image-user-preset-grid {
    display: grid;
    gap: 0.3rem;
}

.image-user-preset-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.3rem;
}

.image-user-preset-apply {
    text-align: left;
}

.image-user-preset-remove {
    border-color: #6f6f6f;
    color: #d8d8d8;
}

.field-check-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem 0.35rem;
    margin-top: 0.45rem;
}

.toggle-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #3a3a3a;
    border-radius: 0.45rem;
    background: linear-gradient(180deg, #141414 0%, #0a0a0a 100%);
    min-height: 2rem;
    padding: 0.3rem 0.48rem;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.toggle-chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.toggle-chip span {
    font-size: 0.64rem;
    color: #bbbbbb;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 700;
}

.toggle-chip.is-active {
    border-color: #ffffff;
    background: linear-gradient(135deg, rgba(46, 168, 255, 0.22), rgba(191, 90, 242, 0.2));
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 20px rgba(120, 172, 255, 0.24);
    transform: translateY(-1px);
}

.toggle-chip.is-active span {
    color: #ffffff;
}

.image-toggle-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.24rem 0.32rem;
    margin-top: 0.45rem;
}

.image-lab-theme .tool-canvas {
    border-radius: 0.45rem;
    border: 1px solid #2e2e2e;
    background: #000000;
    max-height: 52vh;
    object-fit: contain;
}

.image-lab-theme .trust-banner {
    border-radius: 0;
    border-color: #ffffff;
    color: #ffffff;
    background: #0d0d0d;
}

.image-mobile-popout {
    position: fixed;
    right: 0.5rem;
    bottom: 0.7rem;
    z-index: 30;
    border: 1px solid #4a4a4a;
    border-radius: 0.5rem;
    background: rgba(5, 5, 5, 0.92);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    touch-action: none;
}

.image-mobile-popout-handle {
    cursor: grab;
    padding: 0.2rem 0.36rem;
    font-size: 0.58rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid #2f2f2f;
    color: #d9d9d9;
    user-select: none;
}

.image-mobile-popout-canvas {
    display: block;
    width: auto;
    height: auto;
    max-width: 220px;
    max-height: 180px;
    border-radius: 0 0 0.5rem 0.5rem;
    background: #000;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 960px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.45rem;
    }

    .nav-links {
        justify-content: flex-start;
    }

    .tool-grid,
    .split-grid,
    .image-lab-compact-grid {
        grid-template-columns: 1fr !important;
    }

    .before-after-grid,
    .image-preset-grid,
    .image-controls-grid,
    .image-toggle-options-grid,
    .image-dimension-grid,
    .field-check-row {
        grid-template-columns: 1fr;
    }

    .image-preview-panel {
        position: static;
        top: auto;
        order: -2;
    }

    .image-controls-panel {
        max-height: none;
        overflow: visible;
        order: 1;
    }

    .image-mobile-popout {
        display: block;
    }

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

@media (min-width: 961px) {
    .image-mobile-popout {
        display: none !important;
    }
}
