:root {
    color-scheme: light;
    --ink: #202124;
    --muted: #63666a;
    --line: #d9dde3;
    --paper: #ffffff;
    --soft: #f4f7f9;
    --accent: #147d64;
    --accent-2: #0f5d9d;
    --danger: #b3261e;
    --ok: #0d7a3f;
    --shadow: 0 18px 55px rgba(28, 35, 43, .12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f7f9;
    color: var(--ink);
}

code {
    background: rgba(20, 125, 100, .1);
    border-radius: 4px;
    padding: 2px 5px;
}

.app-shell,
.setup-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 38px 0;
}

.workspace,
.setup-panel {
    background: #fff;
    border: 1px solid rgba(217, 221, 227, .95);
    border-radius: 8px;
    box-shadow: 0 14px 42px rgba(28, 35, 43, .09);
    padding: 26px;
}

.workspace {
    display: flex;
    flex-direction: column;
}

.tool-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.brand-logo {
    width: min(300px, 100%);
    height: 76px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    margin-bottom: 16px;
    overflow: hidden;
}

.brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.compact-logo {
    width: 240px;
    height: 64px;
}

.subtitle {
    max-width: 620px;
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

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

.eyebrow {
    margin: 0 0 7px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: clamp(28px, 4vw, 46px);
    line-height: 1.05;
}

h2 {
    font-size: 24px;
}

.ghost-link,
.ghost-button,
.primary-link,
.primary-button {
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.ghost-link,
.ghost-button {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 10px 14px;
    white-space: nowrap;
    cursor: pointer;
}

.primary-link,
.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(20, 125, 100, .2);
}

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

.alert,
.message {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 18px;
}

.install-form {
    display: grid;
    gap: 14px;
    margin: 22px 0 18px;
}

.install-form label {
    display: grid;
    gap: 7px;
    color: var(--ink);
    font-weight: 700;
}

.install-form span {
    font-size: 14px;
}

.install-form input {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

.install-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(20, 125, 100, .12);
    outline: 0;
}

.manual-config {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    padding: 14px;
    margin: 18px 0;
}

.manual-config p {
    margin: 8px 0 12px;
}

.manual-config textarea {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    resize: vertical;
    font: 13px/1.5 Consolas, monospace;
}

.install-grid,
.install-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(120px, 170px);
    gap: 12px;
}

.install-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.account-strip {
    display: grid;
    grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 20px;
}

.quota-card,
.auth-panel,
.plan-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 16px;
}

.quota-card span,
.plan-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.quota-card strong,
.plan-card strong {
    display: block;
    font-size: 22px;
    margin-bottom: 10px;
}

.quota-card small,
.plan-card small {
    color: var(--muted);
    line-height: 1.45;
}

.quota-track {
    height: 9px;
    border-radius: 999px;
    background: #e8edf0;
    overflow: hidden;
    margin-bottom: 10px;
}

.quota-track div {
    height: 100%;
    max-width: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.auth-panel {
    display: grid;
    gap: 12px;
}

.simple-copy {
    display: grid;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
}

.simple-copy strong {
    font-size: 18px;
}

.simple-copy span {
    color: var(--muted);
    font-size: 14px;
}

.auth-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    align-items: end;
}

.auth-note {
    color: var(--muted);
    line-height: 1.45;
}

.auth-form label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.auth-form input {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 15px;
}

.compact-auth {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.auth-form .primary-button {
    grid-column: span 4;
}

.compact-auth .ghost-button {
    grid-column: auto;
}

.alert {
    background: #fff4e0;
    color: #7b4d00;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.message {
    margin-top: 18px;
}

.message.success {
    background: #e6f4ea;
    color: var(--ok);
}

.message.error {
    background: #fce8e6;
    color: var(--danger);
}

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

.drop-zone {
    min-height: 380px;
    border: 2px dashed #aab6c2;
    border-radius: 8px;
    background: #f8fafb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    cursor: pointer;
    padding: 24px;
    transition: border-color .2s ease, background .2s ease;
}

.drop-zone input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.drop-zone.is-dragging,
.drop-zone.has-file {
    border-color: var(--accent);
    background: #edf8f4;
}

.drop-icon {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: white;
    font-size: 38px;
    line-height: 1;
}

.flow-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0 0 18px;
}

.flow-strip div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.flow-strip span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #e8f2ef;
    color: var(--accent);
    font-weight: 800;
}

.flow-strip strong {
    font-size: 14px;
}

.drop-title {
    font-size: 24px;
    font-weight: 800;
}

.drop-text,
.file-name {
    color: var(--muted);
}

.file-name {
    max-width: 100%;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.control-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: #fff;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-weight: 700;
}

.number-control {
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.number-control input {
    width: 100%;
    height: 100%;
    border: 0;
    padding: 0 12px;
    font-size: 16px;
}

.number-control span {
    padding: 0 12px;
    color: var(--muted);
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}

.segmented label {
    cursor: pointer;
}

.segmented input {
    position: absolute;
    opacity: 0;
}

.segmented span {
    display: grid;
    place-items: center;
    min-height: 42px;
    color: var(--muted);
}

.segmented input:checked + span {
    background: var(--accent-2);
    color: white;
}

.tool-status,
.status-grid,
.metrics {
    display: grid;
    gap: 10px;
}

.tool-status div,
.status-grid div,
.metrics div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    background: #fff;
}

.tool-status span,
.status-grid span,
.metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.result-panel {
    margin-top: 22px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: stretch;
}

.preview-wrap {
    min-height: 320px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: repeating-conic-gradient(#f6f7f8 0 25%, #e8ecef 0 50%) 50% / 24px 24px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.preview-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.result-info {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fff;
}

.history-panel {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 18px;
}

.history-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.history-head span,
.muted-text {
    color: var(--muted);
    font-size: 13px;
}

.empty-history {
    border: 1px dashed #aab6c2;
    border-radius: 8px;
    background: #f8fafb;
    padding: 18px;
    display: grid;
    gap: 6px;
}

.empty-history span {
    color: var(--muted);
}

.history-table-wrap {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th,
.history-table td {
    border-bottom: 1px solid var(--line);
    padding: 11px 8px;
    text-align: left;
    white-space: nowrap;
}

.history-thumb {
    width: 58px;
    height: 58px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: repeating-conic-gradient(#f6f7f8 0 25%, #e8ecef 0 50%) 50% / 14px 14px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.history-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.empty-thumb {
    color: var(--muted);
}

.history-table th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.history-badge {
    display: inline-flex;
    border-radius: 999px;
    background: #e8f2ef;
    color: var(--accent);
    padding: 4px 9px;
    font-size: 12px;
    font-weight: 800;
}

.mini-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    border-radius: 6px;
    padding: 0 12px;
    color: #fff;
    background: var(--accent-2);
    text-decoration: none;
    font-weight: 800;
    font-size: 13px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
}

.pagination a,
.pagination span,
.pagination strong {
    border-radius: 6px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.pagination a {
    background: var(--accent-2);
    color: #fff;
}

.pagination span {
    color: var(--muted);
    background: #f0f3f5;
}

.pagination strong {
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
}

.seo-content {
    margin-top: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 18px;
    display: grid;
    gap: 16px;
}

.seo-content p {
    color: var(--muted);
    line-height: 1.6;
    margin: 10px 0 0;
}

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

.faq-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 14px;
}

.faq-grid h3 {
    margin: 0;
    font-size: 16px;
}

.metrics {
    grid-template-columns: 1fr 1fr;
    margin: 16px 0;
}

.setup-panel {
    max-width: 760px;
    margin: 0 auto;
}

.setup-panel p:not(.eyebrow) {
    color: var(--muted);
}

.text-page p {
    line-height: 1.6;
}

.setup-hint {
    overflow-wrap: anywhere;
}

.site-footer {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 18px;
    color: var(--muted);
    font-size: 14px;
}

.site-footer a {
    color: var(--accent-2);
    font-weight: 700;
    text-decoration: none;
}

.status-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin: 20px 0;
}

@media (max-width: 820px) {
    .app-shell,
    .setup-page {
        width: min(100% - 20px, 1120px);
        padding: 18px 0;
    }

    .workspace,
    .setup-panel {
        padding: 18px;
    }

    .tool-header,
    .converter-grid,
    .result-panel,
    .account-strip,
    .flow-strip,
    .faq-grid,
    .install-grid,
    .install-actions,
    .status-grid {
        grid-template-columns: 1fr;
    }

    .history-head {
        display: grid;
    }

    .tool-header {
        display: grid;
        order: 1;
    }

    .brand-logo {
        width: 100%;
        height: 68px;
    }

    .header-actions {
        justify-content: flex-start;
    }

    .workspace > .message,
    .workspace > .alert {
        order: 2;
    }

    .converter-grid {
        order: 3;
    }

    .result-panel {
        order: 4;
    }

    #message {
        order: 5;
    }

    .flow-strip {
        order: 6;
    }

    .account-strip {
        order: 7;
    }

    .history-panel {
        order: 8;
    }

    .seo-content {
        order: 9;
    }

    .site-footer {
        order: 10;
    }

    .auth-form,
    .compact-auth {
        grid-template-columns: 1fr;
    }

    .drop-zone {
        min-height: 260px;
        padding: 20px 16px;
    }

    .drop-title {
        font-size: 22px;
    }

    .control-panel,
    .quota-card,
    .auth-panel,
    .plan-card,
    .history-panel,
    .seo-content {
        padding: 14px;
    }

    .primary-button,
    .primary-link,
    .ghost-link,
    .ghost-button {
        width: 100%;
    }

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

    .history-table th,
    .history-table td {
        padding: 10px 7px;
    }

    .pagination {
        justify-content: stretch;
        display: grid;
        grid-template-columns: 1fr;
        text-align: center;
    }
}
