.polybius-tool {
    --polybius-panel: #ffffff;
    --polybius-panel-soft: #fcfcfd;
    --polybius-text: #101418;
    --polybius-muted: #5a6872;
    --polybius-border: #d8dee4;
    --polybius-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --polybius-accent: #0b84ff;
    --polybius-accent-soft: rgba(11, 132, 255, 0.1);
    --polybius-label-bg: #dbe7f5;
    --polybius-label-border: #b8c6da;
    --polybius-success: #2c7a39;
    --polybius-success-soft: #eef8ef;
    --polybius-warning: #8a631f;
    --polybius-warning-soft: #fff5e3;
    color: var(--polybius-text);
    font-family: "Inter", var(--font-sans);
    padding-top: 0;
}

html[data-theme="dark"] .polybius-tool {
    --polybius-panel: #181b1f;
    --polybius-panel-soft: #20242a;
    --polybius-text: #f1f3f5;
    --polybius-muted: #9aa2ab;
    --polybius-border: #2a3037;
    --polybius-accent: #6ea8ff;
    --polybius-accent-soft: rgba(110, 168, 255, 0.12);
    --polybius-label-bg: rgba(110, 168, 255, 0.14);
    --polybius-label-border: rgba(110, 168, 255, 0.24);
    --polybius-success: #9adca5;
    --polybius-success-soft: rgba(64, 124, 74, 0.22);
    --polybius-warning: #f3d18b;
    --polybius-warning-soft: rgba(138, 99, 31, 0.18);
}

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

.polybius-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;
}

.polybius-panel {
    display: grid;
    gap: 12px;
}

.polybius-mini {
    margin: 0;
    font-size: 0.88rem;
    color: var(--polybius-muted);
    line-height: 1.5;
}

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

.polybius-mini code,
.polybius-note code {
    font-family: var(--polybius-mono);
    font-size: 0.84em;
    padding: 2px 6px;
    border: 1px solid var(--polybius-border);
    border-radius: 8px;
    background: var(--polybius-panel);
    color: var(--polybius-text);
}

.polybius-square-wrap {
    overflow-x: auto;
    padding-bottom: 2px;
}

.polybius-square-grid {
    display: grid;
    grid-template-columns: 40px repeat(5, minmax(44px, 1fr));
    gap: 6px;
    min-width: 310px;
    margin-top: 2px;
}

.polybius-square-cell,
.polybius-square-label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid var(--polybius-border);
    background: var(--polybius-panel);
    color: var(--polybius-text);
    font-weight: 700;
    font-size: 0.92rem;
    text-align: center;
    line-height: 1.15;
}

.polybius-square-cell {
    gap: 2px;
}

.polybius-square-cell span {
    display: inline-block;
}

.polybius-square-cell sub {
    position: relative;
    bottom: -0.18em;
    font-family: var(--polybius-mono);
    font-size: 0.68em;
    font-weight: 800;
    line-height: 1;
    color: var(--polybius-muted);
}

.polybius-square-label {
    background: var(--polybius-label-bg);
    border-color: var(--polybius-label-border);
    color: var(--polybius-text);
    font-size: 0.84rem;
}

.polybius-nested-panel {
    display: grid;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--polybius-border);
    border-radius: 14px;
    background: var(--polybius-panel);
}

.polybius-subtitle {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.2;
    color: var(--polybius-muted);
    font-weight: 800;
    letter-spacing: -0.01em;
}

.polybius-tool .cipher-option-left span {
    color: var(--polybius-muted);
}

.polybius-tool .cipher-option-left input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: #3f7fd8;
    flex: 0 0 auto;
}

.polybius-tool .cipher-option-row.is-disabled,
.polybius-tool .cipher-stepper.is-disabled {
    opacity: 0.55;
}

.polybius-textarea {
    width: 100%;
    min-width: 0;
    min-height: 240px;
    padding: 12px;
    border: 1px solid var(--polybius-border);
    border-radius: 14px;
    font-family: var(--polybius-mono);
    font-size: 0.94rem;
    line-height: 1.48;
    background: var(--polybius-panel);
    color: var(--polybius-text);
    outline: none;
    resize: vertical;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

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

.polybius-textarea::placeholder {
    color: var(--polybius-muted);
}

.polybius-textarea:focus,
.polybius-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;
}

.polybius-button[disabled] {
    opacity: 0.62;
    cursor: not-allowed;
}

.polybius-copy-inline.is-copied {
    color: var(--polybius-success);
    border-color: rgba(44, 122, 57, 0.3);
    background: var(--polybius-success-soft);
}

.polybius-copy-inline.is-failed {
    color: var(--polybius-warning);
    border-color: rgba(138, 99, 31, 0.32);
    background: var(--polybius-warning-soft);
}

@media (min-width: 1024px) {
    .polybius-square-grid {
        gap: 5px;
    }

    .polybius-square-cell,
    .polybius-square-label {
        min-height: 38px;
        border-radius: 10px;
        font-size: 0.86rem;
    }
}

@media (max-width: 560px) {
    .polybius-textarea {
        min-height: 220px;
    }

    .polybius-square-grid {
        grid-template-columns: 34px repeat(5, minmax(40px, 1fr));
        min-width: 274px;
        gap: 5px;
    }

    .polybius-square-cell,
    .polybius-square-label {
        min-height: 38px;
        border-radius: 10px;
        font-size: 0.82rem;
    }
}
