/* Base64 Encoder/Decoder — professional dashboard UI */
.tool-widget:has(.b64-app) {
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}

.b64-app {
    --b64-accent: #00aeef;
    --b64-accent-2: #38bdf8;
    --b64-card: rgba(15, 23, 42, 0.82);
    --b64-border: rgba(148, 163, 184, 0.16);
    --b64-muted: #94a3b8;
    width: 100%;
}

.b64-app [hidden] { display: none !important; }

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

.b64-shell {
    border: 1px solid var(--b64-border);
    border-radius: 20px;
    background:
        radial-gradient(ellipse 70% 45% at 0% 0%, rgba(0, 174, 239, .14), transparent 50%),
        radial-gradient(ellipse 50% 35% at 100% 0%, rgba(167, 139, 250, .08), transparent 45%),
        linear-gradient(180deg, #111827 0%, #0b1220 100%);
    padding: 1.15rem 1.2rem 1.35rem;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}

.b64-trust {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .95rem;
}

.b64-trust-item {
    padding: .35rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--b64-border);
    background: rgba(2, 8, 20, .45);
    font-size: .72rem;
    font-weight: 700;
    color: #e2e8f0;
}

.b64-layout {
    display: grid;
    grid-template-columns: minmax(220px, 270px) 1fr;
    gap: 1.1rem;
    align-items: start;
}

.b64-intro {
    position: sticky;
    top: 1rem;
    padding: 1.2rem;
    border-radius: 18px;
    border: 1px solid var(--b64-border);
    background:
        radial-gradient(circle at top left, rgba(0, 174, 239, .18), transparent 55%),
        linear-gradient(165deg, #111827, #0b1220 70%);
}

.b64-kicker {
    margin: 0 0 .45rem;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--b64-accent-2);
}

.b64-intro-title {
    margin: 0 0 .7rem;
    font-size: 1.35rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
    background: linear-gradient(90deg, #e0f2fe, #7dd3fc 45%, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.b64-intro-text {
    margin: 0 0 1rem;
    color: var(--b64-muted);
    font-size: .9rem;
    line-height: 1.6;
}

.b64-cta {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    margin-bottom: 1rem;
    min-height: 46px;
    font-weight: 800;
}

.b64-why {
    padding: 1rem;
    border-radius: 14px;
    background: rgba(0, 174, 239, .07);
    border: 1px solid rgba(0, 174, 239, .18);
}

.b64-why h3 {
    margin: 0 0 .55rem;
    font-size: .9rem;
    color: #e2e8f0;
}

.b64-why ul {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--b64-muted);
    font-size: .84rem;
    line-height: 1.55;
}

.b64-why li + li { margin-top: .28rem; }

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

.b64-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--b64-border);
}

.b64-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--b64-muted);
    font-size: .82rem;
    font-weight: 700;
    padding: .65rem .75rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .18s ease, background .18s ease;
}

.b64-tab:hover { color: #e2e8f0; }

.b64-tab.active {
    color: var(--b64-accent-2);
    border-bottom-color: var(--b64-accent);
    background: linear-gradient(180deg, transparent, rgba(14, 165, 233, .08));
}

.b64-panel { display: none; }
.b64-panel.active { display: block; }

.b64-dual {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: .75rem;
    align-items: stretch;
}

.b64-card {
    padding: 1rem 1.1rem;
    border-radius: 16px;
    border: 1px solid var(--b64-border);
    background: var(--b64-card);
}

.b64-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .7rem;
}

.b64-card-head h3 {
    margin: 0;
    font-size: .9rem;
    font-weight: 800;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.b64-step {
    display: inline-grid;
    place-items: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
    color: #0b1220;
    background: linear-gradient(145deg, #38bdf8, #0ea5e9);
}

.b64-link-btn {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--b64-accent-2);
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}

.b64-link-btn:hover { color: #e0f2fe; }

.b64-head-actions {
    display: flex;
    gap: .65rem;
}

.b64-textarea {
    width: 100%;
    min-height: 180px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid var(--b64-border);
    background: rgba(2, 8, 20, .55);
    color: #e2e8f0;
    padding: .85rem 1rem;
    font-size: .86rem;
    line-height: 1.5;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

.b64-textarea:focus,
.b64-select:focus,
.b64-tab:focus-visible,
.b64-link-btn:focus-visible,
.b64-swap-btn:focus-visible,
.b64-sample:focus-visible,
.b64-drop:focus-within {
    outline: none;
    border-color: rgba(56, 189, 248, .55);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, .15);
}

.b64-pane-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .65rem;
    flex-wrap: wrap;
    margin-top: .65rem;
    font-size: .78rem;
    color: var(--b64-muted);
}

.b64-pane-actions {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
}

.b64-mid {
    display: flex;
    align-items: center;
    justify-content: center;
}

.b64-swap-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(145deg, #0284c7, #38bdf8);
    box-shadow: 0 10px 24px rgba(14, 165, 233, .35);
    display: grid;
    place-items: center;
    transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.b64-swap-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 12px 30px rgba(14, 165, 233, .48);
}

.b64-controls-grid,
.b64-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.b64-options {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.b64-field {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.b64-field label {
    font-size: .78rem;
    font-weight: 700;
    color: #cbd5e1;
}

.b64-select {
    width: 100%;
    border-radius: 10px;
    border: 1px solid var(--b64-border);
    background: rgba(2, 8, 20, .55);
    color: #e2e8f0;
    padding: .55rem .7rem;
    font-size: .88rem;
    font-family: inherit;
}

.b64-check {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    font-size: .84rem;
    color: #cbd5e1;
    cursor: pointer;
}

.b64-check input {
    margin-top: .15rem;
    accent-color: var(--b64-accent);
}

.b64-data-url-option {
    margin: -.35rem 0 1rem;
    padding: .7rem .8rem;
    border: 1px solid rgba(56, 189, 248, .2);
    border-radius: 10px;
    background: rgba(14, 165, 233, .07);
}

.b64-quick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
}

.b64-quick .btn {
    min-height: 42px;
    font-weight: 700;
    justify-content: center;
}

.b64-status {
    margin: .75rem 0 0;
    min-height: 1.2rem;
    font-size: .84rem;
    color: var(--b64-muted);
}

.b64-status.is-ok { color: #86efac; }
.b64-status.is-error { color: #fca5a5; }

.b64-error {
    margin-top: .55rem;
    padding: .65rem .8rem;
    border-radius: 10px;
    border: 1px solid rgba(248, 113, 113, .35);
    background: rgba(127, 29, 29, .25);
    color: #fecaca;
    font-size: .84rem;
}

.b64-samples {
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.b64-sample {
    appearance: none;
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .6rem .7rem;
    border-radius: 10px;
    border: 1px solid var(--b64-border);
    background: rgba(2, 8, 20, .4);
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.b64-sample:hover {
    border-color: rgba(56, 189, 248, .45);
}

.b64-sample code {
    font-size: .78rem;
    color: #7dd3fc;
    word-break: break-all;
}

.b64-sample span {
    font-size: .78rem;
    color: var(--b64-muted);
}

.b64-help {
    margin: 0 0 1rem;
    color: var(--b64-muted);
    font-size: .9rem;
    line-height: 1.55;
}

.b64-help code {
    color: #7dd3fc;
    font-size: .85em;
}

.b64-file-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 1rem;
    align-items: start;
}

.b64-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 140px;
    padding: 1.25rem;
    border-radius: 14px;
    border: 1.5px dashed rgba(148, 163, 184, .35);
    background: rgba(8, 47, 73, .15);
    cursor: pointer;
    text-align: center;
}

.b64-drop.is-drag {
    border-color: rgba(56, 189, 248, .65);
    background: rgba(8, 47, 73, .35);
}

.b64-drop-title {
    font-weight: 800;
    color: #e2e8f0;
}

.b64-drop-sub {
    font-size: .8rem;
    color: var(--b64-muted);
}

.b64-file-actions {
    display: flex;
    flex-direction: column;
    gap: .55rem;
}

.b64-file-meta {
    margin: .35rem 0 0;
    font-size: .82rem;
    color: var(--b64-muted);
}

.b64-howto h3 { margin: 0 0 .75rem; }

.b64-howto ol {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--b64-muted);
    font-size: .9rem;
    line-height: 1.65;
}

.b64-howto li + li { margin-top: .35rem; }

.b64-related {
    margin: 1rem 0 0;
    font-size: .84rem;
    color: var(--b64-muted);
}

.b64-related a {
    color: #7dd3fc;
    font-weight: 700;
}

.b64-history {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.b64-history-item {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: center;
    padding: .65rem .75rem;
    border-radius: 12px;
    border: 1px solid var(--b64-border);
    background: rgba(2, 8, 20, .35);
}

.b64-history-item p {
    margin: 0;
    font-size: .84rem;
    color: #e2e8f0;
    word-break: break-word;
}

.b64-history-item small {
    font-size: .72rem;
    color: var(--b64-muted);
}

.b64-empty {
    margin: 0;
    color: var(--b64-muted);
    font-size: .86rem;
}

.b64-features {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .65rem;
    margin-top: 1.1rem;
}

.b64-feature {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    padding: .85rem .75rem;
    border-radius: 14px;
    background: rgba(15, 23, 42, .55);
    border: 1px solid var(--b64-border);
}

.b64-feature strong {
    font-size: .8rem;
    color: #e2e8f0;
}

.b64-feature span {
    font-size: .72rem;
    color: var(--b64-muted);
    line-height: 1.4;
}

@media (max-width: 960px) {
    .b64-layout { grid-template-columns: 1fr; }
    .b64-intro { position: static; }
    .b64-dual { grid-template-columns: 1fr; }
    .b64-mid { order: 2; }
    .b64-swap-btn { transform: rotate(90deg); }
    .b64-controls-grid,
    .b64-bottom-grid,
    .b64-file-row,
    .b64-features { grid-template-columns: 1fr; }
    .b64-quick { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .b64-shell {
        padding: .75rem;
        border-radius: 14px;
    }

    .b64-card,
    .b64-intro {
        padding: .8rem;
        border-radius: 13px;
    }

    .b64-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: thin;
        scroll-snap-type: x proximity;
    }

    .b64-tab {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
    }

    .b64-textarea {
        min-height: 150px;
        padding: .7rem;
        font-size: .82rem;
    }

    .b64-head-actions,
    .b64-pane-actions {
        gap: .75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .b64-tab,
    .b64-swap-btn {
        transition: none;
    }
}
