/* Stackaris Base64 Encoder & Decoder - scoped, responsive, no dependencies */
.b64-tool {
    --b64-primary: #2563eb;
    --b64-primary-2: #06b6d4;
    --b64-accent: #14b8a6;
    --b64-bg: #eef4f9;
    --b64-bg-2: #fbfdff;
    --b64-card: rgba(255, 255, 255, 0.94);
    --b64-card-solid: #ffffff;
    --b64-code: #f8fafc;
    --b64-text: #122033;
    --b64-muted: #617086;
    --b64-faint: #93a0b2;
    --b64-border: rgba(15, 23, 42, 0.1);
    --b64-success: #059669;
    --b64-warning: #b45309;
    --b64-danger: #dc2626;
    --b64-shadow: 0 18px 52px rgba(15, 23, 42, 0.1);
    --b64-shadow-soft: 0 8px 26px rgba(15, 23, 42, 0.08);
    --b64-radius-sm: 8px;
    --b64-radius: 14px;
    --b64-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --b64-mono: "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, monospace;
    background:
        linear-gradient(180deg, var(--b64-bg-2), var(--b64-bg) 320px),
        var(--b64-bg);
    color: var(--b64-text);
    font-family: var(--b64-font);
    line-height: 1.6;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    overflow-x: hidden;
    width: 100vw;
}

.b64-tool[data-theme="dark"] {
    --b64-bg: #0f172a;
    --b64-bg-2: #111827;
    --b64-card: rgba(30, 41, 59, 0.92);
    --b64-card-solid: #1e293b;
    --b64-code: rgba(15, 23, 42, 0.72);
    --b64-text: #e7eef9;
    --b64-muted: #a9b5c8;
    --b64-faint: #728098;
    --b64-border: rgba(226, 232, 240, 0.12);
    --b64-shadow: 0 18px 54px rgba(0, 0, 0, 0.38);
    --b64-shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.28);
}

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

.b64-tool h1,
.b64-tool h2,
.b64-tool h3,
.b64-tool p {
    margin-top: 0;
}

.b64-hero {
    background:
        radial-gradient(ellipse 58% 42% at 50% 8%, rgba(37, 99, 235, 0.14), transparent 68%),
        linear-gradient(180deg, var(--b64-bg-2), transparent);
    padding: 58px 20px 24px;
    text-align: center;
}

.b64-hero__content {
    margin: 0 auto;
    max-width: 800px;
}

.b64-kicker,
.b64-eyebrow {
    color: var(--b64-primary);
    font-size: 0.75rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.b64-hero h1 {
    background: linear-gradient(135deg, var(--b64-text) 28%, var(--b64-primary), var(--b64-accent));
    background-clip: text;
    color: var(--b64-text);
    font-size: clamp(2.05rem, 5vw, 3.2rem);
    font-weight: 850;
    letter-spacing: 0;
    line-height: 1.1;
    margin-bottom: 14px;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.b64-hero__copy {
    color: var(--b64-muted);
    font-size: 1.02rem;
    line-height: 1.75;
    margin: 0 auto;
    max-width: 730px;
}

.b64-hero__stats {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    justify-content: center;
    margin-top: 28px;
}

.b64-hero__stats span {
    color: var(--b64-faint);
    display: inline-flex;
    flex-direction: column;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    min-width: 92px;
    text-transform: uppercase;
}

.b64-hero__stats span:not(:last-child) {
    border-right: 1px solid var(--b64-border);
    padding-right: 18px;
}

.b64-hero__stats strong {
    color: var(--b64-primary);
    font-size: 1.08rem;
    letter-spacing: 0;
    text-transform: none;
}

.b64-modebar,
.b64-workspace,
.b64-content,
.b64-faq,
.b64-related {
    margin-left: auto;
    margin-right: auto;
    max-width: 1240px;
    width: calc(100% - 40px);
}

.b64-modebar {
    align-items: center;
    background: var(--b64-card);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius);
    box-shadow: var(--b64-shadow-soft);
    display: flex;
    justify-content: space-between;
    margin-top: 34px;
    padding: 12px 16px;
}

.b64-modebar__name {
    color: var(--b64-text);
    font-size: 0.88rem;
    font-weight: 850;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.b64-theme-toggle,
.b64-btn,
.b64-segment button {
    align-items: center;
    border-radius: var(--b64-radius-sm);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 800;
    justify-content: center;
    min-height: 38px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.b64-theme-toggle {
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.24);
    color: var(--b64-primary);
    gap: 8px;
    padding: 7px 12px;
}

.b64-theme-toggle__track {
    background: linear-gradient(135deg, var(--b64-primary), var(--b64-primary-2));
    border-radius: 999px;
    height: 18px;
    position: relative;
    width: 34px;
}

.b64-theme-toggle__track::after {
    background: #fff;
    border-radius: 50%;
    content: "";
    height: 14px;
    left: 2px;
    position: absolute;
    top: 2px;
    transition: transform 0.18s ease;
    width: 14px;
}

.b64-tool[data-theme="dark"] .b64-theme-toggle__track::after {
    transform: translateX(16px);
}

.b64-workspace {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.82fr);
    padding-bottom: 18px;
}

.b64-panel,
.b64-content,
.b64-faq,
.b64-related {
    background: var(--b64-card);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius);
    box-shadow: var(--b64-shadow-soft);
}

.b64-panel {
    min-width: 0;
}

.b64-panel__header,
.b64-section-heading {
    align-items: center;
    border-bottom: 1px solid var(--b64-border);
    display: flex;
    gap: 14px;
    justify-content: space-between;
    padding: 16px 20px;
}

.b64-panel h2,
.b64-content h2,
.b64-faq h2,
.b64-related h2 {
    color: var(--b64-text);
    font-size: 1.12rem;
    font-weight: 780;
    line-height: 1.25;
    margin: 0;
}

.b64-badge {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: 999px;
    color: var(--b64-muted);
    flex: 0 0 auto;
    font-size: 0.75rem;
    font-weight: 850;
    padding: 8px 12px;
}

.b64-badge.is-good { color: var(--b64-success); }
.b64-badge.is-warn { color: var(--b64-warning); }
.b64-badge.is-bad { color: var(--b64-danger); }

.b64-toolbar,
.b64-editor-grid,
.b64-actions,
.b64-validation,
.b64-dropzone,
.b64-filemeta,
.b64-preview,
.b64-switch--wide {
    margin-left: 20px;
    margin-right: 20px;
}

.b64-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.b64-segment {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    display: inline-grid;
    grid-template-columns: repeat(3, minmax(82px, 1fr));
    overflow: hidden;
}

.b64-segment button {
    background: transparent;
    border: 0;
    color: var(--b64-muted);
    padding: 8px 12px;
}

.b64-segment button.is-active {
    background: linear-gradient(135deg, var(--b64-primary), var(--b64-primary-2));
    color: #fff;
}

.b64-switch {
    align-items: center;
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    color: var(--b64-text);
    display: inline-flex;
    font-size: 0.86rem;
    font-weight: 760;
    gap: 9px;
    min-height: 40px;
    padding: 9px 12px;
}

.b64-switch input {
    accent-color: var(--b64-primary);
    height: 17px;
    width: 17px;
}

.b64-switch--wide {
    display: flex;
    margin-bottom: 20px;
    margin-top: 14px;
}

.b64-editor-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
}

.b64-field {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.b64-field__top {
    align-items: center;
    display: flex;
    justify-content: space-between;
}

.b64-field label {
    color: var(--b64-text);
    font-size: 0.86rem;
    font-weight: 850;
}

.b64-field__top span {
    color: var(--b64-muted);
    font-size: 0.78rem;
    font-weight: 760;
}

.b64-field textarea {
    background:
        linear-gradient(90deg, rgba(37, 99, 235, 0.08) 0 38px, transparent 38px),
        var(--b64-code);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    color: var(--b64-text);
    font-family: var(--b64-mono);
    font-size: 0.92rem;
    line-height: 1.62;
    min-height: 320px;
    outline: none;
    overflow-wrap: normal;
    padding: 16px 16px 16px 52px;
    resize: vertical;
    tab-size: 4;
    white-space: pre-wrap;
    width: 100%;
}

.b64-field textarea::placeholder {
    color: var(--b64-faint);
}

.b64-field textarea:focus,
.b64-btn:focus-visible,
.b64-theme-toggle:focus-visible,
.b64-segment button:focus-visible,
.b64-switch input:focus-visible,
.b64-dropzone:focus-within,
.b64-related a:focus-visible,
.b64-faq summary:focus-visible {
    border-color: rgba(37, 99, 235, 0.52);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
    outline: none;
}

.b64-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.b64-btn {
    border: 1px solid transparent;
    padding: 9px 15px;
}

.b64-btn:hover,
.b64-theme-toggle:hover,
.b64-related a:hover {
    transform: translateY(-1px);
}

.b64-btn--primary {
    background: linear-gradient(135deg, var(--b64-primary), var(--b64-primary-2));
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
    color: #fff;
}

.b64-btn--ghost {
    background: var(--b64-card-solid);
    border-color: var(--b64-border);
    color: var(--b64-text);
}

.b64-btn--quiet {
    background: transparent;
    border-color: var(--b64-border);
    color: var(--b64-muted);
}

.b64-validation {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(20, 184, 166, 0.08));
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    color: var(--b64-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    margin-top: 14px;
    padding: 13px 14px;
}

.b64-panel--upload {
    align-self: start;
}

.b64-dropzone {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(20, 184, 166, 0.08)),
        var(--b64-card-solid);
    border: 1px dashed rgba(37, 99, 235, 0.42);
    border-radius: var(--b64-radius);
    cursor: pointer;
    display: grid;
    justify-items: center;
    margin-top: 18px;
    min-height: 210px;
    padding: 24px;
    text-align: center;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.b64-dropzone.is-dragging {
    border-color: var(--b64-accent);
    transform: translateY(-1px);
}

.b64-dropzone input {
    border: 0;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

.b64-dropzone__icon {
    align-items: center;
    background: linear-gradient(135deg, var(--b64-primary), var(--b64-primary-2));
    border-radius: 50%;
    color: #fff;
    display: inline-flex;
    font-size: 1.8rem;
    font-weight: 300;
    height: 48px;
    justify-content: center;
    line-height: 1;
    margin-bottom: 12px;
    width: 48px;
}

.b64-dropzone strong {
    color: var(--b64-text);
    font-size: 1rem;
}

.b64-dropzone span:last-child {
    color: var(--b64-muted);
    font-size: 0.86rem;
    margin-top: 4px;
}

.b64-filemeta {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    display: grid;
    gap: 10px;
    margin-top: 14px;
    padding: 14px;
}

.b64-filemeta[hidden],
.b64-preview[hidden] {
    display: none;
}

.b64-filemeta div {
    display: grid;
    gap: 2px;
}

.b64-filemeta span {
    color: var(--b64-muted);
    font-size: 0.72rem;
    font-weight: 820;
    text-transform: uppercase;
}

.b64-filemeta strong {
    color: var(--b64-text);
    font-size: 0.88rem;
    overflow-wrap: anywhere;
}

.b64-preview {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    margin-top: 14px;
    max-height: 260px;
    overflow: hidden;
    padding: 10px;
}

.b64-preview img {
    border-radius: 6px;
    display: block;
    height: auto;
    max-height: 236px;
    max-width: 100%;
    object-fit: contain;
    width: 100%;
}

.b64-content,
.b64-faq,
.b64-related {
    margin-top: 18px;
}

.b64-content {
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    padding: 34px 20px;
}

.b64-content p,
.b64-faq p {
    color: var(--b64-muted);
    margin-bottom: 0;
}

.b64-content__grid,
.b64-related__grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.b64-content article {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius);
    padding: 18px;
}

.b64-content h3 {
    color: var(--b64-text);
    font-size: 1rem;
    margin-bottom: 8px;
}

.b64-faq,
.b64-related {
    padding-bottom: 18px;
}

.b64-faq details {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius-sm);
    margin: 10px 20px 0;
    padding: 14px 16px;
}

.b64-faq summary {
    color: var(--b64-text);
    cursor: pointer;
    font-weight: 850;
}

.b64-faq code {
    background: rgba(37, 99, 235, 0.1);
    border-radius: 5px;
    color: var(--b64-primary);
    padding: 1px 5px;
}

.b64-related {
    margin-bottom: 56px;
}

.b64-related__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 0 20px 20px;
}

.b64-related a {
    background: var(--b64-card-solid);
    border: 1px solid var(--b64-border);
    border-radius: var(--b64-radius);
    color: var(--b64-text);
    font-weight: 850;
    padding: 18px;
    text-align: center;
    text-decoration: none;
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.b64-related a:hover {
    border-color: rgba(37, 99, 235, 0.42);
    box-shadow: var(--b64-shadow-soft);
    color: var(--b64-primary);
}

@media (prefers-reduced-motion: reduce) {
    .b64-tool *,
    .b64-tool *::before,
    .b64-tool *::after {
        transition: none !important;
    }
}

@media (max-width: 1080px) {
    .b64-workspace,
    .b64-content {
        grid-template-columns: 1fr;
    }

    .b64-panel--upload {
        align-self: stretch;
    }
}

@media (max-width: 820px) {
    .b64-editor-grid,
    .b64-content__grid,
    .b64-related__grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .b64-hero {
        padding: 38px 16px 22px;
    }

    .b64-hero__stats span:not(:last-child) {
        border-right: 0;
        padding-right: 0;
    }

    .b64-modebar,
    .b64-workspace,
    .b64-content,
    .b64-faq,
    .b64-related {
        width: calc(100% - 28px);
    }

    .b64-modebar,
    .b64-panel__header,
    .b64-section-heading,
    .b64-field__top {
        align-items: flex-start;
        flex-direction: column;
    }

    .b64-modebar {
        gap: 12px;
    }

    .b64-toolbar,
    .b64-editor-grid,
    .b64-actions,
    .b64-validation,
    .b64-dropzone,
    .b64-filemeta,
    .b64-preview,
    .b64-switch--wide {
        margin-left: 16px;
        margin-right: 16px;
    }

    .b64-segment {
        width: 100%;
    }

    .b64-switch {
        width: 100%;
    }

    .b64-field textarea {
        min-height: 240px;
    }

    .b64-actions .b64-btn {
        flex: 1 1 135px;
    }

    .b64-content {
        padding: 26px 16px;
    }

    .b64-faq details {
        margin-left: 16px;
        margin-right: 16px;
    }

    .b64-related__grid {
        padding: 0 16px 16px;
    }
}

@media (max-width: 430px) {
    .b64-hero h1 {
        font-size: 2rem;
    }

    .b64-theme-toggle,
    .b64-segment {
        width: 100%;
    }

    .b64-segment {
        grid-template-columns: 1fr;
    }
}
