body {
    margin: 0;
    font-family: 'Vazirmatn', sans-serif;
    background: #f3effb;
    min-height: 100vh;
}

.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -0.125em;
}

.app-shell {
    position: relative;
    width: min(100%, 430px);
    min-height: 100vh;
    min-height: 100dvh;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background: linear-gradient(135deg, #f8f7ff 0%, #f5efff 55%, #fbf0ff 100%);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.85);
    box-shadow: 0 4px 18px rgba(100, 116, 139, 0.06);
}

.app-navbar {
    width: 100%;
    min-height: 64px;
    margin-inline: auto;
    padding: 0 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.hamburger-button {
    width: 2.5rem;
    height: 2.5rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e9e5f3;
    border-radius: 0.85rem;
    background: #fff;
    color: #64748b;
    font-size: 1.05rem;
    cursor: pointer;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    flex: 0 0 auto;
    margin-inline-end: auto;
    color: #5b21b6;
    text-decoration: none;
}

.app-brand-icon {
    width: 2.35rem;
    height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    color: #fff;
    font-size: 1.1rem;
    background: linear-gradient(135deg, #a855f7, #6366f1);
    box-shadow: 0 5px 14px rgba(124, 58, 237, 0.22);
}

.app-brand-name {
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.navbar-notifications {
    position: relative;
    width: 2.4rem;
    height: 2.4rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e9e5f3;
    border-radius: 0.9rem;
    background: #fff;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
}

.notification-dot {
    position: absolute;
    top: 0.45rem;
    left: 0.45rem;
    width: 0.5rem;
    height: 0.5rem;
    border: 2px solid #fff;
    border-radius: 9999px;
    background: #f43f5e;
}

.app-content {
    width: 100%;
    flex: 1 0 auto;
    box-sizing: border-box;
    padding: 1.25rem 1rem calc(5.5rem + env(safe-area-inset-bottom));
}

body.chat-mode {
    overflow: hidden;
}

.app-shell.chat-mode {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.app-shell.chat-mode .app-header,
.app-shell.chat-mode .bottom-nav {
    display: none;
}

.app-shell.chat-mode .app-content {
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.app-shell.chat-mode .screen-chat.active {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    overflow: hidden;
    padding: 0.65rem 1rem 0;
}

.chat-header {
    min-height: 3rem;
    flex: 0 0 auto;
}

.chat-header button {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.78);
    cursor: pointer;
}

.chat-messages {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.2rem 0.1rem 0.75rem;
}

.chat-composer {
    flex: 0 0 auto;
    padding: 0.6rem 0 calc(0.65rem + env(safe-area-inset-bottom));
}

.chat-composer .icon {
    width: 1rem;
    height: 1rem;
}

/* Custom scrollbar for horizontal navigation */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.glass-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.gradient-btn {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
}

.gradient-btn:hover {
    background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
}

/* Circular Progress styling */
.circle-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 3.8;
}
.circle-progress {
    fill: none;
    stroke-width: 3.8;
    stroke-linecap: round;
    stroke: #06b6d4;
    transition: stroke-dasharray 1s ease;
}

/* Screen Switch Transition */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}
.screen.active {
    display: block;
    opacity: 1;
}

.home-dashboard > * + * {
    margin-top: 1rem;
}

.habit-type-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
    padding: 0.3rem;
    border-radius: 0.95rem;
    background: rgba(226, 232, 240, 0.65);
}

.habit-type-tab {
    min-height: 2.7rem;
    border: 0;
    border-radius: 0.75rem;
    background: transparent;
    color: #64748b;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 800;
    cursor: pointer;
}

.habit-type-tab.active {
    background: #fff;
    color: #6d28d9;
    box-shadow: 0 2px 8px rgba(100, 116, 139, 0.12);
}

.habit-type-description {
    margin: -0.5rem 0 0;
    color: #64748b;
    font-size: 0.72rem;
    line-height: 1.6;
}

.habit-categories {
    display: grid;
    gap: 0.65rem;
}

.habit-category {
    overflow: hidden;
    border: 1px solid #e8e5f1;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 3px 12px rgba(100, 116, 139, 0.045);
}

.habit-category-toggle {
    width: 100%;
    min-height: 3.65rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.8rem;
    border: 0;
    background: transparent;
    color: #334155;
    font: inherit;
    text-align: right;
    cursor: pointer;
}

.habit-category-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #7c3aed;
}

.habit-category-title {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 800;
}

.habit-category-count {
    min-width: 1.5rem;
    padding: 0.15rem 0.35rem;
    border-radius: 99px;
    background: #f5f3ff;
    color: #7c3aed;
    font-size: 0.68rem;
    font-weight: 800;
    text-align: center;
}

.habit-category-chevron {
    width: 0.9rem;
    height: 0.9rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.habit-category-toggle[aria-expanded="true"] .habit-category-chevron {
    transform: rotate(-90deg);
}

.habit-category-items[hidden] {
    display: none !important;
}

.habit-category-items {
    display: grid;
    gap: 0.45rem;
    padding: 0 0.65rem 0.65rem;
}

.habit-choice {
    min-width: 0;
    min-height: 3.4rem;
    display: flex;
    align-items: stretch;
    border: 1px solid #edf0f5;
    border-radius: 0.85rem;
    background: #fff;
    transition: border-color 0.18s ease, background 0.18s ease;
}

.habit-choice.selected {
    border-color: #a78bfa;
    background: #f7f4ff;
}

.habit-choice-button {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: inherit;
    background: transparent;
    color: #334155;
    font: inherit;
    text-align: right;
    cursor: pointer;
}

.habit-choice-button:focus-visible,
.habit-category-toggle:focus-visible,
.habit-type-tab:focus-visible,
.habit-delete-button:focus-visible {
    outline: 3px solid rgba(139, 92, 246, 0.35);
    outline-offset: -2px;
}

.habit-choice-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    color: #7c3aed;
}

.habit-choice-name {
    flex: 1;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.55;
}

.habit-choice-goal {
    flex: 0 0 auto;
    padding: 0.15rem 0.4rem;
    border-radius: 99px;
    background: #fff1f2;
    color: #be123c;
    font-size: 0.62rem;
    font-weight: 800;
}

.habit-choice-goal.build {
    background: #ecfdf5;
    color: #047857;
}

.habit-choice-check {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    color: #7c3aed;
    opacity: 0;
    transform: scale(0.7);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.habit-choice.selected .habit-choice-check {
    opacity: 1;
    transform: scale(1);
}

.habit-delete-button {
    width: 2.65rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.35rem;
    border: 0;
    border-radius: 0.65rem;
    background: #fff1f2;
    color: #e11d48;
    cursor: pointer;
}

.habit-delete-button .icon {
    width: 1rem;
    height: 1rem;
}

.habit-add-trigger:focus-visible,
.habit-dialog-content > input:focus-visible {
    outline: 3px solid rgba(139, 92, 246, 0.35);
    outline-offset: 2px;
}

.habit-add-section {
    display: grid;
    gap: 0.65rem;
}

.habit-add-trigger {
    width: 100%;
    min-height: 3.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border: 1px dashed #c4b5fd;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.7);
    color: #6d28d9;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.habit-add-trigger:hover {
    border-color: #8b5cf6;
    background: #f5f3ff;
}

.habit-add-trigger .icon {
    width: 1.1rem;
    height: 1.1rem;
}

.habit-dialog {
    width: min(390px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
    max-height: 90dvh;
    box-sizing: border-box;
    padding: 1.1rem;
    overflow-y: auto;
    border: 1px solid #e9d5ff;
    border-radius: 1.3rem;
    background: #fff;
    color: #1e293b;
    box-shadow: 0 20px 60px rgba(30, 41, 59, 0.22);
}

.habit-dialog::backdrop {
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
}

.habit-dialog-content {
    display: grid;
    gap: 0.75rem;
    margin: 0;
}

.habit-dialog-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.15rem;
}

.habit-dialog-heading h4 {
    margin: 0;
    color: #1e293b;
    font-size: 1rem;
    font-weight: 900;
}

.habit-dialog-heading p {
    margin: 0.25rem 0 0;
    color: #64748b;
    font-size: 0.72rem;
}

.habit-dialog-close {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.7rem;
    background: #f1f5f9;
    color: #64748b;
    cursor: pointer;
}

.habit-dialog-close .icon {
    width: 1rem;
    height: 1rem;
}

.habit-dialog-label {
    display: block;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 700;
}

.habit-dialog-content > input {
    width: 100%;
    min-height: 2.8rem;
    box-sizing: border-box;
    padding: 0.65rem 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.8rem;
    background: #fff;
    color: #1e293b;
    font: inherit;
    font-size: 0.82rem;
}

.habit-dialog-content > input::placeholder {
    color: #94a3b8;
}

.habit-goal-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.habit-goal-picker legend {
    margin-bottom: 0.45rem;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 800;
}

.habit-goal-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}

.habit-goal-option {
    min-height: 2.45rem;
    padding: 0.4rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #fff;
    color: #64748b;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 800;
    cursor: pointer;
}

.habit-goal-option.active {
    border-color: #a78bfa;
    background: #f5f3ff;
    color: #6d28d9;
}

.habit-icon-picker {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.habit-icon-picker legend {
    margin-bottom: 0.5rem;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 800;
}

.habit-icon-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.45rem;
}

.habit-icon-option {
    min-width: 0;
    min-height: 3.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.35rem 0.15rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.8rem;
    background: #fff;
    color: #64748b;
    font: inherit;
    font-size: 0.64rem;
    font-weight: 700;
    cursor: pointer;
}

.habit-icon-option .icon {
    width: 1.2rem;
    height: 1.2rem;
    color: #7c3aed;
}

.habit-icon-option.selected {
    border-color: #8b5cf6;
    background: #f5f3ff;
    color: #6d28d9;
    box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.15);
}

.habit-icon-option:focus-visible,
.habit-dialog-close:focus-visible {
    outline: 3px solid rgba(139, 92, 246, 0.35);
    outline-offset: 2px;
}

.habit-add-actions {
    display: flex;
    gap: 0.55rem;
    margin-top: 0.7rem;
}

.habit-add-actions button {
    min-height: 2.55rem;
    padding: 0.5rem 1rem;
    border: 0;
    border-radius: 0.75rem;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.habit-add-submit {
    flex: 1;
    background: #7c3aed;
    color: #fff;
}

.habit-add-cancel {
    background: #f1f5f9;
    color: #475569;
}

.drawer-backdrop {
    position: fixed;
    z-index: 55;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.app-drawer {
    position: fixed;
    z-index: 60;
    top: 0;
    right: max(calc((100vw - 430px) / 2), 0px);
    bottom: 0;
    width: min(86vw, 340px);
    box-sizing: border-box;
    padding: 1.1rem;
    overflow-y: auto;
    background: #fff;
    box-shadow: -12px 0 35px rgba(30, 41, 59, 0.16);
    transform: translateX(110%);
    visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s ease;
}

.app-shell.drawer-open .drawer-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.app-shell.drawer-open .app-drawer {
    transform: translateX(0);
    visibility: visible;
}

.drawer-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f1f0f5;
    color: #1e293b;
    font-size: 1rem;
    font-weight: 800;
}

.drawer-close {
    width: 2.35rem;
    height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.8rem;
    background: #f8fafc;
    color: #64748b;
    font-size: 1rem;
    cursor: pointer;
}

.drawer-nav {
    display: grid;
    gap: 0.4rem;
    padding-top: 0.9rem;
}

.drawer-link {
    width: 100%;
    min-height: 3rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.65rem 0.8rem;
    border: 0;
    border-radius: 0.9rem;
    background: transparent;
    color: #475569;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
    cursor: pointer;
}

.drawer-link .icon {
    width: 1.25rem;
    height: 1.25rem;
    color: #8b5cf6;
}

.drawer-link:hover,
.drawer-link.active {
    background: #f5f3ff;
    color: #6d28d9;
}

.bottom-nav {
    position: fixed;
    z-index: 50;
    left: 50%;
    bottom: 0;
    width: min(100%, 430px);
    box-sizing: border-box;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.15rem;
    padding: 0.45rem 0.35rem calc(0.45rem + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    box-shadow: 0 -5px 20px rgba(100, 116, 139, 0.08);
    transform: translateX(-50%);
}

.bottom-nav-link {
    min-width: 0;
    min-height: 3.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    border: 0;
    border-radius: 0.8rem;
    background: transparent;
    color: #94a3b8;
    font: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    white-space: nowrap;
    cursor: pointer;
}

.bottom-nav-link .icon {
    width: 1.05rem;
    height: 1.05rem;
    font-size: 1.05rem;
}

.bottom-nav-link.active,
.bottom-nav-link[aria-expanded="true"] {
    color: #7c3aed;
}

.bottom-nav-link.active .icon,
.bottom-nav-link[aria-expanded="true"] .icon {
    color: #7c3aed;
}

@media (min-width: 431px) {
    .app-shell {
        box-shadow: 0 0 50px rgba(76, 29, 149, 0.07);
    }
}
