.base64-tool {
    --base64-panel: #ffffff;
    --base64-panel-soft: #fcfcfd;
    --base64-text: #101418;
    --base64-muted: #5a6872;
    --base64-border: #d8dee4;
    --base64-amber: #fff5e3;
    --base64-amber-border: #ecd8ab;
    --base64-green: #eef8ef;
    --base64-green-border: #cfe2d1;
    --base64-red: #f3e4e4;
    --base64-red-border: #e9d3d3;
    --base64-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    color: var(--base64-text);
    font-family: "Inter", var(--font-sans);
    padding-top: 0;
}

html[data-theme="dark"] .base64-tool {
    --base64-panel: #181b1f;
    --base64-panel-soft: #20242a;
    --base64-text: #f1f3f5;
    --base64-muted: #9aa2ab;
    --base64-border: #2a3037;
    --base64-amber: rgba(116, 88, 26, 0.2);
    --base64-amber-border: #6f5623;
    --base64-green: rgba(34, 84, 41, 0.22);
    --base64-green-border: #366441;
    --base64-red: rgba(100, 46, 52, 0.24);
    --base64-red-border: #6b3a40;
}

.base64-tool * {
    box-sizing: border-box;
}

.base64-tool .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;
}

.base64-topbar,
.base64-status,
.base64-pill-row,
.base64-textarea-header {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.base64-topbar {
    justify-content: space-between;
}

.base64-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.base64-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    height: 100%;
}

.base64-mini,
.base64-helper {
    margin: 0;
    color: var(--base64-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.base64-mini strong,
.base64-pill strong,
.base64-note strong {
    color: var(--base64-text);
}

.base64-inline,
.base64-mini code,
.base64-note code {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--base64-border);
    border-radius: 999px;
    background: var(--base64-panel);
    color: var(--base64-text);
    font-family: var(--base64-mono);
    font-size: 0.86em;
    white-space: nowrap;
}

.base64-helper-error {
    color: #79531b;
    background: var(--base64-amber);
    border: 1px solid var(--base64-amber-border);
    border-radius: 14px;
    padding: 10px 11px;
}

html[data-theme="dark"] .base64-helper-error {
    color: #f0d48c;
}

.base64-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.base64-textarea-header {
    justify-content: space-between;
}

.base64-textarea {
    width: 100%;
    min-width: 0;
    min-height: 220px;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--base64-border);
    border-radius: 12px;
    background: var(--base64-panel);
    color: var(--base64-text);
    font-family: var(--base64-mono);
    font-size: 14px;
    line-height: 1.45;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.base64-textarea[readonly] {
    background: var(--base64-panel-soft);
}

.base64-textarea.base64-output.has-error {
    border-color: var(--base64-amber-border);
    background: #fffaf0;
}

html[data-theme="dark"] .base64-textarea.base64-output.has-error {
    background: rgba(71, 54, 18, 0.25);
}

.base64-textarea:focus,
.base64-button:focus-visible {
    border-color: rgba(11, 132, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(11, 132, 255, 0.1);
    outline: none;
}

.base64-copy-inline {
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    flex: 0 0 auto;
}

.base64-copy-inline.done {
    color: #245e2d;
    border-color: var(--base64-green-border);
    background: var(--base64-green);
}

.base64-copy-inline.error {
    color: #7b5c1c;
    border-color: var(--base64-amber-border);
    background: var(--base64-amber);
}

html[data-theme="dark"] .base64-copy-inline.done {
    color: #b8ebbf;
}

html[data-theme="dark"] .base64-copy-inline.error {
    color: #f0d48c;
}

@media (max-width: 560px) {
    .base64-tool {
        padding-top: 0;
    }

    .base64-topbar {
        align-items: stretch;
    }

    .base64-actions {
        width: 100%;
    }

    .base64-textarea {
        min-height: 210px;
    }
}
