:root {
    --ao-bg: #f2f2f0;
    --ao-panel: #ffffff;
    --ao-text: #0a1452;
    --ao-muted: #60646f;
    --ao-accent: #c69131;
    --ao-accent-dark: #805512;
    --ao-blue: #1f66ff;
    --ao-line: rgba(10, 20, 82, 0.11);
    --ao-line-strong: rgba(10, 20, 82, 0.2);
    --ao-soft: rgba(198, 145, 49, 0.12);
    --ao-shadow: 0 18px 45px rgba(10, 20, 82, 0.12);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Roboto", "Segoe UI", Tahoma, sans-serif;
    color: var(--ao-text);
    background:
        radial-gradient(circle at 5% 5%, rgba(198, 145, 49, 0.22), transparent 28%),
        radial-gradient(circle at 100% 30%, rgba(31, 102, 255, 0.1), transparent 34%),
        linear-gradient(135deg, #f8f6ef 0%, #eef1f4 100%);
}

button,
input {
    font: inherit;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.convert-app {
    width: min(1500px, 100%);
    min-height: calc(100vh - 24px);
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 10px;
}

.app-header {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    border: 1px solid var(--ao-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--ao-shadow);
    backdrop-filter: blur(16px);
}

.logo-link {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 14px;
    outline: none;
}

.logo-link:focus-visible {
    box-shadow: 0 0 0 4px rgba(31, 102, 255, 0.18);
}

.logo {
    width: 190px;
    height: auto;
}

.header-copy {
    min-width: 0;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--ao-accent-dark);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    font-family: "Archivo Black", "Roboto", sans-serif;
    line-height: 1.02;
}

h1 {
    font-size: clamp(1.05rem, 1.45vw, 1.45rem);
    letter-spacing: -0.025em;
}

.header-copy p:last-child,
.section-head p,
.dropzone span,
.format-card small {
    color: var(--ao-muted);
}

.header-copy p:last-child {
    margin: 4px 0 0;
    font-size: 0.88rem;
}

.workflow-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 0.95fr) minmax(390px, 1.35fr) minmax(300px, 1fr);
    gap: 10px;
}

.panel {
    min-height: 0;
    padding: 14px;
    border: 1px solid var(--ao-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--ao-shadow);
    overflow: auto;
}

.section-head {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
}

.section-head h2 {
    font-size: 1.2rem;
}

.section-head p {
    margin: 4px 0 0;
    line-height: 1.35;
}

.step {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ao-text), var(--ao-blue));
    font-weight: 900;
    box-shadow: 0 10px 20px rgba(10, 20, 82, 0.2);
}

.dropzone {
    min-height: 178px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 7px;
    padding: 18px;
    border: 2px dashed rgba(10, 20, 82, 0.22);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(198, 145, 49, 0.08), transparent 45%),
        #ffffff;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.dropzone strong {
    font-size: 1.05rem;
}

.drop-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    color: var(--ao-text);
    background: var(--ao-soft);
    font-size: 1.7rem;
    font-weight: 900;
}

.drop-target.is-dragover,
.dropzone:hover,
.dropzone:focus-visible {
    border-color: rgba(31, 102, 255, 0.5);
    box-shadow: inset 0 0 0 1px rgba(31, 102, 255, 0.16), 0 16px 28px rgba(10, 20, 82, 0.08);
    transform: translateY(-1px);
}

.source-card {
    margin-top: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 12px;
    border: 1px solid var(--ao-line);
    border-radius: 16px;
    background: #ffffff;
}

#sourceThumb {
    width: 88px;
    height: 88px;
    border-radius: 12px;
    object-fit: cover;
    background:
        linear-gradient(45deg, #f2f2f2 25%, transparent 25%),
        linear-gradient(-45deg, #f2f2f2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f2f2f2 75%),
        linear-gradient(-45deg, transparent 75%, #f2f2f2 75%),
        #ffffff;
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

#sourceThumb.is-pdf {
    object-fit: contain;
    padding: 4px;
}

.source-meta {
    min-width: 0;
}

.label {
    display: block;
    margin-bottom: 4px;
    color: var(--ao-muted);
    font-size: 0.78rem;
}

.source-meta strong {
    display: block;
    overflow-wrap: anywhere;
    line-height: 1.2;
}

.source-meta dl {
    margin: 9px 0 0;
    display: grid;
    gap: 4px;
}

.source-meta dl div,
.result-card > div,
.output-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.source-meta dt,
.source-meta dd {
    margin: 0;
}

.source-meta dt,
.output-row span {
    color: var(--ao-muted);
    font-size: 0.78rem;
}

.source-meta dd,
.output-row strong {
    font-weight: 800;
    text-align: right;
}

.pdf-pages-panel {
    margin-top: 12px;
    padding: 10px;
    border: 1px solid var(--ao-line);
    border-radius: 16px;
    background: #ffffff;
}

.pdf-pages-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.pdf-pages-head strong,
.pdf-pages-head span {
    display: block;
}

.pdf-pages-head span {
    margin-top: 2px;
    color: var(--ao-muted);
    font-size: 0.78rem;
}

.pdf-pages-head button {
    flex: 0 0 auto;
    border: 1px solid var(--ao-line);
    border-radius: 999px;
    padding: 7px 10px;
    color: var(--ao-text);
    background: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.pdf-pages-grid {
    max-height: 46vh;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 8px;
    padding-right: 2px;
}

.pdf-page-card {
    position: relative;
    display: grid;
    gap: 5px;
    padding: 6px;
    border: 1px solid var(--ao-line);
    border-radius: 12px;
    background: #fbfbfc;
    cursor: pointer;
}

.pdf-page-card:has(input:checked) {
    border-color: rgba(198, 145, 49, 0.68);
    background: linear-gradient(135deg, rgba(198, 145, 49, 0.12), #ffffff 62%);
}

.pdf-page-card input {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 18px;
    height: 18px;
    accent-color: var(--ao-accent);
}

.pdf-page-card canvas {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px var(--ao-line);
}

.pdf-page-card span {
    text-align: center;
    color: var(--ao-muted);
    font-size: 0.76rem;
    font-weight: 800;
}

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

.format-card {
    min-height: 112px;
    padding: 12px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    border: 1px solid var(--ao-line);
    border-radius: 16px;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.format-card:hover {
    transform: translateY(-1px);
    border-color: var(--ao-line-strong);
    box-shadow: 0 10px 22px rgba(10, 20, 82, 0.08);
}

.format-card:has(input:checked) {
    border-color: rgba(198, 145, 49, 0.68);
    background: linear-gradient(135deg, rgba(198, 145, 49, 0.13), #ffffff 58%);
}

.format-card input {
    width: 18px;
    height: 18px;
    margin: 1px 0 0;
    accent-color: var(--ao-accent);
}

.format-card strong {
    display: block;
    margin-bottom: 5px;
    font-size: 1rem;
}

.format-card small {
    display: block;
    line-height: 1.35;
}

.settings-panel {
    display: flex;
    flex-direction: column;
}

.control-group {
    display: grid;
    gap: 7px;
    margin-bottom: 12px;
}

.control-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.control-head label {
    font-weight: 800;
}

.control-head output {
    font-weight: 900;
}

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

input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ao-line-strong);
    border-radius: 12px;
    color: var(--ao-text);
    background: #ffffff;
}

input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    border: 1px solid var(--ao-line-strong);
    border-radius: 12px;
    background: #ffffff;
}

input:disabled {
    opacity: 0.58;
    cursor: not-allowed;
}

.result-card,
.output-list {
    padding: 10px;
    border: 1px solid var(--ao-line);
    border-radius: 16px;
    background: #ffffff;
}

.result-card {
    display: grid;
    gap: 6px;
    margin: 4px 0 10px;
}

.result-card strong {
    overflow-wrap: anywhere;
    text-align: right;
}

.output-list {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.output-row {
    padding-bottom: 6px;
    border-bottom: 1px solid var(--ao-line);
}

.output-row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.action-stack {
    margin-top: auto;
    display: grid;
    gap: 8px;
}

.primary-button,
.secondary-button {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-button {
    border: 0;
    color: #ffffff;
    background: linear-gradient(135deg, var(--ao-text), var(--ao-blue));
    box-shadow: 0 14px 28px rgba(10, 20, 82, 0.24);
}

.secondary-button {
    color: var(--ao-text);
    border: 1px solid var(--ao-line-strong);
    background: linear-gradient(180deg, #ffffff, #f5f6fb);
}

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

.primary-button:disabled,
.secondary-button:disabled {
    opacity: 0.46;
    cursor: not-allowed;
    box-shadow: none;
}

@media (max-width: 1180px) {
    .convert-app {
        min-height: auto;
    }

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

    .panel {
        overflow: visible;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 8px;
    }

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

    .logo {
        width: 170px;
    }

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

    .source-card {
        grid-template-columns: 1fr;
    }

    #sourceThumb {
        width: 100%;
        height: 170px;
    }

    .pdf-pages-grid {
        max-height: none;
    }
}
