:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #52627a;
    --line: #d7e0ec;
    --bg: #eef3f9;
    --card: #ffffff;
    --blue: #1d4ed8;
    --blue-dark: #1e3a8a;
    --ok-bg: #dcfce7;
    --ok-ink: #14532d;
    --ng-bg: #fee2e2;
    --ng-ink: #7f1d1d;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
    font-size: 18px;
    line-height: 1.5;
}

body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
body.guest { padding-bottom: 32px; }

.wrap {
    width: min(520px, 100%);
    margin: 0 auto;
    padding: 16px 16px 24px;
}

h1 {
    margin: 8px 0 12px;
    font-size: 28px;
    line-height: 1.3;
}

h2 {
    margin: 0 0 12px;
    font-size: 20px;
}

p { margin: 0 0 10px; }

.lead, .note, .hint, .muted, .who {
    color: var(--muted);
}

.note, .hint { font-size: 16px; }

.app-name {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 800;
    color: var(--blue-dark);
}

.mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-size: 16px;
}

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.who { margin: 0; font-size: 16px; }

.top-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.head-btn {
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    background: #e8eef8;
    color: var(--blue-dark);
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
    cursor: pointer;
}

.head-btn[hidden] { display: none; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    margin: 12px 0;
}

label {
    display: block;
    margin: 12px 0 6px;
    font-weight: 800;
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    font-weight: 700;
}

.check input { width: 28px; height: 28px; }

input, select, button { font: inherit; }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input:not([type]),
select {
    width: 100%;
    min-height: 56px;
    padding: 12px 14px;
    border: 2px solid #b7c5d8;
    border-radius: 12px;
    background: #fff;
    color: var(--ink);
    font-size: 20px;
}

input:focus, select:focus, button:focus-visible {
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 12px 16px;
    border: 0;
    border-radius: 12px;
    background: var(--blue);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.btn-block { width: 100%; margin-top: 16px; }
.btn-secondary { background: #e8eef8; color: var(--blue-dark); }
.btn-danger { background: #b91c1c; color: #fff; }

.linkish, .text-link {
    background: none;
    border: 0;
    color: var(--blue);
    font-weight: 800;
    text-decoration: underline;
    padding: 8px;
    cursor: pointer;
}

.banner {
    border-radius: 12px;
    padding: 12px 14px;
    margin: 12px 0;
    font-weight: 700;
}

.banner p { margin: 0; }
.banner p + p { margin-top: 6px; }
.banner-ok { background: var(--ok-bg); color: var(--ok-ink); }
.banner-error { background: var(--ng-bg); color: var(--ng-ink); }

.stepper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.stepper button {
    width: 64px;
    height: 64px;
    border: 0;
    border-radius: 12px;
    background: #e8eef8;
    color: var(--blue-dark);
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.stepper input {
    flex: 1;
    min-width: 0;
    height: 64px;
    text-align: center;
    font-size: 32px;
    font-weight: 800;
}

.my-month {
    display: block;
    margin-top: 0;
    padding: 12px 16px;
    background: #eff6ff;
    border-color: #bfdbfe;
    color: inherit;
    text-decoration: none;
}
.my-month p { margin: 0; }
.my-month-label { font-size: 16px; font-weight: 800; color: var(--muted); }
.my-month-nums {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 24px;
    font-weight: 800;
}
.my-month-nums .money { color: var(--blue-dark); }

.price { font-weight: 800; font-size: 20px; }
.preview { font-size: 18px; font-weight: 800; color: var(--blue-dark); min-height: 1.5em; }

.month-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
    align-items: center;
    margin: 8px 0 4px;
}

.month-nav .btn { min-height: 48px; margin: 0; font-size: 16px; }
.month-nav .btn:last-child { justify-self: end; }
.month-label { margin: 0; text-align: center; font-size: 22px; font-weight: 800; white-space: nowrap; }

.store {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

a.store { color: inherit; text-decoration: none; }
a.store .name { color: var(--blue); text-decoration: underline; }

.store .name {
    grid-row: 1 / span 2;
    align-self: center;
    margin: 0;
    font-weight: 800;
}

.store .qty, .store .money { margin: 0; text-align: right; }
.store .qty { font-size: 20px; font-weight: 800; }
.store .money { color: var(--blue-dark); font-weight: 800; }
.store-total { border-bottom: 0; background: #eff6ff; margin: 8px -16px -16px; padding: 14px 16px; border-radius: 0 0 16px 16px; }

.day-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.day-head .btn { min-height: 44px; margin: 0; }
.day-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 6px 0;
}
.day-line .nums { margin: 0; font-size: 22px; font-weight: 800; }
.day-line .who { margin: 0; font-weight: 800; text-align: right; }
.day-line.is-old { opacity: 0.45; }
.day-money { margin: 0; color: var(--blue-dark); font-weight: 800; text-align: right; }

.history-head, .pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.history-name { font-size: 22px; font-weight: 800; }
.history-amount { font-weight: 800; }

.badge {
    display: inline-block;
    margin: 0;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 800;
}

.badge-new { background: var(--ok-bg); color: var(--ok-ink); }
.badge-edit { background: #ffedd5; color: #9a3412; }

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--line);
    z-index: 10;
}

.tabbar a {
    flex: 1;
    text-align: center;
    padding: 14px 4px calc(14px + env(safe-area-inset-bottom));
    color: #334155;
    font-weight: 800;
    text-decoration: none;
}

.tabbar a.is-active {
    color: var(--blue);
    box-shadow: inset 0 3px 0 var(--blue);
}

.pager { margin: 8px 0 16px; }
.pager .btn { margin: 0; }

.settings-nav, .seg-tabs {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 8px;
    margin: 4px 0 8px;
}

.settings-nav a, .seg-tabs a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    border-radius: 12px;
    background: #e8eef8;
    color: var(--blue-dark);
    font-weight: 800;
    text-decoration: none;
}

.settings-nav a.is-active, .seg-tabs a.is-active {
    background: var(--blue);
    color: #fff;
}

.block-title {
    margin: 22px 0 8px;
    font-size: 22px;
}

.yen-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.yen-field input { flex: 1; min-width: 0; }
.yen-field span { font-size: 22px; font-weight: 800; }

.count { color: var(--muted); font-size: 16px; font-weight: 700; }

.add-box summary,
.off-group summary,
.list-row summary {
    cursor: pointer;
    list-style: none;
}

.add-box summary::-webkit-details-marker,
.off-group summary::-webkit-details-marker,
.list-row summary::-webkit-details-marker { display: none; }

.add-box summary {
    display: flex;
    align-items: center;
    min-height: 32px;
    color: var(--blue);
    font-weight: 800;
}

.off-group { margin: 22px 0 0; }
.off-group summary {
    padding: 8px 0;
    color: var(--muted);
    font-weight: 800;
}
.off-group summary::before { content: "▸ "; }
.off-group[open] summary::before { content: "▾ "; }

.list { padding: 0 16px; }

.list-row + .list-row { border-top: 1px solid var(--line); }

.list-row summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 0;
}

.list-row summary::after {
    content: "›";
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 24px;
    line-height: 1;
    transition: transform 0.15s;
}

.list-row[open] summary::after { transform: rotate(90deg); }

.row-name { flex: 1; min-width: 0; font-weight: 800; overflow-wrap: anywhere; }
.row-name .badge { margin-left: 4px; vertical-align: middle; }
.row-sub { display: block; color: var(--muted); font-size: 14px; font-weight: 400; }
.row-value { flex: 0 0 auto; color: var(--blue-dark); font-weight: 800; }

.list-row.is-off .row-name,
.list-row.is-off .row-value { color: var(--muted); }

.row-body { padding: 0 0 14px; }

.filter-box summary {
    cursor: pointer;
    color: var(--blue);
    font-weight: 800;
}
.filter-box label:first-of-type { margin-top: 12px; }

.filter-now {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.chip {
    padding: 4px 12px;
    border-radius: 999px;
    background: #dbeafe;
    color: var(--blue-dark);
    font-size: 16px;
    font-weight: 800;
}

.log-row { padding: 10px 0; }
.log-row + .log-row { border-top: 1px solid var(--line); }
.log-row p { margin: 0; }

.log-main {
    display: flex;
    align-items: center;
    gap: 8px;
}

.log-sub {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 15px;
}
.row-body label:first-of-type { margin-top: 0; }

fieldset {
    border: 0;
    margin: 14px 0 0;
    padding: 0;
}

legend {
    font-weight: 800;
    margin-bottom: 6px;
}

.choice {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    margin: 8px 0;
    padding: 10px 12px;
    border: 2px solid #b7c5d8;
    border-radius: 12px;
    background: #fff;
    font-weight: 800;
}

.choice input { width: 28px; height: 28px; flex: 0 0 auto; }

.install-panel { margin-top: 0; }
.install-lead { margin-bottom: 8px; font-size: 22px; font-weight: 800; color: var(--ink); }
.steps { margin: 0 0 8px; padding-left: 1.4em; }
.steps li { margin: 0 0 10px; font-size: 18px; }
.steps li::marker { font-weight: 800; color: var(--blue); }

.user-day {
    display: grid;
    grid-template-columns: 4.2em 1fr;
    gap: 8px;
    padding: 8px 0;
}
.user-day + .user-day { border-top: 1px solid var(--line); }
.user-day p { margin: 0; }
.user-day-date { font-weight: 800; }
.user-day-date span { color: var(--muted); font-size: 14px; font-weight: 400; }
.user-day-line {
    display: grid;
    grid-template-columns: 1fr auto 6em;
    gap: 8px;
    align-items: baseline;
}
.user-day-line > span:nth-child(2) { font-weight: 800; text-align: right; }
.user-day-line .row-value { text-align: right; font-size: 16px; }

.badge-admin { background: #ede9fe; color: #5b21b6; }

.log-fix { margin-top: 6px; }
.log-fix summary {
    display: inline-block;
    padding: 4px 0;
    color: var(--blue);
    font-size: 15px;
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
    list-style: none;
}
.log-fix summary::-webkit-details-marker { display: none; }
.log-fix[open] summary { margin-bottom: 4px; }
.log-fix label { margin-top: 4px; font-size: 16px; }

.delivery-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.delivery-line + .delivery-line { margin-top: 6px; }
