/* Life Calendar Grid (Rating) */
.life-calendar {
    margin: 16px 0;
}

.life-calendar h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.cal-grid-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cal-months {
    display: flex;
    gap: 0;
    margin-bottom: 4px;
    font-size: 11px;
    color: var(--muted);
    padding-left: 24px;
}

.cal-month-label {
    text-align: left;
}

.cal-grid {
    display: grid;
    grid-template-rows: repeat(7, 14px);
    grid-auto-flow: column;
    grid-auto-columns: 14px;
    gap: 2px;
}

.cal-day-label {
    font-size: 10px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
    width: 20px;
    height: 14px;
}

.cal-day {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    background: var(--cal-empty);
    cursor: default;
    position: relative;
}

.cal-day.clickable {
    cursor: pointer;
}

.cal-day[data-level="1"] { background: var(--cal-l1); }
.cal-day[data-level="2"] { background: var(--cal-l2); }
.cal-day[data-level="3"] { background: var(--cal-l3); }
.cal-day[data-level="4"] { background: var(--cal-l4); }

.cal-day[title]:hover {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    z-index: 1;
}

/* Calendar legend */
.cal-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 11px;
    color: var(--muted);
}

.cal-legend-square {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Category Calendar Cards */
.cat-calendars {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.cat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.cat-card-title {
    font-weight: 600;
    margin: 0 0 10px;
    font-size: 15px;
}

/* Filter chips */
.cat-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.cat-filter-chip {
    font-size: 12px !important;
    padding: 4px 10px !important;
    border-radius: 999px !important;
    cursor: pointer;
    transition: opacity .15s ease;
}

.cat-filter-chip[data-value]:not([data-value=""]) {
    background: color-mix(in srgb, var(--chip-color, var(--primary)) 15%, transparent) !important;
    color: var(--chip-color, var(--primary)) !important;
    border: 1px solid color-mix(in srgb, var(--chip-color, var(--primary)) 30%, transparent);
}

.cat-filter-chip.active {
    opacity: 1;
    font-weight: 600;
}

.cat-filter-chip:not(.active) {
    opacity: 0.6;
}

.cat-chip-count {
    font-size: 10px;
    opacity: 0.7;
    margin-left: 2px;
}

.cat-filter-expand {
    font-size: 12px !important;
    padding: 4px 10px !important;
    border-radius: 999px !important;
    background: var(--chip) !important;
    color: var(--chip-text) !important;
    cursor: pointer;
    opacity: 0.8;
    border: 1px dashed var(--border) !important;
}

.cat-filter-expand:hover {
    opacity: 1;
}

/* Compact wrapping calendar grid */
.cat-wrap-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 12px;
}

.cat-wrap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    position: relative;
    cursor: default;
    flex-shrink: 0;
}

.cat-wrap-day.empty {
    background: var(--cal-empty);
    cursor: pointer;
}

.cat-wrap-day.filled {
    cursor: pointer;
    opacity: 0.85;
    transition: opacity .1s ease, transform .1s ease;
}

.cat-wrap-day.filled:hover {
    opacity: 1;
    transform: scale(1.4);
    z-index: 2;
}

.cat-wrap-day.dimmed {
    background: var(--cal-empty) !important;
    opacity: 0.5;
}

/* Multi-value dots */
.cat-multi-dots {
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1px;
}

.cat-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    border: 0.5px solid rgba(255,255,255,0.5);
}

/* Top list */
.cat-top-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cat-top-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 14px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

[data-theme="dark"] .cat-top-list li {
    border-color: rgba(255,255,255,0.05);
}

.cat-top-list li:last-child {
    border-bottom: none;
}

.cat-top-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.cat-top-count {
    margin-left: auto;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    background: var(--chip);
    color: var(--chip-text);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Day popover */
.cat-popover {
    position: fixed;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    z-index: 100;
    max-width: 220px;
    line-height: 1.5;
    pointer-events: auto;
}

[data-theme="dark"] .cat-popover {
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}

/* Word Cloud */
.word-cloud-container {
    margin: 16px 0;
}

.word-cloud-container h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
}

.word-cloud-canvas {
    display: block;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 10px;
}

/* Empty state */
.retro-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 15px;
}

@media (max-width: 640px) {
    .cat-calendars {
        grid-template-columns: 1fr;
    }
}
