@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap');

:root { color-scheme: light; font-family: 'DM Sans', ui-sans-serif, system-ui, sans-serif; font-size: 16px; color: #1b2823; background: #f7f8f5; }
* { box-sizing: border-box; touch-action: manipulation; }
body { min-width: 320px; margin: 0; }
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid #b58845; outline-offset: 3px; }
[hidden] { display: none !important; }
.app-shell { max-width: 560px; min-height: 100vh; margin: 0 auto; padding: 0 24px calc(25px + env(safe-area-inset-bottom)); }
.topbar { height: 90px; display: flex; align-items: center; justify-content: space-between; }
.brand { color: #173e35; font-size: 1.35rem; font-weight: 700; letter-spacing: -.045em; }
.header-actions { display: flex; align-items: center; gap: 3px; }
.user-label { margin-right: 5px; color: #63766a; font-size: .8rem; font-weight: 700; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; background: transparent; border: 0; color: #29453a; }
.icon-button i { font-size: 1.485rem; }
.loading-view { padding: 70px 0; color: #829187; text-align: center; font-size: .9rem; }
.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; }
.lock-view { max-width: 340px; min-height: calc(100dvh - 90px); display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto; padding: 12px 0 60px; }
.code-dots { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 24px; margin-bottom: 35px; }
.code-dots span { width: 14px; height: 14px; border: 2px solid #7f9a83; border-radius: 50%; background: transparent; transition: background .12s, border-color .12s; }
.code-dots span.filled { background: #173e35; border-color: #173e35; }
.number-pad { width: min(100%, 320px); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.number-pad button { min-height: 72px; display: grid; place-items: center; color: #173e35; background: transparent; border: 0; border-radius: 24px; font-size: 2rem; font-weight: 500; line-height: 1; }
.number-pad button:hover, .number-pad button:active { background: #e9efe8; }
.number-pad button:disabled { opacity: .4; cursor: wait; }
.number-pad button i { font-size: 1.65rem; }
.unlock-error { max-width: 300px; margin: -18px 0 15px; color: #aa4b3b; font-size: .88rem; text-align: center; }
.legacy-backup { margin-top: 30px; padding: 13px 15px; background: #fff2df; border-radius: 12px; color: #6d4b27; font-size: .85rem; }
.legacy-backup p { margin: 0 0 7px; }
.legacy-backup button { padding: 5px 0; color: #7c4d20; background: none; border: 0; font-weight: 700; text-decoration: underline; }
.connection-message { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; margin: 0 0 16px; padding: 13px 15px; color: #6d4b27; background: #fff2df; border: 1px solid #edd3a9; border-radius: 12px; font-size: .88rem; line-height: 1.45; }
.connection-message button { min-height: 36px; padding: 5px 0; color: #7c4d20; background: none; border: 0; text-decoration: underline; font-weight: 700; }
.history-intro { margin-bottom: 26px; }
.history-intro h1 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-size: clamp(2.8rem, 11.2vw, 4.4rem); font-weight: 400; line-height: 1.03; letter-spacing: -.04em; }
.count-card { position: relative; margin-top: 16px; padding: 28px 28px 26px; overflow: hidden; color: #f5f7f0; background: #173e35; border-radius: 26px; box-shadow: 0 16px 30px rgba(25, 65, 53, .1); }
.count-card::before { content: ''; position: absolute; width: 215px; height: 215px; right: -105px; top: -110px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 50%; }
.count-card::after { content: ''; position: absolute; width: 165px; height: 165px; right: -86px; top: -83px; border: 1px solid rgba(255, 255, 255, .07); border-radius: 50%; }
.count-line { display: flex; align-items: baseline; gap: 12px; }
.count-line strong { font-size: clamp(5.8rem, 26vw, 8rem); font-weight: 500; line-height: .9; letter-spacing: -.095em; }
.count-line span { color: #d1e1d5; font-size: 1.2rem; }
.home-spacer { height: 0; }
.add-button { width: 100%; min-height: 66px; display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; padding: 13px 20px; color: #fff; background: #c28947; border: 0; border-radius: 18px; box-shadow: 0 9px 18px rgba(171, 115, 55, .15); font-size: 1.05rem; font-weight: 700; }
.add-button:active { transform: translateY(1px); }
.add-button:disabled { cursor: not-allowed; opacity: .55; }
.plus { width: 28px; height: 28px; display: grid; place-items: center; color: #c28947; background: #fff; border-radius: 50%; line-height: 1; }
.plus i { font-size: 1.25rem; }
.activity { margin-top: 41px; }
.section-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 17px; }
.section-header h2 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-size: 1.65rem; font-weight: 400; letter-spacing: -.02em; }
.section-header span { color: #74857a; font-size: .83rem; }
.activity-list { background: #fff; border: 1px solid #e9ece6; border-radius: 19px; overflow: hidden; }
.empty-activity { min-height: 163px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #89978d; text-align: center; }
.empty-icon { width: 34px; height: 34px; display: grid; place-items: center; margin-bottom: 10px; color: #8aa58b; background: #eff4ed; border-radius: 50%; font-size: 1.5rem; line-height: 1; }
.empty-activity p { margin: 0 0 2px; color: #53675b; font-size: .9rem; font-weight: 600; }
.empty-activity > span:last-child { font-size: .8rem; }
.drink-row { min-height: 72px; display: flex; align-items: center; gap: 13px; padding: 12px 15px; }
.drink-row + .drink-row { border-top: 1px solid #eef0eb; }
.row-icon { width: 39px; height: 39px; flex: none; display: grid; place-items: center; background: #f5f4ee; border-radius: 12px; font-size: 1.2rem; }
.row-details { min-width: 0; display: flex; flex: 1; flex-direction: column; gap: 2px; }
.row-details strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; font-weight: 600; }
.row-details span { color: #87948b; font-size: .78rem; }
.remove-button { padding: 8px 1px 8px 7px; color: #829087; background: transparent; border: 0; font-size: .78rem; }
.remove-button:hover { color: #ab5c51; }
.back-button { display: flex; align-items: center; gap: 7px; margin: 15px 0 26px; padding: 8px 0; color: #365f4d; background: none; border: 0; font-size: .9rem; font-weight: 600; }
.back-button i { font-size: 1.15rem; }
.history-session { margin-bottom: 23px; overflow: hidden; background: #fff; border: 1px solid #e9ece6; border-radius: 19px; }
.history-session-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 18px 17px 14px; border-bottom: 1px solid #eef0eb; }
.history-session-head h2 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-size: 1.27rem; font-weight: 400; }
.history-session-head span { flex: none; color: #819187; font-size: .78rem; }
.history-empty { padding: 38px 20px; color: #819187; background: #fff; border-radius: 18px; text-align: center; }
.sheet-open { overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; z-index: 10; background: rgba(14, 31, 24, .4); }
.add-sheet { position: fixed; z-index: 11; right: 0; bottom: 0; left: 0; max-width: 560px; margin: 0 auto; padding: 11px 24px calc(24px + env(safe-area-inset-bottom)); background: #fff; border-radius: 28px 28px 0 0; box-shadow: 0 -15px 50px rgba(16, 39, 28, .15); }
.sheet-handle { width: 42px; height: 5px; margin: 0 auto 22px; background: #d9ded8; border-radius: 10px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 23px; }
.sheet-header h2 { margin: 0; font-family: 'DM Serif Display', Georgia, serif; font-size: 1.95rem; font-weight: 400; letter-spacing: -.025em; }
.close-button { width: 36px; height: 36px; flex: none; display: grid; place-items: center; background: #f2f4f0; border: 0; border-radius: 50%; color: #466052; font-size: 1.2rem; line-height: 1; }
.drink-options { display: grid; gap: 10px; }
.drink-option { min-height: 72px; display: flex; align-items: center; gap: 14px; padding: 10px 16px 10px 11px; background: #f8f9f6; border: 1px solid #e9ece5; border-radius: 15px; color: #26372e; text-align: left; font-size: 1rem; font-weight: 700; }
.drink-option:hover, .drink-option:focus-visible { background: #eef5ec; border-color: #bdd0bd; }
.drink-option > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; }
.drink-option small { margin-top: 2px; color: #829187; font-size: .75rem; font-weight: 500; }
.option-icon { width: 47px; height: 47px; flex: none; display: grid; place-items: center; border-radius: 12px; font-size: 1.45rem; }
.option-icon.beer { background: #fbf0dc; }
.option-icon.wine { background: #f5e9ed; }
.option-icon.liquor { background: #f1ebe1; }
.option-plus { color: #718b76; font-size: 1.45rem; }
.sheet-note { margin: 19px 0 0; color: #91a095; font-size: .78rem; text-align: center; }
.toast { position: fixed; z-index: 20; right: 20px; bottom: calc(22px + env(safe-area-inset-bottom)); left: 20px; max-width: 400px; margin: 0 auto; padding: 12px 18px; transform: translateY(25px); opacity: 0; pointer-events: none; color: #fff; background: #263b31; border-radius: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.17); text-align: center; font-size: .85rem; transition: opacity .2s, transform .2s; }
.toast.visible { transform: translateY(0); opacity: 1; }
@media (max-width: 600px) {
  #home-view { min-height: calc(100vh - 90px - 25px); min-height: calc(100dvh - 90px - 25px - env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
  #home-view .count-card, #home-view .add-button, #home-view .activity { flex-shrink: 0; }
  .home-spacer { height: auto; flex: 1 1 0; min-height: 0; transition: flex-grow .3s ease; }
  #home-view.compact .home-spacer { flex-grow: 0; }
  .activity-list.has-drinks { max-height: 72px; overflow: hidden; }
  #home-view.compact .activity-list.has-drinks { max-height: none; overflow: visible; }
}
@media (max-width: 370px) { .app-shell { padding-right: 18px; padding-left: 18px; } .count-card { padding: 25px 22px; } .add-sheet { padding-right: 18px; padding-left: 18px; } }
@media (max-width: 400px) and (max-height: 650px) {
  .topbar { height: 70px; }
  #home-view { min-height: calc(100vh - 70px - 25px); min-height: calc(100dvh - 70px - 25px - env(safe-area-inset-bottom)); }
  .lock-view { min-height: calc(100dvh - 70px); padding: 8px 0 20px; }
  .number-pad button { min-height: 62px; }
  .count-card { padding: 20px 22px; }
  .count-line strong { font-size: 5rem; }
  .add-button { min-height: 58px; margin-top: 12px; }
  .activity { margin-top: 25px; }
}
@media (min-width: 700px) { .app-shell { padding-top: 12px; } .add-sheet { bottom: 24px; border-radius: 28px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
