/* Text-category workbench: input (with settings), actions, output. No Bootstrap. */
.tn-text-workspace {
    --tn-text-edge: #8c8c8c;
    --tn-text-surface: #363636;
    --tn-text-field: #272727;
    --tn-text-action: #b7d7d4;
    --tn-text-action-ink: #202b2b;
    width: 100%;
    min-width: 0;
    max-width: var(--tn-max, 1280px);
    margin-inline: auto;
}
.tn-text-workspace__header { margin: 0 0 14px; }
.tn-text-workspace__header h1 {
    font-size: clamp(1.35rem, 2vw, 1.8rem);
    line-height: 1.3;
    margin: 0 0 5px;
}
.tn-text-workspace__header p { margin: 0; font-size: .88rem; color: var(--tn-muted, #d1d1d1); }
/* For ordinary desktop viewport heights, the entire interactive workbench fits
   between the header and the persistent bottom navigation. No global overflow: hidden. */
.tn-text-workspace__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 106px minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
    height: clamp(420px, calc(100svh - 282px), 680px);
    min-height: max-content;
}
.tn-text-workspace--no-controls .tn-text-workspace__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tn-text-workspace--no-result .tn-text-workspace__grid {
    grid-template-columns: minmax(0, 1fr) 106px;
}
.tn-text-workspace--no-controls.tn-text-workspace--no-result .tn-text-workspace__grid {
    grid-template-columns: minmax(0, 1fr);
}
.tn-text-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    padding: clamp(10px, 1vw, 16px);
    border: 1px solid var(--tn-text-edge);
    border-radius: 0;
    background: var(--tn-text-surface);
}
.tn-text-panel__heading {
    margin: 0 0 10px;
    padding-bottom: 8px;
    flex: none;
    border-bottom: 1px solid var(--tn-text-edge);
    font-size: 1rem;
    line-height: 1.35;
    font-weight: 650;
}
.tn-text-panel__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 0;
}
.tn-text-panel__settings { flex: none; min-width: 0; }
.tn-text-panel__input-fields {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    min-height: 0;
}
.tn-text-panel__input-fields > label { flex: none; }
.tn-text-panel--input .tn-text-panel__input-fields > textarea {
    flex: 1 1 auto;
    min-height: 160px;
}
.tn-text-panel__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    width: 100%;
}
.tn-text-panel--controls {
    padding: 0;
    border: 0;
    background: none;
    justify-content: center;
}
.tn-text-panel--controls .tn-text-panel__heading {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    padding: 0;
    margin: -1px;
    border: 0;
}
.tn-text-panel--controls .tn-text-panel__body {
    flex: none;
    justify-content: center;
}
.tn-text-panel--controls button { width: 100%; overflow-wrap: anywhere; }
.tn-text-panel--result .tn-text-panel__body {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.tn-text-workspace label { display: inline-block; }
.tn-text-workspace :is(textarea, input, select, button) { font: inherit; }
.tn-text-workspace :is(textarea, input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), select) {
    max-width: 100%;
    border: 1px solid var(--tn-text-edge);
    border-radius: 0;
    background: var(--tn-text-field);
    color: var(--tn-text, #f0f0f0);
}
.tn-text-workspace :is(textarea, input:not([type="radio"]):not([type="checkbox"]):not([type="file"]), select):focus-visible {
    outline: 3px solid var(--tn-focus, #a6dddb);
    outline-offset: 2px;
}
.tn-text-workspace textarea {
    display: block;
    width: 100%;
    padding: 12px;
    resize: vertical;
    line-height: 1.55;
}
.tn-text-workspace .tn-text-output {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}
.tn-text-workspace .tn-text-output textarea {
    flex: 1 1 auto;
    min-height: 175px;
}
.tn-text-workspace input:not([type="radio"]):not([type="checkbox"]):not([type="file"]),
.tn-text-workspace select { padding: 9px 10px; }
.tn-text-workspace input[type="radio"],
.tn-text-workspace input[type="checkbox"] { accent-color: var(--tn-text-action); }
.tn-text-workspace button {
    padding: 10px 8px;
    min-height: 46px;
    border: 1px solid var(--tn-text-edge);
    border-radius: 0;
    background: var(--tn-text-field);
    color: var(--tn-text, #f0f0f0);
    cursor: pointer;
    font-size: .85rem;
}
.tn-text-workspace button[data-tn-text-primary] {
    border-color: var(--tn-text-action);
    background: var(--tn-text-action);
    color: var(--tn-text-action-ink);
    font-weight: 650;
}
.tn-text-workspace button:disabled { opacity: .5; cursor: not-allowed; }
.tn-text-workspace button:hover:not(:disabled) { filter: brightness(1.08); }
.tn-text-workspace button:focus-visible,
.tn-text-workspace__quicknav a:focus-visible {
    outline: 3px solid var(--tn-focus, #a6dddb);
    outline-offset: 2px;
}
.tn-text-workspace__footer { margin-top: 12px; }
.tn-text-workspace__status {
    min-height: 1.3em;
    margin: 5px 0 0;
    color: var(--tn-muted, #d1d1d1);
    font-size: .8rem;
}
.tn-text-workspace__status[data-state="error"] { color: #ffd0c8; }
.tn-text-workspace__quicknav { display: none; }
.tn-text-panel, .tn-text-panel__settings, .tn-text-panel__actions { scroll-margin-top: 12px; }

/* Very low desktop screens cannot contain all options and readable input areas. */
@media (min-width: 901px) and (max-height: 630px) {
    .tn-text-workspace__grid { height: auto; min-height: 440px; }
    .tn-text-panel--input .tn-text-panel__input-fields > textarea,
    .tn-text-workspace .tn-text-output textarea { min-height: 200px; }
}

/* Tablet and phone: accessible vertical layout, with edge anchors. */
@media (max-width: 900px) {
    .tn-text-workspace { padding-right: 52px; }
    .tn-text-workspace__grid,
    .tn-text-workspace--no-controls .tn-text-workspace__grid,
    .tn-text-workspace--no-result .tn-text-workspace__grid,
    .tn-text-workspace--no-controls.tn-text-workspace--no-result .tn-text-workspace__grid {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }
    .tn-text-panel { min-height: 0; }
    .tn-text-panel--controls {
        padding: 10px;
        border: 1px solid var(--tn-text-edge);
        background: var(--tn-text-surface);
    }
    .tn-text-panel--controls .tn-text-panel__body { flex: auto; }
    .tn-text-panel__actions { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; }
    .tn-text-panel__actions button { width: auto; flex: 1 1 135px; }
    .tn-text-panel--input .tn-text-panel__input-fields > textarea,
    .tn-text-workspace .tn-text-output textarea { min-height: 220px; }
    .tn-text-workspace__quicknav {
        display: flex;
        position: fixed;
        right: max(3px, env(safe-area-inset-right));
        top: 32%;
        z-index: 60;
        width: 46px;
        flex-direction: column;
        background: #222;
        border: 1px solid var(--tn-text-edge);
    }
    .tn-text-workspace__quicknav a,
    .tn-text-workspace__quicknav button {
        display: grid;
        place-items: center;
        width: 100%;
        min-height: 48px;
        margin: 0;
        padding: 5px 2px;
        border: 0;
        border-bottom: 1px solid #555;
        border-radius: 0;
        background: none;
        color: #f0f0f0;
        font-size: .7rem;
        line-height: 1.2;
        text-align: center;
        text-decoration: none;
        cursor: pointer;
    }
    .tn-text-workspace__quicknav > :last-child { border-bottom: 0; }
}
@media (max-width: 420px) {
    .tn-text-workspace { padding-right: 45px; }
    .tn-text-workspace__quicknav { width: 40px; }
    .tn-text-panel { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
    .tn-text-workspace__quicknav a { scroll-behavior: auto; }
}

/* Controls and optional tool chrome for the first migrated text tool. */
.tn-tool-breadcrumbs { margin-bottom: 10px; font-size: .84rem; color: var(--tn-muted, #d1d1d1); }
.tn-tool-breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; margin: 0; list-style: none; }
.tn-tool-breadcrumbs li { overflow-wrap: anywhere; }
.tn-tool-breadcrumbs li + li::before { content: "/"; padding-right: 7px; color: #b3b3b3; }
.tn-tool-breadcrumbs a { text-underline-offset: .18em; }
.tn-text-page-share { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 20px; font-size: .78rem; }
.tn-text-page-share > span:first-child { font-weight: 650; margin-right: 4px; }
.tn-text-page-share :is(a, button) {
    color: var(--tn-text, #f0f0f0);
    background: var(--tn-text-field, #272727);
    border: 1px solid var(--tn-line, #989898);
    border-radius: 0;
    padding: 6px 10px;
    min-height: 34px;
    font: inherit;
    cursor: pointer;
    text-decoration: none;
}
.tn-text-page-share :is(a, button):is(:hover, :focus-visible) { background: #505050; }
.tn-text-page-share__status { font-size: .76rem; color: var(--tn-muted, #d1d1d1); }
.tn-text-options { padding: 0; margin: 0; border: 0; min-width: 0; }
.tn-text-options legend { padding: 0; margin-bottom: 12px; font-weight: 650; font-size: .95rem; }
.tn-text-options__items { display: grid; gap: 8px; }
.tn-text-options__items label { display: flex; align-items: center; gap: 7px; padding: 6px 0; cursor: pointer; }
.tn-text-options__items input { flex: none; width: 16px; height: 16px; }
.tn-text-output { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; gap: 8px; }
.tn-text-output textarea { flex: 1 1 auto; }
.tn-text-share { border-top: 1px solid var(--tn-text-edge); padding-top: 14px; margin-top: 6px; }
.tn-text-share h3 { margin: 0 0 8px; font-size: .88rem; font-weight: 650; }
.tn-text-share__buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.tn-text-share__buttons button { font-size: .76rem; min-height: 34px; padding: 6px 9px; }
.tn-text-ad { min-width: 0; max-width: 100%; overflow-wrap: anywhere; margin-block: 15px; }
.tn-text-ad:empty { display: none; }
.tn-text-workspace .ad-slot,
.tn-text-workspace .adsbygoogle { max-width: 100%; }
.tn-text-workspace .AdsenseArea-placeholder,
.tn-text-ad .AdsenseArea-placeholder,
.tn-text-workspace .bg-light,
.tn-text-ad .bg-light {
    background: #353535 !important;
    color: #e5e5e5 !important;
    border: 1px solid #777;
    border-radius: 0;
    padding: 10px;
}
.tn-tool-related { border-top: 1px solid var(--tn-line, #989898); margin-top: 24px; padding-top: 24px; }
.tn-tool-related h2 { font-size: 1.06rem; margin: 0 0 12px; }
.tn-tool-related__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tn-tool-related__item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 68px;
    padding: 11px;
    border: 1px solid var(--tn-line, #989898);
    background: #363636;
    color: var(--tn-text, #f0f0f0);
    text-decoration: none;
    overflow-wrap: anywhere;
    font-size: .82rem;
}
.tn-tool-related__item:hover { background: #505050; }
.tn-tool-related__item img { object-fit: contain; flex: none; }
@media (max-width: 600px) {
    .tn-tool-related__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tn-text-page-share { gap: 6px; }
}


/* Default input-side settings. Tools can opt into the central settings panel. */
.tn-text-workspace .tn-text-options { margin-bottom: 2px; }
.tn-text-workspace .tn-text-options legend { margin-bottom: 6px; }
.tn-text-workspace .tn-text-options__items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
}
.tn-text-workspace .tn-text-options__items label {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 4px 0;
    font-size: .78rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.tn-text-secondary {
    display: grid;
    gap: 14px;
    margin-top: 20px;
}
.tn-text-secondary .tn-text-page-share { margin: 0; }
.tn-text-secondary .tn-text-ad { margin: 0; }
.tn-text-howto { border-top: 1px solid var(--tn-line, #989898); padding-top: 15px; }
.tn-text-howto h2 { font-size: 1.08rem; margin: 0 0 8px; }
.tn-text-howto p { margin: 0 0 9px; font-size: .88rem; line-height: 1.65; }
@media (max-width: 900px) {
    .tn-text-workspace .tn-text-options__items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .tn-text-workspace .tn-text-options__items { grid-template-columns: 1fr; }
}


/* Per-tool choice: central operation panel contains options above the action buttons.
   Keep original layout for tools using the default settings-placement="input". */
.tn-text-workspace--settings-in-controls .tn-text-workspace__grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 300px) minmax(0, 1fr);
}
.tn-text-workspace--settings-in-controls .tn-text-panel--controls {
    padding: clamp(10px, 1vw, 16px);
    border: 1px solid var(--tn-text-edge);
    background: var(--tn-text-surface);
    justify-content: initial;
}
.tn-text-workspace--settings-in-controls .tn-text-panel--controls .tn-text-panel__heading {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    padding-bottom: 8px;
    margin: 0 0 10px;
    border: 0;
    border-bottom: 1px solid var(--tn-text-edge);
}
.tn-text-workspace--settings-in-controls .tn-text-panel--controls .tn-text-panel__body {
    flex: 1 1 auto;
    justify-content: initial;
    min-height: 0;
}
.tn-text-workspace--settings-in-controls .tn-text-panel__actions {
    margin-top: auto;
}
.tn-text-workspace--settings-in-controls .tn-text-options__items {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
}
.tn-text-workspace--settings-in-controls .tn-text-options__items label {
    padding: 5px 0;
    font-size: .84rem;
    line-height: 1.3;
}

@media (max-width: 900px) {
    .tn-text-workspace--settings-in-controls .tn-text-workspace__grid {
        grid-template-columns: minmax(0, 1fr);
        height: auto;
        min-height: 0;
    }
    .tn-text-workspace--settings-in-controls .tn-text-panel__actions {
        margin-top: 12px;
    }
}
@media (max-width: 480px) {
    .tn-text-workspace--settings-in-controls .tn-text-options__items {
        grid-template-columns: minmax(0, 1fr);
    }
}


/* Long option lists remain independently scrollable on desktop so that input,
   actions and output are always usable without scrolling the entire document. */
@media (min-width: 901px) {
    .tn-text-workspace--scroll-settings .tn-text-workspace__grid { min-height: 0; }
    .tn-text-workspace--scroll-settings .tn-text-panel--controls .tn-text-panel__body {
        overflow: hidden;
        min-height: 0;
    }
    .tn-text-workspace--scroll-settings .tn-text-panel__settings {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
        padding-right: 6px;
    }
    .tn-text-workspace--scroll-settings .tn-text-panel__actions {
        flex: 0 0 auto;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--tn-text-edge);
    }
}
.tn-text-settings-note,
.tn-tag-help {
    color: var(--tn-muted, #d1d1d1);
    font-size: .75rem;
    line-height: 1.55;
    margin: 8px 0 0;
}
.tn-text-modes { min-width: 0; }
.tn-text-modes__group {
    border: 1px solid var(--tn-text-edge);
    padding: 10px;
    margin-top: 10px;
}
.tn-text-modes__group h3 {
    font-size: .86rem;
    font-weight: 650;
    margin: 0 0 8px;
    line-height: 1.4;
}
.tn-text-modes .tn-text-options__items label {
    padding: 7px 0;
    align-items: flex-start;
}
.tn-text-modes .tn-text-options__items input { margin-top: 2px; }

/* Tag creation: preserve every existing option and the three conditional custom
   fields, but remove dependency on Bootstrap classes. */
.tn-tag-settings { display: flex; flex-direction: column; min-width: 0; gap: 14px; }
.tn-tag-group {
    border-bottom: 1px solid var(--tn-text-edge);
    padding-bottom: 12px;
    min-width: 0;
}
.tn-tag-group__title {
    display: block;
    font-size: .86rem;
    font-weight: 700;
    line-height: 1.45;
    margin: 0 0 8px;
}
.tn-tag-choices { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tn-tag-choice {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    min-width: 0;
    font-size: .78rem;
    line-height: 1.4;
}
.tn-tag-choice__input { flex: none; margin-top: .17em; }
.tn-tag-choice__label {
    display: inline-block;
    min-width: 0;
    overflow-wrap: anywhere;
    cursor: pointer;
}
.tn-tag-custom { margin-top: 9px; }
.tn-tag-custom .tn-tag-text-input {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.tn-tag-separator { border: 0; border-top: 1px solid var(--tn-text-edge); margin: 0; }
.tn-tag-advanced { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.tn-tag-advanced__item { min-width: 0; }
.tn-tag-subgroup { border: 1px solid #686868; padding: 10px; min-width: 0; }
.tn-tag-subgroup__title { font-size: .81rem; font-weight: 650; margin: 0 0 8px; }
@media (max-width: 900px) {
    .tn-text-workspace--scroll-settings .tn-text-panel__settings { overflow: visible; }
    .tn-text-workspace--scroll-settings .tn-text-panel__actions { border-top: 1px solid var(--tn-text-edge); padding-top: 12px; }
}


/* Character counter: a numeric results panel, not a text-copy output field.
   The central settings use the existing scroll-settings workbench variant. */
.tn-count-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}
.tn-count-settings__title {
    font-size: .9rem;
    line-height: 1.4;
    font-weight: 700;
    margin: 0 0 2px;
}
.tn-count-option {
    min-width: 0;
    margin: 0;
    padding: 9px 10px 11px;
    border: 1px solid #686868;
    border-radius: 0;
}
.tn-count-option legend {
    font-size: .83rem;
    font-weight: 650;
    line-height: 1.45;
    margin-bottom: 8px;
    padding: 0;
}
.tn-count-option__choices {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    min-width: 0;
}
.tn-count-option__choices label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    line-height: 1.4;
    cursor: pointer;
}
.tn-count-results {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    gap: 12px;
}
.tn-count-results__primary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.tn-count-results__metric {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--tn-text-edge);
    background: var(--tn-text-field);
}
.tn-count-results__metric > span {
    color: var(--tn-muted, #d1d1d1);
    font-size: .79rem;
    overflow-wrap: anywhere;
}
.tn-count-results__metric output {
    display: block;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    line-height: 1.25;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.tn-count-results__detail {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}
.tn-count-results__table {
    border-collapse: collapse;
    width: 100%;
    font-size: .83rem;
    line-height: 1.4;
}
.tn-count-results__table caption {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.tn-count-results__table tr {
    border-bottom: 1px solid #696969;
}
.tn-count-results__table .tn-count-results__group-start {
    border-top: 2px solid var(--tn-text-edge);
}
.tn-count-results__table th,
.tn-count-results__table td {
    padding: 8px 4px;
    vertical-align: middle;
}
.tn-count-results__table th {
    font-weight: 500;
    text-align: left;
}
.tn-count-results__table td {
    width: 70px;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.tn-count-results #outputSummary[hidden] {
    display: none !important;
}
@media (max-width: 900px) {
    .tn-count-results__detail {
        flex: none;
        overflow: visible;
    }
}
@media (max-width: 420px) {
    .tn-count-results__primary { gap: 7px; }
    .tn-count-results__metric { padding: 9px; }
    .tn-count-results__table { font-size: .79rem; }
}
