/* ===== Design Tokens ===== */
:root {
    --bg-base: #f4f5f7;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --bg-sidebar-active: rgba(99, 102, 241, 0.2);

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #f8fafc;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #e2e8f0;

    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #eef2ff;
    --accent-glow: rgba(99, 102, 241, 0.25);

    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --danger-hover: #dc2626;

    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);

    --font: 'Inter', system-ui, -apple-system, sans-serif;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 260px;
    --bottom-nav-height: 64px;
    --mobile-header-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --touch-min: 44px;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

button, input, select { font-family: inherit; }
button {
    cursor: pointer;
    border: none;
    background: none;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
input, select {
    outline: none;
    font-size: 16px; /* prevents iOS zoom on focus */
}
a { text-decoration: none; color: inherit; }

.hidden { display: none !important; }

/* ===== Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 28px;
}

.sidebar__logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.sidebar__title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--bg-sidebar-active);
    color: #a5b4fc;
}

.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-item__count {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}

.nav-item.active .nav-item__count {
    background: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}

.sidebar__stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-card {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}

.stat-card__label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-sidebar);
    margin-bottom: 4px;
}

.stat-card__value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-inverse);
}

/* ===== Mobile Top Bar (hidden on desktop) ===== */
.mobile-topbar {
    display: none;
}

/* ===== Bottom Nav & FAB (hidden on desktop) ===== */
.bottom-nav,
.fab {
    display: none;
}

/* ===== Main ===== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    max-width: 1100px;
    width: 100%;
}

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}

.header__title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 4px;
}

.header__subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* ===== Search ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0 14px;
    height: 42px;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 240px;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
    border: none;
    background: none;
    font-size: 0.875rem;
    width: 100%;
    color: var(--text-primary);
}

.search-box input::placeholder { color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px;
    height: 42px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn--primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn--primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--ghost:hover {
    background: var(--bg-base);
    color: var(--text-primary);
}

.btn--danger {
    background: var(--danger);
    color: white;
}

.btn--danger:hover { background: var(--danger-hover); }

.btn--sm {
    height: 34px;
    padding: 0 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-base);
    color: var(--text-primary);
}

.btn-icon:active {
    background: var(--border-light);
    transform: scale(0.94);
}

/* ===== Project Cards ===== */
.content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.project-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
    animation: fadeInUp 0.35s ease both;
}

.project-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.project-card__header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    cursor: pointer;
    user-select: none;
}

.project-card__check {
    width: 26px;
    height: 26px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    cursor: pointer;
}

.project-card__check:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.project-card__check.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.project-card__check.cancelled {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.project-card__info { flex: 1; min-width: 0; }

.project-card__name {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    transition: color var(--transition);
}

.project-card__name.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.project-card__name.cancelled {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.6;
}

.project-card__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.project-card__date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.project-card__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}

.project-card:hover .project-card__actions,
.project-card__actions:focus-within { opacity: 1; }

.project-card__chevron {
    color: var(--text-muted);
    transition: transform var(--transition);
    margin-left: 4px;
}

.project-card.expanded .project-card__chevron {
    transform: rotate(180deg);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.badge--uncompleted { background: var(--accent-light); color: var(--accent); }
.badge--completed   { background: var(--success-bg); color: var(--success); }
.badge--cancelled   { background: var(--danger-bg); color: var(--danger); }

/* ===== Progress Bar ===== */
.progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress__bar {
    width: 80px;
    height: 5px;
    background: var(--border-light);
    border-radius: 10px;
    overflow: hidden;
}

.progress__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 10px;
    transition: width 0.4s ease;
}

.progress__text {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== Sub-tasks ===== */
.project-card__body {
    border-top: 1px solid var(--border-light);
    padding: 0 24px 20px;
    display: none;
}

.project-card.expanded .project-card__body { display: block; }

.subtask-list {
    list-style: none;
    padding: 16px 0 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    group: subtask;
}

.subtask-item:hover { background: var(--bg-base); }

.subtask-item__check {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
    cursor: pointer;
}

.subtask-item__check:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.subtask-item__check.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.subtask-item__check.cancelled {
    background: var(--danger-bg);
    border-color: var(--danger);
    color: var(--danger);
}

.subtask-item__text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
    min-width: 0;
    word-break: break-word;
}

.subtask-item__text.completed {
    text-decoration: line-through;
    color: var(--text-muted);
}

.subtask-item__text.cancelled {
    text-decoration: line-through;
    color: var(--text-muted);
    opacity: 0.6;
}

.subtask-item__actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition);
}

.subtask-item:hover .subtask-item__actions { opacity: 1; }

.subtask-add {
    display: flex;
    gap: 8px;
    padding-top: 8px;
}

.subtask-add input {
    flex: 1;
    height: 38px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.subtask-add input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ===== Empty & Loading ===== */
.loading, .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state__icon {
    width: 64px;
    height: 64px;
    background: var(--accent-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    margin-bottom: 20px;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 24px;
    max-width: 320px;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] { display: none; }

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    animation: modalIn 0.25s ease;
}

.modal--sm { max-width: 380px; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 0;
}

.modal__title {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal__body { padding: 20px 24px 24px; }

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    background: var(--bg-surface);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.confirm-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-sidebar);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 280px;
    animation: toastIn 0.3s ease;
}

.toast--error { border-left: 3px solid var(--danger); }
.toast--success { border-left: 3px solid var(--success); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.toast.fade-out {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(20px); }
}

/* ===== Responsive — Tablet ===== */
@media (max-width: 1024px) {
    .main {
        padding: 24px 24px;
    }

    .header {
        flex-direction: column;
        gap: 16px;
    }

    .header__actions {
        width: 100%;
    }

    .search-box {
        flex: 1;
        min-width: 0;
    }
}

/* ===== Responsive — Mobile (primary experience) ===== */
@media (max-width: 767px) {
    body {
        overscroll-behavior-y: contain;
    }

    .app {
        flex-direction: column;
    }

    .sidebar {
        display: none;
    }

    .mobile-topbar {
        width: 100%;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: sticky;
        top: 0;
        z-index: 200;
        height: calc(var(--mobile-header-height) + var(--safe-top));
        padding: var(--safe-top) 16px 0;
        background: var(--bg-sidebar);
        color: var(--text-inverse);
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.15);
    }

    .mobile-topbar__brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-topbar__title {
        font-size: 1.1rem;
        font-weight: 700;
        letter-spacing: -0.02em;
    }

    .mobile-topbar__stats {
        display: flex;
        gap: 16px;
    }

    .mobile-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
        line-height: 1.2;
    }

    .mobile-stat__value {
        font-size: 1rem;
        font-weight: 700;
        color: #a5b4fc;
    }

    .mobile-stat__label {
        font-size: 0.65rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--text-sidebar);
    }

    .main {
        margin-left: 0;
        padding: 16px 16px calc(var(--bottom-nav-height) + var(--safe-bottom) + 80px);
        max-width: none;
    }

    .header {
        margin-bottom: 20px;
        gap: 12px;
    }

    .header__title {
        font-size: 1.35rem;
    }

    .header__subtitle {
        font-size: 0.82rem;
    }

    .header__actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn--desktop {
        display: none;
    }

    .search-box {
        width: 100%;
        height: var(--touch-min);
        min-width: 0;
        border-radius: var(--radius-lg);
    }

    /* Bottom navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 300;
        height: calc(var(--bottom-nav-height) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--bg-sidebar);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.12);
    }

    .bottom-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 4px;
        color: var(--text-sidebar);
        font-size: 0.65rem;
        font-weight: 600;
        position: relative;
        transition: color var(--transition);
        min-height: var(--touch-min);
    }

    .bottom-nav__item svg {
        opacity: 0.65;
        transition: opacity var(--transition), transform var(--transition);
    }

    .bottom-nav__item.active {
        color: #a5b4fc;
    }

    .bottom-nav__item.active svg {
        opacity: 1;
        transform: scale(1.05);
    }

    .bottom-nav__item:active {
        background: rgba(255, 255, 255, 0.05);
    }

    .bottom-nav__badge {
        position: absolute;
        top: 4px;
        right: calc(50% - 22px);
        background: rgba(99, 102, 241, 0.35);
        color: #c7d2fe;
        font-size: 0.6rem;
        font-weight: 700;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
    }

    .bottom-nav__item:not(.active) .bottom-nav__badge {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-sidebar);
    }

    /* Floating action button */
    .fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 16px);
        right: 16px;
        z-index: 250;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent), #8b5cf6);
        color: white;
        box-shadow: 0 6px 20px var(--accent-glow), 0 2px 8px rgba(15, 23, 42, 0.15);
        transition: transform var(--transition), box-shadow var(--transition);
    }

    .fab:active {
        transform: scale(0.92);
        box-shadow: 0 3px 12px var(--accent-glow);
    }

    /* Project cards — touch-friendly */
    .content {
        gap: 12px;
    }

    .project-card {
        border-radius: var(--radius-md);
    }

    .project-card__header {
        padding: 16px;
        gap: 12px;
        align-items: flex-start;
    }

    .project-card__check {
        width: 28px;
        height: 28px;
        margin-top: 2px;
    }

    .project-card__name {
        font-size: 0.95rem;
        line-height: 1.35;
    }

    .project-card__meta {
        gap: 8px;
    }

    .project-card__date {
        width: 100%;
        margin-top: 2px;
    }

    .project-card__actions {
        opacity: 1;
        flex-shrink: 0;
    }

    .project-card__body {
        padding: 0 16px 16px;
    }

    .subtask-item {
        padding: 12px 8px;
        gap: 10px;
        min-height: var(--touch-min);
    }

    .subtask-item__check {
        width: 26px;
        height: 26px;
    }

    .subtask-item__text {
        font-size: 0.9rem;
        line-height: 1.4;
    }

    .subtask-item__actions {
        opacity: 1;
    }

    .subtask-add {
        flex-direction: column;
        gap: 10px;
    }

    .subtask-add input {
        height: var(--touch-min);
        border-radius: var(--radius-md);
        font-size: 16px;
    }

    .subtask-add .btn {
        width: 100%;
        height: var(--touch-min);
        justify-content: center;
        font-size: 0.9rem;
    }

    .progress__bar {
        width: 60px;
    }

    /* Modals as bottom sheets */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        max-width: none;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        animation: sheetIn 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        max-height: 90dvh;
        overflow-y: auto;
        padding-bottom: var(--safe-bottom);
    }

    .modal--sm {
        max-width: none;
    }

    @keyframes sheetIn {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0); }
    }

    .modal__header {
        padding: 20px 20px 0;
        position: relative;
    }

    .modal__header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: var(--border);
        border-radius: 4px;
    }

    .modal__body {
        padding: 16px 20px 24px;
    }

    .modal__footer {
        flex-direction: column-reverse;
        gap: 10px;
    }

    .modal__footer .btn {
        width: 100%;
        height: var(--touch-min);
        justify-content: center;
        font-size: 0.95rem;
    }

    .form-group input,
    .form-group select {
        height: var(--touch-min);
        font-size: 16px;
    }

    /* Toasts above bottom nav */
    .toast-container {
        bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px);
        right: 12px;
        left: 12px;
    }

    .toast {
        min-width: 0;
        width: 100%;
        justify-content: center;
        text-align: center;
        padding: 14px 16px;
    }

    /* Empty & loading states */
    .loading, .empty-state {
        padding: 48px 16px;
    }

    .empty-state .btn {
        width: 100%;
        height: var(--touch-min);
        justify-content: center;
    }

    /* Disable hover lift on touch */
    .btn--primary:hover {
        transform: none;
    }

    .project-card:hover {
        box-shadow: var(--shadow-card);
        border-color: var(--border);
    }
}

/* Touch devices — always show action buttons */
@media (hover: none) and (pointer: coarse) {
    .project-card__actions,
    .subtask-item__actions {
        opacity: 1;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .bottom-nav__item span:not(.bottom-nav__badge) {
        font-size: 0.58rem;
    }

    .header__title {
        font-size: 1.2rem;
    }
}
