:root {
    --background: #06101d;
    --background-deep: #030912;
    --panel: rgba(10, 26, 43, 0.86);
    --panel-light: rgba(16, 40, 63, 0.76);
    --panel-border: rgba(92, 219, 255, 0.18);
    --panel-border-strong: rgba(92, 219, 255, 0.42);
    --primary: #5cdbff;
    --primary-bright: #8de9ff;
    --primary-dark: #1389aa;
    --secondary: #8075ff;
    --success: #44e2a8;
    --danger: #ff6f91;
    --warning: #f9ca67;
    --text: #edfaff;
    --text-muted: #91aabd;
    --text-dark: #06101d;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    --radius-large: 24px;
    --radius-medium: 16px;
    --radius-small: 10px;
    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(
            circle at top left,
            rgba(30, 135, 180, 0.15),
            transparent 34%
        ),
        linear-gradient(
            150deg,
            var(--background-deep),
            var(--background) 50%,
            #071827
        );
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
textarea,
input {
    font: inherit;
}

button {
    color: inherit;
}

.background-grid {
    position: fixed;
    inset: 0;
    z-index: -3;
    pointer-events: none;
    opacity: 0.24;
    background-image:
        linear-gradient(
            rgba(92, 219, 255, 0.08) 1px,
            transparent 1px
        ),
        linear-gradient(
            90deg,
            rgba(92, 219, 255, 0.08) 1px,
            transparent 1px
        );
    background-size: 44px 44px;
    mask-image:
        linear-gradient(
            to bottom,
            black,
            transparent 82%
        );
}

.background-glow {
    position: fixed;
    z-index: -2;
    width: 420px;
    height: 420px;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(110px);
    opacity: 0.16;
}

.glow-one {
    top: -110px;
    right: -120px;
    background: var(--primary);
}

.glow-two {
    bottom: -180px;
    left: -100px;
    background: var(--secondary);
}

.app-shell {
    width: min(1500px, calc(100% - 40px));
    margin: 0 auto;
    padding: 26px 0 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 18px 24px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-large);
    background: rgba(7, 20, 34, 0.72);
    box-shadow: var(--shadow);
    backdrop-filter: blur(22px);
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    border: 1px solid var(--panel-border-strong);
    border-radius: 16px;
    color: var(--background-deep);
    background:
        linear-gradient(
            135deg,
            var(--primary-bright),
            var(--primary)
        );
    box-shadow: 0 0 28px rgba(92, 219, 255, 0.25);
    font-size: 0.92rem;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.eyebrow,
.section-tag {
    margin: 0 0 4px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: 1.45rem;
    letter-spacing: -0.03em;
}

.system-status {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 150px;
}

.status-dot {
    width: 11px;
    height: 11px;
    flex: 0 0 auto;
    border-radius: 50%;
}

.status-checking {
    background: var(--warning);
    box-shadow: 0 0 18px rgba(249, 202, 103, 0.7);
}

.status-online {
    background: var(--success);
    box-shadow: 0 0 18px rgba(68, 226, 168, 0.72);
}

.status-offline {
    background: var(--danger);
    box-shadow: 0 0 18px rgba(255, 111, 145, 0.72);
}

.status-label {
    display: block;
    margin-bottom: 2px;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
}

.system-status strong {
    font-size: 0.9rem;
}

.hero-section {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
    gap: 32px;
    align-items: center;
    padding: 72px 18px 46px;
}

.hero-section h2 {
    max-width: 820px;
    margin: 12px 0 18px;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.05;
    letter-spacing: -0.055em;
}

.hero-section p {
    max-width: 760px;
    margin: 0;
    color: var(--text-muted);
    font-size: 1.04rem;
    line-height: 1.8;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.hero-metric {
    min-height: 116px;
    padding: 20px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-medium);
    background: rgba(13, 31, 49, 0.72);
    backdrop-filter: blur(18px);
}

.hero-metric span {
    display: block;
    min-height: 34px;
    margin-bottom: 14px;
    color: var(--text-muted);
    font-size: 0.76rem;
    line-height: 1.4;
    text-transform: uppercase;
}

.hero-metric strong {
    color: var(--primary-bright);
    font-size: 1.5rem;
}

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

.panel {
    min-width: 0;
    padding: 24px;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-large);
    background:
        linear-gradient(
            145deg,
            rgba(14, 35, 56, 0.9),
            rgba(6, 19, 33, 0.88)
        );
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
}

.panel-header,
.configuration-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

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

.panel-header > div:first-child,
.configuration-heading > div {
    display: flex;
    align-items: center;
    gap: 12px;
}

.panel-index {
    color: var(--primary);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.15em;
}

.panel h3 {
    margin: 0;
    font-size: 1.05rem;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 17px;
    border-radius: var(--radius-small);
    cursor: pointer;
    transition:
        transform var(--transition),
        border-color var(--transition),
        background var(--transition),
        opacity var(--transition);
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

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

.button-primary {
    border: 1px solid transparent;
    color: var(--text-dark);
    background:
        linear-gradient(
            135deg,
            var(--primary-bright),
            var(--primary)
        );
    box-shadow: 0 14px 34px rgba(92, 219, 255, 0.18);
    font-weight: 850;
}

.button-secondary {
    border: 1px solid var(--panel-border-strong);
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.08);
}

.button-ghost {
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    background: transparent;
}

.button-ghost:hover:not(:disabled) {
    border-color: var(--panel-border-strong);
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.06);
}

.input-mode-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 20px;
    padding: 6px;
    border: 1px solid var(--panel-border);
    border-radius: 13px;
    background: rgba(2, 12, 22, 0.54);
}

.mode-button {
    min-height: 42px;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    font-weight: 750;
    transition:
        color var(--transition),
        background var(--transition);
}

.mode-button.active {
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.12);
}

.input-panel {
    display: none;
}

.input-panel.active {
    display: block;
}

.field-label {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 700;
}

textarea {
    width: 100%;
    min-height: 330px;
    resize: vertical;
    padding: 18px;
    border: 1px solid var(--panel-border);
    outline: none;
    border-radius: 14px;
    color: var(--text);
    background: rgba(2, 11, 20, 0.66);
    line-height: 1.65;
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

textarea::placeholder {
    color: #567083;
}

textarea:focus {
    border-color: var(--panel-border-strong);
    box-shadow: 0 0 0 4px rgba(92, 219, 255, 0.07);
}

.text-counter-row {
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.text-counter-row strong {
    color: var(--primary-bright);
}

.drop-zone {
    display: grid;
    min-height: 370px;
    place-items: center;
    align-content: center;
    padding: 30px;
    border: 1px dashed var(--panel-border-strong);
    border-radius: 16px;
    outline: none;
    text-align: center;
    background:
        linear-gradient(
            145deg,
            rgba(92, 219, 255, 0.04),
            rgba(128, 117, 255, 0.025)
        );
    transition:
        border-color var(--transition),
        transform var(--transition),
        background var(--transition);
}

.drop-zone:hover,
.drop-zone.dragging,
.drop-zone:focus-visible {
    border-color: var(--primary);
    background: rgba(92, 219, 255, 0.07);
    transform: translateY(-2px);
}

.upload-symbol {
    display: grid;
    width: 62px;
    height: 62px;
    margin-bottom: 18px;
    place-items: center;
    border: 1px solid var(--panel-border-strong);
    border-radius: 50%;
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.08);
    font-size: 1.8rem;
}

.drop-zone h4 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.drop-zone p {
    margin: 0 0 22px;
    color: var(--text-muted);
}

.supported-files {
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.selected-file-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(92, 219, 255, 0.06);
}

.selected-file-card > div {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 12px;
}

.selected-file-card strong,
.selected-file-card span {
    display: block;
}

.selected-file-card strong {
    overflow: hidden;
    max-width: 350px;
    margin-bottom: 3px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-file-card span:not(.file-type-indicator) {
    color: var(--text-muted);
    font-size: 0.74rem;
}

.file-type-indicator {
    padding: 8px;
    border-radius: 8px;
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.12);
    font-size: 0.65rem;
    font-weight: 900;
}

.icon-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    flex: 0 0 auto;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    background: transparent;
    font-size: 1.2rem;
}

.configuration-section {
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--panel-border);
}

.ratio-control {
    margin: 22px 0;
}

.ratio-heading,
.ratio-scale {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ratio-heading {
    margin-bottom: 14px;
}

.ratio-heading label {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.ratio-heading output {
    min-width: 58px;
    padding: 7px 11px;
    border: 1px solid var(--panel-border-strong);
    border-radius: 8px;
    color: var(--primary-bright);
    background: rgba(92, 219, 255, 0.08);
    text-align: center;
    font-weight: 850;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
    cursor: pointer;
}

.ratio-scale {
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.7rem;
}

.summarize-button {
    width: 100%;
    min-height: 52px;
}

.button-icon {
    font-size: 1rem;
}

.inline-message {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 0.78rem;
    text-align: center;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.result-placeholder {
    display: grid;
    min-height: 500px;
    place-items: center;
    align-content: center;
    padding: 40px;
    text-align: center;
}

.result-placeholder-icon {
    display: grid;
    width: 78px;
    height: 78px;
    margin-bottom: 20px;
    place-items: center;
    border: 1px solid var(--panel-border-strong);
    border-radius: 22px;
    color: var(--primary);
    background: rgba(92, 219, 255, 0.05);
    box-shadow: 0 0 40px rgba(92, 219, 255, 0.08);
    font-size: 2rem;
}

.result-placeholder h4 {
    margin: 0 0 10px;
    font-size: 1.1rem;
}

.result-placeholder p {
    max-width: 430px;
    margin: 0;
    color: var(--text-muted);
    line-height: 1.7;
}

.summary-display {
    min-height: 390px;
    max-height: 570px;
    overflow-y: auto;
    padding: 22px;
    border: 1px solid var(--panel-border);
    border-radius: 15px;
    background: rgba(2, 11, 20, 0.66);
}

.summary-display p {
    margin: 0;
    color: #dff7ff;
    font-size: 1rem;
    line-height: 1.85;
    white-space: pre-wrap;
}

.statistics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 18px;
}

.stat-card {
    padding: 16px;
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    background: rgba(92, 219, 255, 0.045);
}

.stat-card span {
    display: block;
    margin-bottom: 9px;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
}

.stat-card strong {
    color: var(--primary-bright);
    font-size: 1.15rem;
}

.full-stat {
    grid-column: 1 / -1;
}

.system-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-medium);
    background: var(--panel-border);
}

.system-strip > div {
    padding: 17px;
    background: rgba(7, 20, 34, 0.94);
}

.strip-label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 0.66rem;
    text-transform: uppercase;
}

.system-strip strong {
    font-size: 0.79rem;
}

footer {
    padding: 26px 0 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-align: center;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(1, 7, 13, 0.78);
    backdrop-filter: blur(10px);
}

.loading-card {
    width: min(460px, 100%);
    padding: 32px;
    border: 1px solid var(--panel-border-strong);
    border-radius: 22px;
    background: rgba(8, 24, 39, 0.96);
    box-shadow: var(--shadow);
    text-align: center;
}

.loading-card h3 {
    margin: 22px 0 8px;
}

.loading-card p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
}

.scanner {
    position: relative;
    width: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(92, 219, 255, 0.1);
}

.scanner span {
    position: absolute;
    top: 0;
    left: -40%;
    width: 40%;
    height: 100%;
    border-radius: 999px;
    background: var(--primary);
    box-shadow: 0 0 18px var(--primary);
    animation: scan 1.25s linear infinite;
}

@keyframes scan {
    to {
        left: 100%;
    }
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 120;
    max-width: min(380px, calc(100% - 48px));
    padding: 14px 18px;
    border: 1px solid var(--panel-border-strong);
    border-radius: 12px;
    opacity: 0;
    pointer-events: none;
    color: var(--text);
    background: rgba(9, 30, 46, 0.97);
    box-shadow: var(--shadow);
    transform: translateY(16px);
    transition:
        opacity var(--transition),
        transform var(--transition);
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.error {
    border-color: rgba(255, 111, 145, 0.48);
}

.toast.success {
    border-color: rgba(68, 226, 168, 0.48);
}

.hidden {
    display: none !important;
}

@media (max-width: 1100px) {
    .hero-section,
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .hero-section {
        padding-top: 52px;
    }
}

@media (max-width: 720px) {
    .app-shell {
        width: min(100% - 22px, 1500px);
        padding-top: 12px;
    }

    .topbar {
        align-items: flex-start;
        padding: 16px;
    }

    .system-status {
        min-width: auto;
    }

    .status-label {
        display: none;
    }

    .hero-section {
        padding: 42px 5px 30px;
    }

    .hero-metrics,
    .system-strip {
        grid-template-columns: repeat(2, 1fr);
    }

    .panel {
        padding: 17px;
    }

    .panel-header {
        align-items: flex-start;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .button {
        min-height: 36px;
    }

    .statistics-grid {
        grid-template-columns: 1fr;
    }

    .full-stat {
        grid-column: auto;
    }

    .text-counter-row {
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .brand-icon {
        width: 46px;
        height: 46px;
    }

    .eyebrow {
        display: none;
    }

    h1 {
        font-size: 1.15rem;
    }

    .system-status strong {
        font-size: 0.76rem;
    }

    .hero-metrics,
    .system-strip {
        grid-template-columns: 1fr;
    }

    .input-mode-row {
        grid-template-columns: 1fr;
    }

    .panel-header {
        flex-direction: column;
    }

    .result-actions {
        width: 100%;
        flex-direction: row;
    }

    .result-actions .button {
        flex: 1;
    }

    textarea {
        min-height: 280px;
    }
}