/* Layout */
.app-container { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 20px; }
.controls-panel { width: 250px; background: #f8fafc; padding: 20px; border-radius: 8px; border: 1px solid var(--border-color); height: fit-content; }
.view-panel { flex: 1; min-width: 300px; }

/* 1. Global Horizontal Lock */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

/* 2. Mobile-Only Bounce Lock */
/* (hover: none) and (pointer: coarse) perfectly targets touchscreens! */
@media (hover: none) and (pointer: coarse) {
    body {
        /* Stops the pull-to-refresh and rubber-band bounce effects */
        overscroll-behavior-y: none; 
        overscroll-behavior-x: none; 
    }
    
    /* Make sure the main content area can still scroll vertically if it's long */
    .main-content {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
        height: 100vh;
    }
}

/* Navigation & Tabs */
.tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 15px; }
.tab-btn { padding: 10px 20px; cursor: pointer; border: none; background: none; font-size: 1.1rem; color: var(--text-muted); }
.tab-btn.active { color: var(--primary-color); border-bottom: 3px solid var(--primary-color); font-weight: bold; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Header Nav Controls */
.view-header { display: flex; justify-content: space-between; align-items: center; background: var(--primary-color); color: white; padding: 15px; border-radius: 8px 8px 0 0; }
/* Ensure clickable links inside the header remain white */
.view-header .clickable-link {
    color: white;
    text-decoration-color: rgba(255, 255, 255, 0.6);
}
.view-header .clickable-link:hover {
    color: #f1f5f9;
}
.nav-btn { background: rgba(255,255,255,0.2); border: none; color: white; font-size: 1.2rem; cursor: pointer; padding: 5px 15px; border-radius: 4px; transition: 0.2s; }
.nav-btn:hover { background: rgba(255,255,255,0.4); }
.view-title { font-size: 1.5rem; font-weight: bold; margin: 0; color: white; }

/* Interactive Links */
.clickable-link { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; }
.clickable-link:hover { opacity: 0.8; }

/* Toggles */
.toggle-group { display: flex; gap: 10px; margin: 15px 0; }
.toggle-btn { padding: 5px 15px; border: 1px solid var(--primary-color); background: white; color: var(--primary-color); cursor: pointer; border-radius: 20px; }
.toggle-btn.active { background: var(--primary-color); color: white; }

/* Day Card */
.day-card { border: 1px solid var(--border-color); border-radius: 0 0 8px 8px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.day-card-body { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.day-stat-box { background: #f1f5f9; padding: 15px; border-radius: 6px; text-align: center; }
.day-stat-val { font-size: 1.5rem; font-weight: bold; color: var(--text-main); }
.day-stat-lbl { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }

/* Extensions for future engines */
.ext-section { grid-column: 1 / -1; border-top: 1px solid var(--border-color); padding-top: 15px; margin-top: 10px; }
.ext-title { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; font-weight: bold; }
.ext-grid { display: flex; gap: 15px; flex-wrap: wrap; }
.ext-badge { background: #e2e8f0; padding: 5px 12px; border-radius: 20px; font-size: 0.9rem; }

/* Grid System */
.grid-attributes { background: #fffbeb; border: 1px solid #fde68a; padding: 10px; text-align: center; border-radius: 6px; margin-bottom: 15px; color: #92400e; font-weight: bold; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.month-header { text-align: center; font-weight: bold; padding: 8px; background: #e2e8f0; border-radius: 4px; font-size: 0.9rem;}
.month-cell { border: 1px solid var(--border-color); border-radius: 4px; padding: 8px; min-height: 80px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: 0.1s;}
.month-cell:hover { border-color: var(--primary-color); background: #f8fafc; }
.month-cell.empty { background: transparent; border: 1px dashed transparent; cursor: default; }
.greg-date { font-weight: bold; color: var(--text-main); }
.tib-tithi { text-align: right; color: var(--primary-color); font-size: 1.2rem; font-weight: bold; }

/* Year Grid (Mini Months) */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 15px; }
.mini-month { border: 1px solid var(--border-color); border-radius: 6px; cursor: pointer; overflow: hidden; }
.mini-month-title { background: #f1f5f9; text-align: center; padding: 8px; font-weight: bold; border-bottom: 1px solid var(--border-color); color: var(--text-main); }
.mini-month-body { padding: 10px; text-align: center; color: var(--text-muted); font-size: 0.8rem; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;}
.mini-month:hover { border-color: var(--primary-color); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Generic Table for Losar */
.data-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.data-table th, .data-table td { padding: 10px; border: 1px solid var(--border-color); text-align: left; }
.data-table th { background: #f1f5f9; }

/* The marker for the real-world today */
.real-today {
    box-shadow: inset 0 0 0 2px #10b981 !important; /* Green inner border */
    position: relative;
}
/* Optional: A little green dot in the corner */
.real-today::after {
    content: ''; position: absolute; top: 4px; left: 4px; width: 8px; height: 8px; 
    background: #10b981; border-radius: 50%;
}

/* Mobile Grid Optimizations */
@media (max-width: 600px) {
    .month-grid {
        gap: 2px; /* Reduce space between cells */
    }
    .month-header {
        font-size: 0.75rem;
        padding: 5px 2px;
    }
    .month-cell {
        padding: 2px !important;
    }
    /* Shrink text slightly more on narrow screens */
    .tib-tithi { font-size: 1.1rem !important; }
    .greg-date { font-size: 0.65rem !important; }
}

.month-grid {
    /* This strictly traps the grid inside the screen width */
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important; 
    width: 100%;
}
.month-cell {
    min-width: 0; 
    word-wrap: break-word; /* Let long text wrap instead of pushing boundaries */
}