/* Reset and design tokens */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-text: #2d3748;
    --color-text-muted: #718096;
    --color-heading: #1a202c;
    --color-accent: #667eea;
    --color-accent-end: #764ba2;
    --color-success: #48bb78;
    --border-default: #e2e8f0;
    --border-dashed: #cbd5e0;
    --radius-lg: 32px;
    --radius-md: 24px;
    --radius-sm: 20px;
    --gradient-page: linear-gradient(120deg, #667eea 0%, #764ba2 40%, #f093fb 100%, #ffecd2 120%);
    --gradient-accent: linear-gradient(45deg, var(--color-accent), var(--color-accent-end));
    --gradient-surface: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    --gradient-surface-hover: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
    --gradient-upload-success: linear-gradient(135deg, #f0fff4 0%, #e6fffa 100%);
    --gradient-similarity-hover: linear-gradient(135deg, #e8f0ff 0%, #d8e8ff 100%);
    --shadow-panel: 0 24px 60px rgba(0, 0, 0, 0.12), 0 0 0 1.5px rgba(255, 255, 255, 0.22);
    --shadow-accent: 0 12px 30px rgba(102, 126, 234, 0.15);
    --focus-ring: 0 0 0 3px rgba(102, 126, 234, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --transition-smooth: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}


/* inter-regular - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  src: url('../fonts/inter-v20-latin-regular.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-500 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  src: url('../fonts/inter-v20-latin-500.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-600 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  src: url('../fonts/inter-v20-latin-600.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}
/* inter-700 - latin */
@font-face {
  font-display: swap; /* Check https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display for other options. */
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  src: url('../fonts/inter-v20-latin-700.woff2') format('woff2'); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */
}


body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gradient-page);
    min-height: 100vh;
    color: var(--color-text);
    line-height: 1.6;
    font-weight: 400;
    display: flex;
    flex-direction: column;
}

.ml-value a {
    color: #f1c40f;
    font-weight: bold;
    text-decoration: none;
}

.ml-value a:hover {
    color: #e67e22;
    text-decoration: underline;
}

/* Main layout */
#main-layout {
    flex: 1;
    max-width: 1800px;
    min-width: 0;
    margin: 30px auto;
    padding: 0 15px;
    box-shadow: 0 0 48px 8px rgba(102, 126, 234, 0.1), 0 1.5px 8px 0 rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
}

#main-content-inner {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    width: 100%;
    padding: 25px;
}

.upload-panel,
.results-panel {
    flex: 1 1 0;
    min-width: 600px;
}

/* Footer */
.footer {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding: 15px 0;
    text-align: center;
    position: relative;
    flex-shrink: 0;
}

.footer::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
}

.footer-content p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

@media (max-width: 1100px) {
    #main-layout {
        margin: 10px;
        padding: 0;
    }

    #main-content-inner {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
}

@media (max-width: 768px) {
    #main-layout {
        margin: 20px;
        border-radius: var(--radius-md);
    }

    #main-content-inner {
        padding: 25px;
        gap: 25px;
    }

    .upload-panel,
    .results-panel {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    #main-layout {
        margin: 15px;
        border-radius: var(--radius-sm);
    }

    #main-content-inner {
        padding: 20px;
        gap: 20px;
    }
}

/* Panels */
.panel {
    background: rgba(255, 255, 255, 0.97);
    border-radius: var(--radius-lg);
    padding: 30px 25px;
    box-shadow: var(--shadow-panel);
    backdrop-filter: blur(24px);
    border: 1.5px solid rgba(255, 255, 255, 0.32);
    transition: var(--transition-smooth);
}

.panel:hover {
    transform: translateY(-4px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.3);
}

.panel-header {
    margin-bottom: 20px;
    text-align: center;
}

.panel-header h2 {
    color: var(--color-heading);
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.panel-description {
    color: var(--color-text-muted);
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1.6;
}

/* Upload area */
.upload-area {
    border: 2px dashed var(--border-dashed);
    border-radius: var(--radius-md);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-smooth);
    background: var(--gradient-surface);
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.6s;
}

.upload-area:hover::before {
    left: 100%;
}

.upload-area:hover {
    border-color: var(--color-accent);
    background: var(--gradient-surface-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-accent);
}

.upload-area.has-image {
    border-style: solid;
    border-color: var(--color-success);
    background: var(--gradient-upload-success);
    border-width: 2px;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 25px;
    opacity: 0.6;
    transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
    opacity: 0.8;
    transform: scale(1.1);
}

.upload-text {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
    transition: color 0.3s ease;
}

.upload-hint {
    font-size: 1rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.upload-area img {
    max-width: 520px;
    max-height: 520px;
    border-radius: var(--radius-sm);
    margin-top: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.upload-area img:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.upload-controls {
    display: flex;
    gap: 25px;
    margin-bottom: 15px;
}

/* Advanced options */
.advanced-options {
    margin-bottom: 15px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gradient-surface);
    transition: all 0.3s ease;
}

.advanced-options:hover {
    border-color: var(--border-dashed);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.advanced-summary {
    padding: 25px 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
    color: var(--color-text);
    background: var(--gradient-surface);
    transition: all 0.3s ease;
    list-style: none;
}

.advanced-summary:hover,
.advanced-options[open] .advanced-summary {
    background: var(--gradient-surface-hover);
}

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

.advanced-options[open] .advanced-summary {
    border-bottom: 1px solid var(--border-default);
}

.advanced-icon {
    font-size: 1.3rem;
    opacity: 0.7;
}

.advanced-text {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Threshold / cluster controls (shared classes) */
.threshold-control {
    padding: 30px;
    background: var(--gradient-surface);
    border-radius: 0;
    border: none;
    transition: all 0.3s ease;
}

.extra-precision-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    user-select: none;
}

.extra-precision-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.threshold-label {
    display: block;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 20px;
    font-size: 1.2rem;
}

.threshold-input-group {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.threshold-slider {
    flex: 1;
    height: 12px;
    border-radius: 8px;
    background: var(--border-default);
    outline: none;
    -webkit-appearance: none;
    transition: all 0.3s ease;
}

.threshold-slider:focus {
    box-shadow: var(--focus-ring);
}

.threshold-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-accent);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.threshold-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.threshold-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gradient-accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.threshold-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.threshold-input {
    width: 80px;
    height: 45px;
    border: 2px solid var(--border-default);
    border-radius: 10px;
    padding: 10px 15px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    background: white;
    text-align: center;
    transition: all 0.3s ease;
}

.threshold-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--focus-ring);
}

.threshold-input::-webkit-inner-spin-button,
.threshold-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.threshold-input[type="number"] {
    -moz-appearance: textfield;
}

.threshold-unit,
.threshold-hint {
    font-weight: 500;
    color: var(--color-text-muted);
}

.threshold-unit {
    font-weight: 600;
    font-size: 1.1rem;
}

.threshold-hint {
    font-size: 1rem;
    font-style: italic;
}

/* Buttons */
.btn {
    flex: 1;
    background: var(--gradient-accent);
    color: white;
    border: none;
    padding: 20px 28px;
    border-radius: 18px;
    font-size: 1.2rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.6s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.4);
}

.btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    background: var(--border-dashed);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: linear-gradient(45deg, #718096, #4a5568);
}

.btn-icon {
    font-size: 1.3rem;
}

.btn-text {
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Status messages */
.status {
    text-align: center;
    padding: 12px;
    margin: 10px 0;
    border-radius: 18px;
    font-weight: 600;
    font-size: 1.15rem;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.status.loading {
    background: linear-gradient(135deg, #ebf8ff 0%, #bee3f8 100%);
    color: #2b6cb0;
    border-color: #90cdf4;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.status.success {
    background: linear-gradient(135deg, #f0fff4 0%, #c6f6d5 100%);
    color: #2f855a;
    border-color: #9ae6b4;
}

.status.error {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    color: #c53030;
    border-color: #fc8181;
}

/* Results */
.results-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 1.1rem;
    color: var(--color-text-muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.results-container {
    max-height: 800px;
    overflow-y: auto;
    padding-right: 20px;
}

.results-container::-webkit-scrollbar {
    width: 12px;
}

.results-container::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 8px;
}

.results-container::-webkit-scrollbar-thumb {
    background: var(--border-dashed);
    border-radius: 8px;
    transition: background 0.3s ease;
}

.results-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    margin-bottom: 25px;
    background: var(--gradient-surface);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: var(--gradient-accent);
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.result-item:hover::before {
    transform: scaleY(1);
}

.result-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-accent);
    border-color: var(--color-accent);
    background: var(--gradient-surface-hover);
}

.result-info {
    display: flex;
    align-items: center;
    flex: 1;
    padding-left: 20px;
}

.result-details {
    flex: 1;
}

.result-code {
    font-weight: 700;
    color: var(--color-heading);
    font-size: 1.4rem;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.result-page {
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.similarity {
    color: var(--color-accent);
    font-weight: 700;
    padding: 10px 20px;
    background: var(--gradient-surface-hover);
    border-radius: 30px;
    font-size: 1.1rem;
    border: 2px solid var(--border-dashed);
    display: inline-block;
    transition: all 0.3s ease;
}

.result-item:hover .similarity {
    background: var(--gradient-similarity-hover);
    border-color: var(--color-accent);
    color: #4c51bf;
}

.placeholder {
    text-align: center;
    padding: 100px 30px;
    color: var(--color-text-muted);
}

.placeholder-icon {
    font-size: 6rem;
    margin-bottom: 10px;
    opacity: 0.4;
    transition: all 0.3s ease;
}

.placeholder:hover .placeholder-icon {
    opacity: 0.6;
    transform: scale(1.05);
}

.placeholder-title {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

.placeholder-subtitle {
    font-size: 1.2rem;
    opacity: 0.7;
    line-height: 1.6;
    font-weight: 500;
}

/* Most likely match */
.most-likely.highlight-pop {
    background: linear-gradient(135deg, #fffbe6 80%, #fffde4 100%);
    border: 2px solid #ffe066;
    border-radius: var(--radius-sm);
    box-shadow: 0 6px 24px #ffd70022, 0 2px 8px #0001;
    padding: 20px 20px 15px;
    margin-bottom: 10px;
    transition: box-shadow 0.2s, border 0.2s;
    position: relative;
}

.most-likely-header {
    font-size: 1.6em;
    font-weight: 700;
    color: #b8860b;
    margin-bottom: 25px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.most-likely-crown {
    font-size: 1.6em;
    margin-right: 8px;
    vertical-align: middle;
    filter: drop-shadow(0 2px 4px #ffd70088);
}

.most-likely-flex {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.most-likely-thumb-col {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.most-likely-thumbnail-large {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 18px;
    border: 3px solid #ffd700;
    box-shadow: 0 6px 24px #ffd70033, 0 2px 8px #0001;
    background: #fff;
    transition: box-shadow 0.2s, border 0.2s;
}

.most-likely-thumbnail-large:hover {
    box-shadow: 0 0 0 4px #ffe06688, 0 6px 24px #ffd70033, 0 2px 8px #0001;
    border-color: #ffec99;
}

.most-likely-details-col {
    display: flex;
    flex-direction: column;
    gap: 18px;
    justify-content: center;
}

.most-likely-detail-row {
    display: flex;
    gap: 15px;
    font-size: 1.2em;
    align-items: center;
    line-height: 1.5;
}

.ml-label {
    font-weight: 600;
    color: #b8860b;
    min-width: 120px;
    display: inline-block;
    letter-spacing: 0.2px;
}

.ml-value {
    color: #222;
    font-weight: 400;
    word-break: break-word;
}

@media (max-width: 600px) {
    .most-likely-flex {
        flex-direction: column;
        gap: 25px;
    }

    .most-likely-thumbnail-large {
        width: 120px;
        height: 120px;
    }

    .most-likely-header {
        font-size: 1.3em;
    }
}

.expandable-results {
    border-radius: 12px;
    background: #f7f7fa;
    box-shadow: 0 1px 4px #0001;
    padding: 15px 20px 12px;
    display: flex;
    justify-content: center;
    flex-direction: column;
}

.expand-btn {
    background: #ffd700;
    color: #333;
    border: none;
    border-radius: 8px;
    padding: 10px 22px;
    font-size: 1.1rem;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background 0.2s;
}

.expand-btn:hover {
    background: #ffe066;
}

.results-list {
    margin-top: 12px;
}

/* Buy Me a Coffee (used in index.html) */
.bmc-button {
    display: inline-flex;
    align-items: center;
    background: #ffdd00;
    border-radius: 12px;
    padding: 15px 32px;
    text-decoration: none;
    box-shadow: 0 4px 18px #ffd70044, 0 2px 8px #0001;
    transition: background 0.18s, box-shadow 0.18s, transform 0.18s;
    border: 2px solid #ffb347;
    font-size: 1.2em;
    position: relative;
    outline: none;
}

.bmc-button:hover,
.bmc-button:focus {
    background: #ffe066;
    box-shadow: 0 8px 32px #ffb34755, 0 2px 8px #0001;
    transform: scale(1.06) translateY(-2px);
}

.bmc-button img {
    filter: drop-shadow(0 2px 4px #ffd70088);
}

.bmc-button.metallic-blue {
    background: linear-gradient(120deg, #3a8dde 0%, #1e3c72 100%);
    border: 2.5px solid #5ec6fa;
    color: #fff;
    box-shadow: 0 4px 18px #3a8dde55, 0 2px 8px #0002;
    position: relative;
    overflow: hidden;
}

.bmc-button.metallic-blue span {
    color: #fff;
}

.bmc-button.metallic-blue::before {
    content: '';
    position: absolute;
    left: -60%;
    top: -50%;
    width: 220%;
    height: 200%;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.18) 0%, rgba(255, 255, 255, 0.38) 50%, rgba(255, 255, 255, 0.12) 100%);
    transform: skewX(-24deg);
    pointer-events: none;
    opacity: 0.7;
    z-index: 1;
    animation: shine-move 2.5s linear infinite;
}

@keyframes shine-move {
    0% { left: -60%; }
    100% { left: 100%; }
}

.bmc-button.metallic-blue:hover,
.bmc-button.metallic-blue:focus {
    background: linear-gradient(120deg, #5ec6fa 0%, #1e3c72 100%);
    box-shadow: 0 8px 32px #3a8dde88, 0 2px 8px #0002;
    border-color: #aee6ff;
}

.bmc-button.metallic-blue img {
    filter: drop-shadow(0 2px 4px #5ec6fa88);
}
