/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0f1117;
    --surface:   #1a1f2e;
    --surface2:  #242938;
    --border:    #2e3347;
    --text:      #e2e8f0;
    --text-muted:#8892a4;
    --accent:    #4f46e5;
    --accent-h:  #6366f1;
    --danger:    #ef4444;
    --radius:    8px;
    --shadow:    0 2px 8px rgba(0,0,0,.35);
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: none;
    border-radius: var(--radius);
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger    { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: .25rem .4rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── Habit card ───────────────────────────────────────────── */
.habit-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.habit-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: .75rem;
}

.habit-name {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.habit-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── 30-day grid ──────────────────────────────────────────── */
.grid-scroll {
    overflow-x: auto;
    padding-bottom: .25rem;
}

.day-grid {
    display: grid;
    grid-template-columns: repeat(30, 1fr);
    gap: 4px;
    min-width: 480px;
}

.day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.day-label {
    font-size: .55rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1;
    white-space: nowrap;
}

.day-check {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    border: 2px solid var(--border);
    background: var(--surface2);
    cursor: pointer;
    transition: background .12s, border-color .12s, transform .1s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    color: #fff;
    user-select: none;
}

.day-check:hover {
    border-color: var(--accent);
    transform: scale(1.1);
}

.day-check.done {
    border-color: transparent;
    color: #fff;
}

.day-check.today {
    box-shadow: 0 0 0 2px var(--accent);
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
}
.empty-state h2 { font-size: 1.25rem; margin-bottom: .5rem; color: var(--text); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}
.modal-overlay.hidden { display: none; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) * 1.5);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.modal h2 { margin-bottom: 1.25rem; font-size: 1.2rem; }

.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field label { font-size: .8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.field input[type="text"] {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: .55rem .75rem;
    font-size: .95rem;
    outline: none;
    transition: border-color .15s;
}
.field input[type="text"]:focus { border-color: var(--accent); }
.field input[type="color"] {
    width: 48px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    cursor: pointer;
    padding: 2px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .65rem 1rem;
    font-size: .875rem;
    box-shadow: var(--shadow);
    z-index: 200;
    animation: slide-in .2s ease;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

@keyframes slide-in {
    from { transform: translateY(1rem); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 500px) {
    .app-header h1 { font-size: 1.3rem; }
    .habit-card     { padding: 1rem; }
}
