.encoding-tool {
    display: grid;
    gap: 16px;
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
    color-scheme: dark;
}

.encoding-toolbar {
    display: grid;
    grid-template-columns: minmax(180px, 1.1fr) minmax(180px, 1fr) minmax(160px, 0.85fr) minmax(140px, 0.7fr) minmax(180px, 1fr);
    gap: 12px;
    align-items: end;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 8px;
    background: #111b2c;
}

.encoding-toolbar,
.encoding-detect,
.encoding-workbench,
.encoding-actions,
.encoding-jwt-viewer {
    min-width: 0;
    max-width: 100%;
}

.encoding-field {
    min-width: 0;
    display: grid;
    gap: 7px;
}

.encoding-field > span,
.encoding-pane > span {
    color: #93a4ba;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.encoding-field select,
.encoding-field input {
    width: 100%;
    min-width: 0;
    height: 42px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: #0b1120;
    color: #e5edf7;
    padding: 0 10px;
    font: inherit;
    color-scheme: dark;
    -webkit-tap-highlight-color: transparent;
}

.encoding-segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 42px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    overflow: hidden;
    background: #0b1120;
}

.encoding-segmented label {
    min-width: 0;
    display: flex;
    position: relative;
}

.encoding-segmented input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
}

.encoding-segmented span {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #c9d6e6;
    font-size: 0.84rem;
    font-weight: 800;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.encoding-segmented input:checked + span {
    background: #35c2e8;
    color: #062331;
}

.encoding-samples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.encoding-samples button {
    height: 34px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: #172033;
    color: #dbe6f4;
    padding: 0 12px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.encoding-samples button:hover {
    border-color: #35c2e8;
    color: #35c2e8;
}

.encoding-detect {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    background: #0f1726;
}

.encoding-detect__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.encoding-detect__header span {
    color: #93a4ba;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.encoding-detect__header button,
.encoding-detect__candidate {
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 8px;
    background: #172033;
    color: #dbe6f4;
    font: inherit;
    cursor: pointer;
}

.encoding-detect__header button {
    height: 32px;
    padding: 0 12px;
    font-size: 0.78rem;
    font-weight: 800;
    touch-action: manipulation;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.encoding-detect__results {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 44px;
    align-items: center;
    color: #93a4ba;
    font-size: 0.84rem;
    contain: layout paint;
}

.encoding-detect__candidate {
    display: grid;
    gap: 3px;
    min-width: 190px;
    max-width: 320px;
    padding: 9px 10px;
    text-align: left;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.encoding-detect__candidate strong {
    color: #e5edf7;
    font-size: 0.82rem;
}

.encoding-detect__candidate span {
    color: #93a4ba;
    font-size: 0.74rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.encoding-detect__candidate em {
    color: #7dd3fc;
    font-size: 0.72rem;
    font-style: normal;
    font-weight: 800;
}

.encoding-detect__candidate:hover {
    border-color: #35c2e8;
}

.encoding-workbench {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
}

.encoding-pane {
    min-width: 0;
    display: grid;
    gap: 8px;
}

.encoding-pane textarea {
    width: 100%;
    min-width: 0;
    min-height: 360px;
    resize: vertical;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 8px;
    background: #0b1120;
    color: #e5edf7;
    padding: 14px;
    font: 0.9rem/1.55 "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    overflow-wrap: anywhere;
}

.encoding-pane textarea:focus,
.encoding-field select:focus,
.encoding-field input:focus {
    outline: 2px solid rgba(53, 194, 232, 0.45);
    outline-offset: 1px;
}

.encoding-pane textarea[readonly] {
    background: #0f1726;
}

.encoding-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.encoding-actions .app-shell__button,
.encoding-actions .app-primary {
    min-width: 108px;
    height: 42px;
    touch-action: manipulation;
    transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease, opacity 0.16s ease;
}

.encoding-actions .app-shell__button:disabled,
.encoding-actions .app-primary:disabled,
.encoding-samples button:disabled,
.encoding-detect__header button:disabled {
    cursor: wait;
    opacity: 0.68;
}

.encoding-status {
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    color: #93a4ba;
    font-size: 0.84rem;
}

.encoding-status.is-error {
    color: #f87171;
}

.encoding-status.is-ok {
    color: #7dd3fc;
}

.encoding-jwt-viewer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.encoding-jwt-viewer.is-hidden {
    display: none;
}

.encoding-jwt-card {
    min-width: 0;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    background: #0f1726;
    overflow: hidden;
}

.encoding-jwt-card--header {
    border-color: rgba(125, 211, 252, 0.4);
}

.encoding-jwt-card--payload {
    border-color: rgba(167, 243, 208, 0.36);
}

.encoding-jwt-card--time {
    border-color: rgba(250, 204, 21, 0.4);
}

.encoding-jwt-card--signature {
    border-color: rgba(216, 180, 254, 0.36);
}

.encoding-jwt-card__title {
    margin: 0;
    padding: 10px 12px;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    background: rgba(15, 23, 38, 0.8);
}

.encoding-jwt-card--header .encoding-jwt-card__title {
    color: #7dd3fc;
}

.encoding-jwt-card--payload .encoding-jwt-card__title {
    color: #a7f3d0;
}

.encoding-jwt-card--time .encoding-jwt-card__title {
    color: #fde68a;
}

.encoding-jwt-card--signature .encoding-jwt-card__title {
    color: #d8b4fe;
}

.encoding-jwt-card pre {
    margin: 0;
    max-height: 320px;
    overflow: auto;
    padding: 12px;
    color: #e5edf7;
    font: 0.82rem/1.55 "JetBrains Mono", "Cascadia Code", Consolas, monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.encoding-jwt-times {
    display: grid;
    gap: 10px;
    padding: 12px;
}

.encoding-jwt-time {
    display: grid;
    gap: 5px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(250, 204, 21, 0.08);
}

.encoding-jwt-time strong {
    color: #fde68a;
    font-size: 0.82rem;
}

.encoding-jwt-time span {
    color: #cbd5e1;
    font-size: 0.8rem;
}

.encoding-jwt-time .encoding-jwt-time__kst {
    color: #facc15;
    font-weight: 900;
}

.encoding-jwt-note {
    margin: 0;
    padding: 0 12px 12px;
    color: #93a4ba;
    font-size: 0.78rem;
}

@media (max-width: 1120px) {
    .encoding-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .encoding-workbench,
    .encoding-jwt-viewer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1280px) {
    .has-app-shell .encoding-toolbar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .encoding-toolbar {
        grid-template-columns: 1fr;
    }

    .encoding-field select,
    .encoding-field input,
    .encoding-pane textarea {
        font-size: 16px;
    }

    .encoding-pane textarea {
        min-height: 260px;
    }

    .encoding-detect__candidate {
        max-width: 100%;
        min-width: 0;
        width: 100%;
    }

    .encoding-detect__candidate span {
        overflow: visible;
        text-overflow: clip;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .encoding-actions .app-shell__button,
    .encoding-actions .app-primary {
        width: 100% !important;
    }

    .encoding-status {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .encoding-tool *,
    .encoding-tool *::before,
    .encoding-tool *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
