#b64-tool {
    --b64-ink: #172033;
    --b64-muted: #687289;
    --b64-line: #e4e8f0;
    --b64-soft: #f5f7fb;
    --b64-accent: #5b5bd6;
    --b64-accent-dark: #4747bd;
    --b64-accent-soft: #eeeeff;
    --b64-teal: #159d91;
    --b64-danger: #c43c52;
    --b64-success: #137b61;
    --b64-shadow: 0 18px 50px rgba(34, 43, 72, 0.08);
    color: var(--b64-ink);
    font-family: Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
    line-height: 1.65;
}

#b64-tool,
#b64-tool * {
    box-sizing: border-box;
}

#b64-tool button,
#b64-tool input,
#b64-tool textarea {
    font: inherit;
}

#b64-tool button {
    margin: 0;
}

#b64-tool [hidden] {
    display: none !important;
}

#b64-tool .b64-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(310px, 0.92fr);
    gap: 18px;
    padding: 18px;
    border: 1px solid var(--b64-line);
    border-radius: 24px;
    background:
        radial-gradient(circle at 10% 0%, rgba(91, 91, 214, 0.08), transparent 28%),
        linear-gradient(135deg, #fbfbff 0%, #f7fafc 100%);
    box-shadow: var(--b64-shadow);
}

#b64-tool .b64-panel,
#b64-tool .b64-output-panel {
    border: 1px solid rgba(220, 225, 236, 0.95);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
}

#b64-tool .b64-panel {
    min-width: 0;
    padding: 22px;
}

#b64-tool .b64-section-heading {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    margin-bottom: 18px;
}

#b64-tool .b64-section-heading h2,
#b64-tool .b64-section-heading p {
    margin: 0;
}

#b64-tool .b64-section-heading h2 {
    color: var(--b64-ink);
    font-size: 18px;
    font-weight: 750;
    letter-spacing: 0.01em;
    line-height: 1.35;
}

#b64-tool .b64-section-heading p {
    margin-top: 2px;
    color: var(--b64-muted);
    font-size: 12px;
    line-height: 1.5;
}

#b64-tool .b64-step {
    display: inline-grid;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    place-items: center;
    border-radius: 10px;
    background: var(--b64-accent-soft);
    color: var(--b64-accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
}

#b64-tool .b64-drop-zone {
    display: flex;
    min-height: 194px;
    padding: 24px 18px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border: 1.5px dashed #b8bfd0;
    border-radius: 15px;
    background:
        linear-gradient(90deg, rgba(91, 91, 214, 0.025) 1px, transparent 1px),
        linear-gradient(rgba(91, 91, 214, 0.025) 1px, transparent 1px),
        #fafbfe;
    background-size: 16px 16px;
    cursor: pointer;
    outline: none;
    text-align: center;
    transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

#b64-tool .b64-drop-zone:hover,
#b64-tool .b64-drop-zone:focus-visible,
#b64-tool .b64-drop-zone.is-dragging {
    border-color: var(--b64-accent);
    background-color: #f7f7ff;
    box-shadow: 0 0 0 4px rgba(91, 91, 214, 0.09);
}

#b64-tool .b64-drop-zone.is-dragging {
    transform: translateY(-2px);
}

#b64-tool .b64-drop-zone[aria-disabled="true"] {
    cursor: wait;
    opacity: 0.62;
}

#b64-tool .b64-upload-icon {
    display: grid;
    width: 48px;
    height: 48px;
    margin-bottom: 10px;
    place-items: center;
    border-radius: 15px;
    background: var(--b64-accent-soft);
    color: var(--b64-accent);
}

#b64-tool .b64-upload-icon svg {
    width: 25px;
    height: 25px;
}

#b64-tool .b64-drop-zone strong {
    color: var(--b64-accent);
    font-size: 15px;
}

#b64-tool .b64-drop-zone > span:not(.b64-upload-icon) {
    margin-top: 1px;
    color: #59647a;
    font-size: 13px;
}

#b64-tool .b64-drop-zone small {
    margin-top: 9px;
    color: #667085;
    font-size: 12px;
}

#b64-tool .b64-divider {
    display: flex;
    margin: 17px 0 14px;
    align-items: center;
    gap: 10px;
    color: #687286;
    font-size: 11px;
}

#b64-tool .b64-divider::before,
#b64-tool .b64-divider::after {
    height: 1px;
    flex: 1;
    background: var(--b64-line);
    content: "";
}

#b64-tool .b64-url-form label {
    display: block;
    margin-bottom: 6px;
    color: #4d5870;
    font-size: 12px;
    font-weight: 700;
}

#b64-tool .b64-field-row {
    position: relative;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

#b64-tool .b64-input-icon {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 12px;
    width: 18px;
    height: 18px;
    color: #667085;
    pointer-events: none;
    transform: translateY(-50%);
}

#b64-tool .b64-input-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

#b64-tool .b64-field-row input {
    min-width: 0;
    height: 44px;
    padding: 0 12px 0 39px;
    flex: 1;
    border: 1px solid #d9deea;
    border-radius: 10px;
    background: #fff;
    color: var(--b64-ink);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#b64-tool .b64-field-row input:focus {
    border-color: var(--b64-accent);
    box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.1);
}

#b64-tool .b64-field-row input::placeholder {
    color: #697386;
}

#b64-tool .b64-field-row button,
#b64-tool .b64-paste-button,
#b64-tool .b64-primary-button,
#b64-tool .b64-secondary-button,
#b64-tool .b64-text-button {
    min-height: 44px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

#b64-tool .b64-field-row button {
    padding: 0 16px;
    border: 0;
    background: var(--b64-ink);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

#b64-tool .b64-field-row button:not(:disabled):hover {
    background: #2b354a;
}

#b64-tool .b64-url-form > small {
    display: block;
    margin-top: 5px;
    color: #667085;
    font-size: 11px;
}

#b64-tool .b64-paste-button {
    display: flex;
    width: 100%;
    margin-top: 13px;
    padding: 10px 12px;
    align-items: center;
    justify-content: center;
    border: 1px solid #dce1ec;
    background: #fff;
    color: #4f5a70;
    font-size: 12px;
    font-weight: 700;
}

#b64-tool .b64-paste-button:not(:disabled):hover {
    border-color: #c8cedd;
    background: var(--b64-soft);
}

#b64-tool .b64-paste-button > span:first-child {
    display: inline-flex;
    margin-right: 7px;
}

#b64-tool .b64-paste-button svg {
    width: 17px;
    height: 17px;
}

#b64-tool .b64-paste-button kbd {
    min-width: 22px;
    margin-left: 9px;
    padding: 1px 5px;
    border: 1px solid #d9deea;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #f8f9fb;
    color: #515c70;
    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
}

#b64-tool .b64-paste-button .b64-key-plus {
    margin: 0 -6px 0 2px;
    color: #667085;
    font-size: 9px;
}

#b64-tool .b64-status {
    min-width: 0;
    padding: 9px 11px;
    flex: 1;
    border: 1px solid #dce1ed;
    border-radius: 9px;
    background: var(--b64-soft);
    color: #536078;
    font-size: 11px;
}

#b64-tool .b64-status-row {
    display: flex;
    margin-top: 12px;
    align-items: stretch;
    gap: 8px;
}

#b64-tool .b64-cancel-button {
    padding: 0 12px;
    flex: 0 0 auto;
    border: 1px solid #e0bfc6;
    border-radius: 9px;
    background: #fff;
    color: #9b2f42;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
}

#b64-tool .b64-cancel-button:hover {
    background: #fff4f6;
}

#b64-tool .b64-status[data-kind="error"] {
    border-color: #f1ced5;
    background: #fff5f6;
    color: var(--b64-danger);
}

#b64-tool .b64-status[data-kind="success"] {
    border-color: #c7e8dd;
    background: #f1fbf7;
    color: var(--b64-success);
}

#b64-tool .b64-status[data-kind="busy"]::before {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 7px;
    border: 2px solid #c8cce7;
    border-top-color: var(--b64-accent);
    border-radius: 50%;
    content: "";
    vertical-align: -1px;
    animation: b64-spin 0.7s linear infinite;
}

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

#b64-tool .b64-preview-panel {
    display: flex;
    flex-direction: column;
}

#b64-tool .b64-preview-stage {
    position: relative;
    display: grid;
    min-height: 302px;
    flex: 1;
    place-items: center;
    overflow: hidden;
    border: 1px solid #e1e5ee;
    border-radius: 14px;
    background-color: #f4f6f9;
    background-image:
        linear-gradient(45deg, #e9ecf2 25%, transparent 25%),
        linear-gradient(-45deg, #e9ecf2 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e9ecf2 75%),
        linear-gradient(-45deg, transparent 75%, #e9ecf2 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}

#b64-tool .b64-preview-empty {
    display: flex;
    width: 100%;
    min-height: 302px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(250, 251, 253, 0.91);
    color: #70798d;
    text-align: center;
}

#b64-tool .b64-preview-empty > span {
    display: grid;
    width: 54px;
    height: 54px;
    margin-bottom: 10px;
    place-items: center;
    border: 1px solid #e2e6ee;
    border-radius: 16px;
    background: #fff;
}

#b64-tool .b64-preview-empty svg {
    width: 27px;
    height: 27px;
}

#b64-tool .b64-preview-empty strong {
    color: #596477;
    font-size: 13px;
}

#b64-tool .b64-preview-empty small {
    margin-top: 3px;
    color: #667085;
    font-size: 11px;
}

#b64-tool .b64-preview-stage img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 410px;
    object-fit: contain;
}

#b64-tool .b64-file-info {
    margin-top: 12px;
}

#b64-tool .b64-file-name-row {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
}

#b64-tool .b64-file-icon {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    border-radius: 9px;
    background: #eaf8f5;
    color: var(--b64-teal);
}

#b64-tool .b64-file-icon svg {
    width: 18px;
    height: 18px;
}

#b64-tool .b64-file-name-row > div {
    min-width: 0;
}

#b64-tool .b64-file-name-row strong,
#b64-tool .b64-file-name-row span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#b64-tool .b64-file-name-row strong {
    color: #384258;
    font-size: 12px;
}

#b64-tool .b64-file-name-row span {
    color: #687286;
    font-size: 11px;
}

#b64-tool .b64-file-info dl {
    display: grid;
    margin: 11px 0 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
}

#b64-tool .b64-file-info dl div {
    min-width: 0;
    padding: 8px;
    border-radius: 9px;
    background: var(--b64-soft);
}

#b64-tool .b64-file-info dt,
#b64-tool .b64-file-info dd {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#b64-tool .b64-file-info dt {
    color: #687286;
    font-size: 11px;
}

#b64-tool .b64-file-info dd {
    margin-top: 1px;
    color: #465167;
    font-size: 12px;
    font-weight: 700;
}

#b64-tool .b64-output-panel {
    margin-top: 18px;
    padding: 22px;
    box-shadow: 0 12px 35px rgba(34, 43, 72, 0.06);
    scroll-margin-top: 12px;
    animation: b64-reveal 0.28s ease both;
}

@keyframes b64-reveal {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

#b64-tool .b64-output-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

#b64-tool .b64-output-header .b64-section-heading {
    margin-bottom: 13px;
}

#b64-tool .b64-format-switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid #e0e4ed;
    border-radius: 11px;
    background: var(--b64-soft);
}

#b64-tool .b64-format-switch label {
    cursor: pointer;
}

#b64-tool .b64-format-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

#b64-tool .b64-format-switch span {
    display: grid;
    min-height: 44px;
    padding: 7px 11px;
    border-radius: 8px;
    color: #5f697c;
    font-size: 11px;
    font-weight: 700;
    place-items: center;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

#b64-tool .b64-format-switch input:checked + span {
    background: #fff;
    color: var(--b64-accent);
    box-shadow: 0 2px 8px rgba(32, 39, 69, 0.1);
}

#b64-tool .b64-format-switch input:focus-visible + span {
    outline: 2px solid var(--b64-accent);
    outline-offset: 1px;
}

#b64-tool .b64-format-switch input:disabled + span {
    cursor: wait;
    opacity: 0.58;
}

#b64-tool .b64-output-meta {
    display: flex;
    margin-bottom: 6px;
    justify-content: flex-end;
    gap: 6px;
}

#b64-tool .b64-output-meta span {
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--b64-soft);
    color: #5f697c;
    font-size: 11px;
}

#b64-tool textarea#b64-output {
    display: block;
    width: 100%;
    min-height: 190px;
    padding: 14px;
    resize: vertical;
    border: 1px solid #dfe3ec;
    border-radius: 12px;
    background: #f9fafc;
    color: #39445a;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
    word-break: break-all;
}

#b64-tool textarea#b64-output:focus {
    border-color: #b8bee8;
    box-shadow: 0 0 0 3px rgba(91, 91, 214, 0.08);
}

#b64-tool .b64-output-actions {
    display: flex;
    margin-top: 11px;
    align-items: center;
    gap: 8px;
}

#b64-tool .b64-output-actions button {
    display: inline-flex;
    padding: 0 15px;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 750;
}

#b64-tool .b64-output-actions button svg {
    width: 16px;
    height: 16px;
}

#b64-tool .b64-primary-button {
    background: var(--b64-accent);
    color: #fff;
    box-shadow: 0 7px 16px rgba(91, 91, 214, 0.2);
}

#b64-tool .b64-primary-button:not(:disabled):hover {
    background: var(--b64-accent-dark);
    transform: translateY(-1px);
}

#b64-tool .b64-secondary-button {
    border-color: #dce1eb !important;
    background: #fff;
    color: #4e5a70;
}

#b64-tool .b64-secondary-button:not(:disabled):hover {
    background: var(--b64-soft);
}

#b64-tool .b64-text-button {
    margin-left: auto !important;
    padding-right: 4px !important;
    padding-left: 4px !important;
    background: transparent;
    color: #596477;
}

#b64-tool .b64-text-button:not(:disabled):hover {
    color: var(--b64-danger);
}

#b64-tool button:disabled,
#b64-tool input:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

#b64-tool .b64-privacy-note {
    display: flex;
    margin: 12px 2px 0;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #626c7f;
    font-size: 11px;
    text-align: center;
}

#b64-tool .b64-privacy-note svg {
    width: 15px;
    height: 15px;
    flex: 0 0 15px;
    color: var(--b64-teal);
}

#b64-tool .b64-guide {
    margin-top: 56px;
    padding-top: 42px;
    border-top: 1px solid var(--b64-line);
}

#b64-tool .b64-guide-intro {
    max-width: 720px;
}

#b64-tool .b64-eyebrow {
    color: var(--b64-accent);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
}

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

#b64-tool .b64-guide h2 {
    margin-bottom: 12px;
    color: var(--b64-ink);
    font-size: 25px;
    line-height: 1.45;
    letter-spacing: -0.02em;
}

#b64-tool .b64-guide-intro > p {
    margin-bottom: 0;
    color: var(--b64-muted);
    font-size: 13px;
}

#b64-tool .b64-howto {
    margin-top: 35px;
    padding: 25px;
    border-radius: 17px;
    background: #f7f8fc;
}

#b64-tool .b64-howto > h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

#b64-tool .b64-howto ol {
    display: grid;
    margin: 0;
    padding: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    list-style: none;
}

#b64-tool .b64-howto li {
    display: flex;
    min-width: 0;
    gap: 10px;
}

#b64-tool .b64-howto li > span {
    display: grid;
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    place-items: center;
    border-radius: 50%;
    background: var(--b64-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
}

#b64-tool .b64-howto strong {
    display: block;
    margin-bottom: 4px;
    color: #3d485f;
    font-size: 12px;
}

#b64-tool .b64-howto p {
    margin-bottom: 0;
    color: #5f697d;
    font-size: 12px;
    line-height: 1.65;
}

#b64-tool .b64-guide-grid {
    display: grid;
    margin-top: 20px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

#b64-tool .b64-guide-grid article {
    padding: 20px;
    border: 1px solid var(--b64-line);
    border-radius: 14px;
    background: #fff;
}

#b64-tool .b64-guide-grid article > span {
    display: inline-grid;
    min-width: 35px;
    height: 29px;
    padding: 0 7px;
    place-items: center;
    border-radius: 8px;
    background: var(--b64-accent-soft);
    color: var(--b64-accent);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 10px;
    font-weight: 800;
}

#b64-tool .b64-guide-grid h3 {
    margin: 11px 0 5px;
    color: #3d485f;
    font-size: 13px;
}

#b64-tool .b64-guide-grid p {
    margin-bottom: 0;
    color: #606a7e;
    font-size: 12px;
}

#b64-tool .b64-guide-grid code {
    padding: 1px 3px;
    border-radius: 3px;
    background: #f0f1f5;
    color: #535e75;
    font-size: 0.95em;
}

#b64-tool details {
    border-bottom: 1px solid var(--b64-line);
}

#b64-tool details:first-of-type {
    margin-top: 27px;
    border-top: 1px solid var(--b64-line);
}

#b64-tool summary {
    position: relative;
    padding: 15px 34px 15px 2px;
    color: #485369;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    list-style: none;
}

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

#b64-tool summary::after {
    position: absolute;
    top: 50%;
    right: 7px;
    color: var(--b64-accent);
    content: "+";
    font-size: 18px;
    font-weight: 400;
    transform: translateY(-50%);
}

#b64-tool details[open] summary::after {
    content: "−";
}

#b64-tool details > p {
    margin: -4px 34px 15px 2px;
    color: #5f697d;
    font-size: 12px;
}

@media (max-width: 820px) {
    #b64-tool .b64-workspace {
        grid-template-columns: 1fr;
    }

    #b64-tool .b64-preview-stage,
    #b64-tool .b64-preview-empty {
        min-height: 260px;
    }

    #b64-tool .b64-howto ol,
    #b64-tool .b64-guide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    #b64-tool .b64-workspace {
        gap: 12px;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    #b64-tool .b64-panel,
    #b64-tool .b64-output-panel {
        padding: 17px;
        border-radius: 14px;
    }

    #b64-tool .b64-drop-zone {
        min-height: 175px;
        padding: 20px 12px;
    }

    #b64-tool .b64-field-row {
        flex-wrap: wrap;
    }

    #b64-tool .b64-field-row input {
        flex-basis: 100%;
    }

    #b64-tool .b64-field-row button {
        width: 100%;
    }

    #b64-tool .b64-input-icon {
        top: 22px;
        transform: translateY(-50%);
    }

    #b64-tool .b64-paste-button kbd,
    #b64-tool .b64-paste-button .b64-key-plus {
        display: none;
    }

    #b64-tool .b64-file-info dl {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #b64-tool .b64-file-info dl div:last-child {
        grid-column: 1 / -1;
    }

    #b64-tool .b64-file-info dd {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
    }

    #b64-tool .b64-output-header {
        display: block;
    }

    #b64-tool .b64-format-switch {
        width: 100%;
        margin-bottom: 12px;
    }

    #b64-tool .b64-format-switch label {
        flex: 1;
    }

    #b64-tool .b64-format-switch span {
        text-align: center;
    }

    #b64-tool .b64-output-actions {
        flex-wrap: wrap;
    }

    #b64-tool .b64-output-actions .b64-primary-button,
    #b64-tool .b64-output-actions .b64-secondary-button {
        flex: 1;
    }

    #b64-tool .b64-output-actions .b64-text-button {
        width: 100%;
        margin-left: 0 !important;
    }

    #b64-tool .b64-privacy-note {
        align-items: flex-start;
        text-align: left;
    }

    #b64-tool .b64-guide {
        margin-top: 42px;
        padding-top: 34px;
    }

    #b64-tool .b64-guide h2 {
        font-size: 21px;
    }

    #b64-tool .b64-howto {
        padding: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    #b64-tool *,
    #b64-tool *::before,
    #b64-tool *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
