/**
 * Base64 encode / decode.
 */

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.em-b64__tabs {
    display: flex;
    gap: .4em;
    margin-bottom: 1em;
    border-bottom: 1px solid var(--em-line, #e5e7eb);
}

.em-b64__tab {
    padding: .6em 1.1em;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--em-soft, #6b7280);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.em-b64__tab.is-active {
    border-bottom-color: var(--em-brand, #2563eb);
    color: var(--em-brand, #2563eb);
}

/* ── The row of controls ───────────────────────────────────────────────── */

.em-b64__bar {
    display: flex;
    flex-wrap: wrap;
    gap: .8em 1.2em;
    align-items: center;
    padding: .75em 1em;
    border: 1px solid var(--em-line, #e5e7eb);
    border-radius: 10px;
    background: var(--em-surface, #fff);
}

/* Encode and decode are one control, so they sit in one pill. */
.em-b64__group {
    display: inline-flex;
    padding: 3px;
    border-radius: 8px;
    background: var(--em-tint, #f0f6ff);
}

.em-b64__way {
    padding: .4em .95em;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--em-soft, #6b7280);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.em-b64__way.is-active {
    background: var(--em-brand, #2563eb);
    color: var(--em-on-brand, #fff);
}

.em-b64__check {
    display: flex;
    align-items: center;
    gap: .45em;
    color: var(--em-ink, inherit);
}

.em-b64__check input { accent-color: var(--em-brand, #2563eb); }

.em-b64__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5em;
    margin-left: auto;
}

.em-b64__copy,
.em-b64__swap,
.em-b64__clear {
    padding: .5em 1em;
    border: 1px solid var(--em-brand, #2563eb);
    border-radius: 8px;
    background: transparent;
    color: var(--em-brand, #2563eb);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.em-b64__clear {
    border-color: var(--em-line, #e5e7eb);
    color: var(--em-soft, #6b7280);
    font-weight: 400;
}

/* ── What it has to say ────────────────────────────────────────────────── */

.em-b64__status {
    margin: .9em 0 0;
    padding: .65em .9em;
    border-left: 3px solid var(--em-line, #e5e7eb);
    border-radius: 0 8px 8px 0;
    font-size: .92rem;
    line-height: 1.55;
    color: var(--em-ink, inherit);
}

.em-b64__status.is-good { border-left-color: #16a34a; background: rgba(22, 163, 74, .10); }

/* The decode failure is the message people came for. */
.em-b64__status.is-bad {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, .10);
    font-weight: 600;
}

/* ── Boxes ─────────────────────────────────────────────────────────────── */

.em-b64__panes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 1em;
    margin-top: 1em;
}

.em-b64__label {
    display: block;
    margin: 1em 0 .4em;
    font-weight: 600;
    color: var(--em-ink, inherit);
}

.em-b64__panes .em-b64__label { margin-top: 0; }

.em-b64__area {
    display: block;
    width: 100%;
    padding: .8em;
    border: 1px solid var(--em-line, #e5e7eb);
    border-radius: 10px;
    background: var(--em-surface, #fff);
    color: var(--em-ink, inherit);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .88rem;
    line-height: 1.6;
    resize: vertical;
    /* Base64 is one unbroken run of characters and must wrap, or the box
       scrolls sideways forever. */
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.em-b64__area:focus-visible {
    outline: 2px solid var(--em-brand, #2563eb);
    outline-offset: 1px;
}

/* ── File side ─────────────────────────────────────────────────────────── */

.em-b64__drop { margin-bottom: 1em; }
.em-b64__drop strong { color: var(--em-ink, inherit); }

.em-b64__filemeta {
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9rem;
    overflow-wrap: anywhere;
    color: var(--em-ink, inherit);
}

@media (max-width: 560px) {
    .em-b64__actions { margin-left: 0; width: 100%; }
}
