.site-preferences { display: flex; align-items: center; gap: .65rem; order: 4; margin-inline-start: 1rem; }
.site-preferences form { margin: 0; }
.site-preferences .form-select { width: auto; min-width: 112px; height: 44px; border-radius: 12px; cursor: pointer; appearance: none; -webkit-appearance: none; background-image: none; padding-inline: .85rem; text-align: center; text-align-last: center; }
#theme-toggle { position: relative; display: inline-grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; padding: 0; border: 1px solid #dce5f2; border-radius: 14px; background: linear-gradient(145deg, #fff, #edf3fc); color: #4564a2; box-shadow: 0 2px 6px #18365b0d, inset 0 1px 0 #ffffffb3; cursor: pointer; transition: background .2s, border-color .2s, box-shadow .2s, transform .2s; }
#theme-toggle:hover { border-color: #94b6ed; box-shadow: 0 4px 12px #2563eb20; transform: translateY(-1px); }
#theme-toggle:active { transform: scale(.94); }
#theme-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; }
.theme-icons { position: relative; display: block; width: 22px; height: 22px; }
.theme-icons svg { position: absolute; inset: 0; width: 22px; height: 22px; transition: opacity .2s, transform .3s; }
.theme-sun { opacity: 0; transform: rotate(-60deg) scale(.6); }
[data-bs-theme="dark"] #theme-toggle { background: linear-gradient(145deg, #2b3b55, #202e44); border-color: #465976; color: #f4cf7a; box-shadow: inset 0 1px 0 #ffffff0a, 0 2px 6px #0002; }
[data-bs-theme="dark"] #theme-toggle:hover { border-color: #c3a566; box-shadow: 0 0 16px #f4cf7a16; }
[data-bs-theme="dark"] .theme-moon { opacity: 0; transform: rotate(60deg) scale(.6); }
[data-bs-theme="dark"] .theme-sun { opacity: 1; transform: rotate(0) scale(1); }
@media (prefers-reduced-motion: reduce) {
    #theme-toggle, .theme-icons svg { transition: none; }
}
.hero-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 1rem; }
.hero-actions .btn { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 60px; text-align: center; }
@media (max-width: 575.98px) {
    .hero-actions { grid-template-columns: minmax(0, 1fr); }
}
.main-nav { margin-left: 0; margin-inline-start: auto; }
.navbar-brand { margin-right: 0; margin-inline-end: .75rem; }
html[dir="rtl"] body { font-family: "Vazirmatn", sans-serif; }
.calculator-grid, .calculator-display, .keyboard-board, .image-preview-frame { direction: ltr; }
textarea { unicode-bidi: plaintext; }
.key-dot { margin-right: 0; margin-inline-end: 6px; }
[data-bs-theme="dark"] {
    --bg: #101827; --surface: #1b2638; --text: #edf2fa; --muted: #afbed2;
    --border: #3c4a60; --primary: #8bb4ff; --primary-dark: #b0ccff;
    --bs-body-color: #edf2fa; --bs-body-bg: #101827; --bs-secondary-color: #afbed2;
    --bs-border-color: #3c4a60; --bs-tertiary-bg: #26344a;
}
[data-bs-theme="dark"] body { background: linear-gradient(135deg, #152035, var(--bg)); }
[data-bs-theme="dark"] .navbar { background: #182337f5; }
[data-bs-theme="dark"] .footer { background: #152035; }
[data-bs-theme="dark"] :is(.hero-card, .calculator-card, .image-converter-card) { background: linear-gradient(135deg, #1b2638, #22314a); }
[data-bs-theme="dark"] .card { --bs-card-bg: var(--surface); }
[data-bs-theme="dark"] :is(textarea, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .form-select) { background-color: var(--surface); color: var(--text); border-color: var(--border); }
[data-bs-theme="dark"] :is(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
[data-bs-theme="dark"] .btn-primary { color: #101827; }
[data-bs-theme="dark"] .btn-outline-primary:hover { color: #101827; }
[data-bs-theme="dark"] .calculator-btn { background: #26344a; color: var(--text); }
[data-bs-theme="dark"] .calculator-btn:hover { background: #354864; }
[data-bs-theme="dark"] .calculator-btn-op { color: #d0b8ff; }
[data-bs-theme="dark"] .calculator-btn-equals { background: var(--primary); color: #101827; }
[data-bs-theme="dark"] :is(.bg-light, .editor-canvas-area) { background: #26344a !important; color: var(--text); }
[data-bs-theme="dark"] .format-btn { background: #26344a; color: #d7e3f7; }
[data-bs-theme="dark"] :is(#clearBtn, #convertBtn) { color: #101827; }
[data-bs-theme="dark"] #date-result { background: var(--surface); color: var(--text); }
[data-bs-theme="dark"] #close-result { background: #34445d; color: var(--text); }
[data-bs-theme="dark"] .keyboard-surface { background: #142035; border-color: var(--border); }
[data-bs-theme="dark"] .keyboard-key { background: #26344a; color: var(--text); border-color: #596a85; box-shadow: 0 3px 0 #0b1220; }
[data-bs-theme="dark"] .keyboard-key.tested { background: #145c44; color: #ecfff7; }
[data-bs-theme="dark"] .keyboard-key.pressed { background: #245aba; color: white; }
@media (max-width: 991.98px) {
    .site-preferences { order: 2; width: 100%; margin: .75rem 0 0; justify-content: flex-end; }
    .main-nav { order: 3; margin-inline-start: 0; }
}
