:root {
    --sq-border: #e2e6ee;
    --sq-border-strong: #b6bac0;
    --sq-muted: #64748b;
    --sq-ink: #1e2530;
    --sq-accent: #2563eb;
    --sq-accent-soft: #eef4ff;
    --sq-panel: #f7f9fc;
    --sq-good: #059669;
    --sq-good-soft: #ecfdf5;
    --sq-warn: #b45309;
    --sq-shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --sq-shadow-md: 0 6px 18px rgba(16, 24, 40, 0.08);
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--sq-ink);
    background: #f4f7fb;
}

#app {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

h1:focus {
    outline: none;
}

.btn:focus-visible,
.segmented button:focus-visible {
    outline: 2px solid var(--sq-accent);
    outline-offset: 1px;
}

/* ---------- Landing ---------- */

.landing {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.25rem 3rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -10%, rgba(37, 99, 235, 0.16), transparent 55%),
        linear-gradient(180deg, #f7f9fc 0%, #eef2f7 100%);
}

.landing-card {
    width: min(36rem, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.landing-logo {
    width: 8.5rem;
    height: 8.5rem;
    border-radius: 1.35rem;
    object-fit: cover;
    box-shadow:
        0 1px 2px rgba(16, 24, 40, 0.06),
        0 18px 40px rgba(37, 99, 235, 0.22);
    margin-bottom: 1.5rem;
}

.landing h1 {
    font-size: clamp(1.45rem, 3vw, 1.85rem);
    font-weight: 650;
    letter-spacing: -0.03em;
    margin: 0 0 0.45rem;
    color: #111827;
}

.upload-lede {
    color: var(--sq-muted);
    margin: 0 0 1.75rem;
    max-width: 28rem;
    line-height: 1.5;
}

.landing-steps {
    display: flex;
    gap: 0.6rem;
    list-style: none;
    padding: 0;
    margin: 1.35rem 0 0;
    color: var(--sq-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.landing-steps li {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.landing-steps li:not(:last-child)::after {
    content: "";
    width: 1.25rem;
    height: 1px;
    background: var(--sq-border);
}

.privacy-note {
    margin-top: 0.9rem;
    color: var(--sq-muted);
    font-size: 0.78rem;
}

/* ---------- Drop zone ---------- */

.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    min-height: 12.5rem;
    padding: 2rem 1.5rem;
    text-align: center;
    border: 1.5px dashed #c5d0e0;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
    backdrop-filter: blur(8px);
    transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.dropzone.is-active {
    border-color: var(--sq-accent);
    background: #eff4ff;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.12);
}

.dropzone.is-disabled {
    opacity: 0.6;
    pointer-events: none;
}

.dropzone-icon {
    font-size: 1.9rem;
    line-height: 1;
}

.dropzone-title {
    font-weight: 600;
}

.dropzone-hint {
    color: var(--sq-muted);
    font-size: 0.875rem;
}

/* The file input covers the whole zone so native click-to-browse and drag-and-drop both work. */
.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* ---------- Settings ---------- */

.settings-card {
    width: 100%;
    margin-bottom: 1rem;
    padding: 1rem 1.1rem 0.9rem;
    border: 1px solid var(--sq-border);
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--sq-shadow-sm);
    text-align: left;
}

.control {
    margin-bottom: 0.95rem;
}

.control:last-child {
    margin-bottom: 0.1rem;
}

.control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 650;
    color: var(--sq-muted);
    margin-bottom: 0.45rem;
}

.control-value {
    flex: none;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
    color: var(--sq-accent);
    background: var(--sq-accent-soft);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
}

.control-hint {
    margin: 0.4rem 0 0;
    color: var(--sq-muted);
    font-size: 0.76rem;
    line-height: 1.4;
}

.segmented {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    border: 1px solid var(--sq-border);
    border-radius: 0.65rem;
    background: #ffffff;
}

.segmented button {
    flex: 1;
    padding: 0.35rem 0;
    border: none;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--sq-muted);
    font-size: 0.85rem;
    font-weight: 550;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.segmented button:hover:not(.is-selected):not(:disabled) {
    background: var(--sq-panel);
    color: var(--sq-ink);
}

.segmented button.is-selected {
    background: var(--sq-accent);
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.35);
}

.segmented button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* Slider: thin neutral track with an accent thumb, instead of Bootstrap's solid blue puck. */
.settings-card .form-range {
    height: 1.1rem;
    padding: 0;
    margin-top: 0.6rem;
}

.settings-card .form-range::-webkit-slider-runnable-track {
    height: 0.3rem;
    border-radius: 999px;
    background: #dbe1ec;
}

.settings-card .form-range::-moz-range-track {
    height: 0.3rem;
    border-radius: 999px;
    background: #dbe1ec;
}

.settings-card .form-range::-webkit-slider-thumb {
    width: 0.95rem;
    height: 0.95rem;
    margin-top: -0.325rem;
    background: #ffffff;
    border: 2px solid var(--sq-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
    transition: transform 120ms ease;
}

.settings-card .form-range::-moz-range-thumb {
    width: 0.95rem;
    height: 0.95rem;
    background: #ffffff;
    border: 2px solid var(--sq-accent);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
}

.settings-card .form-range:active::-webkit-slider-thumb {
    transform: scale(1.15);
}

.range-ends {
    display: flex;
    justify-content: space-between;
    color: var(--sq-muted);
    font-size: 0.7rem;
    margin-top: 0.15rem;
}

/* ---------- Progress and results ---------- */

.progress-card,
.result-card {
    width: 100%;
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--sq-border);
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: var(--sq-shadow-md);
    text-align: left;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.progress-label strong {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-count {
    flex: none;
    color: var(--sq-muted);
    font-variant-numeric: tabular-nums;
}

.progress {
    height: 0.55rem;
    border-radius: 999px;
    background: #e8edf5;
}

.progress-bar {
    background: var(--sq-accent);
    border-radius: 999px;
    transition: width 160ms ease;
}

.savings-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 0.8rem;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
    color: var(--sq-muted);
}

.savings-badge {
    flex: none;
    font-weight: 650;
    color: var(--sq-good);
    background: var(--sq-good-soft);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
}

.savings-badge.is-worse {
    color: var(--sq-warn);
    background: #fffbeb;
}

.file-list {
    list-style: none;
    margin: 0.9rem 0 0;
    padding: 0.35rem 0;
    max-height: 13rem;
    overflow-y: auto;
    border-top: 1px solid var(--sq-border);
    scrollbar-width: thin;
    font-size: 0.8rem;
}

.file-list li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.2rem 0;
}

.file-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-stat {
    flex: none;
    color: var(--sq-muted);
    font-variant-numeric: tabular-nums;
}

.file-stat.is-good {
    color: var(--sq-good);
}

.file-stat.is-error {
    color: var(--sq-warn);
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.result-headline {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}

.result-headline .big {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--sq-good);
    line-height: 1.1;
}

.result-sub {
    color: var(--sq-muted);
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.btn-primary {
    --bs-btn-bg: var(--sq-accent);
    --bs-btn-border-color: var(--sq-accent);
    --bs-btn-hover-bg: #1d4ed8;
    --bs-btn-hover-border-color: #1d4ed8;
    --bs-btn-active-bg: #1e40af;
    font-weight: 600;
}

.btn-light {
    --bs-btn-bg: #ffffff;
    --bs-btn-border-color: var(--sq-border);
    --bs-btn-hover-bg: var(--sq-panel);
    --bs-btn-hover-border-color: var(--sq-border-strong);
    font-weight: 550;
}

.error-banner {
    width: 100%;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    border: 1px solid #fcd34d;
    border-radius: 0.75rem;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.88rem;
    text-align: left;
}

/* ---------- Blazor boot and error UI ---------- */

.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 40vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--sq-accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    inset: calc(40vh + 2.3rem) 0 auto 0.2rem;
    color: var(--sq-muted);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: #fffbeb;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

@media (max-width: 900px) {
    .landing {
        align-items: flex-start;
        padding: 2rem 1rem 2.5rem;
    }

    .landing-logo {
        width: 6.5rem;
        height: 6.5rem;
        border-radius: 1.1rem;
        margin-bottom: 1.15rem;
    }

    .dropzone {
        min-height: 11rem;
        padding: 1.25rem;
    }
}

@media (max-width: 640px) {
    .landing-steps {
        flex-wrap: wrap;
        justify-content: center;
    }

    .card-actions .btn {
        flex: 1 1 auto;
    }

    .segmented button {
        font-size: 0.8rem;
    }
}
