:root {
    --blue: #1976d2;
    --red: #e53935;
    --border: #ddd0b8;
    --bg: #efe7d6;
    --text: #24292f;
    --muted: #a99e86;
    --beige: #faf5e9;
    --beige-head: #f0e7d2;
    --beige-other: #ece3d0;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.navbar__brand { font-weight: 700; font-size: 18px; }
.navbar__btn {
    border: 1px solid var(--blue);
    background: var(--blue);
    color: #fff;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
}
.navbar__btn:active { opacity: .85; }

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px;
}

/* 月ナビ */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.month-nav__btn {
    text-decoration: none;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
}
.month-nav__btn:active { background: #eef1f5; }
.month-nav__label {
    font-size: 20px;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

/* 設定金額 */
.amount-line {
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 14px;
    color: var(--text);
}
#remainingValue { color: var(--blue); }

/* カレンダー */
.calendar {
    background: var(--beige);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.calendar__head, .calendar__row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}
.calendar__cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.calendar__cell:nth-child(7n) { border-right: none; }

.calendar__cell--head {
    text-align: center;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 700;
    background: var(--beige-head);
}

.calendar__day {
    font: inherit;
    background: var(--beige);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 6px;
    min-height: 84px;
    cursor: pointer;
    text-align: left;
    width: 100%;
}
.calendar__day:active { background: #efe3c8; }
.calendar__day.is-other-month {
    background: var(--beige-other);
    color: var(--muted);
    cursor: default;
}
.calendar__day.is-today { outline: 2px solid var(--blue); outline-offset: -2px; }

.calendar__num { font-size: 14px; font-weight: 700; }
.calendar__val {
    margin-top: auto;
    align-self: flex-end;
    font-size: 13px;
    font-weight: 700;
    color: #2e7d32;
}

/* 曜日色 */
.dow-sun, .dow-sun .calendar__num { color: var(--red); }
.dow-sat, .dow-sat .calendar__num { color: var(--blue); }

/* モーダル */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal__panel {
    position: relative;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    width: min(90vw, 340px);
    box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.modal__title { margin: 0 0 14px; font-size: 17px; }
.modal__input {
    width: 100%;
    font-size: 20px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: right;
}
.modal__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.btn { border: none; border-radius: 6px; padding: 10px 18px; font-size: 14px; cursor: pointer; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--ghost { background: #eef1f5; color: var(--text); }
.btn--danger { background: #fff; color: var(--red); border: 1px solid var(--red); margin-right: auto; }
.btn--danger[hidden] { display: none; }

/* スマホ：カレンダーを縦長に */
@media (max-width: 640px) {
    .container { padding: 10px; }
    .month-nav__label { font-size: 18px; }
    .calendar__day { min-height: 64px; }
    .calendar__num { font-size: 13px; }
    .calendar__val { font-size: 11px; }
}
