/* Text Diff Checker — professional dual-editor UI */
.tool-widget:has(.tdf-app) {
    padding: 0;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}

.tdf-app {
    --tdf-accent: #00aeef;
    --tdf-accent-2: #38bdf8;
    --tdf-add: #34d399;
    --tdf-del: #f87171;
    --tdf-chg: #fbbf24;
    --tdf-card: rgba(15, 23, 42, 0.82);
    --tdf-border: rgba(148, 163, 184, 0.16);
}

.tdf-shell {
    border: 1px solid var(--tdf-border);
    border-radius: 20px;
    background:
        radial-gradient(ellipse 70% 45% at 0% 0%, rgba(0,174,239,.14), transparent 50%),
        radial-gradient(ellipse 50% 35% at 100% 0%, rgba(167,139,250,.08), transparent 45%),
        linear-gradient(180deg, #111827 0%, #0b1220 100%);
    padding: 1.15rem 1.2rem 1.35rem;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
}

.tdf-trust {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: .95rem;
}
.tdf-trust-item {
    padding: .35rem .7rem;
    border-radius: 999px;
    border: 1px solid var(--tdf-border);
    background: rgba(2, 8, 20, .45);
    font-size: .72rem;
    font-weight: 700;
    color: #cbd5e1;
}

.tdf-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.tdf-kicker {
    margin: 0 0 .25rem;
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tdf-accent-2);
}
.tdf-hero-text {
    margin: 0;
    max-width: 42rem;
    color: var(--text-muted);
    font-size: .9rem;
    line-height: 1.5;
}

.tdf-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .3rem;
    margin-bottom: 1rem;
    border-radius: 12px;
    background: rgba(2, 8, 20, .55);
    border: 1px solid var(--tdf-border);
}
.tdf-tab {
    flex: 1 1 auto;
    min-width: 110px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: .82rem;
    padding: .65rem .75rem;
    border-radius: 9px;
    cursor: pointer;
}
.tdf-tab.active {
    background: linear-gradient(135deg, rgba(0,174,239,.25), rgba(56,189,248,.12));
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(0,174,239,.35);
}

.tdf-workspace {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: .75rem;
    align-items: stretch;
    margin-bottom: .85rem;
}

.tdf-panel {
    background: var(--tdf-card);
    border: 1px solid var(--tdf-border);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.tdf-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--tdf-border);
}
.tdf-panel-head h3 {
    margin: 0;
    font-size: .92rem;
    font-weight: 800;
}
.tdf-link-btn {
    border: none;
    background: none;
    color: var(--tdf-accent-2);
    font-size: .78rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
}
.tdf-link-btn:hover { text-decoration: underline; }

.tdf-editor {
    display: grid;
    grid-template-columns: 42px 1fr;
    flex: 1;
    min-height: 240px;
    background: rgba(2, 8, 20, .55);
}
.tdf-gutter {
    padding: .85rem .35rem;
    text-align: right;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .72rem;
    line-height: 1.65;
    color: #64748b;
    border-right: 1px solid var(--tdf-border);
    user-select: none;
    overflow: hidden;
    white-space: pre;
}
.tdf-textarea {
    width: 100%;
    height: 100%;
    min-height: 240px;
    max-height: 420px;
    resize: vertical;
    border: none;
    background: transparent;
    color: #e2e8f0;
    padding: .85rem .9rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    line-height: 1.65;
}
.tdf-textarea::placeholder {
    color: #64748b;
    opacity: 1;
    white-space: pre-line;
}
.tdf-textarea:focus { outline: none; }

.tdf-panel-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding: .7rem 1rem;
    border-top: 1px solid var(--tdf-border);
    background: rgba(15,23,42,.45);
}
.tdf-stats {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem .9rem;
    font-size: .75rem;
    color: var(--text-muted);
}
.tdf-stats strong { color: var(--tdf-accent-2); }
.tdf-upload {
    font-size: .78rem;
    font-weight: 700;
    color: var(--tdf-accent-2);
    cursor: pointer;
}
.tdf-upload:hover { text-decoration: underline; }

.tdf-mid {
    display: flex;
    align-items: center;
    justify-content: center;
}
.tdf-swap-btn {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(135deg, #00aeef, #0284c7 55%, #7c3aed);
    box-shadow: 0 10px 28px rgba(0,174,239,.35);
    display: grid;
    place-items: center;
    transition: transform .15s;
}
.tdf-swap-btn:hover { transform: scale(1.06); }

.tdf-actions-bar {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}
.tdf-actions-bar .btn { min-width: 180px; min-height: 44px; }

.tdf-results-grid {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: .9rem;
    margin-bottom: 1rem;
    align-items: start;
}
.tdf-card {
    background: var(--tdf-card);
    border: 1px solid var(--tdf-border);
    border-radius: 16px;
    padding: 1rem 1.05rem;
}
.tdf-diff-card { padding-top: .85rem; }

.tdf-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-bottom: .85rem;
}
.tdf-leg {
    padding: .28rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 800;
    border: 1px solid transparent;
}
.tdf-leg-add { color: #86efac; background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.25); }
.tdf-leg-del { color: #fca5a5; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.25); }
.tdf-leg-chg { color: #fcd34d; background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.25); }
.tdf-leg-same { color: #94a3b8; background: rgba(148,163,184,.1); border-color: rgba(148,163,184,.2); }

.tdf-diff-view {
    max-height: 480px;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--tdf-border);
    background: rgba(2, 8, 20, .45);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.55;
}
.tdf-row {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: .55rem;
    padding: .45rem .7rem;
    border-bottom: 1px solid rgba(148,163,184,.08);
}
.tdf-row:last-child { border-bottom: none; }
.tdf-meta {
    display: flex;
    gap: .35rem;
    align-items: flex-start;
    color: #64748b;
    font-size: .72rem;
    font-weight: 700;
    padding-top: .1rem;
}
.tdf-mark {
    width: 16px;
    text-align: center;
}
.tdf-row.is-add { background: rgba(52,211,153,.1); }
.tdf-row.is-del { background: rgba(239,68,68,.1); }
.tdf-row.is-chg { background: rgba(251,191,36,.08); }
.tdf-row.is-same { color: #94a3b8; }
.tdf-row.is-add .tdf-mark { color: #34d399; }
.tdf-row.is-del .tdf-mark { color: #f87171; }
.tdf-row.is-chg .tdf-mark { color: #fbbf24; }
.tdf-content { min-width: 0; white-space: pre-wrap; word-break: break-word; }
.tdf-del-token {
    background: rgba(239,68,68,.28);
    color: #fecaca;
    text-decoration: line-through;
    border-radius: 3px;
    padding: 0 .12rem;
}
.tdf-add-token {
    background: rgba(52,211,153,.28);
    color: #bbf7d0;
    border-radius: 3px;
    padding: 0 .12rem;
}

.tdf-summary h4 {
    margin: 0 0 .85rem;
    font-size: .95rem;
    font-weight: 800;
}
.tdf-summary-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .55rem;
}
.tdf-summary-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .55rem .65rem;
    border-radius: 10px;
    background: rgba(2, 8, 20, .4);
    border: 1px solid var(--tdf-border);
    font-size: .82rem;
    color: var(--text-muted);
}
.tdf-summary-list strong { color: #e2e8f0; font-size: .95rem; }
.tdf-summary-list .is-add strong { color: #86efac; }
.tdf-summary-list .is-del strong { color: #fca5a5; }
.tdf-summary-list .is-chg strong { color: #fcd34d; }
.tdf-summary-list .is-same strong { color: #94a3b8; }

.tdf-side-actions {
    display: grid;
    gap: .55rem;
    margin-top: .75rem;
}
.tdf-side-actions .btn { min-height: 42px; width: 100%; }

.tdf-features {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .65rem;
}
.tdf-feature {
    text-align: center;
    padding: .85rem .55rem;
    border-radius: 12px;
    border: 1px solid var(--tdf-border);
    background: rgba(15,23,42,.45);
}
.tdf-feature strong {
    display: block;
    font-size: .82rem;
    margin-bottom: .25rem;
}
.tdf-feature span {
    font-size: .72rem;
    color: var(--text-muted);
}

@media (max-width: 980px) {
    .tdf-workspace { grid-template-columns: 1fr; }
    .tdf-swap-btn { transform: rotate(90deg); }
    .tdf-results-grid { grid-template-columns: 1fr; }
    .tdf-features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .tdf-shell { padding: .9rem; border-radius: 16px; }
    .tdf-features { grid-template-columns: 1fr; }
    .tdf-editor { min-height: 180px; }
    .tdf-textarea { min-height: 180px; }
    .tdf-results-grid { grid-template-columns: 1fr; }
    .tdf-actions-bar { width: 100%; }
    .tdf-actions-bar .btn { min-width: 0; width: 100%; }
}
