:root {
    --bg: #020812;
    --bg-2: #071629;
    --elevated: rgba(7, 20, 37, 0.66);
    --elevated-2: rgba(8, 28, 47, 0.56);
    --line: rgba(148, 211, 255, 0.2);
    --line-strong: rgba(148, 211, 255, 0.38);
    --text: #f2f8ff;
    --text-soft: #9db0c8;
    --accent: #00bbff;
    --accent-2: #3a8dff;
    --accent-amber: #ff9f1a;
    --success: #34d399;
    --danger: #fb7185;
    --radius-xl: 24px;
    --radius-lg: 18px;
    --shadow-1: 0 24px 60px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 14px 34px rgba(0, 187, 255, 0.24);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        linear-gradient(165deg, rgba(2, 9, 18, 0.82), rgba(4, 20, 40, 0.84)),
        radial-gradient(circle at 5% -10%, rgba(0, 187, 255, 0.26), transparent 42%),
        radial-gradient(circle at 100% 5%, rgba(255, 159, 26, 0.18), transparent 32%),
        url("/BGR.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

body {
    display: flex;
    justify-content: center;
    padding: 14px;
}

.page {
    max-width: 1220px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.header {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    background:
        linear-gradient(132deg, rgba(5, 22, 40, 0.7), rgba(6, 18, 32, 0.52)),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0 2px, transparent 2px 10px);
    backdrop-filter: blur(14px) saturate(125%);
    box-shadow: var(--shadow-1);
    text-align: center;
    padding: 28px 20px 24px;
}

.header::after {
    content: "";
    position: absolute;
    inset: -30% auto auto -10%;
    width: 300px;
    height: 300px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(0, 187, 255, 0.32), transparent 70%);
    pointer-events: none;
}

.kicker {
    margin: 0 0 8px;
    color: var(--accent-amber);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.74rem;
    font-weight: 700;
}

.header h1 {
    margin: 0;
    font-size: clamp(2rem, 3.4vw, 3.1rem);
    letter-spacing: 0.01em;
    text-wrap: balance;
}

.subtitle {
    margin: 10px auto 0;
    font-size: 1rem;
    color: var(--text-soft);
    max-width: 700px;
}

.hero-badges {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.hero-badges span {
    border: 1px solid rgba(0, 187, 255, 0.35);
    background: linear-gradient(130deg, rgba(0, 187, 255, 0.14), rgba(58, 141, 255, 0.1));
    color: #dcf4ff;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.76rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.main {
    display: grid;
    grid-template-columns: minmax(0, 1.18fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    gap: 20px;
}

.upload-card {
    grid-column: 1 / 2;
}

.settings-card {
    grid-column: 2 / 3;
    grid-row: 1 / 3;
}

.result-card {
    grid-column: 1 / 2;
}

@media (max-width: 980px) {
    .main {
        grid-template-columns: 1fr;
    }

    .settings-card,
    .upload-card,
    .result-card {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

.card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    border: 1px solid var(--line);
    background:
        linear-gradient(155deg, var(--elevated), var(--elevated-2)),
        radial-gradient(circle at top right, rgba(0, 187, 255, 0.18), transparent 44%);
    backdrop-filter: blur(16px) saturate(128%);
    padding: 20px 20px 18px;
    box-shadow: var(--shadow-1);
}

.card::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(173, 226, 255, 0.18);
    pointer-events: none;
}

.card h2 {
    margin: 0 0 14px;
    font-size: 1rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ecf0ff;
}

.upload-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.upload-sep {
    color: var(--text-soft);
    font-size: 0.82rem;
}

.upload-hint {
    margin: 0 0 11px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.file-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 11px 15px;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    background: linear-gradient(145deg, rgba(4, 36, 67, 0.68), rgba(8, 22, 37, 0.86));
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.file-label:hover {
    transform: translateY(-1px);
    border-color: rgba(0, 187, 255, 0.95);
    box-shadow: var(--shadow-2);
}

.file-label-camera {
    background: linear-gradient(145deg, rgba(3, 86, 96, 0.74), rgba(8, 36, 50, 0.95));
    border-color: rgba(34, 211, 238, 0.5);
}

.file-label input[type="file"] {
    display: none;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.field-row > label {
    font-size: 0.84rem;
    color: #d3daef;
}

.field-hint {
    font-size: 0.74rem;
    color: var(--text-soft);
}

.range-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex: 1;
    appearance: none;
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(0, 187, 255, 0.68), rgba(255, 159, 26, 0.74));
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: #0f1324;
    box-shadow: 0 0 0 4px rgba(0, 187, 255, 0.28);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.9);
    background: #0f1324;
    box-shadow: 0 0 0 4px rgba(0, 187, 255, 0.28);
}

#loweringValue,
#camberValue,
#tintValue {
    min-width: 58px;
    text-align: right;
    font-weight: 600;
    color: #e6eaff;
    font-size: 0.84rem;
}

input[type="text"],
input[type="file"],
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    font-size: 0.9rem;
    background: linear-gradient(135deg, rgba(5, 17, 30, 0.78), rgba(5, 24, 40, 0.78));
    color: var(--text);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

textarea {
    min-height: 84px;
    resize: vertical;
}

input[type="text"]:focus,
input[type="file"]:focus,
select:focus,
textarea:focus {
    border-color: rgba(0, 187, 255, 0.95);
    box-shadow: 0 0 0 4px rgba(0, 187, 255, 0.2);
    background: rgba(7, 22, 36, 0.9);
}

input[type="file"]::file-selector-button {
    margin-right: 10px;
    border: 1px solid var(--line-strong);
    background: linear-gradient(140deg, rgba(0, 187, 255, 0.26), rgba(58, 141, 255, 0.24));
    color: #e7ebff;
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    cursor: pointer;
    color: #dce2f5;
}

.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent);
}

.image-preview {
    margin-top: 10px;
    min-height: 220px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background:
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 12px),
        linear-gradient(155deg, rgba(4, 19, 35, 0.92), rgba(8, 28, 46, 0.9));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.placeholder {
    color: #a8b1cf;
    font-size: 0.9rem;
}

.primary-btn {
    margin-top: 10px;
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(135deg, #ff9f1a, #ff8a00 46%, #ef6c00);
    cursor: pointer;
    box-shadow: var(--shadow-2);
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 34px rgba(255, 138, 0, 0.46);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn[disabled] {
    opacity: 0.62;
    cursor: not-allowed;
    box-shadow: none;
}

.status {
    margin-top: 9px;
    min-height: 18px;
    font-size: 0.8rem;
    color: var(--text-soft);
}

.status.error {
    color: var(--danger);
}

.status.success {
    color: var(--success);
}

.camera-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
}

.camera-modal[hidden] {
    display: none;
}

.camera-modal-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

.camera-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.62);
}

.camera-modal-close {
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 8px;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 5px 10px;
}

.camera-video {
    flex: 1;
    min-height: 0;
    object-fit: cover;
}

.camera-canvas {
    display: none;
}

.camera-modal-actions {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.7);
}

.camera-cancel-btn {
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: transparent;
    color: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
}

.camera-error {
    margin: 0;
    padding: 9px 12px;
    text-align: center;
    color: var(--danger);
    background: rgba(0, 0, 0, 0.84);
    font-size: 0.83rem;
}

.camera-error[hidden] {
    display: none;
}

.footer {
    text-align: center;
    color: #8f97b2;
    font-size: 1.05rem;
    font-weight: 600;
    padding: 4px 0 8px;
}

.footer a {
    color: inherit;
    text-decoration: none;
}

.footer a:hover {
    color: #d9e2ff;
}

/* Unified page-specific styles moved from index inline block */
.base-mode-highlight {
    border: 2px solid #f59e0b !important;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.24), rgba(249, 115, 22, 0.18)) !important;
    padding: 12px 14px !important;
    border-radius: 12px !important;
    color: #fff !important;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), 0 10px 24px rgba(249, 115, 22, 0.25) !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
}

.base-mode-highlight input[type="checkbox"] {
    transform: scale(1.35);
    accent-color: #f59e0b !important;
    margin-right: 6px;
}

.footer {
    font-size: 2.5rem !important;
    font-weight: 700 !important;
    color: #f8f9ff !important;
    letter-spacing: 0.02em;
}

.footer a,
.footer a:visited,
.footer a:hover,
.footer a:active {
    color: inherit !important;
    text-decoration: none !important;
}

.result-gallery-controls {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.result-nav-btn {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(10, 19, 34, 0.85);
    color: #fff;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
}

.result-nav-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#resultCounter {
    font-size: 0.82rem;
    color: #cbd5e1;
    min-width: 54px;
    text-align: center;
}

#resultThumbs {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.result-thumb {
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    border-radius: 10px;
    padding: 0;
    cursor: pointer;
    width: 74px;
    height: 56px;
    overflow: hidden;
    position: relative;
}

.result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.result-thumb.active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.result-thumb.basis {
    border-color: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

#resultBaseHint {
    margin-top: 8px;
    font-size: 0.76rem;
    color: #fbbf24;
}

.header-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 8px;
}

.header-logo {
    height: 64px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
}

.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.94);
    backdrop-filter: blur(2px);
}

.lightbox-modal[hidden] {
    display: none;
}

.lightbox-image {
    width: 100vw;
    height: 100vh;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
    border: 0;
    background: #000;
}

.lightbox-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}

.preview-fullsize-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    background: rgba(0, 0, 0, 0.58);
    color: #fff;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    z-index: 4;
    font-size: 0.95rem;
    line-height: 1;
}

.preview-toolbar {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
}

.fullsize-btn {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(7, 16, 29, 0.82);
    color: #e9f4ff;
    border-radius: 10px;
    padding: 7px 11px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
}

