/* ============================================
   Commit History Heatmap — Design System
   ============================================ */
:root {
    --bg-primary: #0D1117;
    --bg-secondary: #161B22;
    --bg-card: rgba(22, 27, 34, 0.9);
    --bg-glass: rgba(22, 27, 34, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-primary: #E6EDF3;
    --text-secondary: #8B949E;
    --text-muted: #484F58;
    --accent: #58A6FF;
    --accent-glow: rgba(88, 166, 255, 0.2);
    --green-0: #161B22;
    --green-1: #0E4429;
    --green-2: #006D32;
    --green-3: #26A641;
    --green-4: #39D353;
    --radius: 8px;
    --radius-sm: 4px;
    --radius-cell: 3px;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, sans-serif;
}

[data-theme="light"] {
    --bg-primary: #F6F8FA;
    --bg-secondary: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --text-primary: #1F2328;
    --text-secondary: #656D76;
    --text-muted: #B1BAC4;
    --green-0: #EBEDF0;
    --green-1: #9BE9A8;
    --green-2: #40C463;
    --green-3: #30A14E;
    --green-4: #216E39;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

.app {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.header {
    padding: 16px 0 12px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.header-actions {
    display: flex;
    gap: 6px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 1.5rem;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-3), var(--accent));
    border-radius: var(--radius);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 700;
}

.tagline {
    font-size: 0.66rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    color: var(--accent);
}

.icon {
    width: 18px;
    height: 18px;
}

.moon-icon {
    display: none;
}

[data-theme="light"] .sun-icon {
    display: none;
}

[data-theme="light"] .moon-icon {
    display: block;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--green-3), var(--green-4));
    color: #fff;
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.76rem;
}

.btn-text {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.76rem;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-text:hover {
    color: var(--accent);
}

.section {
    margin-bottom: 20px;
}

.section h2 {
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Input */
.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.input-header label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.input-actions {
    display: flex;
    gap: 6px;
}

textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.8rem;
    resize: vertical;
    transition: border-color var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
    color: var(--text-muted);
}

.hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.hint code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
}

.stat-card {
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    text-align: center;
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--green-3);
}

.stat-icon {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--green-4);
}

.stat-label {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Heatmap */
.heatmap-scroll {
    overflow-x: auto;
    padding-bottom: 8px;
}

.heatmap-container {
    display: flex;
    gap: 3px;
    min-width: fit-content;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-cell {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-cell);
    transition: all 0.15s ease;
    cursor: default;
}

.heatmap-cell:hover {
    transform: scale(1.4);
    outline: 1px solid var(--accent);
    z-index: 2;
}

.legend {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    justify-content: flex-end;
}

.legend-label {
    font-size: 0.62rem;
    color: var(--text-muted);
}

.legend-cell {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-cell);
}

/* Matrix */
.matrix-scroll {
    overflow-x: auto;
}

.matrix-container {
    display: grid;
    gap: 3px;
    min-width: fit-content;
}

.matrix-cell {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-cell);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.52rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.15s ease;
}

.matrix-cell:hover {
    transform: scale(1.15);
}

.matrix-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 4px;
}

/* Trend Chart */
.trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding-top: 8px;
}

.trend-bar {
    flex: 1;
    min-width: 16px;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(180deg, var(--green-4), var(--green-2));
    transition: height 0.4s ease;
    position: relative;
}

.trend-bar:hover {
    opacity: 0.9;
}

.trend-bar .bar-label {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.52rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.trend-bar .bar-count {
    position: absolute;
    top: -16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.56rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.82rem;
    opacity: 0;
    transition: all 0.35s ease;
    z-index: 100;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}