:root {
    --bg: #ffffff;
    --text: #1a1a1a;
    --muted: #666;
    --border: #ccc;
    --card-bg: #ffffff;
    --input-bg: #ffffff;
    --ok-bg: #e6f7e6;
    --ok-border: #4caf50;
    --error-bg: #fdecea;
    --error-border: #f44336;
    --spinner-track: #e6e6e6;
    --spinner-accent: #2196f3;
}

[data-theme="dark"] {
    --bg: #121212;
    --text: #e8e8e8;
    --muted: #a0a0a0;
    --border: #444;
    --card-bg: #1e1e1e;
    --input-bg: #2a2a2a;
    --ok-bg: #163a1c;
    --ok-border: #4caf50;
    --error-bg: #3a1a18;
    --error-border: #f44336;
    --spinner-track: #333333;
    --spinner-accent: #64b5f6;
}

#rainbow-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(to right,
        hsl(0, 100%, 50%), hsl(51, 100%, 50%), hsl(103, 100%, 50%), hsl(154, 100%, 50%),
        hsl(206, 100%, 50%), hsl(257, 100%, 50%), hsl(309, 100%, 50%), hsl(360, 100%, 50%));
    animation: rainbow-hue-shift 6s linear infinite;
    z-index: 1001;
}

@keyframes rainbow-hue-shift {
    from {
        filter: hue-rotate(0deg);
    }
    to {
        filter: hue-rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    #rainbow-bar {
        animation: none;
    }
}

body {
    font-family: system-ui, sans-serif;
    max-width: 560px;
    margin: 40px auto;
    padding: 0 16px;
    background: var(--bg);
    color: var(--text);
    transition: background-color 0.2s, color 0.2s;
}

.seo-intro h1 {
    font-size: 1.7rem;
    margin-bottom: 4px;
}

.seo-intro p {
    color: var(--muted);
    margin: 0 0 20px;
}

label {
    display: block;
    margin-top: 16px;
    font-weight: 600;
}

select,
#captchaAnswer {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.captcha-challenge {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--input-bg);
}

#captchaQuestion {
    flex: 1;
    font-weight: 600;
}

#captchaRefresh {
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--card-bg);
    color: var(--text);
    font-size: 1.1rem;
}

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

#dropZone {
    margin-top: 4px;
    padding: 24px 16px;
    box-sizing: border-box;
    border: 2px dashed var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--muted);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

#dropZone:hover,
#dropZone:focus-visible {
    border-color: var(--spinner-accent);
    color: var(--text);
}

#dropZone:focus-visible {
    outline: 2px solid var(--spinner-accent);
    outline-offset: 2px;
}

#dropZone.drag-active {
    border-color: var(--spinner-accent);
    background: color-mix(in srgb, var(--spinner-accent) 12%, var(--input-bg));
    color: var(--text);
}

#dropZoneIcon {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 6px;
}

#dropZoneText {
    font-size: 0.9rem;
    word-break: break-word;
}

button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

#result {
    margin-top: 20px;
    padding: 12px;
    border-radius: 6px;
    display: none;
}

#result.ok {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    display: block;
}

#result.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    display: block;
}

#result a {
    font-weight: 600;
    color: inherit;
}

.preview-media {
    display: block;
    margin: 0 0 12px;
}

.preview-image, .preview-video {
    max-width: 100%;
    max-height: 320px;
    border-radius: 6px;
}

.preview-audio {
    width: 100%;
}

.preview-pdf {
    width: 100%;
    height: 400px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.result-message {
    margin: 0 0 8px;
}

.download-button {
    display: inline-block;
    padding: 8px 16px;
    background: var(--spinner-accent);
    color: #06213c;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

#progress-container {
    display: none;
    margin: 28px auto 0;
    text-align: center;
}

.spinner {
    width: 56px;
    height: 56px;
    margin: 0 auto;
    border: 6px solid var(--spinner-track);
    border-top-color: var(--spinner-accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#progress-label {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--muted);
}

#controls {
    position: fixed;
    bottom: 16px;
    right: 16px;
    display: flex;
    gap: 8px;
    align-items: center;
    z-index: 1000;
}

.control-chip {
    height: 40px;
    margin-top: 0;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

#controls button {
    width: 40px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#langSelect {
    width: auto;
    padding: 0 10px;
    box-sizing: border-box;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Dims the rest of the page while the drawer is open - without this, the opaque drawer just
   slices across whatever text happens to be underneath it, which reads as a rendering glitch
   rather than an intentional overlay. Sits below the drawer (z-index) but above everything else. */
#quickLinksBackdrop {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 35%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 998;
}

#quickLinksBackdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

#quickLinksDrawer {
    position: fixed;
    top: 40px;
    left: 0;
    width: 210px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
}

#quickLinksDrawer.is-open {
    transform: translateX(0);
}

#quickLinks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    box-shadow: 4px 6px 20px rgb(0 0 0 / 25%);
}

#quickLinksLabel {
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 2px;
}

#quickLinks a {
    color: var(--text);
    text-decoration: none;
}

#quickLinks a:hover,
#quickLinks a:focus-visible {
    text-decoration: underline;
}

#quickLinksToggle {
    position: absolute;
    top: 20px;
    left: 100%;
    width: 36px;
    height: 48px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border);
    border-left: 0;
    border-radius: 0 8px 8px 0;
    background: var(--card-bg);
    color: var(--text);
    font-size: 1.7rem;
    line-height: 1;
    box-shadow: 4px 6px 20px rgb(0 0 0 / 25%);
    transition: color 0.2s ease;
}

#quickLinksToggle:hover,
#quickLinksToggle:focus-visible {
    color: var(--spinner-accent);
}

#quickLinksToggle:focus-visible {
    outline: 2px solid var(--spinner-accent);
    outline-offset: 2px;
}

#quickLinksDrawer.is-open #quickLinksToggle span {
    display: block;
    transform: rotate(180deg);
}

#changelog {
    position: fixed;
    bottom: 64px;
    left: 16px;
    z-index: 999;
    display: flex;
    flex-direction: column-reverse;
    max-width: 280px;
}

/* Sits directly below the changelog widget, above copyright - same left-aligned fixed-footer
   column, same muted small-text treatment as the rest of that stack. */
#footerLinks {
    position: fixed;
    bottom: 40px;
    left: 16px;
    right: 16px;
    z-index: 999;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 0.8rem;
}

#footerLinks a {
    color: var(--muted);
    text-decoration: none;
}

#footerLinks a:hover,
#footerLinks a:focus-visible {
    text-decoration: underline;
}

#footerLinks .footer-separator {
    color: var(--border);
}

#changelog summary {
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--muted);
    user-select: none;
    list-style: none;
}

#changelog summary::-webkit-details-marker {
    display: none;
}

#changelog summary::before {
    content: '▸ ';
}

#changelog[open] summary::before {
    content: '▾ ';
}

#changelogContent {
    max-height: 200px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: var(--text);
}

#changelogContent ul {
    margin: 0 0 8px;
    padding-left: 18px;
}

#changelogContent li {
    margin-bottom: 4px;
}

.changelog-date {
    font-weight: 600;
    margin-top: 8px;
}

.changelog-date:first-child {
    margin-top: 0;
}

#copyright {
    position: fixed;
    bottom: 16px;
    left: 16px;
    font-size: 0.8rem;
    color: var(--muted);
    z-index: 1000;
}

/* Standalone informational pages (privacy/terms/faq/contact) - src/main/resources/pages/,
   served by esley.converter.pages.StaticPageController. Same body/theme shell as the converter
   form, but a plain readable content column instead of the form layout. */
.back-link {
    display: inline-block;
    margin-bottom: 16px;
    color: var(--spinner-accent);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: underline;
}

.back-link:hover,
.back-link:focus-visible {
    text-decoration: none;
}

.page-content h1 {
    font-size: 1.6rem;
    margin: 0 0 8px;
}

.page-content h2 {
    font-size: 1.15rem;
    margin: 28px 0 8px;
}

.page-content p,
.page-content li {
    line-height: 1.6;
    color: var(--text);
}

.page-content ul,
.page-content ol {
    padding-left: 22px;
}

.page-content .page-updated {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 24px;
}

.faq-item {
    margin-bottom: 20px;
}

.faq-item h2 {
    font-size: 1rem;
    margin: 0 0 6px;
}

#contactForm .form-status {
    margin-top: 16px;
    padding: 12px;
    border-radius: 6px;
    display: none;
}

#contactForm .form-status.ok {
    background: var(--ok-bg);
    border: 1px solid var(--ok-border);
    display: block;
}

#contactForm .form-status.error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    display: block;
}

#contactForm input[type=text],
#contactForm input[type=email],
#contactForm textarea {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    box-sizing: border-box;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

#contactForm textarea {
    resize: vertical;
    min-height: 120px;
}

/* Below this width the h1/intro text reaches the left edge, where the quickLinks toggle tab
   sits (top: 40px, same as the body's top margin) - colliding with whatever the heading/intro
   wraps to. Reserving a left gutter on the intro block itself (not a fixed pixel offset on the
   tab) keeps the tab clear for the full height of that block regardless of how many lines it
   wraps into in any language - a vertical offset tuned for one language's line count would just
   break for a longer one. Content that scrolls under the tab later (a small fixed corner
   element, same as #controls) is the normal, accepted trade-off for a persistent nav affordance. */
@media (max-width: 600px) {
    .seo-intro {
        padding-left: 44px;
    }

    /* On narrow screens these were fixed over the bottom-left corner, permanently covering
       the last lines of on-page text while scrolling through the long FAQ/Regulamin/Polityka
       pages. Below this width there's no spare margin for them to float in, so they go back
       into normal document flow and land after the page content instead. */
    #changelog,
    #footerLinks,
    #copyright {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        max-width: none;
    }

    #footerLinks {
        margin: 16px 0 4px;
    }

    #copyright {
        margin: 4px 0 24px;
    }

    /* #controls (theme/language) stays fixed - small enough not to block reading - but body
       needs room at the bottom so it doesn't rest directly on top of the last line of text. */
    body {
        padding-bottom: 64px;
    }
}
