* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, sans-serif;
    background: #fafafa;
    color: #222;
}

h1 {
    margin: 0 0 20px;
    font-size: 32px;
    line-height: 1.1;
}

.container {
    max-width: 560px;
    margin: 48px auto;
    padding: 0 20px;
}

.card {
    background: white;
    border: 1px solid #d9d9d9;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
}

.boot-card {
    text-align: center;
    color: #555;
}

label {
    display: block;
    margin-top: 16px;
    margin-bottom: 6px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
}

input,
textarea,
select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #bdbdbd;
    border-radius: 8px;
    background: #fff;
    color: #222;
    font: inherit;
}

input:focus,
textarea:focus,
select:focus {
    border-color: #176b3a;
    box-shadow: 0 0 0 3px rgb(23 107 58 / 14%);
    outline: none;
}

button {
    margin-top: 16px;
    padding: 10px 16px;
    border: 1px solid #222;
    border-radius: 8px;
    background: #222;
    color: white;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

button:disabled {
    border-color: #cfcfcf;
    background: #ececec;
    color: #888;
    cursor: not-allowed;
}

.msg {
    min-height: 1.2em;
    margin-top: 12px;
    color: #b00020;
}

.msg:not(:empty) {
    border: 1px solid #f0b8c0;
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff5f6;
    font-size: 14px;
    line-height: 1.4;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
}

.topbar-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.topbar-user {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.35;
}

.topbar-user-label {
    margin-right: 4px;
}

.topbar-email {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 12px;
}

.topbar nav a {
    color: #333;
    font-size: 14px;
    font-weight: 600;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

textarea {
    resize: vertical;
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h2 {
    margin: 0;
    font-size: 19px;
}

.dashboard-view,
.habits-view,
.habit-detail-view,
.history-view {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.page-heading h1 {
    margin: 2px 0 0;
}

.eyebrow {
    margin: 0;
    color: #68776e;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.section-intro {
    margin: 8px 0 12px;
    color: #59645d;
    line-height: 1.45;
}

.text-link {
    color: #176b3a;
    font-weight: 700;
    text-underline-offset: 3px;
}

.flash-message {
    margin: 0;
    border: 1px solid #b9dfc8;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f1fbf5;
    color: #176b3a;
    font-size: 14px;
    font-weight: 600;
}

.habit-list,
.weekly-progress-list,
.streak-list,
.habit-groups,
.history-days,
.detail-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.habit-row,
.weekly-progress-row,
.streak-row,
.history-day,
.form-card,
.detail-history {
    border: 1px solid #d9e2dc;
    border-radius: 10px;
    padding: 15px;
    background: #fcfffc;
}

.habit-row-header,
.weekly-progress-row,
.streak-row,
.history-day-header,
.habit-group-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.habit-name {
    margin: 0;
    font-weight: 750;
}

.habit-description,
.muted-text,
.history-day-status {
    margin: 4px 0 0;
    color: #59645d;
    font-size: 14px;
    line-height: 1.4;
}

.emoji-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.emoji-slot {
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 1px solid #b8c8bd;
    border-radius: 50%;
    background: #fff;
    color: #96a69b;
    font-size: 22px;
    line-height: 1;
}

.emoji-slot:hover:not(:disabled) {
    border-color: #176b3a;
    background: #eef9f1;
}

.emoji-slot.is-complete {
    border-color: #176b3a;
    background: #dff5e5;
    color: #132f1f;
}

.weekly-action {
    margin-top: 10px;
}

.weekly-progress-row.is-complete {
    border-color: #79bd8d;
    background: #f1fbf4;
}

.weekly-progress-row.is-missed {
    border-color: #e3a7a7;
    background: #fff6f6;
}

.state-label {
    border-radius: 999px;
    padding: 3px 8px;
    background: #e8efe9;
    color: #30513a;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.is-missed .state-label {
    background: #fde5e5;
    color: #8c2525;
}

.form-card {
    display: flex;
    flex-direction: column;
}

.form-card h2 {
    margin-bottom: 4px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-grid label,
.form-card > label {
    margin-top: 14px;
}

.optional {
    color: #68776e;
    font-weight: 400;
}

.check-label,
.radio-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
}

.check-label input,
.radio-label input {
    width: auto;
    margin: 0;
}

.schedule-fieldset {
    margin: 18px 0 0;
    border: 1px solid #d9e2dc;
    border-radius: 8px;
    padding: 12px;
}

.schedule-fieldset legend {
    padding: 0 5px;
    color: #435449;
    font-size: 14px;
    font-weight: 700;
}

.schedule-fieldset > div label {
    margin-top: 10px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.secondary-button {
    border-color: #9a5a31;
    background: #fff;
    color: #8a4922;
}

.secondary-button:hover:not(:disabled) {
    border-color: #8a4922;
    background: #fff4ed;
}

.text-button {
    align-self: flex-start;
    margin-top: 10px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #176b3a;
    font-size: 13px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.text-button:hover:not(:disabled) {
    background: transparent;
    color: #0e4825;
}

.habit-group-title {
    margin: 8px 0 0;
    font-size: 16px;
}

.habit-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #d9e2dc;
    border-radius: 8px;
    padding: 12px;
    color: inherit;
    text-decoration: none;
}

.habit-summary:hover {
    border-color: #79bd8d;
    background: #f4fbf5;
}

.habit-summary-name {
    font-weight: 700;
}

.history-day h2 {
    font-size: 17px;
}

.history-activities {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.history-activities .habit-row {
    padding: 12px;
    background: #fff;
}

.empty-message {
    margin: 0;
    border: 1px dashed #bcc9bf;
    border-radius: 8px;
    padding: 18px;
    color: #59645d;
    line-height: 1.45;
    text-align: center;
}

@media (max-width: 640px) {
    .container {
        margin: 20px auto;
        padding: 0 16px;
    }

    .card {
        padding: 16px;
    }

    .topbar,
    .page-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar nav {
        justify-content: flex-start;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }
}
