/**
 * Free client-side TA indicators (RSI/MACD/MFI/ATR/均线/布林带),
 * formula explanation cards, bottom subchart, and color-theme presets. Lives in its own
 * stylesheet to stay outside the 8600-line maintainability budget that
 * scripts/check-maintainability.php enforces on vip-chart-terminal.css.
 */
body.td-vip-body .td-vip-chart-shell {
    display: grid;
    grid-template-rows: minmax(0, 1fr);
}
body.td-vip-body .td-vip-chart-shell.has-ta-subchart {
    grid-template-rows: minmax(0, 1fr) var(--td-vip-ta-subchart-height, 210px);
    gap: 1px;
}

body.td-vip-body .td-vip-chart-shell.has-ta-subchart-collapsed {
    grid-template-rows: minmax(0, 1fr) 36px;
}

body.td-vip-body .td-vip-chart-host {
    grid-row: 1;
    min-height: 0;
}

.td-vip-ta-subchart-shell {
    position: relative;
    z-index: 3;
    display: grid;
    grid-template-rows: 34px minmax(0, 1fr);
    grid-row: 2;
    min-width: 0;
    min-height: 150px;
    overflow: hidden;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(248, 250, 252, 0.92);
}

.td-vip-ta-subchart-shell.is-collapsed {
    grid-template-rows: 36px;
    min-height: 36px;
}

.td-vip-ta-subchart-shell.is-hidden,
.td-vip-ta-subchart-shell[hidden] {
    display: none !important;
}

.td-vip-ta-subchart-head {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(138px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 5px 8px 4px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    background: rgba(255, 255, 255, 0.42);
    pointer-events: auto;
    color: rgba(15, 23, 42, 0.72);
}

.td-vip-ta-subchart-title {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
}

.td-vip-ta-subchart-title strong {
    flex: 0 0 auto;
    font-size: 12px;
    font-weight: 600;
}

.td-vip-ta-subchart-title span {
    overflow: hidden;
    color: rgba(100, 116, 139, 0.88);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-vip-ta-subchart-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.td-vip-ta-subchart-tabs::-webkit-scrollbar {
    display: none;
}

.td-vip-ta-subchart-tab,
.td-vip-ta-subchart-collapse {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.82);
    color: #475569;
    font: 11px/1.2 inherit;
    min-height: 24px;
    padding: 3px 8px;
    white-space: nowrap;
    cursor: pointer;
}

.td-vip-ta-subchart-tab.is-active {
    border-color: rgba(37, 99, 235, 0.58);
    background: rgba(239, 246, 255, 0.95);
    color: #1d4ed8;
    font-weight: 650;
}

.td-vip-ta-subchart-collapse {
    justify-self: end;
}

.td-vip-ta-subchart-resize {
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    z-index: 4;
    width: 100%;
    height: 8px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: ns-resize;
}

.td-vip-ta-subchart-resize::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 3px;
    width: 44px;
    height: 2px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.52);
    transform: translateX(-50%);
}

.td-vip-ta-subchart-host {
    grid-row: 2;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
}

.td-vip-ta-subchart-shell.is-collapsed .td-vip-ta-subchart-host,
.td-vip-ta-subchart-shell.is-collapsed .td-vip-ta-subchart-resize {
    display: none;
}

body.td-vip-body.is-night-mode .td-vip-ta-subchart-shell {
    border-top-color: rgba(51, 65, 85, 0.86);
    background: rgba(15, 23, 42, 0.96);
}

body.td-vip-body.is-night-mode .td-vip-ta-subchart-head {
    color: rgba(226, 232, 240, 0.78);
    border-bottom-color: rgba(51, 65, 85, 0.78);
    background: rgba(15, 23, 42, 0.66);
}

body.td-vip-body.is-night-mode .td-vip-ta-subchart-title span {
    color: rgba(148, 163, 184, 0.9);
}

body.td-vip-body.is-night-mode .td-vip-ta-subchart-tab,
body.td-vip-body.is-night-mode .td-vip-ta-subchart-collapse {
    border-color: rgba(71, 85, 105, 0.82);
    background: rgba(15, 23, 42, 0.78);
    color: #cbd5e1;
}

body.td-vip-body.is-night-mode .td-vip-ta-subchart-tab.is-active {
    border-color: rgba(96, 165, 250, 0.72);
    background: rgba(30, 58, 138, 0.56);
    color: #bfdbfe;
}

.td-vip-indicator-list--classic-ta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.td-vip-ta-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    border-radius: 7px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(241, 245, 249, 0.72));
}

.td-vip-ta-toolbar-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.td-vip-ta-toolbar-copy strong {
    color: #111827;
    font-size: 12.5px;
    font-weight: 650;
}

.td-vip-ta-toolbar-copy span {
    color: #64748b;
    font-size: 10.5px;
    line-height: 1.25;
}

.td-vip-ta-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}

.td-vip-ta-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    padding: 6px 8px;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 6px 18px -18px rgba(15, 23, 42, 0.24);
}

.td-vip-ta-card.is-enabled {
    border-color: rgba(37, 99, 235, 0.52);
    box-shadow: inset 3px 0 0 rgba(37, 99, 235, 0.72), 0 12px 26px -24px rgba(37, 99, 235, 0.5);
}

.td-vip-ta-card.is-active-subchart {
    border-color: rgba(14, 165, 233, 0.64);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.12), inset 3px 0 0 rgba(14, 165, 233, 0.82), 0 12px 26px -24px rgba(14, 165, 233, 0.42);
}

.td-vip-ta-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-height: 26px;
}

.td-vip-ta-card-title-wrap {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.td-vip-ta-card-title {
    color: #0f172a;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-vip-ta-card-note {
    display: none;
}

.td-vip-ta-card-actions,
.td-vip-ta-badges {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

.td-vip-ta-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #334155;
    font-size: 10.5px;
    white-space: nowrap;
    cursor: pointer;
}

.td-vip-ta-switch input {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: #2563eb;
}

.td-vip-ta-info-btn {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.42);
    border-radius: 5px;
    background: #fff;
    color: #475569;
    font: 10.5px/1.2 inherit;
    padding: 3px 6px;
    cursor: pointer;
}

.td-vip-ta-info-btn:hover,
.td-vip-ta-info-btn:focus-visible {
    border-color: rgba(37, 99, 235, 0.54);
    color: #1d4ed8;
}

.td-vip-ta-badges span {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.78);
    color: #475569;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.td-vip-ta-settings-panel {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.22);
}

.td-vip-ta-settings-panel[hidden] {
    display: none !important;
}

.td-vip-ta-card.is-settings-open {
    border-color: rgba(37, 99, 235, 0.38);
}

.td-vip-ta-settings-btn.is-open {
    border-color: rgba(37, 99, 235, 0.52);
    background: rgba(37, 99, 235, 0.08);
    color: #1d4ed8;
}

.td-vip-ta-inline-note {
    color: #64748b;
    font-size: 10.5px;
    line-height: 1.35;
}

.td-vip-ta-panel-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.td-vip-ta-settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.td-vip-ta-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.td-vip-ta-field-label {
    color: #64748b;
    font-size: 10px;
    font-weight: 650;
    line-height: 1;
}

.td-vip-ta-field-hint {
    color: #94a3b8;
    font-size: 10px;
    font-style: normal;
    line-height: 1.2;
}

.td-vip-ta-input,
.td-vip-ta-select,
.td-vip-ta-theme-select {
    width: 100%;
    min-height: 26px;
    border: 1px solid rgba(148, 163, 184, 0.42);
    border-radius: 5px;
    background: #fff;
    color: #0f172a;
    font: 11.5px/1.2 inherit;
    padding: 2px 6px;
}

.td-vip-ta-color {
    width: 100%;
    min-width: 38px;
    height: 26px;
    padding: 1px;
    border: 1px solid rgba(148, 163, 184, 0.42);
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

.td-vip-ta-section {
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    padding: 12px 14px 14px;
    background: rgba(248, 250, 252, 0.6);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.td-vip-indicator-ta-kicker {
    margin: 0 0 2px;
    font-size: 10px;
    letter-spacing: 0.055em;
    text-transform: uppercase;
    font-weight: 600;
    color: #64748b;
}

body.td-vip-body.is-night-mode .td-vip-indicator-ta-kicker {
    color: #94a3b8;
}

.td-vip-ta-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.td-vip-ta-section-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    letter-spacing: 0.02em;
}
.td-vip-ta-theme-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #475569;
}
.td-vip-ta-theme-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #fff;
    color: #1f2937;
    border-radius: 4px;
    padding: 2px 8px;
    font: inherit;
    cursor: pointer;
}
.td-vip-ta-section-note {
    font-size: 11px;
    color: #64748b;
    margin: 0;
    line-height: 1.6;
}
.td-vip-ta-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.td-vip-ta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #fff;
    border-radius: 8px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
    position: relative;
}
.td-vip-ta-chip.is-enabled {
    border-color: rgba(41, 98, 255, 0.55);
    box-shadow: 0 0 0 2px rgba(41, 98, 255, 0.12);
}
.td-vip-ta-chip-toggle {
    appearance: none;
    border: 0;
    background: transparent;
    color: #1f2937;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font: inherit;
    cursor: pointer;
    padding: 0 4px;
}
.td-vip-ta-chip-color {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.18);
}
.td-vip-ta-chip-label { font-weight: 500; }
.td-vip-ta-chip-period {
    font-size: 11px;
    color: #64748b;
    background: rgba(148, 163, 184, 0.18);
    padding: 0 4px;
    border-radius: 4px;
}
.td-vip-ta-chip-info,
.td-vip-ta-chip-subchart {
    appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #fff;
    color: #475569;
    font: 11px/1 inherit;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
}
.td-vip-ta-chip-info:hover { background: #eef2ff; border-color: rgba(99, 102, 241, 0.5); }
.td-vip-ta-chip-subchart[aria-pressed="true"] {
    background: #eef2ff;
    color: #4338ca;
    border-color: rgba(99, 102, 241, 0.6);
}
.td-vip-ta-chip-color-picker {
    width: 24px;
    height: 22px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 4px;
    padding: 0;
    background: #fff;
    cursor: pointer;
}
.td-vip-ta-formula-card {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 10;
    width: min(320px, 80vw);
    background: #0f172a;
    color: #f8fafc;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.32);
    font-size: 12px;
    line-height: 1.55;
}
.td-vip-ta-formula-card strong {
    display: block;
    margin-bottom: 6px;
    color: #fde68a;
    font-weight: 600;
}
.td-vip-ta-formula-card pre {
    margin: 0 0 6px;
    padding: 6px 8px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
}
.td-vip-ta-formula-card p {
    margin: 0;
    color: #cbd5e1;
}

/* Night-mode tuning. */
body.td-vip-body.is-night-mode .td-vip-ta-section {
    background: rgba(15, 23, 42, 0.4);
    border-color: rgba(75, 85, 99, 0.5);
}
body.td-vip-body.is-night-mode .td-vip-ta-section-title { color: #f3f4f6; }
body.td-vip-body.is-night-mode .td-vip-ta-section-note { color: #94a3b8; }
body.td-vip-body.is-night-mode .td-vip-ta-theme-select,
body.td-vip-body.is-night-mode .td-vip-ta-chip,
body.td-vip-body.is-night-mode .td-vip-ta-chip-info,
body.td-vip-body.is-night-mode .td-vip-ta-chip-subchart {
    background: #1f2937;
    color: #f3f4f6;
    border-color: rgba(75, 85, 99, 0.7);
}
body.td-vip-body.is-night-mode .td-vip-ta-chip-toggle { color: #f3f4f6; }
body.td-vip-body.is-night-mode .td-vip-ta-chip-period {
    background: rgba(75, 85, 99, 0.5);
    color: #cbd5e1;
}

/* Roadmap #3: MTF overlay row. */
.td-vip-ta-mtf-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    border: 1px dashed rgba(148, 163, 184, 0.5);
    border-radius: 8px;
    margin-top: 4px;
    background: rgba(255, 255, 255, 0.6);
}
.td-vip-ta-mtf-row.is-enabled {
    border-style: solid;
    border-color: rgba(147, 51, 234, 0.6);
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.12);
}
.td-vip-ta-mtf-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    cursor: pointer;
}
.td-vip-ta-mtf-tf {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #fff;
    color: #1f2937;
    border-radius: 4px;
    padding: 2px 8px;
    font: inherit;
    cursor: pointer;
}
.td-vip-ta-mtf-color {
    width: 24px;
    height: 22px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}
body.td-vip-body.is-night-mode .td-vip-ta-mtf-row {
    background: rgba(31, 41, 55, 0.6);
    border-color: rgba(75, 85, 99, 0.7);
}
body.td-vip-body.is-night-mode .td-vip-ta-mtf-tf,
body.td-vip-body.is-night-mode .td-vip-ta-mtf-color {
    background: #1f2937;
    color: #f3f4f6;
    border-color: rgba(75, 85, 99, 0.7);
}

/* Roadmap #6: drag-and-drop reorder visual states. */
.td-vip-indicator-item.is-dragging { opacity: 0.4; }
.td-vip-indicator-item.is-drop-target {
    outline: 2px dashed rgba(41, 98, 255, 0.6);
    outline-offset: -2px;
    background: rgba(41, 98, 255, 0.04);
}

/* Roadmap #4: parameter templates UI inside the indicator settings panel. */
.td-vip-indicator-templates {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.18);
    margin-top: 6px;
}
.td-vip-indicator-templates-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.td-vip-indicator-templates-label {
    font-size: 12px;
    font-weight: 600;
    color: #4338ca;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.td-vip-indicator-template-save {
    appearance: none;
    border: 1px solid rgba(99, 102, 241, 0.4);
    background: #fff;
    color: #4338ca;
    font: 11px inherit;
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.td-vip-indicator-template-save:hover { background: #eef2ff; }
.td-vip-indicator-templates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.td-vip-indicator-template-btn {
    appearance: none;
    border: 1px solid rgba(99, 102, 241, 0.4);
    background: #fff;
    color: #4338ca;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.12s ease;
}
.td-vip-indicator-template-btn:hover { background: #eef2ff; }
.td-vip-indicator-templates-empty {
    font-size: 11px;
    color: #6366f1;
    opacity: 0.7;
}
body.td-vip-body.is-night-mode .td-vip-indicator-templates {
    background: rgba(67, 56, 202, 0.18);
    border-color: rgba(99, 102, 241, 0.4);
}
body.td-vip-body.is-night-mode .td-vip-indicator-templates-label,
body.td-vip-body.is-night-mode .td-vip-indicator-template-btn,
body.td-vip-body.is-night-mode .td-vip-indicator-template-save { color: #c7d2fe; background: #1f2937; }

/* Current free-TA card layout overrides the retired chip-popover formula card. */
.td-vip-ta-card .td-vip-ta-formula-card {
    position: static;
    width: auto;
    margin-top: 2px;
    border-radius: 7px;
    box-shadow: none;
}

body.td-vip-body.is-night-mode .td-vip-ta-toolbar {
    border-color: rgba(51, 65, 85, 0.86);
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.9));
}

body.td-vip-body.is-night-mode .td-vip-ta-toolbar-copy strong,
body.td-vip-body.is-night-mode .td-vip-ta-card-title {
    color: #f8fafc;
}

body.td-vip-body.is-night-mode .td-vip-ta-toolbar-copy span,
body.td-vip-body.is-night-mode .td-vip-ta-card-note,
body.td-vip-body.is-night-mode .td-vip-ta-field-label,
body.td-vip-body.is-night-mode .td-vip-ta-inline-note {
    color: #94a3b8;
}

body.td-vip-body.is-night-mode .td-vip-ta-card {
    border-color: rgba(51, 65, 85, 0.86);
    background: rgba(15, 23, 42, 0.92);
    box-shadow: none;
}

body.td-vip-body.is-night-mode .td-vip-ta-card.is-enabled {
    border-color: rgba(96, 165, 250, 0.64);
    box-shadow: inset 3px 0 0 rgba(96, 165, 250, 0.8);
}

body.td-vip-body.is-night-mode .td-vip-ta-card.is-active-subchart {
    border-color: rgba(56, 189, 248, 0.72);
    box-shadow: inset 0 0 0 1px rgba(14, 165, 233, 0.14), inset 3px 0 0 rgba(56, 189, 248, 0.88);
}

body.td-vip-body.is-night-mode .td-vip-ta-settings-panel {
    border-top-color: rgba(71, 85, 105, 0.78);
}

body.td-vip-body.is-night-mode .td-vip-ta-settings-btn.is-open {
    border-color: rgba(96, 165, 250, 0.72);
    background: rgba(30, 64, 175, 0.28);
    color: #bfdbfe;
}

body.td-vip-body.is-night-mode .td-vip-ta-switch {
    color: #cbd5e1;
}

body.td-vip-body.is-night-mode .td-vip-ta-info-btn,
body.td-vip-body.is-night-mode .td-vip-ta-input,
body.td-vip-body.is-night-mode .td-vip-ta-select,
body.td-vip-body.is-night-mode .td-vip-ta-theme-select,
body.td-vip-body.is-night-mode .td-vip-ta-color {
    border-color: rgba(71, 85, 105, 0.9);
    background: #0f172a;
    color: #e2e8f0;
}

body.td-vip-body.is-night-mode .td-vip-ta-badges span {
    background: rgba(51, 65, 85, 0.92);
    color: #cbd5e1;
}

@media (max-width: 900px) {
    body.td-vip-body .td-vip-chart-shell {
        grid-template-rows: auto minmax(420px, 1fr);
    }

    body.td-vip-body .td-vip-chart-shell.has-ta-subchart {
        grid-template-rows: auto minmax(340px, 1fr) minmax(176px, var(--td-vip-ta-subchart-height, 210px));
    }

    body.td-vip-body .td-vip-chart-shell.has-ta-subchart-collapsed {
        grid-template-rows: auto minmax(340px, 1fr) 36px;
    }

    body.td-vip-body .td-vip-chart-shell > .td-vip-chart-bar {
        grid-row: 1;
    }

    body.td-vip-body .td-vip-chart-host {
        grid-row: 2;
    }

    body.td-vip-body .td-vip-ta-subchart-shell {
        grid-row: 3;
        min-height: 176px;
    }

    body.td-vip-body .td-vip-ta-subchart-shell.is-collapsed {
        min-height: 36px;
    }

    .td-vip-ta-subchart-head {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .td-vip-ta-subchart-title {
        display: none;
    }

    .td-vip-ta-card-grid {
        grid-template-columns: 1fr;
    }

    .td-vip-ta-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ============================================================
 * Compact mode (紧凑模式)
 * ============================================================
 * 触发：用户点击工具栏「紧凑模式」勾选框 → 在 .td-vip-ta-card-grid
 * 上加 .is-compact 类。功能/参数完全保留，仅做视觉密度优化：
 *   1) 描述文本 + 分组 chip 隐藏（信息保留在 title tooltip）
 *   2) 字段 label 与 input 横向排列（节省每字段 14px 高度）
 *   3) 卡片 padding 与 gap 收紧
 *   4) 卡片网格切到 auto-fill minmax(280px) → 宽屏多列
 *   5) 输入控件高度从 28 → 24
 * 整卡高度由 ~210px 缩到 ~92px（约 2.3×）。
 * ============================================================ */

/* 工具栏内"紧凑模式"开关样式 */
.td-vip-ta-toolbar-actions {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.td-vip-ta-compact-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #475569;
    cursor: pointer;
    user-select: none;
    padding: 3px 8px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    border-radius: 999px;
    background: #fff;
    transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.td-vip-ta-compact-toggle:hover {
    border-color: rgba(99, 102, 241, 0.55);
    color: #4338ca;
}

.td-vip-ta-compact-toggle input {
    width: 13px;
    height: 13px;
    margin: 0;
    accent-color: #6366f1;
    cursor: pointer;
}

.td-vip-ta-compact-toggle:has(input:checked) {
    border-color: rgba(99, 102, 241, 0.6);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    color: #4338ca;
}

body.td-vip-body.is-night-mode .td-vip-ta-compact-toggle {
    background: #1f2937;
    color: #cbd5e1;
    border-color: rgba(75, 85, 99, 0.7);
}

body.td-vip-body.is-night-mode .td-vip-ta-compact-toggle:hover,
body.td-vip-body.is-night-mode .td-vip-ta-compact-toggle:has(input:checked) {
    border-color: rgba(129, 140, 248, 0.7);
    background: rgba(99, 102, 241, 0.18);
    color: #c7d2fe;
}

/* ============================================================
 * Compact card grid — 多列紧凑布局
 * ============================================================ */
.td-vip-ta-card-grid.is-compact {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
}

/* 卡片整体收紧 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-card {
    gap: 0;
    padding: 6px 8px;
    box-shadow: 0 4px 12px -10px rgba(15, 23, 42, 0.16);
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-card.is-enabled {
    box-shadow: inset 3px 0 0 rgba(37, 99, 235, 0.72), 0 4px 14px -10px rgba(37, 99, 235, 0.45);
}

/* 标题更紧凑：与按钮同基线对齐 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-card-head {
    align-items: center;
    gap: 6px;
    min-height: 26px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-card-title {
    font-size: 12.5px;
    line-height: 1.25;
}

/* 隐藏描述与 chip：信息已通过 title 属性保留供悬停查看 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-card-note,
.td-vip-ta-card-grid.is-compact .td-vip-ta-badges {
    display: none;
}

/* 启用开关 + 公式按钮更紧凑 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-switch {
    font-size: 10.5px;
    gap: 4px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-switch input {
    width: 13px;
    height: 13px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-info-btn {
    padding: 2px 6px;
    font-size: 10.5px;
    line-height: 1.2;
}

/* 设置网格保持 3 列，gap 减小 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-settings-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

/* ============================================================
 * 关键改动：字段 label 与 input 横向同行
 *   原：column 布局 (label 在上 / input 在下) ≈ 38px 高
 *   新：row 布局 (label 在左 / input 在右) ≈ 24px 高
 * ============================================================ */
.td-vip-ta-card-grid.is-compact .td-vip-ta-field {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-field-label {
    flex: 0 0 auto;
    min-width: 28px;
    max-width: 56px;
    font-size: 10px;
    color: #64748b;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-field-hint {
    display: none; /* hint 文本只在标准模式显示 */
}

/* 输入控件矮一点 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-input,
.td-vip-ta-card-grid.is-compact .td-vip-ta-select {
    min-height: 24px;
    padding: 2px 6px;
    font-size: 11.5px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-color {
    height: 24px;
    min-width: 30px;
    flex: 1 1 auto;
}

/* MACD/CMF 等含子参数的卡片，settings-grid 保留更宽容的换行 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-card[data-ta-id="macd"] .td-vip-ta-settings-grid,
.td-vip-ta-card-grid.is-compact .td-vip-ta-card[data-ta-id="bb"] .td-vip-ta-settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 复选框字段（如 CMF 的零轴）保持原样，但收紧 gap */
.td-vip-ta-card-grid.is-compact .td-vip-ta-field input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
}

/* 公式卡（点击「公式」展开）在紧凑模式下更纤细 */
.td-vip-ta-card-grid.is-compact .td-vip-ta-formula-card {
    font-size: 11px;
    padding: 8px 10px;
}

.td-vip-ta-card-grid.is-compact .td-vip-ta-formula-card pre {
    font-size: 10.5px;
    padding: 5px 7px;
}

/* 在窄屏（< 720px）紧凑模式回退到单列以避免控件挤压 */
@media (max-width: 720px) {
    .td-vip-ta-card-grid.is-compact {
        grid-template-columns: 1fr;
    }
    .td-vip-ta-card-grid.is-compact .td-vip-ta-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .td-vip-ta-card-grid.is-compact .td-vip-ta-field-label {
        max-width: 64px;
    }
}

/* 夜间模式：紧凑模式无需特殊覆盖，复用现有夜间规则即可 */
body.td-vip-body.is-night-mode .td-vip-ta-card-grid.is-compact .td-vip-ta-field-label {
    color: #94a3b8;
}
