.tool-workspace:has(.text-format) {
    padding-bottom: 1.85rem;
}

.text-format {
    --tf-accent: var(--ct-primary, #2aab98);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex: 1;
    min-height: 0;
}

.text-format .tool-status {
    min-height: 1.25rem;
}

.text-format .tf-card {
    padding: clamp(0.9rem, 1.8vw, 1.25rem);
    border: 1px solid var(--ct-border, #e2e6ec);
    border-radius: 0.9rem;
    background: #fff;
    flex-shrink: 0;
}

.text-format .tool-panes {
    flex: 1 1 auto;
    min-height: clamp(26rem, calc(100vh - 24rem), 40rem);
}

.tool-page-shell .text-format .tool-pane > .tool-editor,
.tool-page-shell .text-format .tool-textarea,
.tool-page-shell .text-format .tool-editor .tool-textarea {
    min-height: clamp(26rem, calc(100vh - 26rem), 40rem);
}

.text-format .dev-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}

.text-format .dev-card-title {
    margin: 0;
    color: var(--ct-text, #1a2332);
    font-size: 1rem;
    font-weight: 700;
}

.tf-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.tf-stats span {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.6rem;
    border-radius: 999px;
    background: var(--ct-primary-soft, #e8f7f4);
    color: var(--ct-text, #1a2332);
    font-size: 0.78rem;
    font-weight: 600;
}

.tf-options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 1.25rem;
}

.tf-group {
    display: grid;
    gap: 0.75rem;
    min-width: 0;
}

.tf-group-title {
    margin: 0;
    color: var(--ct-text-muted, #667085);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tf-field {
    display: grid;
    gap: 0.4rem;
    min-width: 0;
}

.tf-field.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

.tf-label {
    color: var(--ct-text, #1a2332);
    font-size: 0.82rem;
    font-weight: 600;
}

.tf-seg {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.22rem;
    border-radius: 0.7rem;
    background: #f3f5f8;
}

.tf-seg-item {
    margin: 0;
    cursor: pointer;
}

.tf-seg-item input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tf-seg-item span {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    padding: 0.42rem 0.65rem;
    border-radius: 0.5rem;
    color: var(--ct-text-muted, #667085);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    user-select: none;
    transition: background 0.12s, color 0.12s, box-shadow 0.12s;
}

.tf-seg-item:hover input:not(:checked) + span {
    color: var(--ct-text, #1a2332);
    background: rgba(255, 255, 255, 0.55);
}

.tf-seg-item input:checked + span {
    color: var(--ct-text, #1a2332);
    background: #fff;
    box-shadow: 0 1px 4px rgba(20, 30, 45, 0.08);
}

.tf-seg-item input:focus-visible + span {
    outline: 2px solid var(--tf-accent);
    outline-offset: 1px;
}

.tf-glyph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1rem;
    color: var(--tf-accent);
    font-style: normal;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 700;
}

.tf-custom {
    width: 11rem;
    max-width: 100%;
}

.tf-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem 0.65rem;
    margin-top: 0.95rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.7rem;
    background: linear-gradient(180deg, #f8fbfa 0%, #f3f7f6 100%);
    border: 1px solid rgba(42, 171, 152, 0.14);
}

.tf-preview-label {
    color: var(--ct-text-muted, #667085);
    font-size: 0.75rem;
    font-weight: 700;
}

.tf-preview code {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0.15rem 0.4rem;
    border-radius: 0.35rem;
    background: #fff;
    color: var(--ct-text, #1a2332);
    font-size: 0.8rem;
}

.tf-preview-arrow {
    color: var(--tf-accent);
    font-weight: 700;
}

@media (max-width: 900px) {
    .tf-options-grid {
        grid-template-columns: 1fr;
    }

    .text-format .tool-panes {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .tool-page-shell .text-format .tool-pane > .tool-editor,
    .tool-page-shell .text-format .tool-textarea,
    .tool-page-shell .text-format .tool-editor .tool-textarea {
        min-height: 20rem;
    }
}
