:root {
    color-scheme: light;
    --page: #f4f1ea;
    --surface: #fffdfa;
    --surface-soft: #f8f6f0;
    --ink: #171a18;
    --muted: #68706b;
    --line: #ded8cc;
    --line-strong: #c8bfae;
    --brand: #0f8a62;
    --brand-dark: #096647;
    --amber: #ef9c38;
    --red: #b42318;
    --black: #111714;
    --shadow: 0 18px 44px rgba(51, 42, 29, 0.1);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, rgba(15, 138, 98, 0.08), rgba(15, 138, 98, 0) 220px),
        var(--page);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
    font: inherit;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(15, 138, 98, 0.22);
    outline-offset: 2px;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 22px;
}

.login-panel {
    width: min(100%, 390px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--black);
    color: #fff;
    font-weight: 900;
    margin-bottom: 18px;
}

h1,
h2,
p {
    margin: 0;
}

.login-panel h1 {
    font-size: 30px;
    line-height: 1.08;
    letter-spacing: 0;
}

.login-form {
    display: grid;
    gap: 12px;
    margin-top: 24px;
}

label {
    color: #28312c;
    font-weight: 800;
}

input[type="password"],
input[type="text"],
input[type="number"] {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--ink);
    background: #fff;
    outline: none;
}

input[type="password"]:focus,
input[type="text"]:focus,
input[type="number"]:focus {
    border-color: var(--brand);
}

.login-form button,
.primary-button,
.secondary-button,
.download-button,
.icon-button {
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 900;
    cursor: pointer;
}

.login-form button,
.primary-button {
    color: #fff;
    background: var(--black);
}

.login-form button:hover,
.primary-button:hover {
    background: #25312b;
}

.primary-button:disabled,
.secondary-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.secondary-button,
.download-button {
    color: #083e2d;
    background: #dff3ea;
}

.secondary-button:hover,
.download-button:hover {
    background: #caeadc;
}

.form-error,
.status-text.is-error {
    color: var(--red);
}

.app-shell {
    width: min(1320px, calc(100% - 44px));
    margin: 0 auto;
    padding: 24px 0 44px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.title-block {
    min-width: 0;
}

.eyebrow {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 8px;
    border: 1px solid rgba(15, 138, 98, 0.22);
    border-radius: 999px;
    padding: 6px 10px;
    background: rgba(255, 253, 250, 0.72);
    color: var(--brand-dark);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.topbar h1 {
    font-size: 48px;
    line-height: 1;
    letter-spacing: 0;
}

.top-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.file-stats {
    display: flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 253, 250, 0.86);
}

.file-stats span {
    min-width: 96px;
    min-height: 50px;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 8px 14px;
}

.file-stats span + span {
    border-left: 1px solid var(--line);
}

.file-stats small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.file-stats strong {
    color: var(--ink);
    font-size: 20px;
    line-height: 1;
}

.icon-button {
    width: auto;
    padding: 0;
    display: inline-flex;
    gap: 7px;
    padding: 0 12px;
    align-items: center;
    justify-content: center;
    place-items: center;
    background: #fff4ed;
    color: #8c3514;
    border: 1px solid #f1d0bd;
    line-height: 1;
}

.icon-button span {
    font-size: 24px;
    line-height: 1;
}

.icon-button b {
    font-size: 13px;
}

.logout-link {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
    background: rgba(255, 253, 250, 0.86);
    color: var(--ink);
    text-decoration: none;
    font-weight: 900;
}

.tool-layout {
    display: grid;
    grid-template-columns: minmax(360px, 530px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.convert-panel {
    display: grid;
    gap: 14px;
}

.drop-panel,
.settings-panel,
.result-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.drop-panel,
.settings-panel,
.result-panel {
    padding: 16px;
}

.drop-zone {
    position: relative;
    min-height: 192px;
    display: grid;
    place-items: center;
    gap: 12px;
    border: 1.5px dashed var(--line-strong);
    border-radius: 10px;
    padding: 22px;
    background: var(--surface-soft);
    text-align: center;
    transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.drop-zone.is-dragover {
    border-color: var(--brand);
    background: #edf8f2;
    transform: translateY(-2px);
}

.drop-zone input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.drop-art {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: var(--black);
    box-shadow: inset 0 -8px 0 rgba(255, 255, 255, 0.12);
}

.drop-art span {
    width: 30px;
    height: 30px;
    border: 3px solid #fff;
    border-radius: 8px;
    position: relative;
}

.drop-art span::before,
.drop-art span::after {
    content: "";
    position: absolute;
    background: #fff;
    border-radius: 999px;
}

.drop-art span::before {
    width: 12px;
    height: 3px;
    left: 6px;
    top: 12px;
}

.drop-art span::after {
    width: 3px;
    height: 12px;
    left: 11px;
    top: 7px;
}

.drop-zone h2 {
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: 0;
}

.drop-zone p {
    margin-top: 5px;
    color: var(--muted);
    font-weight: 700;
}

.drop-zone b {
    color: var(--brand-dark);
    font-size: 13px;
}

.upload-progress {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    background: #fff;
}

.progress-copy {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    color: var(--ink);
    font-size: 13px;
}

.progress-copy span {
    color: var(--brand-dark);
    font-weight: 900;
}

.progress-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8e1d5;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--brand), var(--amber));
    transition: width 220ms ease;
}

.original-head,
.result-head,
.panel-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.original-head {
    margin: 16px 0 10px;
}

.original-head h2,
.panel-title h2,
.result-head h2 {
    font-size: 18px;
    line-height: 1.1;
    letter-spacing: 0;
}

.original-head span,
.result-head span,
.panel-title span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-align: right;
}

.panel-title span {
    min-width: 52px;
    border-radius: 999px;
    padding: 6px 9px;
    color: #5b3208;
    background: #fff1da;
}

.original-list {
    display: grid;
    gap: 9px;
}

.original-empty {
    min-height: 84px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    padding: 14px;
}

.original-item {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    background: #fff;
    animation: rise-in 260ms ease both;
}

.original-thumb {
    width: 64px;
    aspect-ratio: 1;
    border-radius: 8px;
    object-fit: cover;
    background: #ece7dd;
}

.original-meta {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.original-meta strong,
.original-meta span,
.result-meta strong,
.result-meta span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.original-meta strong {
    color: var(--ink);
    font-size: 14px;
}

.original-meta span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.settings-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 13px;
}

.panel-title,
.quality-field,
.switch-field,
#nameFormatWrap,
.settings-panel .primary-button,
.status-text {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 8px;
}

.field label,
.quality-field label {
    font-size: 13px;
}

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

.switch-field {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.switch-field input {
    width: 18px;
    height: 18px;
    accent-color: var(--brand);
}

.settings-panel .primary-button {
    margin-top: 4px;
}

.status-text {
    min-height: 20px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.result-panel {
    min-height: 560px;
}

.result-head {
    margin-bottom: 14px;
}

.result-head > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.result-head .secondary-button {
    flex: 0 0 auto;
}

.empty-state {
    min-height: 430px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    text-align: center;
    padding: 24px;
}

.empty-state strong {
    color: var(--ink);
}

.result-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.result-item {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    animation: rise-in 260ms ease both;
}

.result-preview {
    position: relative;
    background: #ece7dd;
}

.thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    display: block;
    object-fit: cover;
}

.result-badge {
    position: absolute;
    left: 9px;
    bottom: 9px;
    border-radius: 999px;
    padding: 5px 8px;
    background: rgba(17, 23, 20, 0.82);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
}

.result-meta {
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 10px;
}

.result-meta strong {
    font-size: 14px;
}

.result-meta span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
    font-weight: 700;
}

.download-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 8px 12px;
    text-decoration: none;
    font-size: 13px;
}

.is-hidden {
    display: none !important;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1060px) {
    .tool-layout {
        grid-template-columns: 1fr;
    }

    .convert-panel {
        grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
        align-items: start;
    }
}

@media (max-width: 780px) {
    .app-shell {
        width: min(100% - 28px, 680px);
        padding-top: 18px;
    }

    .topbar {
        display: grid;
        align-items: start;
    }

    .topbar h1 {
        font-size: 38px;
    }

    .top-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .file-stats {
        flex: 1 1 220px;
    }

    .file-stats span {
        min-width: 0;
        flex: 1;
    }

    .convert-panel {
        grid-template-columns: 1fr;
    }

    .result-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 20px, 520px);
        padding-bottom: 28px;
    }

    .topbar h1 {
        font-size: 32px;
        line-height: 1.05;
    }

    .top-actions,
    .result-head,
    .original-head,
    .panel-title {
        align-items: stretch;
    }

    .top-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .file-stats,
    .file-stats {
        grid-column: 1 / -1;
    }

    .icon-button {
        width: 100%;
    }

    .logout-link {
        min-height: 44px;
    }

    .drop-panel,
    .settings-panel,
    .result-panel {
        padding: 12px;
    }

    .drop-zone {
        min-height: 178px;
        padding: 18px 12px;
    }

    .drop-zone h2 {
        font-size: 22px;
    }

    .settings-panel {
        grid-template-columns: 1fr;
    }

    .result-head {
        display: grid;
    }

    .result-head .secondary-button,
    .download-button {
        width: 100%;
    }

    .empty-state {
        min-height: 300px;
    }
}
