:root {
    /* Premium Light Theme */
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f1f5f9;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(241, 245, 249, 0.6);
    
    --red: #ef4444;
    --yellow: #d97706;
    --green: #16a34a;
    --blue: #2563eb;
    --orange: #ea580c;
    --teal: #14b8a6;

    --radius: 12px;
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 2px 8px -1px rgba(0, 0, 0, 0.04);
    
    --dash-red-bg: linear-gradient(135deg, rgba(239, 68, 68, 0.08), rgba(239, 68, 68, 0.01));
    --dash-yellow-bg: linear-gradient(135deg, rgba(217, 119, 6, 0.08), rgba(217, 119, 6, 0.01));
    --dash-green-bg: linear-gradient(135deg, rgba(22, 163, 74, 0.08), rgba(22, 163, 74, 0.01));
    --dash-blue-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.01));
    --dash-orange-bg: linear-gradient(135deg, rgba(234, 88, 12, 0.08), rgba(234, 88, 12, 0.01));
    --dash-text: #0f172a;

    /* חצי לילה עדין במשבצת היום (top) לעומת חצי יום רגיל (bottom) — היממה
       העברית נפתחת בלילה, וההפרדה הזו רק משקפת זאת חזותית; אינה משנה מיקום
       שום סימון (ראו js/ui.js: marker-wrapper עליון/תחתון, ו-css להלן). */
    --cell-night-tint: rgba(15, 23, 42, 0.055);

    /* חלון ביוץ ופוריות (docs/SPEC_FERTILITY_INSIGHTS.md §3.4-א) — צניעות מכוונת: גוון עדין ורגוע. */
    --fertility-window-bg: rgba(20, 184, 166, 0.08);
    --fertility-peak-bg: rgba(20, 184, 166, 0.16);
}

[data-theme="dark"] {
    /* Premium Dark Theme */
    --bg-color: #0b0f19;
    --surface: #131c2e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --input-bg: #0b0f19;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    
    --glass-bg: rgba(19, 28, 46, 0.85);
    --glass-border: rgba(30, 41, 59, 0.6);
    
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.2);
    
    --dash-red-bg: linear-gradient(135deg, rgba(239, 68, 68, 0.12), transparent);
    --dash-yellow-bg: linear-gradient(135deg, rgba(217, 119, 6, 0.12), transparent);
    --dash-green-bg: linear-gradient(135deg, rgba(22, 163, 74, 0.12), transparent);
    --dash-blue-bg: linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent);
    --dash-orange-bg: linear-gradient(135deg, rgba(234, 88, 12, 0.12), transparent);
    --dash-text: #f8fafc;

    /* בכהה ה-surface כבר כהה, ולכן התיחום צריך שכבה כהה יותר (לא בהירה) כדי להיראות. */
    --cell-night-tint: rgba(0, 0, 0, 0.22);
    --fertility-window-bg: rgba(20, 184, 166, 0.15);
    --fertility-peak-bg: rgba(20, 184, 166, 0.25);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Rubik', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    padding-bottom: 16px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes popIn {
    0% { transform: scale(0.96); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes slideLeft {
    from { transform: translateX(-15px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideRight {
    from { transform: translateX(15px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes bottomSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
@keyframes pulseGlow {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

.slide-left-anim { animation: slideLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.slide-right-anim { animation: slideRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Desktop Double-Panel Layout */
.app-layout {
    display: flex;
    max-width: 1300px;
    margin: 0 auto;
    padding: 12px;
    gap: 14px;
    align-items: flex-start;
    direction: rtl;
}

/* Sidebar Styling */
.sidebar {
    width: 250px;
    flex-shrink: 0;
    position: sticky;
    top: 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 10;
}

.sidebar-brand {
    font-size: 1.25em;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.top-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.top-actions button {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: right;
}

.top-actions button:hover {
    background: var(--input-bg);
    color: var(--text-main);
}

.top-actions button.active-tab {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

/* Sidebar Integrated Controls (Calendar Navigation) */
.sidebar-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar-controls-title {
    font-size: 0.8em;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.sidebar-nav-btn {
    width: 100%;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.sidebar-nav-btn:hover {
    background: var(--input-bg);
    border-color: var(--text-muted);
}

.sidebar-nav-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.sidebar-select-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--input-bg);
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.sidebar-select-group select {
    width: 100%;
    padding: 6px;
    font-size: 0.85em;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-main);
    font-family: inherit;
    outline: none;
    cursor: pointer;
}

.sidebar-actions-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* שתי שורות נפרדות: עיצוב/הדפסה/מייל מול זום — לא עוד קבוצה שטוחה אחת
   שגולשת לשתי שורות באקראי לפי רוחב הסיידבר. */
.sidebar-actions-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    row-gap: 10px;
}

.sidebar-actions-row + .sidebar-actions-row {
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.sidebar-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sidebar-action-label {
    font-size: 0.72em;
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-action-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-action-circle:hover {
    transform: translateY(-2px);
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* מיקוד מקלדת על אלמנטים לחיצים שאינם <button>/<a> (יום בלוח, פעולה מהירה
   בסיידבר) — מוצג רק בניווט מקלדת (:focus-visible), לא בלחיצת עכבר. */
.day:focus-visible,
.yearly-day-cell:focus-visible,
.sidebar-action-circle:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* כלי ניווט הלוח והדשבורדים שייכים ללשונית "לוח שנה" בלבד — switchView() מוסיפה/
   מסירה את .calendar-view-active מה-body, וכאן זה נאכף בלי להתנגש עם ה-display
   הדינמי (JS) שכל כרטיס דשבורד מקבל בהתאם לנתונים (chazaka/life/day-state). */
body:not(.calendar-view-active) .calendar-only-panel {
    display: none !important;
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

h1 {
    font-size: 1.8em;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
    letter-spacing: -0.5px;
}

/* Compact Smart Dashboard */
.dashboard {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-right: 4px solid var(--primary);
    transition: all 0.3s;
}

.dashboard-text {
    flex: 1;
    font-size: 0.95em;
    color: var(--text-main);
    line-height: 1.4;
}

.dashboard-text strong {
    font-weight: 600;
    font-size: 1.05em;
}

/* Dashboard Cycle Progress */
.dashboard-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.progress-bar-container {
    width: 100px;
    height: 6px;
    background: var(--input-bg);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* קבוצת כרטיסי המצב (index.html): כרטיס היום הראשי נשאר בעל המשקל החזותי המלא,
   ושלושת פאנלי ההרחבה (מצב חיים / חזקה / סימוני יום) מוצגים באופן קומפקטי יותר —
   בלי לצמצם מילה מהתוכן ההלכתי עצמו, רק את "עוצמת" הכרטיס (ריפוד/צל/רווח). כך
   ערימה של עד ארבעה כרטיסים לא נקראת כארבע אזהרות נפרדות ושוות-משקל. */
.dashboard-stack .dashboard {
    margin-bottom: 8px;
}

.dashboard-stack .dashboard:last-child {
    margin-bottom: 16px;
}

.dashboard-stack #life-container,
.dashboard-stack #chazaka-container,
.dashboard-stack #day-state-container {
    padding: 10px 16px;
    font-size: 0.92em;
    box-shadow: none;
}

.dashboard.dash-red { background: var(--dash-red-bg); border-right-color: var(--red); }
.dashboard.dash-yellow { background: var(--dash-yellow-bg); border-right-color: var(--yellow); }
.dashboard.dash-green { background: var(--dash-green-bg); border-right-color: var(--green); }
.dashboard.dash-blue { background: var(--dash-blue-bg); border-right-color: var(--blue); }
.dashboard.dash-orange { background: var(--dash-orange-bg); border-right-color: var(--orange); }

/* תזכורת וסת הגוף (B2) בכרטיס היום: בלוק שני — ולכן הכרטיס נאלץ להיתפס לשורה
   נפרדת, שאחרת שני הבלוקים היו נדחסים זה לצד זה (הכרטיס הוא flex-row). */
.dashboard.dash-body {
    flex-wrap: wrap;
    align-items: flex-start;
}

.dashboard-body-reminder {
    flex-basis: 100%;
    border-top: 1px dashed var(--border-color);
    padding-top: 10px;
}

.dashboard.dash-red .progress-bar-fill { background: var(--red); }
.dashboard.dash-yellow .progress-bar-fill { background: var(--yellow); }
.dashboard.dash-green .progress-bar-fill { background: var(--green); }
.dashboard.dash-blue .progress-bar-fill { background: var(--blue); }
.dashboard.dash-orange .progress-bar-fill { background: var(--orange); }

/* Unified Mobile Controls Header (Hidden on Desktop) */
.mobile-controls-header {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.mobile-controls-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: space-between;
}

.mobile-controls-row select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9em;
    outline: none;
    font-weight: 500;
}

.mobile-controls-buttons {
    display: flex;
    gap: 6px;
}

.mobile-controls-buttons button {
    padding: 6px 12px;
    font-size: 0.85em;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    color: var(--text-main);
    cursor: pointer;
}

.mobile-controls-buttons button:hover {
    background: var(--input-bg);
}

/* Month Title */
.month-title-display {
    font-size: 1.4em;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 12px;
    text-align: right;
    letter-spacing: -0.3px;
}

/* Calendar Grid Container */
.calendar-view-container {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: var(--shadow-sm);
}

/* Grid Spacing Rules */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    user-select: none;
}

.day-header {
    text-align: center;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.8em;
    padding: 4px 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.day {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 80px;
    /* חצי עליון (עונת לילה) מגוון עדין, חצי תחתון (עונת יום) רגיל — קו חד באמצע,
       בלי לגעת ב-marker-wrapper העליון/תחתון שכבר ממוקמים לפי אותה מוסכמה. */
    background: linear-gradient(to bottom, var(--cell-night-tint) 0%, var(--cell-night-tint) 50%, transparent 50%, transparent 100%), var(--surface);
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.day:hover {
    border-color: var(--primary);
    background: var(--input-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    z-index: 2;
}

.day-dates {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    margin-bottom: 4px;
}

.day-num {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-main);
}

.day-heb {
    font-size: 0.7em;
    color: var(--text-muted);
}

.day:hover .day-num {
    color: var(--primary);
}

.note-icon {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.85em;
    opacity: 0.8;
    cursor: pointer;
    padding: 4px;
    margin: -4px;
    z-index: 1;
}

.note-icon:hover {
    opacity: 1;
}

/* Markers styling */
.marker-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.marker {
    width: 100%;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.65em;
    font-weight: 700;
    text-align: center;
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    line-height: 1.2;
}

/* צבעי הסימונים (.marker) — גוונים כהים ("700"→"800") ולא הבהירים המקוריים
   ("500"→"600"): נמדד בפועל שטקסט לבן על הגוונים הבהירים נופל ל-2.1–3.8:1
   ניגודיות (WCAG AA לטקסט קטן דורש 4.5:1) — כי גרדיאנט לבהיר מבטיח שקצה אחד
   שלו תמיד ייכשל. הגוונים כאן שומרים על אותה משפחת צבע (לזיהוי חזותי קיים) אבל
   כהים מספיק ששני קצוות הגרדיאנט עוברים ניגודיות (נמדד: 5.0–6.7:1). */
.bg-red { background: linear-gradient(135deg, #b91c1c, #991b1b); }
.bg-yellow { background: linear-gradient(135deg, #b45309, #92400e); }
.bg-green { background: linear-gradient(135deg, #047857, #065f46); }
.bg-blue { background: linear-gradient(135deg, #1d4ed8, #1e40af); }
.bg-orange { background: linear-gradient(135deg, #c2410c, #9a3412); }
/* וסת הגוף — המיחוש שתועד על הראייה (B2). */
.bg-purple { background: linear-gradient(135deg, #7e22ce, #6b21a8); }
/* חלון ביוץ ופוריות (docs/SPEC_FERTILITY_INSIGHTS.md) — טורקיז, צניעות מכוונת. */
.bg-teal { background: linear-gradient(135deg, #0d9488, #0f766e); }

/* Today date highlight */
.day-today {
    border: 2px solid var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
    z-index: 1;
    animation: pulseGlow 3s infinite;
}

/* Sections Switching */
.section-container {
    display: none;
}

.section-container.active {
    display: block;
    animation: fadeIn 0.3s ease-out forwards;
}

/* Table styling */
.table-wrapper {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: center;
    font-size: 0.9em;
}

th {
    background: var(--input-bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.8em;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: var(--input-bg);
}

/* About and credits cards */
.about-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    line-height: 1.6;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.about-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.about-card h3 {
    color: var(--primary);
    font-size: 1.15em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.about-card ul {
    padding-right: 20px;
}

.about-card li {
    margin-bottom: 6px;
    font-size: 0.9em;
}

.credit-box {
    text-align: center;
    background: var(--dash-blue-bg);
    border: 1px solid rgba(37, 99, 235, 0.15);
    padding: 20px;
    border-radius: var(--radius);
}

.credit-box p {
    margin-bottom: 8px;
}

/* --------------------------------------------------------------------
   סרגל צד קבוע לניווט — לשוניות "הגדרות" ו"אודות". אותו מנגנון בשתי
   הלשוניות (.side-nav-layout), כדי שהתחושה תהיה אחידה בכל האפליקציה.
   מתקפל לשורת "פצפוצים" אופקית ברוחב מסך צר (כמו שהיה קודם), ונשאר
   סרגל צד אמיתי, דביק (sticky), ברוחב דסקטופ.
   -------------------------------------------------------------------- */
.side-nav-layout {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.side-nav {
    flex: 0 0 200px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: sticky;
    top: 12px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.15s ease;
}

.side-nav a:hover,
.side-nav a:focus-visible {
    background: var(--input-bg);
    color: var(--text-main);
    border-color: var(--border-color);
    transform: translateX(-3px);
}

.side-nav a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.side-nav-content {
    flex: 1;
    min-width: 0;
}

/* מתחת לרוחב מסוים אין מקום לסרגל צד אמיתי — חוזר לשורת פצפוצים אופקית
   שגוללת בעצמה, בדיוק כמו ההתנהגות הקודמת. */
@media (max-width: 900px) {
    .side-nav-layout {
        flex-direction: column;
    }

    .side-nav {
        flex-direction: row;
        flex-wrap: wrap;
        position: static;
        width: 100%;
        gap: 8px;
        padding-bottom: 14px;
        margin-bottom: 14px;
        border-bottom: 1px solid var(--border-color);
    }

    .side-nav a {
        flex: 0 0 auto;
        padding: 6px 14px;
        border-radius: 20px;
        border-color: var(--border-color);
        background: var(--surface);
    }

    .side-nav a.active {
        transform: none;
    }
}

/* Settings items */
.settings-section {
    margin-bottom: 28px;
    scroll-margin-top: 12px;
}

.settings-section-title {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: start;
}

/* משתמש ברוחב הדסקטופ: כרטיסי ההגדרות הקצרים נפרסים בשתי עמודות במקום עמודה
   שטוחה אחת שגוררת גלילה ארוכה גם כשיש הרבה מקום פנוי בצדדים. */
@media (min-width: 700px) {
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .settings-group.settings-span-2 {
        grid-column: span 2;
    }
}

.settings-group {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.settings-group:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

/* מסך "מדדים ותובנות" (docs/SPEC_FERTILITY_INSIGHTS.md §4) — רשת כרטיסי KPI,
   3 טורים בדסקטופ רחב וטור יחיד במובייל (§4.5-3). */
.insights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 20px 0;
}

@media (min-width: 900px) {
    .insights-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.insight-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.insight-card .insight-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.insight-card .insight-card-value {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--text-main);
}

.insight-card .insight-card-sub {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.5;
}

/* הגרף אינו נדחס במסכים צרים אלא נגלל אופקית (§4.5-3). */
.chart-scroll-x {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 12px;
    box-shadow: var(--shadow);
    font-size: 0.85em;
    line-height: 1.6;
    color: var(--text-main);
    z-index: 20;
    display: none;
    white-space: nowrap;
}

/* כרטיסי הגדרות ארוכים/נדירים עטופים כ-<details> — "מצב חיים" (ארוך משמעותית
   משאר ההגדרות, ולכן פתוח מלכתחילה כדי שלא יוסתר תוכן פעיל) ו"מתגי חומרא"
   (מחלוקות פוסקים נדירות, סגור כברירת מחדל אלא אם מתג כלשהו כבר דלוק —
   ר' js/app.js). */
.settings-group.settings-collapsible summary {
    cursor: pointer;
    list-style: none;
}

.settings-group.settings-collapsible summary::-webkit-details-marker {
    display: none;
}

.settings-group.settings-collapsible summary h4 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.settings-group.settings-collapsible summary h4::after {
    content: '▾';
    font-size: 0.8em;
    color: var(--text-muted);
    margin-inline-start: 4px;
    transition: transform 0.15s ease;
}

.settings-group.settings-collapsible[open] summary h4::after {
    transform: rotate(180deg);
}

.settings-group h4 {
    font-size: 1em;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.settings-group p {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Inputs & buttons styles */
.text-input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95em;
    outline: none;
    transition: border 0.2s;
}

.text-input:focus {
    border-color: var(--primary);
}

.action-btn {
    display: inline-block;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    text-align: center;
}

.action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-primary { background: var(--primary); color: white; }
.btn-blue { background: var(--blue); color: white; }
/* אדום/ירוק/צהוב/כתום: לא var(--red)/(--green)/(--yellow)/(--orange) — אותם
   משתנים משמשים גם כטקסט על משטח בהיר/כהה (עמוד "אודות", כרטיסי אזהרה), ושם
   הגוון הבהיר עצמו עובד; אבל כרקע מלא מאחורי טקסט לבן הוא נכשל בניגודיות
   (נמדד: 3.2–3.8:1, נדרש 4.5:1). לכן לכפתורים גוון כהה נפרד ("700"), שנמדד
   עובר (5.0–6.5:1) בלי לגעת במשתנה המשותף ובלי סיכון רגרסיה בערכת הכהה. */
.btn-red { background: #b91c1c; color: white; }
.btn-green { background: #15803d; color: white; }
.btn-yellow { background: #b45309; color: white; }
.btn-orange { background: #c2410c; color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-clear { background: var(--input-bg); color: var(--text-main); }

/* קבוצות פעולה מתקפלות במודאל היום (index.html #modal): פעולות פחות שכיחות
   (בדיקה / מיחוש / סימוני יום) מקופלות כברירת מחדל, כדי שרוב הימים לא ידרשו
   גלילה מעבר לארבעת הכפתורים העיקריים. אין כאן מידע הלכתי שמוסתר בשקט —
   רק טופסי קלט אופציונליים, בשונה מפאנלי הדשבורד (ר' .dashboard-stack). */
.action-group {
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
    margin-top: 4px;
}

.action-group summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9em;
    font-weight: 600;
    padding-bottom: 4px;
}

.action-group summary::-webkit-details-marker {
    display: none;
}

.action-group summary::after {
    content: '▾';
    color: var(--text-muted);
    font-size: 0.8em;
    font-weight: 400;
    transition: transform 0.15s ease;
    margin-inline-start: 8px;
}

.action-group[open] summary::after {
    transform: rotate(180deg);
}

.action-group summary span {
    display: flex;
    align-items: center;
}

.action-group[open] summary {
    margin-bottom: 8px;
}

/* Custom OTP Passcode Inputs */
.pin-inputs {
    display: flex;
    gap: 8px;
    margin: 16px 0;
    direction: ltr;
    justify-content: center;
}

.pin-digit {
    width: 44px;
    height: 52px;
    font-size: 1.8em;
    text-align: center;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    font-weight: 600;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
}

.pin-digit:focus {
    border-color: var(--primary);
    background: var(--surface);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.15);
}

/* Modals overlays & screens */
#lock-screen, #setup-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

#lock-screen h2, #setup-screen h2 {
    font-size: 2em;
    margin-bottom: 8px;
    font-weight: 800;
}

#lock-screen p, #setup-screen p {
    color: var(--text-muted);
    font-size: 0.95em;
    text-align: center;
    margin-bottom: 20px;
}

.error-msg {
    color: var(--red);
    font-weight: 600;
    font-size: 0.85em;
    height: 18px;
    margin-bottom: 12px;
}

/* Dynamic Glass Modals overlay */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow);
    animation: popIn 0.2s ease-out;
    /* מודאל פעולות היום (ובכלל: כל מודאל) עלול להיות גבוה ממסך נייד/רזולוציה
       נמוכה — גלילה פנימית עדינה במקום גלישה מחוץ למסך. */
    max-height: 85vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.modal-content h3 {
    font-size: 1.25em;
    font-weight: 800;
    margin-bottom: 4px;
}

.modal-content p {
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.modal-drag-handle {
    width: 36px;
    height: 4px;
    background: var(--border-color);
    border-radius: 10px;
    margin: 0 auto 16px auto;
    display: none;
}

.note-area {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9em;
    resize: none;
    height: 70px;
    outline: none;
    margin-bottom: 10px;
}

.note-area:focus {
    border-color: var(--primary);
}

/* Toast alert messages */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
    pointer-events: none;
}

.toast {
    background: var(--text-main);
    color: var(--surface);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.85em;
    font-weight: 600;
    box-shadow: var(--shadow);
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Compact Full-Screen Yearly View Grid */
#yearly-calendar-wrapper {
    display: block;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 12px;
}

.yearly-row {
    display: grid;
    grid-template-columns: 100px 75px repeat(30, 1fr);
    min-width: 1280px;
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    border-radius: 6px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    direction: rtl;
    position: relative;
    z-index: 1;
}

.yearly-row:hover {
    z-index: 10;
}

.yearly-month-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: var(--surface-hover);
    border-left: 1px solid var(--border-color);
    padding: 6px;
    font-weight: 700;
    text-align: center;
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.yearly-month-info .m-name {
    font-size: 1.05em;
    color: var(--primary);
}

.yearly-month-info .m-status {
    font-size: 0.72em;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: normal;
}

.yearly-row-labels {
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background: var(--input-bg);
    justify-content: space-around;
    padding: 2px 0;
}

.yearly-row-labels .row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72em;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
    height: 22px;
}

.yearly-day-cell {
    position: relative;
    border-left: 1px solid var(--border-color);
    cursor: pointer;
    min-height: 52px;
}

.yearly-cell-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3px 1px;
    /* אותה הפרדה עדינה לילה/יום כמו בתצוגת החודש (.day); ריחוף עדיין דורס
       ל-var(--surface) האחיד למטה, שם הכרטיס נפתח ומוצגים בו פרטים מלאים. */
    background: linear-gradient(to bottom, var(--cell-night-tint) 0%, var(--cell-night-tint) 50%, transparent 50%, transparent 100%);
    transition: all 0.2s ease;
    z-index: 1;
}

.yearly-day-cell:hover {
    z-index: 10;
}

.yearly-day-cell:hover .yearly-cell-inner {
    top: -8px;
    left: -45px;
    right: -45px;
    bottom: -60px;
    height: max-content;
    background: var(--surface) !important;
    border: 2px solid var(--primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    padding: 8px 6px;
}

.yearly-day-cell.empty {
    background: var(--input-bg);
    cursor: default;
    border-left: 1px solid var(--border-color);
}

.yearly-day-cell.empty:hover {
    background: var(--input-bg);
}

.yearly-day-cell:last-child {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
}

.yearly-day-cell.day-today .yearly-cell-inner {
    outline: 2px solid var(--primary) !important;
    outline-offset: -2px !important;
    border-radius: 4px;
    z-index: 2;
}

.yearly-day-cell:hover.day-today .yearly-cell-inner {
    outline: none !important;
}

.yearly-day-cell .day-dates {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    width: 100%;
}

.yearly-day-cell .day-weekday {
    font-size: 0.65em;
    color: var(--text-muted);
    margin-bottom: 1px;
    text-align: center;
    white-space: nowrap;
}

.yearly-day-cell .day-num {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--text-main);
    text-align: center;
}

.yearly-day-cell .marker-wrapper {
    display: flex;
    justify-content: center;
    gap: 2px;
    min-height: 4px;
    width: 100%;
}

.yearly-day-cell .marker {
    height: 4px;
    padding: 0;
    font-size: 0;
    border-radius: 50%;
    width: 4px;
    margin: 0;
    box-shadow: none;
}

.yearly-day-cell .marker svg,
.yearly-day-cell .marker span {
    display: none;
}

.yearly-day-cell .note-icon {
    display: none;
}

/* Expansion of markers and text on hover */
.yearly-day-cell:hover .marker-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    margin: 4px 0;
}

.yearly-day-cell:hover .marker {
    height: auto;
    width: auto;
    border-radius: 4px;
    font-size: 0.72em;
    padding: 3px 6px;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.yearly-day-cell:hover .marker svg,
.yearly-day-cell:hover .marker span {
    display: inline-block !important;
}

.yearly-day-cell:hover .day-dates {
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 4px 0;
    margin: 4px 0;
}

.yearly-day-cell:hover .day-weekday {
    font-size: 0.75em;
    font-weight: bold;
    color: var(--primary);
}

.yearly-day-cell:hover .day-num {
    font-size: 1.1em;
}

.yearly-day-cell:hover .note-icon {
    display: inline-block !important;
    position: absolute;
    top: 6px;
    left: 6px;
}

/* Empty states */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 10px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    fill: var(--border-color);
}

.empty-state h4 {
    color: var(--text-main);
    font-size: 1.1em;
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.85em;
}

/* Bottom Navigation (Mobile Tab-bar) */
/* Global "software update available" mark — floats above every tab, spec:
   "מציגה באופן גלובלי בתוכנה סימון קטן... ולחיצה עליו מובילה לדף ההגדרות". */
.update-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 600;
    background: var(--primary);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.update-badge .icon {
    width: 15px;
    height: 15px;
}

.update-badge-close {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    line-height: 1;
    font-size: 0.95em;
    cursor: pointer;
    margin-inline-start: 2px;
}

/* Same shape as .update-badge, opposite corner (right instead of left) so
   the two can never overlap when both a software update and a stale-backup
   reminder are true at the same time. */
.backup-reminder-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 600;
    background: var(--orange);
    color: white;
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.backup-reminder-badge .icon {
    width: 15px;
    height: 15px;
}

.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 10px rgba(0,0,0,0.03);
    justify-content: space-around;
    padding: 8px 0;
    z-index: 500;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7em;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.nav-item span {
    font-size: 1.4em;
    margin-bottom: 2px;
}

.nav-item.active {
    color: var(--primary);
}

/* Responsive Overrides */
@media (max-width: 950px) {
}

@media (max-width: 850px) {
    .app-layout {
        flex-direction: column;
        gap: 0;
        padding: 12px;
    }
    
    .sidebar {
        display: none; /* Hide sidebar on mobile */
    }
    
    .mobile-controls-header {
        display: flex; /* Show mobile controls */
    }
    
    .bottom-nav {
        display: flex; /* Show bottom navigation */
    }
    
    body {
        padding-bottom: 80px; /* Space for bottom nav */
    }
    
    /* Modals become bottom sheets */
    .modal-overlay {
        align-items: flex-end;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 80vh;
        border-radius: 20px 20px 0 0;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        animation: bottomSheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    }
    
    .modal-drag-handle {
        display: block;
    }
}

@media (max-width: 500px) {
    .day {
        min-height: 60px;
    }
    
    .day-num {
        font-size: 0.95em;
    }
    
    .marker {
        font-size: 0.55em;
        padding: 1px 2px;
    }
    
    th, td {
        padding: 6px;
        font-size: 0.8em;
    }
}

/* Print CSS Styles */
@media print {
    @page { size: A4 portrait; margin: 1cm; }
    body { background: white !important; font-size: 10pt !important; color: black !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .app-layout { padding: 0 !important; max-width: 100% !important; }
    .sidebar, .bottom-nav, .mobile-controls-header, .modal-overlay, .toast-container { display: none !important; }
    #print-container { display: block !important; }
    .calendar { border: 1px solid #000; gap: 0; }
    .day-header { background: #f0f0f0; border-bottom: 1px solid #000; color: #000; font-weight: bold; }
    .day { border: 1px solid #000 !important; border-radius: 0 !important; min-height: 60px !important; background: #fff !important; box-shadow: none !important; transform: none !important; }
    .marker { border: 1px solid #000; color: #000 !important; background: none !important; font-size: 7pt; }
    .bg-red { background-color: #ffcccc !important; }
    .bg-yellow { background-color: #fff4cc !important; }
    .bg-green { background-color: #ccffcc !important; }
    .bg-blue { background-color: #cceeff !important; }
    .bg-orange { background-color: #ffe6cc !important; }
    .bg-purple { background-color: #f0e0ff !important; }
    .bg-teal { background-color: #ccf5ef !important; }
}

/* Modern SVG Vector Icons Sizing & Colors */
.icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2.2;
    fill: none;
    vertical-align: middle;
    display: inline-block;
    transition: transform 0.2s;
}

.text-icon {
    width: 20px;
    height: 20px;
    margin-left: 8px;
}

.top-actions button .icon {
    width: 20px;
    height: 20px;
}

.top-actions button:hover .icon {
    transform: scale(1.08);
}

.sidebar-actions-grid .sidebar-action-circle .icon {
    width: 20px;
    height: 20px;
}

.bottom-nav .nav-item .icon {
    width: 22px;
    height: 22px;
    margin-bottom: 4px;
}

/* Hide SVG and Labels in Yearly View to preserve Dot layout */
.yearly-row .marker svg,
.yearly-row .marker span {
    display: none !important;
}

/* Forgot Passcode Recovery Screen styling */
#lock-recovery-container {
    animation: fadeIn 0.3s ease-out;
}

#forgot-pin-link:hover {
    text-decoration: underline !important;
}

/* ===== Halachic help: info bubbles + guide tab ===== */

/* Small "?" bubble shown next to a value or a setting. */
.help-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    margin-inline-start: 6px;
    border-radius: 50%;
    border: 1px solid var(--primary);
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    vertical-align: middle;
    transition: background 0.15s ease, transform 0.15s ease;
}

.help-dot:hover {
    background: var(--primary);
    color: #fff;
    transform: scale(1.08);
}

/* Board legend (מקרא הסימונים): one line per marking, each with its own bubble. */
.board-legend {
    margin-top: 18px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    line-height: 1.7;
}

.board-legend > summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95em;
}

.board-legend h4 {
    font-size: 0.95em;
    margin: 16px 0 8px;
    color: var(--text-main);
}

.legend-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.legend-list li {
    font-size: 0.86em;
    margin-bottom: 6px;
    color: var(--text-muted);
}

.legend-list li b {
    color: var(--text-main);
}

/* גרסה קומפקטית: שבבים ברצף (שם + בועת "?") במקום רשימה אנכית עם פסקת הסבר
   מלאה לכל פריט — ר' ההערה ב-index.html מעל .board-legend. */
.legend-list-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
}

.legend-list-compact li {
    margin-bottom: 0;
    white-space: nowrap;
}

.link-like {
    background: none;
    border: none;
    padding: 0;
    color: var(--primary);
    font-weight: 600;
    font-family: inherit;
    font-size: inherit;
    cursor: pointer;
    text-decoration: underline;
}

.legend-note {
    font-size: 0.8em;
    color: var(--text-muted);
    margin: 14px 0 4px;
    border-top: 1px solid var(--border-color);
    padding-top: 10px;
}

/* Guide tab: one card per topic, grouped by category. */
.guide-category {
    margin-bottom: 22px;
    scroll-margin-top: 12px;
}

.guide-category > h3 {
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary);
    font-size: 1.05em;
}

.guide-topic {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
}

.guide-topic h4 {
    margin: 0 0 4px 0;
    font-size: 1em;
}

.guide-topic .guide-summary {
    color: var(--text-muted, #6b7280);
    font-size: 0.88em;
    margin-bottom: 8px;
}

.guide-topic p {
    margin: 0 0 8px 0;
    line-height: 1.65;
    font-size: 0.92em;
}

.guide-topic ul {
    margin: 0 0 8px 0;
    padding-inline-start: 20px;
    font-size: 0.9em;
    line-height: 1.6;
}

.guide-sources {
    font-size: 0.82em;
    color: var(--text-muted, #6b7280);
    border-top: 1px dashed var(--border-color);
    padding-top: 8px;
    margin-top: 6px;
}

.guide-sources b {
    color: var(--text-main);
}

.guide-intro {
    background: rgba(79, 70, 229, 0.06);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 20px;
    font-size: 0.9em;
    line-height: 1.6;
}

