/* Matrix theme: overrides presentation only; task handlers and form values are untouched. */
html.matrix-theme {
    color-scheme: dark;
    background: #030803;
    --bg-body: #030803;
    --panel-top: #020c04;
    --panel-bottom: #020c04;
    --field-bg: #020602;
    --field-border: #008f24;
    --primary: #00ff41;
    --primary-glow: #00ff4133;
    --text-main: #b2f3bc;
    --text-muted: #81bd8d;
    --border-light: #195b2a;
    --danger: #ff5555;
    --mono: 'JetBrains Mono', 'Courier New', monospace;
    scrollbar-color: #227a35 #030803;
}
.matrix-theme body {
    position: relative;
    isolation: isolate;
    min-height: 100vh;
    background: transparent;
    color: var(--text-main);
    font: 400 12px/1.6 var(--mono);
}
.matrix-theme ::selection { background: #00ff41; color: #020602; }
.matrix-theme button, .matrix-theme input, .matrix-theme select, .matrix-theme textarea { font-family: var(--mono); }
.matrix-theme .holiday-background, .matrix-theme .snowfall-overlay { display: none; }
.matrix-theme .card::before, .matrix-theme .card::after,
.matrix-theme .tabs-nav::before, .matrix-theme .source-panel::before,
.matrix-theme button::before { content: none; background-image: none; filter: none; }

/* Fixed decorative layers cannot intercept input or participate in focus. */
#matrix-rain { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -3; pointer-events: none; opacity: .57; }
.matrix-circuit { position: fixed; top: 0; height: 100vh; width: clamp(95px, calc((100vw - 860px) / 2 - 16px), 430px); z-index: -2; pointer-events: none; overflow: hidden; opacity: .8; }
.matrix-circuit-left { left: 0; }
.matrix-circuit-right { right: 0; transform: scaleX(-1); }
.matrix-circuit .trace { fill: none; stroke: #1d6f30; stroke-width: 1.1; vector-effect: non-scaling-stroke; }
.matrix-circuit .current { fill: none; stroke: #00ff41; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-dasharray: 9 91; stroke-dashoffset: 100; animation: matrix-current 7s linear infinite; }
.matrix-circuit circle { fill: #030803; stroke: #43be5d; stroke-width: 1; vector-effect: non-scaling-stroke; }
.matrix-circuit .terminal-node { animation: matrix-node 3.8s ease-in-out infinite; }
.matrix-binary { position: fixed; bottom: 6vh; z-index: -1; width: min(28vw, 340px); overflow: hidden; color: #00ff41; opacity: .15; font: 10px/1.8 var(--mono); letter-spacing: 3px; pointer-events: none; white-space: pre; user-select: none; }
.matrix-binary-left { left: 3vw; }
.matrix-binary-right { right: 3vw; text-align: right; }
.matrix-grid { position: fixed; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(90deg, transparent 49.8%, #12501b12 50%, transparent 50.2%) 0 0 / 80px 80px, radial-gradient(ellipse at center, #03080333 0%, transparent 75%); }
@keyframes matrix-current { to { stroke-dashoffset: 0; } }
@keyframes matrix-node { 0%,100% { fill: #071b0b; stroke: #247f37; opacity:.45; } 50% { fill: #a4ffb7; stroke: #00ff41; opacity:1; } }
@keyframes matrix-cursor { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }

/* Two centered panels, sharp edges and corner brackets rather than clipped controls. */
.matrix-theme .app-wrapper { max-width: 892px; width: 100%; margin: 64px auto 55px; padding: 0 16px; gap: 30px; z-index: 1; }
.matrix-theme .card {
    border: 1px solid #00ff41;
    border-radius: 2px;
    padding: 21px 22px;
    background: linear-gradient(#00ff41,#00ff41) left top/19px 2px no-repeat,
        linear-gradient(#00ff41,#00ff41) left top/2px 19px no-repeat,
        linear-gradient(#00ff41,#00ff41) right bottom/19px 2px no-repeat,
        linear-gradient(#00ff41,#00ff41) right bottom/2px 19px no-repeat,
        rgba(2,12,4,.88);
    box-shadow: 0 0 15px #00ff4133, inset 0 0 10px #00ff410d;
}
.matrix-theme .card::after { content: ''; position: absolute; pointer-events: none; inset: 5px; height: auto; border: 1px solid #00ff411c; border-radius: 0; background: none; filter: none; }
.matrix-theme .workspace-card { padding-top: 22px; }
.matrix-theme .workspace-card::before { content: ''; display: block; position: absolute; left: 8px; right: 8px; top: -9px; height: 4px; z-index: 2; background: repeating-linear-gradient(130deg, #00ff41 0 2px, transparent 2px 5px) left/52px 100% no-repeat, repeating-linear-gradient(130deg, #00ff41 0 2px, transparent 2px 5px) right/52px 100% no-repeat, linear-gradient(#00ff41,#00ff41) center/calc(100% - 116px) 1px no-repeat; filter: drop-shadow(0 0 4px #00ff4170); }
.matrix-theme .badge { color: #00ff41; font: 600 11px/1.6 var(--mono); letter-spacing: .02em; margin: 17px 0 10px; }
.matrix-theme .badge::before { color: #00ff41; font-size: 13px; text-shadow: 0 0 8px #00ff4199; }
.matrix-theme .connection-header { margin-bottom: 16px; }
.matrix-theme .connection-header .badge { margin: 0; }
.matrix-theme .connection-header button { min-height: 27px; padding: 4px 10px; font-size: 9px; }
.matrix-theme .connection-fields { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 15px; }
.matrix-theme .connection-fields>.col { flex: initial !important; }
.matrix-theme .connection-actions { display: grid !important; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px !important; }
.matrix-theme .connection-actions button { font-size: 10px; padding: 8px 5px; }
.matrix-theme .row { gap: 14px; margin-bottom: 19px; }
.matrix-theme .col, .matrix-theme .col-auto { gap: 7px; }
.matrix-theme label { font-size: 10px; font-weight: 500; line-height: 1.6; color: #8fdb9d; }
.matrix-theme input:not([type=radio]):not([type=checkbox]), .matrix-theme textarea, .matrix-theme select {
    background: #020602; border: 1px solid #008f24; border-top-color: #008f24;
    border-radius: 3px; box-shadow: inset 0 0 7px #00ff4105;
    color: #c0f8c9; caret-color: #00ff41; font-size: 12px; line-height: 1.6;
}
.matrix-theme input, .matrix-theme select { min-height: 34px; padding: 6px 9px; }
.matrix-theme textarea { padding: 9px 11px; scrollbar-color: #227a35 #030803; }
.matrix-theme input::placeholder, .matrix-theme textarea::placeholder { color: #71a37a; opacity: 1; }
.matrix-theme input:focus, .matrix-theme textarea:focus, .matrix-theme select:focus { border-color: #00ff41 !important; box-shadow: 0 0 10px #00ff4138, inset 0 0 5px #00ff410c !important; }
.matrix-theme :is(input,textarea,select,button,a,summary):focus-visible { outline: 2px solid #9dffb2; outline-offset: 3px; }
.matrix-theme button {
    border-radius: 2px; border: 1px solid #008f24; min-height: 34px;
    background: #020602; color: #8cfaa4; font-size: 10px; font-weight: 600; padding: 7px 11px;
    box-shadow: inset 0 0 8px #00ff4108;
}
.matrix-theme button:not(.tab-btn):not(.advanced-text-button):not(.advanced-close) { clip-path: polygon(5px 0,100% 0,100% calc(100% - 5px),calc(100% - 5px) 100%,0 100%,0 5px); }
.matrix-theme button:not(.tab-btn):not(.advanced-text-button)::after { content: ''; position: absolute; width: 8px; height: 1px; background: currentColor; right: -1px; bottom: 3px; transform: rotate(-45deg); pointer-events: none; opacity: .7; }
.matrix-theme button:disabled { opacity: .42; cursor: not-allowed; }
.matrix-theme .btn-danger { background: #2a0505; border-color: #ff2a2a; color: #ff5555; box-shadow: inset 0 0 8px #ff2a2a0a; }
.matrix-theme .task-actions .btn-matrix, .matrix-theme #tab6 [data-action=start], .matrix-theme .auth-card .btn-matrix { background: #00ff41; border-color: #00ff41; color: #021305; font-weight: 700; box-shadow: 0 0 14px #00ff4144; }
@media(hover:hover) {
    .matrix-theme button:not(:disabled):hover { border-color: #00ff41; background-color: #062b10; color: #c0ffcb; box-shadow: 0 0 12px #00ff413d, inset 0 0 8px #00ff4111; transform: none; }
    .matrix-theme .task-actions .btn-matrix:not(:disabled):hover, .matrix-theme #tab6 [data-action=start]:not(:disabled):hover { background: #72ff96; color: #020602; }
    .matrix-theme .btn-danger:not(:disabled):hover { color: #ff9999; border-color: #ff5555; background: #3b0808; box-shadow: 0 0 12px #ff2a2a44; }
    .matrix-theme input:hover, .matrix-theme textarea:hover, .matrix-theme select:hover { border-color: #17be40; }
}
.matrix-theme .tabs-nav { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); padding: 5px; gap: 5px; border: 1px solid #1d7d34; border-radius: 3px; background: #020902; margin-bottom: 17px; }
.matrix-theme .tabs-nav:has(> :nth-child(6)) { grid-template-columns: repeat(6,minmax(0,1fr)); }
.matrix-theme .tab-btn { background: transparent; border: 1px solid transparent; color: #76b985; box-shadow: none; border-radius: 2px; padding: 8px 3px; min-height: 34px; font-size: 9px; white-space: normal; line-height: 1.5; }
.matrix-theme .tab-btn.active { background: #063a13; color: #abffbd; border-color: #00ff41; box-shadow: inset 0 0 12px #00ff411f, 0 0 6px #00ff411f; }
.matrix-theme .advanced-entry { margin-bottom: 19px; padding: 12px 13px; border: 1px solid #195b2a; border-radius: 3px; background: #031606; gap: 12px; }
.matrix-theme .advanced-entry strong { font-size: 11px; font-weight: 500; color: #a1ffb3; }
.matrix-theme .advanced-entry p { font-size: 9px; color: #77b484; margin-top: 4px; }
.matrix-theme .advanced-entry button { min-height: 29px; font-size: 9px; padding: 6px 9px; }
.matrix-theme .target-panels { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; align-items: stretch; }
.matrix-theme #t1_targets { height: 169px; min-height: 169px; flex: 1; }
.matrix-theme #t1_ok { height: 126px; min-height: 126px; margin-bottom: 0 !important; flex: 1; }
.matrix-theme .scan-panel button { min-height: 36px; background: repeating-linear-gradient(135deg,#00ff4110 0 2px,transparent 2px 6px),#031206; }
.matrix-theme .source-panel { background: #031106 !important; border: 1px solid #195b2a !important; border-radius: 3px !important; padding: 11px 13px !important; margin-top: 0; gap: 13px; align-items: center; }
.matrix-theme .source-panel>.col-auto { flex: 1; }
.matrix-theme .source-panel>.col-auto:last-child { border-left-color: #236f35 !important; padding-left: 20px !important; margin-left: 0 !important; }
.matrix-theme .source-panel>.col { flex-basis: 160px; }
.matrix-theme .radio-group { min-height: 24px; gap: 7px 14px; }
.matrix-theme .radio-label { color: #91c99d; font-size: 11px; }
.matrix-theme input[type=radio], .matrix-theme input[type=checkbox] { accent-color: #00ff41; min-height: 0; width: 13px; height: 13px; box-shadow: none; }
.matrix-theme .send-settings { grid-template-columns: minmax(0,2.2fr) minmax(0,.85fr) minmax(0,.85fr) minmax(0,1.5fr); gap: 11px; margin-bottom: 0; }
.matrix-theme .send-settings label { font-size: 8px; line-height: 1.6; }
.matrix-theme .send-settings .col>div { gap: 5px !important; }
.matrix-theme .send-settings .col>div button { padding: 5px 7px; font-size: 9px; white-space: nowrap; }
.matrix-theme .send-settings .task-actions { grid-column: auto; flex-wrap: nowrap; width: auto; gap: 7px !important; }
.matrix-theme .send-settings .task-actions button { flex: 1; font-size: 10px; padding: 7px 6px; white-space: nowrap; }
.matrix-theme .log-console { height: 185px; background: #010501; background-image: none; border: 1px solid #008f24; border-radius: 3px; padding: 13px 14px; box-shadow: inset 0 0 14px #000; color: #8fffaa; font: 400 11px/1.9 var(--mono); scrollbar-color: #227a35 #030803; }
.matrix-theme .log-console:empty::before { content: 'Sẵn sàng. Nhật ký sẽ hiển thị khi tác vụ bắt đầu.'; display: block; color: #8fffaa; font: 400 11px/1.9 var(--mono); }
.matrix-theme .log-console::after { content: '_'; display: block; width: max-content; font: 700 14px/1.5 var(--mono); color: #00ff41; animation: matrix-cursor 1.1s step-end infinite; }

/* OTP, authentication and advanced settings share the same palette. */
.matrix-theme .modal-overlay, .matrix-theme .advanced-overlay { background: #010801f5; backdrop-filter: none; }
.matrix-theme .modal-overlay .card { border-color: #00ff41; }
.matrix-theme .logo-title { color: #00ff41; text-shadow: 0 0 14px #00ff4133; }
.matrix-theme .logo-subtitle, .matrix-theme .links a, .matrix-theme .msg-succ { color: #81d994; }
.matrix-theme .auth-page { background: transparent; }
.matrix-theme .auth-card input { min-height: 41px; }
.matrix-theme .auth-card button { min-height: 40px; }
.matrix-theme .advanced-dialog { border: 1px solid #00ff41; border-radius: 3px; background: #020c04; box-shadow: 0 0 24px #00ff4122; }
.matrix-theme .advanced-header { border-top: 2px solid #00ff41; }
.matrix-theme .advanced-header h2, .matrix-theme .advanced-section-heading h3, .matrix-theme .advanced-folder-title strong, .matrix-theme .advanced-recipient-copy strong { color: #b2f3bc; }
.matrix-theme .advanced-toolbar, .matrix-theme .advanced-list-actions, .matrix-theme .advanced-message p, .matrix-theme .advanced-review-row { color: #8acb98; }
.matrix-theme .advanced-tabs, .matrix-theme .advanced-folder, .matrix-theme .advanced-recipient-list, .matrix-theme .advanced-footer, .matrix-theme .advanced-message { background: #020902; border-color: #195b2a; border-radius: 3px; }
.matrix-theme .advanced-tabs button { color: #87c995; }
.matrix-theme .advanced-tabs button.selected { background: #063a13; color: #acffbf; border-color: #00ff41; }
.matrix-theme .advanced-notice, .matrix-theme .advanced-photo-note, .matrix-theme .advanced-folder-icon, .matrix-theme .advanced-review-stats span { background: #061c0a; border-color: #195b2a; color: #94dda4; border-radius: 3px; }
.matrix-theme .advanced-notice.error { border-color: #b83c3c; color: #ff8b8b; }
.matrix-theme .advanced-photo-note strong, .matrix-theme .advanced-photo-note p, .matrix-theme .advanced-kind, .matrix-theme .advanced-review-row b { color: #99dfa7; }
.matrix-theme .advanced-kind, .matrix-theme .advanced-empty, .matrix-theme .advanced-recipient, .matrix-theme .advanced-review-row { border-color: #195b2a; }
.matrix-theme .advanced-empty, .matrix-theme .advanced-recipient-copy small { color: #81bd8d; }
.matrix-theme .advanced-body, .matrix-theme .advanced-recipient-list { scrollbar-color: #227a35 #030803; }
.matrix-theme #tab6 .ls-box { border-color: #195b2a; border-radius: 3px; background: #020b03bb; }
.matrix-theme #tab6 .ls-error { border-color: #b83c3c; color: #ff8b8b; }
.matrix-theme #tab6 [data-action=stop] { background: #2a0505; border-color: #ff2a2a; color: #ff5555; }

/* A local visual preference; never indicates Telegram connection health. */
.matrix-motion-toggle { position: fixed; right: 18px; bottom: 15px; z-index: 5; font: 10px var(--mono); opacity: .75; }
.matrix-theme.matrix-paused .matrix-circuit *, .matrix-theme.matrix-paused .log-console::after { animation-play-state: paused; }
@media(min-width:1600px) { .matrix-theme .app-wrapper { margin-top: 84px; } }
@media(max-width:950px) { .matrix-theme .app-wrapper { padding: 0 16px; } .matrix-circuit { opacity: .24; } }
@media(max-width:700px) {
    .matrix-theme .app-wrapper { margin-top: 35px; gap: 27px; padding: 0 12px; }
    .matrix-theme .card { padding: 19px 14px; }
    .matrix-theme .connection-fields, .matrix-theme .connection-actions { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px !important; }
    .matrix-theme .tabs-nav, .matrix-theme .tabs-nav:has(> :nth-child(6)) { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .matrix-theme .tab-btn { font-size: 9px; }
    .matrix-theme .advanced-entry { flex-direction: row; align-items: center; }
    .matrix-theme .advanced-entry strong { font-size: 10px; }
    .matrix-theme .send-settings { grid-template-columns: minmax(0,2fr) minmax(0,1fr) minmax(0,1fr); }
    .matrix-theme .send-settings>.col:first-child { grid-column: auto; }
    .matrix-theme .send-settings .task-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .matrix-theme .send-settings .task-actions button { flex: 0 1 130px; }
    .matrix-theme .source-panel>.col-auto { width: auto; }
    .matrix-theme .source-panel>.col { flex-basis: 100%; max-width: none !important; }
    .matrix-theme .source-panel>.col-auto:last-child { border-left: 1px solid #236f35 !important; }
    .matrix-theme .target-panels>.col { flex-basis: auto; }
    .matrix-theme input:not([type=radio]):not([type=checkbox]), .matrix-theme textarea, .matrix-theme select { font-size: 13px; }
    .matrix-binary { font-size: 8px; opacity: .09; }
    #matrix-rain { opacity: .36; }
    .matrix-motion-toggle { right: 12px; bottom: 8px; font-size: 9px !important; }
}
@media(max-width:480px) {
    .matrix-theme .connection-actions button { font-size: 9px; }
    .matrix-theme .advanced-entry { flex-direction: column; align-items: stretch; }
    .matrix-theme .target-panels { grid-template-columns: 1fr; }
    .matrix-theme #t1_targets { min-height: 135px; height: 135px; }
    .matrix-theme #t1_ok { min-height: 110px; height: 110px; }
    .matrix-theme .send-settings { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .matrix-theme .send-settings>.col:first-child { grid-column: 1 / -1; }
    .matrix-theme .send-settings .task-actions button { flex: 1; }
    .matrix-theme .source-panel { flex-direction: column; align-items: stretch; }
    .matrix-theme .source-panel>.col-auto:last-child { border-left: 0 !important; border-top: 1px solid #195b2a; padding: 10px 0 0 !important; }
    .matrix-theme .source-panel>.col { flex-basis: auto; }
    .matrix-theme .connection-header .badge { font-size: 10px; }
    .matrix-theme .connection-header button { font-size: 8px; }
    .matrix-circuit { display: none; }
}
@media(prefers-reduced-motion:reduce) { .matrix-theme *, .matrix-theme *::before, .matrix-theme *::after { animation: none !important; transition: none !important; } }
