:root {
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
    --bg: #f4f6f5;
    --surface: #ffffff;
    --text: #18221f;
    --muted: #6a7470;
    --line: #dde4e1;
    --primary: #176b5b;
    --primary-soft: #e4f3ee;
    --danger: #b53d36;
    --shadow: 0 10px 30px rgba(30, 45, 40, .09);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); text-align: center; background: var(--surface); border-radius: 24px; padding: 30px; box-shadow: var(--shadow); }
.login-card img { border-radius: 24px; }
.login-card h1 { margin: 16px 0 8px; font-size: 1.45rem; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-card input { width: 100%; padding: 15px; text-align: center; font-size: 20px; letter-spacing: .18em; border: 1px solid var(--line); border-radius: 13px; margin-bottom: 12px; }
.message { padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; }
.message.error { background: #fff0ef; color: #9d302a; }
.app-shell { min-height: 100vh; padding-bottom: calc(94px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(244,246,245,.92); backdrop-filter: blur(15px); padding: calc(14px + env(safe-area-inset-top)) 18px 12px; border-bottom: 1px solid rgba(221,228,225,.75); }
.eyebrow { margin: 0 0 2px; color: var(--primary); font-size: .75rem; font-weight: 800; letter-spacing: .08em; }
.topbar h1 { margin: 0; font-size: 1.25rem; }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--surface); font-size: 26px; line-height: 1; box-shadow: 0 3px 12px rgba(30,45,40,.08); }
.menu { position: absolute; right: 16px; top: calc(70px + env(safe-area-inset-top)); width: 190px; padding: 8px; border-radius: 14px; background: var(--surface); box-shadow: 0 14px 40px rgba(20,30,28,.17); border: 1px solid var(--line); }
.menu button, .menu a { display: block; width: 100%; border: 0; background: transparent; text-align: left; padding: 12px; border-radius: 9px; color: var(--text); text-decoration: none; }
.menu button:active, .menu a:active { background: var(--bg); }
.connection-banner { position: sticky; top: calc(70px + env(safe-area-inset-top)); z-index: 15; padding: 9px 16px; text-align: center; background: #fff1d8; color: #765313; font-size: .86rem; }
.content { width: min(100%, 720px); margin: 0 auto; padding: 16px; }
.summary-row { display: flex; justify-content: space-between; align-items: end; margin: 2px 2px 18px; }
.summary-row div { display: flex; align-items: baseline; gap: 8px; }
.summary-row strong { font-size: 2rem; }
.summary-row span { color: var(--muted); }
.sync-status { font-size: .78rem; }
.category-block { margin: 0 0 20px; }
.category-title { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.category-title h2 { margin: 0; font-size: .94rem; }
.category-title span { color: var(--muted); font-size: .82rem; }
.item-list { display: grid; gap: 9px; }
.item-card { display: grid; grid-template-columns: 46px 1fr 42px; align-items: center; min-height: 70px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 4px 14px rgba(30,45,40,.045); overflow: hidden; }
.check-button { align-self: stretch; border: 0; background: transparent; display: grid; place-items: center; }
.check-circle { width: 27px; height: 27px; border: 2px solid #9aacA5; border-radius: 50%; display: grid; place-items: center; color: white; font-weight: 900; }
.check-button:active .check-circle { background: var(--primary); border-color: var(--primary); }
.item-main { min-width: 0; padding: 12px 4px; }
.item-name { font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; }
.item-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 5px; color: var(--muted); font-size: .82rem; }
.edit-button { align-self: stretch; border: 0; background: transparent; color: #7b8581; font-size: 20px; }
.empty-state { text-align: center; padding: 65px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); font-size: 1.12rem; margin: 12px 0 5px; }
.empty-state p { margin: 0; }
.empty-icon { width: 58px; height: 58px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 28px; font-weight: 900; }
.empty-state.compact { padding: 50px 20px; }
.add-button { position: fixed; z-index: 18; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: center; gap: 7px; min-width: 146px; min-height: 54px; border: 0; border-radius: 999px; background: var(--primary); color: white; font-weight: 900; font-size: 17px; box-shadow: 0 12px 28px rgba(23,107,91,.31); }
.add-button span { font-size: 24px; line-height: 0; }
.toast { position: fixed; z-index: 100; left: 50%; top: calc(84px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: calc(100% - 34px); padding: 11px 16px; background: #1f2926; color: white; border-radius: 999px; box-shadow: var(--shadow); font-size: .88rem; }
dialog { border: 0; padding: 0; color: var(--text); }
dialog::backdrop { background: rgba(15, 24, 21, .42); backdrop-filter: blur(2px); }
.sheet-dialog { width: min(100%, 650px); max-width: none; margin: auto 0 0; border-radius: 24px 24px 0 0; background: var(--surface); }
.sheet { padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet-handle { width: 44px; height: 5px; border-radius: 99px; background: #d4dcda; margin: 2px auto 12px; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; }
.sheet-header h2 { margin: 0; font-size: 1.2rem; }
.close-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--bg); font-size: 25px; }
.sheet label { display: block; margin: 17px 0 7px; font-weight: 800; font-size: .88rem; }
.sheet input, .sheet select { width: 100%; padding: 14px; border: 1px solid #cbd5d1; border-radius: 12px; background: white; font-size: 16px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.item-dates { display: grid; gap: 7px; margin-top: 18px; padding: 12px 14px; border-radius: 12px; background: var(--bg); }
.item-dates div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.item-dates span { color: var(--muted); font-size: .8rem; }
.item-dates strong { font-size: .84rem; text-align: right; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-top: 24px; }
.primary, .secondary { border: 0; border-radius: 12px; min-height: 48px; font-weight: 900; }
.primary { background: var(--primary); color: white; }
.secondary { background: #e9eeec; color: var(--text); }
.full { width: 100%; }
.danger-link { width: 100%; margin-top: 18px; border: 0; background: transparent; color: var(--danger); padding: 10px; }
.page-dialog { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; background: var(--bg); }
.dialog-page { min-height: 100%; }
.dialog-header { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 50px 1fr 70px; align-items: center; min-height: calc(62px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0; background: rgba(244,246,245,.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; text-align: center; font-size: 1.08rem; }
.back-button, .text-button { border: 0; background: transparent; }
.back-button { font-size: 38px; color: var(--primary); }
.text-button { color: var(--danger); font-size: .83rem; }
.history-root { width: min(100%, 720px); margin: 0 auto; padding: 14px 16px calc(30px + env(safe-area-inset-bottom)); }
.history-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; background: var(--surface); padding: 14px; border-bottom: 1px solid var(--line); }
.history-card:first-child { border-radius: 14px 14px 0 0; }
.history-card:last-child { border-bottom: 0; border-radius: 0 0 14px 14px; }
.history-card:only-child { border-radius: 14px; }
.history-name { font-weight: 800; }
.history-meta { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.history-dates { display: grid; gap: 2px; margin-top: 7px; color: var(--muted); font-size: .75rem; }
.restore-button { border: 1px solid var(--primary); color: var(--primary); background: white; border-radius: 10px; padding: 8px 11px; font-weight: 800; white-space: nowrap; }
.restore-button:disabled { border-color: var(--line); color: var(--muted); background: var(--bg); cursor: default; }
@media (min-width: 700px) {
    .sheet-dialog { margin: auto; border-radius: 24px; }
    .sheet { padding: 12px 26px 28px; }
}
@media (max-width: 420px) {
    .two-columns { grid-template-columns: 1fr; gap: 0; }
}
