.a1z26-puzzle-tool {
    --puzzle-surface: #f7f9fc;
    --puzzle-surface-strong: #ffffff;
    --puzzle-border: #d6deea;
    --puzzle-border-strong: #c1cddd;
    --puzzle-text: #13213a;
    --puzzle-muted: #64738a;
    --puzzle-blue: #2864d7;
    --puzzle-blue-soft: #e8f0fd;
    --puzzle-blue-border: #b9cdf2;
    --puzzle-green: #17733a;
    --puzzle-green-soft: #edf8f0;
    --puzzle-green-border: #bfdfc8;
    --puzzle-amber: #795a0d;
    --puzzle-amber-soft: #fff8e8;
    --puzzle-amber-border: #e7d39d;
    --puzzle-red: #8a3434;
    --puzzle-red-soft: #fceded;
    --puzzle-red-border: #e8c4c4;
    color: var(--puzzle-text);
    font-family: "Inter", var(--font-sans);
}

.a1z26-puzzle-tool [hidden] {
    display: none !important;
}

.a1z26-puzzle-topbar .tool-topbar-start,
.a1z26-puzzle-mode {
    width: 330px;
}

.tool-template .a1z26-puzzle-mode.a1z26-puzzle-mode {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.a1z26-puzzle-mode .cipher-segment-btn {
    flex: 1 1 0;
    min-width: 0;
}

.a1z26-puzzle-layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
    min-width: 0;
}

.a1z26-puzzle-settings {
    min-width: 0;
}

.a1z26-puzzle-settings-summary {
    display: none;
}

.a1z26-puzzle-settings-body,
.a1z26-puzzle-workspace,
.a1z26-puzzle-mode-panel {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.a1z26-puzzle-section,
.a1z26-puzzle-io,
.a1z26-puzzle-challenge-card {
    min-width: 0;
    border: 1px solid var(--puzzle-border);
    border-radius: 15px;
    background: var(--puzzle-surface);
}

.a1z26-puzzle-section {
    padding: 16px;
}

.a1z26-puzzle-section-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 14px;
    color: #58677e;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.065em;
    line-height: 1.25;
    text-transform: uppercase;
}

.a1z26-puzzle-section-title::before {
    width: 3px;
    height: 15px;
    border-radius: 999px;
    background: var(--puzzle-blue);
    content: "";
    opacity: 0.6;
}

.a1z26-puzzle-difficulty {
    display: grid;
    gap: 8px;
}

.a1z26-puzzle-difficulty-button {
    width: 100%;
    min-height: 66px;
    padding: 10px 12px;
    border: 1px solid var(--puzzle-border);
    border-radius: 11px;
    background: var(--puzzle-surface-strong);
    color: #44536a;
    cursor: pointer;
    text-align: left;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.a1z26-puzzle-difficulty-button:hover {
    border-color: #aebbd0;
    background: #f2f6fc;
}

.a1z26-puzzle-difficulty-button[aria-pressed="true"] {
    border-color: var(--puzzle-blue-border);
    background: var(--puzzle-blue-soft);
    color: #153b78;
}

.a1z26-puzzle-difficulty-button:focus-visible,
.a1z26-puzzle-mini-button:focus-visible,
.a1z26-puzzle-option:focus-within,
.a1z26-puzzle-field input:focus-visible,
.a1z26-puzzle-field select:focus-visible,
.a1z26-puzzle-io textarea:focus-visible {
    outline: 3px solid rgba(40, 100, 215, 0.18);
    outline-offset: 1px;
}

.a1z26-puzzle-difficulty-button strong,
.a1z26-puzzle-difficulty-button span {
    display: block;
}

.a1z26-puzzle-difficulty-button strong {
    font-size: 0.93rem;
    line-height: 1.3;
}

.a1z26-puzzle-difficulty-button span {
    margin-top: 3px;
    color: var(--puzzle-muted);
    font-size: 0.84rem;
    line-height: 1.4;
}

.a1z26-puzzle-difficulty-button[aria-pressed="true"] span {
    color: #4c658b;
}

.a1z26-puzzle-option-list {
    display: grid;
    gap: 8px;
}

.a1z26-puzzle-option {
    display: flex;
    gap: 10px;
    align-items: center;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--puzzle-border);
    border-radius: 10px;
    background: var(--puzzle-surface-strong);
    color: #394860;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 650;
}

.a1z26-puzzle-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--puzzle-blue);
}

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

.a1z26-puzzle-field-spaced {
    margin-top: 14px;
}

.a1z26-puzzle-label {
    color: #33435d;
    font-size: 0.9rem;
    font-weight: 750;
}

.a1z26-puzzle-field input,
.a1z26-puzzle-field select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--puzzle-border-strong);
    border-radius: 10px;
    background: var(--puzzle-surface-strong);
    color: var(--puzzle-text);
    font: inherit;
    font-size: 0.92rem;
}

.a1z26-puzzle-field small,
.a1z26-puzzle-help {
    margin: 0;
    color: var(--puzzle-muted);
    font-size: 0.84rem;
    line-height: 1.48;
}

.a1z26-puzzle-status,
.a1z26-puzzle-result,
.a1z26-puzzle-hint,
.a1z26-puzzle-expert-note {
    padding: 11px 13px;
    border: 1px solid var(--puzzle-amber-border);
    border-radius: 11px;
    background: var(--puzzle-amber-soft);
    color: var(--puzzle-amber);
    font-size: 0.88rem;
    font-weight: 650;
    line-height: 1.5;
}

.a1z26-puzzle-status.is-good,
.a1z26-puzzle-result.is-good {
    border-color: var(--puzzle-green-border);
    background: var(--puzzle-green-soft);
    color: var(--puzzle-green);
}

.a1z26-puzzle-status.is-error,
.a1z26-puzzle-result.is-error {
    border-color: var(--puzzle-red-border);
    background: var(--puzzle-red-soft);
    color: var(--puzzle-red);
}

.a1z26-puzzle-result.is-info,
.a1z26-puzzle-hint,
.a1z26-puzzle-expert-note {
    border-color: var(--puzzle-blue-border);
    background: #f2f6fd;
    color: #36577e;
}

.a1z26-puzzle-io-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    min-width: 0;
}

.a1z26-puzzle-io {
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 16px;
}

.a1z26-puzzle-output-io {
    background: #f9fbfe;
}

.a1z26-puzzle-io:focus-within {
    border-color: var(--puzzle-blue-border);
    box-shadow: 0 0 0 3px rgba(40, 100, 215, 0.07);
}

.a1z26-puzzle-io-head {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
}

.a1z26-puzzle-io-head h2 {
    margin: 0;
    color: var(--puzzle-text);
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: -0.01em;
}

.a1z26-puzzle-mini-button,
.a1z26-puzzle-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 5px 12px;
    border: 1px solid var(--puzzle-border);
    border-radius: 999px;
    background: var(--puzzle-surface-strong);
    color: #506079;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 750;
    white-space: nowrap;
}

button.a1z26-puzzle-mini-button {
    cursor: pointer;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button.a1z26-puzzle-mini-button:hover:not(:disabled) {
    border-color: #aebbd0;
    background: #eef3fa;
    color: #233d69;
}

button.a1z26-puzzle-mini-button.is-done {
    border-color: var(--puzzle-green-border);
    background: var(--puzzle-green-soft);
    color: var(--puzzle-green);
}

button.a1z26-puzzle-mini-button.is-error {
    border-color: var(--puzzle-red-border);
    background: var(--puzzle-red-soft);
    color: var(--puzzle-red);
}

button.a1z26-puzzle-mini-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.a1z26-puzzle-io textarea {
    width: 100%;
    min-width: 0;
    min-height: 236px;
    max-width: 100%;
    padding: 13px 14px;
    resize: vertical;
    border: 1px solid var(--puzzle-border-strong);
    border-radius: 11px;
    background: var(--puzzle-surface-strong);
    color: #223049;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.94rem;
    line-height: 1.62;
}

.a1z26-puzzle-output-io textarea {
    background: #fcfdff;
}

.a1z26-puzzle-io textarea::placeholder,
.a1z26-puzzle-field input::placeholder {
    color: #8b97a8;
}

.a1z26-puzzle-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 16px;
    padding-top: 2px;
    color: var(--puzzle-muted);
    font-size: 0.84rem;
    font-weight: 600;
}

.a1z26-puzzle-stats strong {
    color: var(--puzzle-text);
}

.a1z26-puzzle-preview-section {
    background: var(--puzzle-surface-strong);
}

.a1z26-puzzle-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 162px;
    padding: 20px;
    border: 1px dashed var(--puzzle-border-strong);
    border-radius: 13px;
    background: #fbfcfe;
    text-align: center;
}

.a1z26-puzzle-empty {
    margin: 0;
    color: #78869a;
    font-size: 0.91rem;
}

.a1z26-puzzle-preview-title {
    margin: 0 0 12px;
    color: #607088;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.a1z26-puzzle-code {
    margin: 0;
    color: #142646;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: clamp(1rem, 1.7vw, 1.2rem);
    font-weight: 750;
    line-height: 1.85;
    overflow-wrap: anywhere;
}

.a1z26-puzzle-hint {
    margin-top: 12px;
}

.a1z26-puzzle-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.a1z26-puzzle-chips > span {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--puzzle-border);
    border-radius: 999px;
    background: var(--puzzle-surface-strong);
    color: var(--puzzle-muted);
    font-size: 0.83rem;
    line-height: 1.2;
}

.a1z26-puzzle-chips strong {
    color: var(--puzzle-text);
}

.a1z26-puzzle-map-section {
    overflow: hidden;
    background: var(--puzzle-surface-strong);
}

.a1z26-puzzle-map {
    display: grid;
    grid-template-columns: repeat(13, minmax(42px, 1fr));
    gap: 6px;
    min-width: 650px;
    overflow: hidden;
}

.a1z26-puzzle-map-section {
    overflow-x: auto;
    scrollbar-width: thin;
}

.a1z26-puzzle-map > span {
    display: grid;
    place-items: center;
    min-height: 56px;
    padding: 5px;
    border: 1px solid var(--puzzle-border);
    border-radius: 9px;
    background: var(--puzzle-surface);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.a1z26-puzzle-map strong {
    color: var(--puzzle-text);
    font-size: 0.9rem;
}

.a1z26-puzzle-map small {
    color: #4470b0;
    font-size: 0.79rem;
    font-weight: 750;
}

.a1z26-puzzle-metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 9px;
    background: var(--puzzle-surface-strong);
}

.a1z26-puzzle-metrics > div {
    display: grid;
    gap: 4px;
    min-width: 0;
    padding: 11px 12px;
    border: 1px solid var(--puzzle-border);
    border-radius: 11px;
    background: var(--puzzle-surface);
    text-align: center;
}

.a1z26-puzzle-metrics span {
    color: var(--puzzle-muted);
    font-size: 0.79rem;
    font-weight: 700;
}

.a1z26-puzzle-metrics strong {
    color: var(--puzzle-text);
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.a1z26-puzzle-challenge-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    background: var(--puzzle-surface-strong);
}

.a1z26-puzzle-challenge-code {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 170px;
    padding: 20px;
    border: 1px dashed var(--puzzle-blue-border);
    border-radius: 13px;
    background: #f6f9fe;
    text-align: center;
}

.a1z26-puzzle-challenge-code code {
    color: #17315d;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: clamp(1.05rem, 2vw, 1.32rem);
    font-weight: 800;
    line-height: 1.8;
    overflow-wrap: anywhere;
}

.a1z26-puzzle-expert-note {
    margin: 0;
}

.a1z26-puzzle-challenge-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.a1z26-puzzle-challenge-actions .cipher-btn {
    width: 100%;
}

html[data-theme="dark"] .a1z26-puzzle-tool {
    --puzzle-surface: #1c2532;
    --puzzle-surface-strong: #151d28;
    --puzzle-border: #354256;
    --puzzle-border-strong: #46566d;
    --puzzle-text: #edf3fd;
    --puzzle-muted: #aab7ca;
    --puzzle-blue: #71a4ff;
    --puzzle-blue-soft: #203858;
    --puzzle-blue-border: #4772af;
    --puzzle-green: #91d6a4;
    --puzzle-green-soft: #173325;
    --puzzle-green-border: #386b48;
    --puzzle-amber: #efd78f;
    --puzzle-amber-soft: #3a301c;
    --puzzle-amber-border: #6e5a28;
    --puzzle-red: #f2b0b0;
    --puzzle-red-soft: #3b2228;
    --puzzle-red-border: #75414b;
}

html[data-theme="dark"] .a1z26-puzzle-section-title,
html[data-theme="dark"] .a1z26-puzzle-difficulty-button span,
html[data-theme="dark"] .a1z26-puzzle-field small,
html[data-theme="dark"] .a1z26-puzzle-help,
html[data-theme="dark"] .a1z26-puzzle-stats,
html[data-theme="dark"] .a1z26-puzzle-empty,
html[data-theme="dark"] .a1z26-puzzle-preview-title,
html[data-theme="dark"] .a1z26-puzzle-chips > span,
html[data-theme="dark"] .a1z26-puzzle-metrics span {
    color: var(--puzzle-muted);
}

html[data-theme="dark"] .a1z26-puzzle-difficulty-button,
html[data-theme="dark"] .a1z26-puzzle-option,
html[data-theme="dark"] .a1z26-puzzle-field input,
html[data-theme="dark"] .a1z26-puzzle-field select,
html[data-theme="dark"] .a1z26-puzzle-mini-button,
html[data-theme="dark"] .a1z26-puzzle-badge,
html[data-theme="dark"] .a1z26-puzzle-io textarea,
html[data-theme="dark"] .a1z26-puzzle-chips > span {
    background: var(--puzzle-surface-strong);
    color: var(--puzzle-text);
}

html[data-theme="dark"] .a1z26-puzzle-difficulty-button:hover,
html[data-theme="dark"] button.a1z26-puzzle-mini-button:hover:not(:disabled) {
    border-color: #61728b;
    background: #253246;
}

html[data-theme="dark"] .a1z26-puzzle-difficulty-button[aria-pressed="true"] {
    border-color: var(--puzzle-blue-border);
    background: var(--puzzle-blue-soft);
    color: #e5efff;
}

html[data-theme="dark"] .a1z26-puzzle-difficulty-button[aria-pressed="true"] span {
    color: #bed2f1;
}

html[data-theme="dark"] .a1z26-puzzle-output-io,
html[data-theme="dark"] .a1z26-puzzle-preview,
html[data-theme="dark"] .a1z26-puzzle-challenge-code {
    background: #17202d;
}

html[data-theme="dark"] .a1z26-puzzle-io textarea::placeholder,
html[data-theme="dark"] .a1z26-puzzle-field input::placeholder {
    color: #8090a5;
}

html[data-theme="dark"] .a1z26-puzzle-code,
html[data-theme="dark"] .a1z26-puzzle-challenge-code code,
html[data-theme="dark"] .a1z26-puzzle-map small {
    color: #a9c8ff;
}

html[data-theme="dark"] .a1z26-puzzle-result.is-info,
html[data-theme="dark"] .a1z26-puzzle-hint,
html[data-theme="dark"] .a1z26-puzzle-expert-note {
    border-color: var(--puzzle-blue-border);
    background: #1b304c;
    color: #c6d9f6;
}

@media (max-width: 1023px) {
    .a1z26-puzzle-topbar .tool-topbar-start,
    .a1z26-puzzle-mode {
        width: 100%;
    }

    .a1z26-puzzle-layout {
        display: flex;
        flex-direction: column;
    }

    .a1z26-puzzle-workspace {
        order: 1;
        width: 100%;
    }

    .a1z26-puzzle-settings {
        order: 2;
        width: 100%;
        border: 1px solid var(--puzzle-border);
        border-radius: 15px;
        background: var(--puzzle-surface);
        overflow: hidden;
    }

    .a1z26-puzzle-settings-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 52px;
        padding: 12px 16px;
        color: var(--puzzle-text);
        cursor: pointer;
        font-size: 0.94rem;
        font-weight: 750;
        list-style: none;
    }

    .a1z26-puzzle-settings-summary::-webkit-details-marker {
        display: none;
    }

    .a1z26-puzzle-settings-hint {
        color: var(--puzzle-muted);
        font-size: 0.82rem;
        font-weight: 650;
    }

    .a1z26-puzzle-settings[open] .a1z26-puzzle-settings-hint {
        font-size: 0;
    }

    .a1z26-puzzle-settings[open] .a1z26-puzzle-settings-hint::after {
        font-size: 0.82rem;
        content: "Hide options";
    }

    .a1z26-puzzle-settings-body {
        padding: 0 14px 14px;
    }

    .a1z26-puzzle-io-grid {
        grid-template-columns: 1fr;
    }

    .a1z26-puzzle-io textarea {
        min-height: 190px;
    }

    .a1z26-puzzle-map {
        grid-template-columns: repeat(13, 46px);
    }
}

@media (max-width: 699px) {
    .a1z26-puzzle-actions,
    .a1z26-puzzle-challenge-actions {
        grid-template-columns: 1fr 1fr;
    }

    .a1z26-puzzle-actions {
        display: grid;
        width: 100%;
    }

    .a1z26-puzzle-actions .cipher-btn {
        width: 100%;
    }

    .a1z26-puzzle-actions .cipher-btn:first-child {
        grid-column: 1 / -1;
    }

    .a1z26-puzzle-section,
    .a1z26-puzzle-io,
    .a1z26-puzzle-challenge-card {
        padding: 14px;
        border-radius: 13px;
    }

    .a1z26-puzzle-mode .cipher-segment-btn {
        padding-inline: 8px;
    }

    .a1z26-puzzle-metrics {
        grid-template-columns: 1fr 1fr;
    }

    .a1z26-puzzle-challenge-actions .cipher-btn:first-child {
        grid-column: 1 / -1;
    }

    .a1z26-puzzle-challenge-code {
        min-height: 145px;
        padding: 16px 12px;
    }

    .a1z26-puzzle-preview {
        min-height: 140px;
        padding: 16px 12px;
    }
}

@media (max-width: 390px) {
    .a1z26-puzzle-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .a1z26-puzzle-io-head {
        align-items: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .a1z26-puzzle-tool *,
    .a1z26-puzzle-tool *::before,
    .a1z26-puzzle-tool *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
