:root{
  --bg:#FFF8F0; --ink:#4A2E1C; --muted:#86644C; --line:#EFE3D5; --soft:#F6EADF; --honey:#F2B66B;
  --green:#2F7A4E; --green-soft:#E3F2E1; --red:#B3261E; --red-soft:#FDECE8; --amber:#9A4610; --amber-soft:#FFF1E4;
  --blue:#2E5F8F; --blue-soft:#E6F0F8; --card:#FFFFFF; --shadow:0 6px 18px rgba(74,46,28,.12); --r:20px;
  --nav-h:74px;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:'Noto Sans SC',system-ui,-apple-system,'Segoe UI',sans-serif;-webkit-tap-highlight-color:transparent}
body{min-height:100vh}
a{color:var(--ink)}
button,input,select,textarea{font-family:inherit;color:var(--ink)}
button{cursor:pointer}
.num{font-family:'Baloo 2',system-ui,sans-serif;font-weight:800}
#app{max-width:560px;margin:0 auto;min-height:100vh;position:relative;padding-bottom:calc(var(--nav-h) + 20px + env(safe-area-inset-bottom))}
#app.noTabs{padding-bottom:24px}
.page{padding:16px;display:flex;flex-direction:column;gap:12px}
.head{display:flex;align-items:center;gap:12px;padding:16px 16px 6px}
.head h1{font-size:24px;margin:0;line-height:1.2;font-weight:900}
.head .sub{font-size:12px;color:var(--muted)}
.grow{flex:1;min-width:0}
.row{display:flex;align-items:center;gap:8px}
.col{display:flex;flex-direction:column;gap:6px}
.wrap{flex-wrap:wrap}
.muted{color:var(--muted)}
.small{font-size:12px}
.tiny{font-size:11px}
.card{background:var(--card);border-radius:var(--r);padding:12px 14px;box-shadow:var(--shadow)}
.btn{height:44px;border:0;border-radius:14px;padding:0 16px;font-weight:800;font-size:14px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;gap:6px;text-decoration:none;white-space:nowrap}
.btn.dark{background:var(--ink);color:#fff}
.btn.honey{background:var(--honey)}
.btn.white{background:#fff;box-shadow:var(--shadow)}
.btn.green{background:var(--green);color:#fff}
.btn.red{background:var(--red-soft);color:var(--red)}
.btn.big{height:58px;border-radius:999px;font-size:17px;width:100%}
.btn:disabled{opacity:.5;cursor:default}
.iconbtn{width:44px;height:44px;border-radius:14px;border:0;background:#fff;box-shadow:0 4px 12px rgba(74,46,28,.14);display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;text-decoration:none}
.chip{height:38px;border:0;border-radius:999px;padding:0 14px;background:#fff;font-weight:800;font-size:13px;white-space:nowrap;box-shadow:0 2px 6px rgba(74,46,28,.08)}
.chip.on{background:var(--ink);color:#fff}
.chips{display:flex;gap:6px;overflow-x:auto;padding:2px 2px 6px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.seg{display:grid;gap:4px;background:var(--soft);border-radius:14px;padding:4px}
.seg button{height:38px;border:0;border-radius:10px;background:transparent;font-weight:800;font-size:14px}
.seg button.on{background:var(--ink);color:#fff}
.field{display:flex;flex-direction:column;gap:4px;font-size:12px;font-weight:800;color:var(--muted)}
.input{height:46px;border:2px solid var(--line);border-radius:14px;padding:0 12px;font-size:15px;background:#fff;width:100%;outline:none}
.input:focus{border-color:var(--honey)}
.input.big{height:54px;font-size:24px;font-family:'Baloo 2',sans-serif;font-weight:800}
.autobox{min-height:48px;border-radius:14px;background:var(--green-soft);padding:6px 12px;display:flex;align-items:center;gap:10px}
.tag{font-size:10px;font-weight:900;border-radius:6px;padding:1px 6px;white-space:nowrap}
.t-fridge{background:var(--green-soft);color:var(--green)}
.t-freezer{background:var(--blue-soft);color:var(--blue)}
.t-pantry{background:var(--soft);color:var(--muted)}
.pill{font-size:11px;font-weight:800;border-radius:999px;padding:2px 8px}
/* bottom nav */
#tabs{position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:100%;max-width:560px;height:calc(var(--nav-h) + env(safe-area-inset-bottom));padding-bottom:env(safe-area-inset-bottom);background:#fff;border-radius:22px 22px 0 0;box-shadow:0 -6px 18px rgba(74,46,28,.10);display:flex;justify-content:space-around;align-items:center;z-index:20}
#tabs a{text-decoration:none;display:flex;flex-direction:column;align-items:center;gap:2px;font-size:11px;font-weight:700;color:#9C8270;min-width:56px}
#tabs a.on{color:var(--ink);font-weight:900}
#tabs a .dot{width:5px;height:5px;border-radius:999px;background:transparent}
#tabs a.on .dot{background:var(--honey)}
#tabs a.plus{margin-top:-24px;color:var(--ink);font-weight:800}
#tabs a.plus .big{width:56px;height:56px;border-radius:18px;background:var(--honey);display:flex;align-items:center;justify-content:center;box-shadow:0 6px 14px rgba(74,46,28,.25);border:3px solid #fff}
#tabs a.plus.on .big{background:var(--ink)}
#tabs a.plus.on .big svg{stroke:#fff}
/* scene */
.scene{position:relative;width:100%;aspect-ratio:780/1365;background:#F3E2D0 center/cover no-repeat;overflow:hidden}
.scene .spot{position:absolute;display:block;border-radius:12px}
.scene .spot:focus-visible{outline:3px solid var(--honey)}
.scene .lab{position:absolute;background:rgba(74,46,28,.86);color:#fff;font-size:11px;font-weight:800;padding:2px 8px;border-radius:999px;pointer-events:none;white-space:nowrap}
.scene .lab.light{background:rgba(255,255,255,.94);color:var(--ink);font-weight:900}
.badge{position:absolute;min-width:22px;height:22px;border-radius:999px;color:#fff;font-weight:900;font-size:12px;display:flex;align-items:center;justify-content:center;border:2px solid #fff;padding:0 4px;pointer-events:none}
.hud{position:absolute;left:10px;right:10px;top:10px;display:flex;align-items:center;gap:8px;background:rgba(255,248,240,.94);border-radius:20px;padding:8px 10px;box-shadow:var(--shadow)}
.xpbar{height:10px;border-radius:999px;background:#EADBC9;overflow:hidden}
.xpbar>i{display:block;height:100%;background:#6FBF86;border-radius:999px}
.bubble{position:absolute;background:#fff;border-radius:16px;padding:7px 11px;font-size:12px;font-weight:700;line-height:1.4;text-decoration:none;box-shadow:var(--shadow);max-width:48%}
.panel{position:relative;margin-top:-170px;background:var(--bg);border-radius:24px 24px 0 0;box-shadow:0 -8px 24px rgba(74,46,28,.14);padding:12px 14px;display:flex;flex-direction:column;gap:6px}
.band{position:relative;height:190px;overflow:hidden;background:#FBEBDD}
.band img{position:absolute;left:0;top:0;width:100%;height:100%;object-fit:cover}
.band:after{content:'';position:absolute;left:0;right:0;bottom:0;height:64px;background:linear-gradient(180deg,rgba(255,248,240,0),var(--bg))}
.band .tl{position:absolute;left:12px;top:12px;z-index:2}
.band .tr{position:absolute;right:12px;top:12px;z-index:2}
.band .title{position:absolute;left:16px;bottom:8px;z-index:2}
.band .title b{font-size:24px;display:block;line-height:1.2}
/* backpack */
.shelf .grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}
.slot{position:relative;height:60px;border-radius:14px;background:#fff;border:2.5px solid #CFE5D5;box-shadow:0 3px 0 #E8DCCF;display:flex;align-items:center;justify-content:center;padding:0;overflow:visible}
.slot img{width:46px;height:46px;object-fit:contain;mix-blend-mode:multiply}
.slot .ini{width:34px;height:34px;border-radius:999px;display:flex;align-items:center;justify-content:center;font-weight:900;font-size:15px;color:var(--ink)}
.slot .cnt{position:absolute;right:2px;bottom:1px;font-family:'Baloo 2',sans-serif;font-weight:800;font-size:11px;background:rgba(255,255,255,.92);border-radius:6px;padding:0 3px;line-height:15px;max-width:94%;overflow:hidden;white-space:nowrap}
.slot .alert{position:absolute;left:-6px;top:-6px;width:18px;height:18px;border-radius:999px;background:var(--red);color:#fff;font-size:11px;font-weight:900;display:flex;align-items:center;justify-content:center;border:2px solid #fff}
.slot.warn{border-color:#E8A33A;background:#FFF4E4;box-shadow:0 3px 0 #EBCB9C}
.slot.bad{border-color:#D9443A;background:#FDECE8;box-shadow:0 3px 0 #E7B0A8}
.slot.sel{border-color:var(--ink);box-shadow:0 0 0 3px var(--honey)}
.slot.empty{border-style:dashed;border-color:#E3D3C2;background:transparent;box-shadow:none;color:#C9B29C;font-size:22px;font-weight:800;text-decoration:none}
.detail{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--nav-h) + 10px + env(safe-area-inset-bottom));width:calc(100% - 28px);max-width:532px;background:#fff;border-radius:20px;padding:8px 10px;display:flex;align-items:center;gap:10px;box-shadow:0 10px 30px rgba(74,46,28,.22);z-index:15}
.thumb{width:48px;height:48px;border-radius:14px;display:flex;align-items:center;justify-content:center;overflow:hidden;flex-shrink:0;background:#fff;border:2px solid var(--line)}
.thumb img{width:42px;height:42px;object-fit:contain;mix-blend-mode:multiply}
/* lists */
.item{background:#fff;border-radius:14px;padding:6px 8px;display:flex;align-items:center;gap:10px;min-height:52px;box-shadow:0 2px 6px rgba(74,46,28,.06)}
.check{width:26px;height:26px;border-radius:8px;border:2px solid #C9B29C;background:#fff;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.check.on{background:var(--green);border-color:var(--green)}
.ev{display:flex;align-items:center;gap:10px;background:#fff;border-radius:14px;padding:8px 12px;box-shadow:0 2px 6px rgba(74,46,28,.06)}
.qty{display:flex;align-items:center;gap:8px}
.qty .v{flex:1;text-align:center;font-family:'Baloo 2',sans-serif;font-weight:800;font-size:32px}
.qty button{width:56px;height:56px;border:0;border-radius:16px;font-size:26px;font-weight:800;background:var(--soft)}
.qty button.plus{background:var(--honey)}
.mini{display:flex;align-items:center;gap:4px}
.mini button{width:40px;height:40px;border:0;border-radius:12px;background:var(--soft);font-size:20px;font-weight:800}
.mini button.plus{background:var(--honey)}
.mini .v{min-width:50px;text-align:center;font-family:'Baloo 2',sans-serif;font-weight:800;font-size:16px;white-space:nowrap}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.food{text-decoration:none;background:#fff;border-radius:20px;padding:10px;display:flex;flex-direction:column;gap:4px;box-shadow:var(--shadow);border:0;text-align:left}
.food .pic{height:80px;display:flex;align-items:center;justify-content:center}
.food .pic img{max-width:100%;max-height:80px;object-fit:contain;mix-blend-mode:multiply}
.food .pic .ini{width:58px;height:58px;font-size:24px}
.ini{border-radius:999px;display:flex;align-items:center;justify-content:center;font-weight:900}
.cal{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:3px;text-align:center}
.cal .d{height:44px;border:0;background:transparent;border-radius:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-family:'Baloo 2',sans-serif;font-weight:700;font-size:15px}
.cal .d.today{background:var(--ink);color:#fff}
.cal .d.plan{box-shadow:0 0 0 2px var(--honey) inset;color:var(--amber)}
.cal .d.sel{outline:2px solid var(--ink)}
.cal .dots{display:flex;gap:2px;height:6px}
.cal .dots i{width:6px;height:6px;border-radius:999px;display:block}
.trophy{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;background:#E9D3B5;border:5px solid #C99B6D;border-radius:18px;padding:10px}
.medal{display:flex;flex-direction:column;align-items:center;gap:4px;text-align:center;border:0;background:transparent;padding:4px 0}
.medal .m{width:54px;height:54px;border-radius:999px;display:flex;align-items:center;justify-content:center;font-family:'Baloo 2',sans-serif;font-weight:800;font-size:16px;border:3px solid #fff;background:var(--honey)}
.medal.no .m{background:#D6BB98;border-color:#C99B6D;color:#9C7F5E}
.medal span{font-size:10px;font-weight:800;line-height:1.2}
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--nav-h) + 80px);background:var(--ink);color:#fff;border-radius:999px;padding:10px 18px;font-weight:800;font-size:14px;z-index:50;box-shadow:var(--shadow);max-width:90%;text-align:center}
.modal{position:fixed;inset:0;background:rgba(43,26,15,.55);display:flex;align-items:flex-end;justify-content:center;z-index:40}
.sheet{background:var(--bg);width:100%;max-width:560px;border-radius:26px 26px 0 0;padding:16px 16px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px;max-height:90vh;overflow:auto}
.center-modal{align-items:center}
.center-modal .sheet{border-radius:28px;width:calc(100% - 40px);max-width:360px;align-items:center;text-align:center}
.spin{width:22px;height:22px;border:3px solid var(--line);border-top-color:var(--ink);border-radius:999px;animation:sp 1s linear infinite}
@keyframes sp{to{transform:rotate(360deg)}}
@keyframes pulse{0%,100%{transform:scale(1)}50%{transform:scale(1.15)}}
@keyframes bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)}}
.pulse{animation:pulse 1.2s ease-in-out infinite}
.bob{animation:bob 2.4s ease-in-out infinite}
@media (prefers-reduced-motion:reduce){.pulse,.bob,.spin{animation:none}}
.empty-note{text-align:center;color:var(--muted);font-size:13px;padding:18px 8px}
.jar{width:150px;height:150px;border:5px solid #E9D9C8;border-top-width:3px;border-radius:8px 8px 34px 34px;background:#FFFDF8;position:relative;overflow:hidden;display:flex;flex-direction:column;justify-content:flex-end;margin:0 auto}
.jar .fill{display:flex;flex-wrap:wrap-reverse;justify-content:center;gap:4px;padding:8px}
.jar .fill i{display:block;height:34px;border-radius:999px;box-shadow:inset -5px -5px 0 rgba(0,0,0,.12)}
.jar .juice{border-top:6px solid rgba(255,255,255,.45)}
.base{width:132px;height:44px;background:#F3D9D2;border-radius:12px 12px 18px 18px;margin:-2px auto 0;display:flex;align-items:center;justify-content:center;gap:10px}
/* tablet: rail on the left, wider content */
@media (min-width:900px){
  #app{max-width:1100px;padding-left:110px;padding-bottom:30px}
  #tabs{left:0;top:0;bottom:0;transform:none;width:100px;max-width:none;height:100vh;flex-direction:column;justify-content:flex-start;gap:10px;padding:24px 0;border-radius:0 22px 22px 0;box-shadow:6px 0 18px rgba(74,46,28,.08)}
  #tabs a.plus{margin-top:0}
  .detail{left:auto;right:auto;transform:none;position:sticky;bottom:16px;width:auto;margin:0 16px}
  .home-wrap{display:grid;grid-template-columns:minmax(0,440px) minmax(0,1fr);gap:20px;align-items:start;padding:16px}
  .home-wrap .panel{margin-top:0;border-radius:24px}
  .shelf .grid{grid-template-columns:repeat(8,minmax(0,1fr))}
  .grid2{grid-template-columns:repeat(4,minmax(0,1fr))}
  .toast{bottom:30px}
}

.picw{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:100%}
.picw img{position:absolute;inset:0;margin:auto;background:#fff;border-radius:10px;mix-blend-mode:normal}
.slot.warn .picw img,.slot.bad .picw img{mix-blend-mode:multiply;background:transparent}
.food .pic .picw img{max-height:80px}
