/* Responsive */

/* ─── 1400px ─────────────────────────────────────────────────── */

@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ─── 1180px: tablet landscape ───────────────────────────────── */

@media (max-width: 1180px) {
    .dashboard-grid,
    .dash-bottom-row,
    .projects-grid,
    .notes-grid,
    .prompts-grid-layout {
        grid-template-columns: 1fr;
    }

    .calendar-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .month-grid,
    .month-header-row {
        grid-template-columns: 30px repeat(7, minmax(0, 1fr));
        gap: 4px;
    }

    .dtp-layout {
        grid-template-columns: 1fr;
    }

    .dtp-visual {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

/* ─── 980px: tablet — Flex-Column-Layout (Header + Content) ─── */

@media (max-width: 980px) {
    /* Feste Viewport-Höhe, kein Body-Scroll — main-content scrollt */
    html,
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .app-shell {
        display: flex;
        flex-direction: column;
        height: 100dvh;
        min-height: unset;
    }

    .main-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding: 20px;
    }

    .sidebar {
        position: relative;
        flex-shrink: 0;
        z-index: 20;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        height: 56px;
        padding: 0 16px;
        border-right: none;
        border-bottom: 1px solid var(--sidebar-border);
        box-shadow:
            0 1px 0 rgba(255, 255, 255, 0.04),
            0 4px 16px rgba(0, 0, 0, 0.22);
    }

    .sidebar::after,
    .nav-divider {
        display: none;
    }

    .logo-section {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 0;
        margin: 0;
        border: none;
    }

    .logo-mark {
        width: 34px;
        height: 34px;
        font-size: 14px;
        border-radius: 10px;
        box-shadow: none;
    }

    .logo-copy h1 {
        margin: 0;
        font-size: 14px;
        white-space: nowrap;
    }

    .logo-copy p {
        display: none;
    }

    .nav-menu {
        flex: 1;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: flex-start;
        gap: 3px;
        min-width: 0;
        padding: 0 4px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        width: auto;
        height: 36px;
        padding: 7px 14px;
        font-size: 13px;
        white-space: nowrap;
        border-radius: 10px;
    }

    .nav-item.active::before {
        top: auto;
        bottom: 4px;
        left: 8px;
        width: calc(100% - 16px);
        height: 3px;
        transform: none;
        border-radius: 999px;
    }

    .sidebar-footer {
        flex-shrink: 0;
        margin-top: 0;
        padding-top: 0;
        border-top: none;
    }

    .status-pill {
        min-height: 30px;
        padding: 4px 10px;
        font-size: 11px;
        white-space: nowrap;
        border-radius: 10px;
    }

    .calendar-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .board-container {
        overflow-x: auto;
        padding-bottom: 16px;
        -webkit-overflow-scrolling: touch;
    }
}

/* ─── 768px: large phone / small tablet ──────────────────────── */

@media (max-width: 768px) {
    .panel {
        padding: 18px;
    }

    .topbar {
        margin-bottom: 22px;
        gap: 12px;
    }

    .topbar h2 {
        font-size: 26px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea,
    .flow-step-textarea,
    .prompt-note-input,
    .backlog-input,
    .auth-form input {
        font-size: 16px;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
    }

    .btn-sm {
        height: 38px;
        padding: 0 14px;
    }

    .color-dot {
        width: 34px;
        height: 34px;
    }

    .stat-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .forecast-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dash-hero-top,
    .panel-header {
        flex-wrap: wrap;
    }
}

/* ─── 680px ───────────────────────────────────────────────────── */

@media (max-width: 680px) {
    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar h2 {
        font-size: 23px;
    }

    .main-content {
        padding: 14px;
    }

    .calendar-grid,
    .board-container,
    .prompts-grid-layout,
    .notes-grid {
        grid-template-columns: 1fr;
    }

    .board-container {
        display: flex;
        flex-direction: column;
    }

    .board-column {
        width: 100%;
    }

    .panel,
    .section-block,
    .modal {
        border-radius: 18px;
    }

    .panel {
        padding: 16px;
    }

    .day-type-controls {
        width: 100%;
    }

    .day-type-btn {
        flex: 1;
        height: 40px;
        text-align: center;
    }

    .day-budget {
        gap: 12px;
        padding: 14px 16px;
    }

    .topbar .btn-primary,
    .topbar .btn-secondary {
        width: 100%;
        justify-content: center;
    }

    .dtp-metrics {
        grid-template-columns: 1fr;
    }
}

/* ─── 480px: phone, fixe Bottom-Navigation ───────────────────── */

@media (max-width: 480px) {
    html,
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .app-shell {
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: 100dvh;
        min-height: unset;
    }

    .main-content {
        height: 100%;
        overflow-y: auto;
        padding: 12px 12px calc(68px + env(safe-area-inset-bottom, 4px));
        overscroll-behavior-y: contain;
        -webkit-overflow-scrolling: touch;
    }

    .logo-section,
    .sidebar-footer,
    .nav-divider {
        display: none;
    }

    .sidebar {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 50;
        display: flex;
        flex-direction: row;
        align-items: stretch;
        gap: 0;
        height: auto;
        padding: 4px 6px env(safe-area-inset-bottom, 4px);
        border-top: 1px solid var(--sidebar-border);
        border-bottom: none;
        box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.28);
        backdrop-filter: blur(18px);
        -webkit-backdrop-filter: blur(18px);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%),
            linear-gradient(180deg, var(--sidebar-2) 0%, var(--sidebar) 100%);
    }

    .nav-menu {
        flex: 1;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        justify-content: flex-start;
        gap: 2px;
        min-width: 0;
        padding: 2px 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-menu::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        flex: 1 1 0;
        min-width: 60px;
        max-width: 88px;
        min-height: 52px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 4px;
        font-size: 10.5px;
        letter-spacing: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border: none;
        border-radius: 10px;
    }

    .nav-item:hover {
        transform: none;
    }

    .nav-item.active {
        background: rgba(127, 143, 255, 0.18);
        border-color: transparent;
        box-shadow: none;
    }

    .nav-item.active::before {
        display: none;
    }

    .topbar {
        margin-bottom: 14px;
        gap: 10px;
        flex-direction: column;
        align-items: stretch;
    }

    .topbar h2 {
        margin-bottom: 6px;
        font-size: 20px;
        letter-spacing: -0.03em;
    }

    .topbar p {
        font-size: 13px;
    }

    .panel {
        padding: 14px;
        border-radius: 16px;
    }

    .panel-header {
        margin-bottom: 14px;
    }

    .section-block {
        border-radius: 16px;
    }

    .btn-primary,
    .btn-secondary,
    .btn-danger {
        height: 48px;
        padding: 0 16px;
    }

    .btn-icon {
        width: 44px;
        height: 44px;
        border-radius: 12px;
    }

    .btn-sm,
    .copy-btn,
    .cat-filter-btn {
        height: 40px;
        padding: 0 14px;
        font-size: 13px;
    }

    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 92svh;
        overflow-y: auto;
        padding: 24px 20px calc(16px + env(safe-area-inset-bottom, 0px));
        border-radius: 26px 26px 0 0;
    }

    .modal-wide {
        max-height: 96svh;
    }

    .form-actions {
        flex-wrap: wrap;
        gap: 10px;
    }

    .form-actions .btn-primary,
    .form-actions .btn-secondary,
    .form-actions .btn-danger {
        flex: 1;
        min-width: 0;
    }

    .stat-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .forecast-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
    }

    .forecast-day:nth-child(n+5) {
        display: none;
    }

    .board-container {
        display: flex;
        flex-direction: column;
    }

    .board-column,
    .calendar-grid,
    .prompts-grid-layout,
    .notes-grid {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .day-budget {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px;
    }

    .budget-info {
        gap: 12px;
        font-size: 12.5px;
    }

    .budget-bar {
        width: 100%;
        min-width: unset;
    }

    .prompt-actions {
        flex-wrap: wrap;
        gap: 8px;
    }

    .month-grid,
    .month-header-row {
        grid-template-columns: 24px repeat(7, minmax(0, 1fr));
        gap: 2px;
    }

    .month-cell {
        min-height: 36px;
        padding: 3px;
        border-radius: 6px;
    }

    .month-kw-cell {
        font-size: 8px;
    }
}

/* ─── 360px: sehr kleine Phones ──────────────────────────────── */

@media (max-width: 360px) {
    .nav-item {
        min-width: 52px;
        padding: 6px 2px;
        font-size: 9px;
    }

    .main-content {
        padding: 10px 10px calc(68px + env(safe-area-inset-bottom, 4px));
    }

    .stat-cards {
        grid-template-columns: 1fr;
    }

    .topbar h2 {
        font-size: 18px;
    }

    .panel {
        padding: 12px;
    }
}