:root {
    --panel-bg: var(--bg-default);
    --panel-border: var(--border-default);
    --text-muted: var(--fg-muted);
    --accent: var(--success-emphasis);
    --dashboard-max-width: 1280px;
    --dashboard-sidebar-width: 300px;
}

.dashboard {
    width: 100%;
    max-width: var(--dashboard-max-width);
}

.dashboard-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dashboard-header h1 {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--fg-default);
}

.dashboard-subtitle {
    margin: 0;
    color: var(--text-muted);
}

.year-picker {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.year-picker-value {
    font-size: 1.25rem;
    font-weight: 600;
    min-width: 3.5rem;
    text-align: center;
    color: var(--fg-default);
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-fg);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.record-work-action {
    margin-bottom: 1.5rem;
}

.btn-record-work {
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--dashboard-sidebar-width);
    gap: 1.5rem;
    align-items: start;
}

.dashboard-primary {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.dashboard-primary .record-work-action {
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.heatmap-section,
.paintings-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 1.25rem;
}

.heatmap-section h2,
.paintings-panel h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg-default);
}

.paintings-panel-top {
    margin-bottom: 0.75rem;
}

.paintings-panel-top h2 {
    margin: 0 0 0.5rem;
}

.paintings-panel-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.35rem;
}

.paintings-action-btn {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    font-size: 0.75rem;
    padding: 0.3rem 0.4rem;
    text-align: center;
}

.paintings-panel-full {
    max-width: none;
}

.paintings-full-section {
    margin-top: 0;
}

.sidebar-panel {
    min-width: 0;
}

.section-hint {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Contribution grid (GitHub-style) */
.contribution-grid-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    padding-top: 3.5rem;
    margin-top: -3.5rem;
}

.contribution-grid {
    display: grid;
    grid-template-areas:
        "corner months"
        "labels weeks";
    grid-template-columns: auto 1fr;
    column-gap: 0.35rem;
    row-gap: 0.25rem;
}

.grid-corner {
    grid-area: corner;
    width: 1.75rem;
}

.grid-months-row {
    grid-area: months;
    display: flex;
    gap: 3px;
    align-items: flex-end;
    min-height: 14px;
    padding-bottom: 2px;
}

.grid-month-cell {
    width: 12px;
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.grid-month-label {
    position: absolute;
    left: 0;
    bottom: 0;
    font-size: 0.65rem;
    line-height: 1;
    color: var(--text-muted);
    white-space: nowrap;
    pointer-events: none;
}

.grid-labels {
    grid-area: labels;
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-right: 0;
}

.grid-day-label {
    height: 12px;
    font-size: 0.65rem;
    line-height: 12px;
    color: var(--text-muted);
    text-align: right;
    padding-right: 0.25rem;
}

.grid-weeks {
    grid-area: weeks;
    display: flex;
    gap: 3px;
    overflow: visible;
}

.grid-week-column {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.grid-cell {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: none;
    padding: 0;
    display: block;
    flex-shrink: 0;
}

button.grid-cell {
    position: relative;
    cursor: pointer;
    transition: transform 0.1s ease, outline 0.1s ease;
}

button.grid-cell:hover {
    transform: scale(1.15);
    outline: 1px solid var(--border-default);
    z-index: 2;
}

.grid-cell-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    padding: 0.45rem 0.65rem;
    background: var(--tooltip-bg);
    color: var(--tooltip-fg);
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease, visibility 0.12s ease;
    box-shadow: var(--shadow-overlay);
    z-index: 20;
}

.grid-cell-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--tooltip-bg);
}

.grid-cell-tooltip-date {
    font-weight: 500;
}

.grid-cell-tooltip-hours {
    color: var(--tooltip-accent);
    font-weight: 600;
}

button.grid-cell:hover .grid-cell-tooltip,
button.grid-cell:focus-visible .grid-cell-tooltip {
    opacity: 1;
    visibility: visible;
}

.grid-cell-empty {
    background: transparent;
    pointer-events: none;
}

.grid-cell-level-0 { background-color: var(--grid-empty); }
.grid-cell-level-1 { background-color: var(--grid-level-1); }
.grid-cell-level-2 { background-color: var(--grid-level-2); }
.grid-cell-level-3 { background-color: var(--grid-level-3); }
.grid-cell-level-4 { background-color: var(--grid-level-4); }

.grid-legend {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-cell {
    pointer-events: none;
}

.legend-label {
    margin: 0 0.25rem;
}

/* Paintings panel */
.paintings-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.painting-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--panel-border);
    cursor: pointer;
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    transition: background 0.15s ease;
}

.painting-item:hover {
    background: var(--item-hover-bg);
}

.painting-item-selected {
    background: var(--item-selected-bg);
}

.painting-item-selected:hover {
    background: var(--item-selected-bg);
}

.painting-item:last-child {
    border-bottom: none;
}

.painting-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--fg-default);
}

.painting-meta {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.painting-hours {
    color: var(--accent-fg);
    font-weight: 600;
}

.painting-status {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.painting-status-active {
    background: var(--status-active-bg);
    color: var(--status-active-fg);
}

.painting-status-done {
    background: var(--status-done-bg);
    color: var(--status-done-fg);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 1040;
}

.modal-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-default);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    box-shadow: var(--shadow-overlay);
    width: min(440px, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    z-index: 1050;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    background: var(--bg-muted);
    border-radius: 6px 6px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg-default);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

.modal-close:hover {
    color: var(--fg-default);
}

.modal-body {
    padding: 1.25rem;
}

.modal-section + .modal-section {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--panel-border);
}

.modal-section h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--fg-default);
}

.log-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.log-list li {
    display: flex;
    justify-content: space-between;
    padding: 0.35rem 0;
    font-size: 0.9rem;
}

.log-painting {
    color: var(--fg-default);
}

.log-hours {
    color: var(--accent-fg);
    font-weight: 600;
}

.log-total {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--fg-default);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.modal-panel-wide {
    width: min(520px, calc(100vw - 2rem));
}

.modal-backdrop-nested {
    z-index: 1060;
}

.modal-panel-nested {
    z-index: 1070;
}

.painting-name-edit {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.painting-name-edit .form-control {
    flex: 1;
}

.painting-detail-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.painting-detail-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.painting-detail-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-fg);
}

.painting-detail-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.painting-detail-end-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.painting-workdays h3 {
    margin-bottom: 0.75rem;
}

.workday-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.workday-item {
    display: grid;
    grid-template-columns: 7.5rem 1fr auto;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0;
    font-size: 0.875rem;
}

.workday-date {
    color: var(--fg-default);
    white-space: nowrap;
}

.workday-bar-track {
    height: 10px;
    background: var(--grid-empty);
    border-radius: 4px;
    overflow: hidden;
}

.workday-bar-fill {
    height: 100%;
    min-width: 4px;
    background: linear-gradient(90deg, var(--grid-level-2), var(--grid-level-4));
    border-radius: 4px;
    transition: width 0.2s ease;
}

.workday-hours {
    color: var(--accent-fg);
    font-weight: 600;
    min-width: 3rem;
    text-align: right;
}

.painting-detail-actions {
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--panel-border);
}

.complete-hint {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.day-painting-item {
    grid-template-columns: minmax(5rem, 1.25fr) 1.5fr auto;
}

.day-painting-name {
    color: var(--fg-default);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.day-log-add-action {
    margin-top: 0.5rem;
}

.day-log-add-action .btn {
    width: 100%;
}

.validation-message {
    color: var(--danger-fg);
    font-size: 0.875rem;
    margin: 0.75rem 0 0;
}
