:root {
    --pink:        #FFB7C5;
    --pink-light:  #FFE0E9;
    --mint:        #B5EAD7;
    --lavender:    #C7CEEA;
    --peach:       #FFDAC1;
    --bg:          #FFF5F8;
    --text:        #5C4B6B;
    --text-light:  #9B8AAB;
    --white:       #FFFFFF;
    --danger:      #c0392b;
    --shadow:      0 4px 12px rgba(200, 150, 180, 0.18);
    --radius:      16px;
}

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

body {
    font-family: 'Nunito', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ── Nav ── */
header {
    background: var(--white);
    box-shadow: var(--shadow);
    padding: 0 1.5rem;
}

nav {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 64px;
}

.logo { font-size: 1.3rem; font-weight: 800; }

.nav-links { display: flex; gap: 1.5rem; }

.nav-links a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

/* ── Main layout ── */
main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ── Page header ── */
.page-header { text-align: center; margin-bottom: 2rem; }
.page-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.4rem; }
.date { color: var(--text-light); }
.progress-summary { margin-top: 0.6rem; font-size: 1.1rem; font-weight: 700; }

/* ── Filter bar ── */
.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.filter-group {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.filter-chip {
    padding: 0.35rem 0.9rem;
    border: 2px solid var(--pink-light);
    border-radius: 50px;
    background: var(--white);
    color: var(--text-light);
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--pink); color: var(--text); }
.filter-chip.active { background: var(--pink); border-color: var(--pink); color: var(--text); }

/* ── Section progress bar ── */
.section-progress-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}
.section-progress-bar {
    flex: 1;
    height: 7px;
    background: var(--pink-light);
    border-radius: 4px;
    overflow: hidden;
}
.section-progress-fill {
    height: 100%;
    background: #4caf7d;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.section-progress-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light);
    white-space: nowrap;
}

/* ── Progress grid ── */
.progress-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 0.4rem;
}
.progress-cell {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: var(--pink-light);
}
.progress-cell.filled {
    background: #4caf7d;
}

/* ── Points ── */
.points-badge {
    display: inline-block;
    background: var(--lavender);
    border-radius: 50px;
    padding: 0.35rem 1rem;
    font-weight: 800;
    font-size: 1.05rem;
    margin-top: 0.6rem;
}
.points-earned {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
    background: var(--lavender);
    border-radius: var(--radius);
    padding: 0.5rem 1.25rem;
    display: inline-block;
    margin: 0.5rem 0;
}

/* ── Sections ── */
.habit-section { margin-bottom: 2rem; }
.habit-section h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

/* ── Habit cards ── */
.habit-list { list-style: none; display: flex; flex-direction: column; gap: 0.7rem; }

.habit-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.15s;
    position: relative;
}
.habit-card:hover { transform: translateY(-2px); }
.habit-card-link {
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
}
button.habit-card-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    width: 100%;
}
.habit-card.has-details-btn { padding-left: 3rem; }
.habit-details-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--white);
    box-shadow: var(--shadow);
    text-decoration: none;
    font-size: 0.95rem;
}
.habit-card .btn,
.habit-card form:not(.habit-card-link),
.habit-card .checkmark { position: relative; z-index: 1; }
.habit-card.completed { background: var(--mint); opacity: 0.85; }

.habit-info { display: flex; flex-direction: column; gap: 0.15rem; }
.habit-name { font-weight: 700; font-size: 1.05rem; }
.habit-card.completed .habit-name { text-decoration: line-through; }
.habit-desc { color: var(--text-light); font-size: 0.88rem; }
.habit-freq { color: var(--text-light); font-size: 0.8rem; font-style: italic; }

.habit-actions { display: flex; gap: 0.5rem; align-items: center; }

.checkmark { font-size: 1.4rem; color: #4caf7d; }

/* ── Buttons ── */
.btn {
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 50px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.12); }

.btn-complete  { background: var(--pink);     color: var(--text); }
.btn-primary   { background: var(--pink);     color: var(--text); }
.btn-secondary { background: var(--lavender); color: var(--text); }
.btn-qr        { background: var(--peach);    color: var(--text); }
.btn-danger    { background: #ffb3b3;         color: #8b0000; }
.btn-undo      { background: #e8e0f0;         color: var(--text-light); }
.btn-sm        { padding: 0.35rem 0.8rem; font-size: 0.85rem; }

/* ── Habits management page ── */
.habits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.habits-header h1 { font-size: 1.8rem; font-weight: 800; }

/* ── Forms ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    max-width: 500px;
    margin: 0 auto;
}
.card h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1.25rem; }
label { display: block; font-weight: 700; margin-bottom: 0.4rem; font-size: 0.95rem; }

input[type="text"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--pink-light);
    border-radius: var(--radius);
    font-family: 'Nunito', sans-serif;
    font-size: 1rem;
    color: var(--text);
    background: var(--white);
    transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--pink);
}
textarea { resize: vertical; min-height: 80px; }

.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

/* ── QR page ── */
.qr-container {
    text-align: center;
    padding: 1rem;
}
.qr-container h1 { font-size: 1.6rem; font-weight: 800; margin-bottom: 0.5rem; }
.qr-container img {
    max-width: 260px;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1.5rem auto;
    display: block;
}

/* ── Completion form ── */
.complete-form { max-width: 480px; }
.complete-habit-name {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
    font-weight: 700;
    margin-bottom: 0.4rem;
}
.complete-form h1 { font-size: 1.6rem; }

.photo-upload-label {
    display: block;
    background: var(--pink-light);
    border: 2px dashed var(--pink);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
    transition: background 0.2s;
}
.photo-upload-label:hover { background: var(--pink); }
.photo-upload-label input[type="file"] { display: none; }

.photo-preview {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-top: 0.75rem;
}

/* ── Complete / QR scan result ── */
.complete-container {
    text-align: center;
    padding: 3rem 1rem;
}
.complete-container .big-emoji { font-size: 4rem; margin-bottom: 1rem; }
.complete-container h1 { font-size: 2rem; font-weight: 800; margin-bottom: 0.5rem; }
.complete-container p { color: var(--text-light); font-size: 1.1rem; margin-bottom: 0.5rem; }
.complete-container .btn { margin-top: 1.5rem; }

.completion-note {
    background: var(--pink-light);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 1rem auto;
    max-width: 400px;
    font-style: italic;
    color: var(--text);
}
.completion-photo {
    display: block;
    max-width: 320px;
    width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 1rem auto;
    object-fit: cover;
}

/* ── History page ── */
.history-day {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
}
.history-day-header {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}
.history-empty { color: var(--text-light); font-style: italic; font-size: 0.9rem; }
.history-habits { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.history-entry { margin-bottom: 0.75rem; }
.history-entry:last-child { margin-bottom: 0; }

.history-tag {
    background: var(--mint);
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-size: 0.88rem;
    font-weight: 600;
    display: inline-block;
}
.history-note {
    color: var(--text-light);
    font-size: 0.9rem;
    font-style: italic;
    margin: 0.3rem 0 0.4rem 0.25rem;
}
.history-thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: block;
    margin-top: 0.4rem;
    transition: transform 0.15s;
}
.history-thumb:hover { transform: scale(1.05); }

/* ── Mobile ── */
@media (max-width: 500px) {
    .page-header h1 { font-size: 1.6rem; }
    .habit-card { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .habit-actions { width: 100%; justify-content: flex-end; }
}
