:root,
[data-bs-theme="dark"] {
    color-scheme: dark;
    --app-bg: #0f1115;
    --app-surface: #171a21;
    --app-surface-secondary: #1e222b;
    --app-surface-hover: #252a35;
    --app-border: #2b313d;
    --app-text: #f3f4f6;
    --app-text-muted: #9ca3af;
    --app-primary: #7c5cff;
    --app-primary-hover: #6d4df0;
    --app-success: #32c48d;
    --app-danger: #ef5b68;
    --app-warning: #f5b942;
    --safe-bottom: calc(76px + env(safe-area-inset-bottom));
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);
    --bs-secondary-color: var(--app-text-muted);
    --bs-secondary-bg: var(--app-surface-secondary);
    --bs-tertiary-bg: var(--app-surface-secondary);
    --bs-card-bg: var(--app-surface);
    --bs-card-border-color: var(--app-border);
    --bs-modal-bg: var(--app-surface);
    --bs-modal-border-color: var(--app-border);
    --bs-form-control-bg: var(--app-surface-secondary);
    --bs-form-control-color: var(--app-text);
    --bs-form-control-border-color: var(--app-border);
    --bs-form-select-bg: var(--app-surface-secondary);
    --bs-form-select-color: var(--app-text);
    --bs-form-select-border-color: var(--app-border);
    --bs-btn-close-color: #ffffff;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

html {
    background-color: var(--app-bg);
}

body.app-body,
body.auth-body {
    min-height: 100vh;
    color: var(--app-text);
    background:
        radial-gradient(110% 120% at 0% 0%, #252947 0%, rgba(37, 41, 71, 0) 35%),
        radial-gradient(80% 100% at 100% 100%, #1f2a3c 0%, rgba(31, 42, 60, 0) 45%),
        var(--app-bg);
    background-color: var(--app-bg);
}

a {
    color: #b3a2ff;
}

a:hover {
    color: #d0c6ff;
}

.text-muted {
    color: var(--app-text-muted) !important;
}

.app-shell {
    max-width: 980px;
    min-height: 100vh;
    background: transparent;
}

.app-header {
    border-bottom: 1px solid var(--app-border);
    background: rgba(23, 26, 33, 0.88);
    backdrop-filter: blur(12px);
}

.app-brand {
    text-decoration: none;
    font-weight: 700;
    color: var(--app-text);
    letter-spacing: 0.2px;
}

.top-nav-link {
    text-decoration: none;
    color: var(--app-text-muted);
    padding: 8px 12px;
    border-radius: 10px;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.top-nav-link:hover,
.top-nav-link[aria-current="page"] {
    color: var(--app-text);
    background: var(--app-surface-hover);
}

.app-content {
    padding-bottom: var(--safe-bottom);
}

.card,
.modal-content {
    background-color: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 16px;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.32);
}

.container,
.container-fluid,
main,
section,
header,
nav,
footer {
    background-color: transparent;
}

.modal-content {
    border-radius: 18px;
}

.btn {
    min-height: 44px;
    border-radius: 12px;
}

.btn-primary {
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--app-primary-hover) !important;
    border-color: var(--app-primary-hover) !important;
}

.btn-outline-secondary {
    color: var(--app-text-muted);
    border-color: var(--app-border);
}

.btn-outline-secondary:hover {
    color: var(--app-text);
    background: var(--app-surface-hover);
    border-color: #3b4352;
}

.btn-outline-danger {
    color: #f38d96;
    border-color: rgba(239, 91, 104, 0.45);
}

.btn-outline-danger:hover {
    color: #fff;
    background: rgba(239, 91, 104, 0.8);
    border-color: rgba(239, 91, 104, 0.8);
}

.btn-outline-warning {
    color: #ffd98b;
    border-color: rgba(245, 185, 66, 0.45);
}

.btn-outline-warning:hover {
    color: #1a1a1a;
    background: var(--app-warning);
    border-color: var(--app-warning);
}

.btn-outline-success {
    color: #7ff0c4;
    border-color: rgba(50, 196, 141, 0.45);
}

.btn-outline-success:hover {
    color: #0b1a14;
    background: var(--app-success);
    border-color: var(--app-success);
}

.form-control,
.form-select,
.form-control-color,
textarea,
input[type="date"],
input[type="time"],
input[type="color"] {
    min-height: 44px;
    color: var(--app-text);
    background-color: var(--app-surface-secondary);
    border-color: var(--app-border);
    color-scheme: dark;
}

.form-select option,
select option {
    color: var(--app-text);
    background-color: var(--app-surface-secondary);
}

.form-control::placeholder,
textarea::placeholder {
    color: #7f8797;
}

.form-control:focus,
.form-select:focus,
textarea:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="color"]:focus {
    color: var(--app-text);
    background-color: var(--app-surface-secondary);
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(124, 92, 255, 0.24);
}

.form-control:disabled,
.form-select:disabled {
    color: #7d8798;
    background-color: #141720;
}

.form-check-input {
    background-color: var(--app-surface-secondary);
    border-color: var(--app-border);
}

.form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(124, 92, 255, 0.24);
}

.btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    opacity: 0.8;
}

.btn-close:hover {
    opacity: 1;
}

.modal-header,
.modal-footer {
    background: transparent;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill {
    -webkit-text-fill-color: var(--app-text);
    -webkit-box-shadow: 0 0 0px 1000px var(--app-surface-secondary) inset;
    transition: background-color 9999s ease-in-out 0s;
}

.invalid-feedback {
    color: #ff9aa3;
}

.alert {
    border-radius: 14px;
    border-width: 1px;
}

.alert-success {
    color: #b9f7df;
    background: rgba(50, 196, 141, 0.12);
    border-color: rgba(50, 196, 141, 0.35);
}

.alert-danger {
    color: #ffc0c6;
    background: rgba(239, 91, 104, 0.12);
    border-color: rgba(239, 91, 104, 0.35);
}

.alert-warning {
    color: #ffe6b4;
    background: rgba(245, 185, 66, 0.14);
    border-color: rgba(245, 185, 66, 0.4);
}

.alert-info {
    color: #b9ddff;
    background: rgba(78, 153, 255, 0.14);
    border-color: rgba(78, 153, 255, 0.35);
}

.badge.text-bg-success-subtle {
    background-color: rgba(50, 196, 141, 0.18) !important;
    color: #9bf3cf !important;
}

.badge.text-bg-secondary {
    background-color: rgba(120, 130, 150, 0.25) !important;
    color: #d6dbe6 !important;
}

.auth-main {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.auth-card-wrapper {
    width: 100%;
    max-width: 420px;
}

.auth-card-wrapper .card,
.app-shell .card {
    overflow: hidden;
}

.auth-main .container,
.auth-main .container-fluid {
    background: transparent;
}

.auth-brand h1 {
    color: var(--app-text);
}

.mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 76px;
    z-index: 1000;
    border-top: 1px solid var(--app-border);
    background: rgba(23, 26, 33, 0.95);
    backdrop-filter: blur(10px);
}

.mobile-bottom-nav .nav-item,
.mobile-bottom-nav .nav-logout-btn {
    width: 100%;
    border: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--app-text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    line-height: 1;
}

.mobile-bottom-nav .nav-item i,
.mobile-bottom-nav .nav-logout-btn i {
    font-size: 1.1rem;
}

.mobile-bottom-nav .nav-item[aria-current="page"] {
    color: #c9bcff;
}

.nav-form-item {
    margin: 0;
}

.category-card {
    border-left: 4px solid var(--category-color, var(--app-primary));
}

.category-card-inactive {
    opacity: 0.78;
}

.category-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 92, 255, 0.14);
    color: #c9bcff;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.icon-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.icon-pill {
    min-height: 44px;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--app-surface-secondary);
    width: 100%;
    color: var(--app-text-muted);
    transition: all 0.2s ease;
}

.icon-option input:checked + .icon-pill {
    border-color: var(--app-primary);
    color: #d9d1ff;
    background: rgba(124, 92, 255, 0.2);
}

.category-preview {
    background: var(--app-surface-secondary);
}

.task-card {
    border-left: 4px solid var(--category-color, var(--app-primary));
}

.task-card-inactive {
    opacity: 0.78;
}

.task-meta-grid {
    display: grid;
    gap: 6px;
}

.priority-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    border: 1px solid var(--app-border);
    color: var(--app-text);
    background: var(--app-surface-secondary);
}

.priority-level-4,
.priority-level-5 {
    border-color: rgba(124, 92, 255, 0.35);
    color: #d8cdff;
}

.task-form-section,
.task-summary-card {
    background: var(--app-surface);
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.weekday-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.weekday-pill {
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--app-border);
    background: var(--app-surface-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--app-text-muted);
    transition: all 0.2s ease;
}

.weekday-pill i {
    opacity: 0;
}

.weekday-option input:checked + .weekday-pill {
    border-color: var(--app-primary);
    background: rgba(124, 92, 255, 0.16);
    color: #e7e0ff;
}

.weekday-option input:checked + .weekday-pill i {
    opacity: 1;
    color: #cfc4ff;
}

.weekday-section.is-invalid .weekday-pill {
    border-color: rgba(239, 91, 104, 0.45);
}

.preview-color-dot {
    width: 16px;
    height: 40px;
    border-radius: 999px;
}

.preview-icon-wrap {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(124, 92, 255, 0.18);
    color: #cfc4ff;
}

@media (min-width: 768px) {
    .mobile-bottom-nav {
        display: none;
    }

    .app-content {
        padding-bottom: 1.25rem;
    }

    .icon-grid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }

    .weekday-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
