/* MealLog Ver.0.23 - usability + analytics refinement */

/* Header: always show Share and inherit Google avatar */
.share-action{
  width:auto !important;
  min-width:78px !important;
  height:48px !important;
  padding:0 13px !important;
  border-radius:18px !important;
  display:inline-flex !important;
  align-items:center;
  justify-content:center;
  gap:6px;
  font-size:.82rem !important;
  background:linear-gradient(145deg,#4b3371,#291b4b) !important;
}
.share-action>span{font-size:1.15rem;line-height:1}
.share-action>b{font-size:.78rem;white-space:nowrap}
.profile-action img{object-fit:cover;background:#261b45}

/* Search execution button */
.search-run-button{font-size:0 !important}
.search-run-button>span{
  display:grid;place-items:center;
  width:100%;height:100%;
  font-size:2rem !important;
  line-height:1;
  transform:translateX(-1px);
}

/* Place buttons */
.place-button.dineout .place-icon,
.place-button.takeout .place-icon{font-size:1.35rem}

/* Summary cards: no fake arrow, no icon/text collision */
.summary-tile{
  grid-template-columns:64px minmax(0,1fr) !important;
  gap:12px !important;
}
.summary-icon{position:static !important}
.summary-copy{padding-right:0 !important}
.summary-copy>span,.summary-copy>strong,.summary-copy>small{max-width:100%}

/* Recent heading: never split the title in the middle */
.recent-heading{align-items:center !important}
.recent-heading-copy{min-width:0}
.recent-heading h2{
  display:flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
  word-break:keep-all;
}
.recent-icon{flex:0 0 auto}
.recent-title-text{white-space:nowrap;word-break:keep-all}
.view-tools{display:flex;align-items:center;gap:8px;flex:0 0 auto}
.analysis-button,.view-all-button{
  min-height:42px;
  padding:0 15px;
  border:0;
  border-radius:999px;
  color:#fff;
  font-weight:800;
  cursor:pointer;
  white-space:nowrap;
}
.analysis-button{
  background:linear-gradient(145deg,#ff4f89,#d52a68);
  box-shadow:0 9px 18px rgba(255,72,134,.20),inset 0 1px 0 rgba(255,255,255,.18)
}
.view-all-button{background:linear-gradient(145deg,#4a316d,#2a1c4a) !important}

/* Empty state: no decorative + */
.empty-state{min-height:210px !important;padding:28px 16px !important}
.empty-state h3{margin:0 0 8px !important}
.empty-state p{margin:0 0 18px !important}

/* old bottom promotional CTA is intentionally removed */
.bottom-cta{display:none !important}

/* Price suffix inside field */
.price-input-wrap{position:relative;display:block}
.price-input-wrap input{padding-right:46px !important}
.price-unit{
  position:absolute;
  right:16px;
  top:50%;
  transform:translateY(-50%);
  color:#e9dff4;
  font-weight:800;
  pointer-events:none;
}

/* Modal system: header / close / action area don't move with content scroll */
.modal-card{
  max-height:calc(100dvh - 24px) !important;
  margin:12px auto !important;
  scrollbar-gutter:stable;
}
.modal-header{
  position:sticky !important;
  top:0 !important;
  z-index:30 !important;
  margin:-2px -2px 12px !important;
  padding:8px 2px 10px !important;
  background:linear-gradient(180deg,rgba(30,17,69,.995) 0%,rgba(30,17,69,.96) 82%,rgba(30,17,69,0) 100%) !important;
}
.modal-header .icon-button{flex:0 0 auto}
.detail-close{
  position:sticky !important;
  top:8px !important;
  z-index:40 !important;
  display:block !important;
  margin:0 0 -38px auto !important;
  box-shadow:0 8px 18px rgba(0,0,0,.22)
}

/* Add/edit meal: only center body scrolls. Header and Save remain visible. */
#mealForm.modal-card{
  width:min(720px,calc(100% - 18px)) !important;
  height:min(760px,calc(100dvh - 16px)) !important;
  max-height:calc(100dvh - 16px) !important;
  padding:14px 18px 0 !important;
  overflow:hidden !important;
  display:grid !important;
  grid-template-rows:auto minmax(0,1fr) auto;
}
#mealForm>.modal-header{position:relative !important;margin:0 !important;padding:0 0 10px !important;background:transparent !important}
.modal-scroll-body{
  min-height:0;
  overflow-y:auto;
  overflow-x:hidden;
  padding:2px 2px 10px;
  overscroll-behavior:contain;
}
#mealForm .modal-footer{
  position:relative !important;
  bottom:auto !important;
  z-index:30;
  margin:0 -18px !important;
  padding:10px 18px calc(10px + env(safe-area-inset-bottom)) !important;
  min-height:66px;
  border-top:1px solid rgba(255,255,255,.10);
  background:linear-gradient(180deg,rgba(20,12,53,.98),rgba(13,8,39,1)) !important;
}
#saveMeal{
  min-width:210px;
  min-height:48px;
  border:0 !important;
  border-radius:16px !important;
  color:#fff !important;
  background:linear-gradient(145deg,#ff4f86,#ff766b) !important;
  box-shadow:0 10px 22px rgba(255,68,127,.25),inset 0 1px 0 rgba(255,255,255,.24) !important;
}

/* Compact entry form */
#mealForm .photo-actions{gap:8px !important}
#mealForm .photo-action{min-height:72px !important;padding:10px 12px !important;border-radius:16px !important}
#mealForm .action-icon{width:36px !important;height:36px !important;border-radius:12px !important}
#mealForm .preview-area{margin-top:8px !important;padding:10px !important}
.compact-form-grid{
  grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  gap:10px 12px !important;
  margin-top:10px !important;
}
.compact-form-grid .wide{grid-column:1/-1}
.compact-form-grid label>span,.compact-form-grid .field-label{margin-bottom:5px !important;font-size:.78rem !important}
.compact-form-grid input,.compact-form-grid select,.compact-form-grid textarea{padding:11px 12px !important;border-radius:12px !important}
.compact-place-block .choice-pills{gap:7px !important}
.compact-place-block .choice-pills label span{min-height:44px !important;border-radius:13px !important;font-size:.82rem}
.compact-rating-block .rating-row{min-height:40px;align-items:center}
.compact-rating-block .rating-stars button{font-size:1.65rem !important}
.compact-rating-block .clear-rating{font-size:.72rem !important;padding:6px 8px !important}
.price-field small{font-size:.65rem !important;margin-top:4px !important;display:block}
.advanced-fields{
  border:1px solid rgba(255,255,255,.11);
  border-radius:14px;
  background:rgba(255,255,255,.035);
  overflow:hidden;
}
.advanced-fields>summary{
  min-height:42px;
  display:flex;
  align-items:center;
  padding:0 13px;
  color:#f1e8f7;
  font-weight:800;
  font-size:.78rem;
  cursor:pointer;
  list-style:none;
}
.advanced-fields>summary::-webkit-details-marker{display:none}
.advanced-fields>summary::after{content:'＋';margin-left:auto;color:#ff8caf;font-size:1rem}
.advanced-fields[open]>summary::after{content:'－'}
.advanced-fields-inner{display:grid;gap:10px;padding:0 12px 12px}

/* Analysis */
.analysis-card{
  width:min(820px,calc(100% - 18px)) !important;
  max-height:calc(100dvh - 20px) !important;
  overflow:auto !important;
  padding:18px !important;
}
.analysis-header{margin:-4px -4px 8px !important;padding:8px 4px 12px !important}
.analysis-toolbar{
  position:sticky;
  top:66px;
  z-index:20;
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:8px;
  padding:8px;
  margin:0 0 14px;
  border-radius:16px;
  background:rgba(20,12,53,.94);
  backdrop-filter:blur(12px);
}
.analysis-period{
  min-height:42px;
  border:1px solid rgba(255,255,255,.12);
  border-radius:12px;
  background:#2d1d50;
  color:#e8dff0;
  font-weight:800;
  cursor:pointer;
}
.analysis-period.active{background:linear-gradient(145deg,#fff2f6,#ffdce7);color:#e83c71;border-color:#ff78a3}
.analysis-period-caption{margin:2px 0 10px;color:#bcaece;font-size:.78rem;font-weight:700}
.analysis-kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}
.analysis-kpi-grid article{
  min-height:100px;
  padding:14px;
  border:1px solid rgba(255,255,255,.11);
  border-radius:18px;
  background:linear-gradient(145deg,rgba(69,42,105,.75),rgba(33,22,69,.86));
  display:flex;
  flex-direction:column;
  justify-content:space-between;
}
.analysis-kpi-grid span{color:#cdbfda;font-size:.72rem;font-weight:700}
.analysis-kpi-grid strong{color:#fff;font-size:1.45rem;line-height:1.15}
.analysis-section{margin-top:14px;padding:15px;border:1px solid rgba(255,255,255,.11);border-radius:18px;background:rgba(255,255,255,.035)}
.analysis-section h3{margin:0 0 12px;color:#fff;font-size:1rem}
.analysis-section-head{display:flex;justify-content:space-between;align-items:center;gap:12px}.analysis-section-head small{color:#bfb0ce;white-space:nowrap}.legend{display:inline-block;width:10px;height:10px;border-radius:3px;margin:0 4px 0 8px}.legend.count{background:#ff4f86}.legend.spend{background:#ff9d2f}
.analysis-bar-row{display:grid;grid-template-columns:90px minmax(0,1fr) 54px;align-items:center;gap:10px;margin:9px 0;color:#eadff1;font-size:.78rem}.analysis-bar-row b{text-align:right;color:#fff}.analysis-bar-track{height:12px;border-radius:999px;background:#211640;overflow:hidden}.analysis-bar{display:block;height:100%;min-width:2px;border-radius:inherit}.analysis-bar.home{background:#ff5e8c}.analysis-bar.dineout{background:#7a6ff0}.analysis-bar.takeout{background:#20c5d2}
.analysis-month-row{display:grid;grid-template-columns:42px minmax(0,1fr) 120px;align-items:center;gap:9px;margin:9px 0;font-size:.72rem;color:#dfd2e9}.analysis-month-row b{text-align:right;color:#fff;font-size:.7rem}.analysis-month-bars{display:grid;gap:3px}.analysis-month-bars i{display:block;height:6px;border-radius:999px}.analysis-count-bar{background:#ff4f86}.analysis-spend-bar{background:#ff9d2f}
.analysis-store-row{display:grid;grid-template-columns:30px minmax(0,1fr);gap:10px;align-items:center;padding:9px 0;border-bottom:1px solid rgba(255,255,255,.07)}.analysis-store-row:last-child{border-bottom:0}.analysis-rank{width:28px;height:28px;border-radius:10px;display:grid;place-items:center;background:#3a275f;color:#fff;font-weight:900}.analysis-store-row strong{display:block;color:#fff;font-size:.85rem}.analysis-store-row small{display:block;margin-top:3px;color:#c8b9d6;font-size:.67rem;line-height:1.45}.analysis-empty{margin:6px 0;color:#bfb0cc;font-size:.78rem}

/* Share/detail/store modals: close stays reachable while scrolling */
.share-card,.detail-card,.store-history-card{
  max-height:calc(100dvh - 24px) !important;
  overflow:auto !important;
}
.share-card>.modal-header{position:sticky !important;top:0 !important;z-index:25 !important}

@media(max-width:760px){
  /* Header has 3 actions on mobile too */
  .app-header{gap:8px !important}
  .app-header-actions{gap:5px !important}
  .share-action{display:inline-flex !important;min-width:56px !important;width:56px !important;height:42px !important;padding:0 !important;border-radius:15px !important}
  .share-action>b{display:none}
  .share-action>span{font-size:1.15rem}

  /* place selector must stay three across */
  .place-buttons{display:grid !important;grid-template-columns:repeat(3,minmax(0,1fr)) !important;gap:7px !important}
  .place-button{min-width:0 !important;min-height:70px !important;padding:7px 3px !important;flex-direction:column !important}
  .place-button strong{font-size:.70rem !important;white-space:nowrap !important;word-break:keep-all !important}
  .place-button.takeout strong{font-size:.64rem !important}

  /* summary cards stay three across without overlap */
  .summary-grid{grid-template-columns:repeat(3,minmax(0,1fr)) !important;gap:7px !important}
  .summary-tile{
    min-height:126px !important;
    display:flex !important;
    flex-direction:column !important;
    align-items:flex-start !important;
    justify-content:flex-start !important;
    gap:5px !important;
    padding:10px 8px !important;
  }
  .summary-icon{width:32px !important;height:32px !important;border-radius:10px !important;font-size:1.12rem !important;flex:0 0 auto}
  .summary-copy{display:grid !important;gap:2px !important;width:100% !important;min-width:0}
  .summary-copy>span{font-size:.58rem !important;white-space:nowrap !important}
  .summary-copy>strong{font-size:1.26rem !important;white-space:nowrap !important;overflow:hidden;text-overflow:ellipsis}
  .summary-copy>small{font-size:.49rem !important;line-height:1.2 !important;white-space:normal !important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}

  .recent-heading{display:flex !important;align-items:center !important;gap:8px !important}
  .recent-heading-copy{flex:1 1 auto;min-width:0}
  .recent-heading p{font-size:.52rem !important}
  .recent-heading h2{font-size:1.22rem !important;gap:5px !important;white-space:nowrap !important}
  .view-tools{gap:5px !important}
  .analysis-button,.view-all-button{min-height:34px !important;padding:0 9px !important;font-size:.62rem !important}

  /* record modal compact */
  #mealForm.modal-card{
    width:calc(100% - 8px) !important;
    height:calc(100dvh - 8px) !important;
    max-height:calc(100dvh - 8px) !important;
    margin:4px auto !important;
    padding:10px 12px 0 !important;
    border-radius:20px !important;
  }
  #mealForm>.modal-header{padding-bottom:6px !important}
  #mealForm .modal-header h2{font-size:1.25rem !important}
  #mealForm .eyebrow{margin-bottom:2px !important;font-size:.55rem !important}
  #mealForm .photo-action{min-height:58px !important;padding:7px 9px !important;gap:8px !important}
  #mealForm .action-icon{width:30px !important;height:30px !important}
  #mealForm .photo-action strong{font-size:.76rem !important}
  #mealForm .photo-action small{font-size:.56rem !important}
  .compact-form-grid{gap:7px 8px !important;margin-top:7px !important}
  .compact-form-grid label>span,.compact-form-grid .field-label{font-size:.70rem !important;margin-bottom:3px !important}
  .compact-form-grid input,.compact-form-grid select,.compact-form-grid textarea{padding:9px 10px !important;min-height:42px !important;font-size:.82rem !important}
  .compact-place-block .choice-pills label span{min-height:40px !important;font-size:.74rem !important}
  .compact-rating-block .rating-row{min-height:34px}
  .compact-rating-block .rating-stars button{font-size:1.42rem !important;padding:0 3px !important}
  .advanced-fields>summary{min-height:38px !important;font-size:.70rem !important}
  #mealForm .modal-footer{margin:0 -12px !important;padding:8px 12px calc(8px + env(safe-area-inset-bottom)) !important;min-height:58px}
  #saveMeal{min-height:44px !important;min-width:170px !important;font-size:.84rem !important}
  .upload-status{font-size:.60rem !important}

  /* analysis */
  .analysis-card{width:calc(100% - 8px) !important;margin:4px auto !important;padding:12px !important;border-radius:20px !important}
  .analysis-toolbar{top:58px !important;gap:5px !important;padding:6px !important}
  .analysis-period{min-height:38px !important;font-size:.72rem !important}
  .analysis-kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr)) !important;gap:7px !important}
  .analysis-kpi-grid article{min-height:82px !important;padding:11px !important;border-radius:14px !important}
  .analysis-kpi-grid strong{font-size:1.18rem !important}
  .analysis-section{padding:12px !important;border-radius:15px !important}
  .analysis-bar-row{grid-template-columns:72px minmax(0,1fr) 46px !important;gap:7px !important;font-size:.70rem !important}
  .analysis-month-row{grid-template-columns:34px minmax(0,1fr) 92px !important;gap:6px !important}.analysis-month-row b{font-size:.58rem !important}
}

@media(max-width:420px){
  /* Do not hide Share button */
  .round-action.share-action{display:inline-flex !important}
  .app-brand-copy small{display:none !important}
  .app-brand-copy strong{font-size:1.42rem !important}
  .app-brand-icon{width:44px !important;height:44px !important}
  .record-button{padding:0 8px !important;min-height:42px !important}
  .record-button>span{width:25px !important;height:25px !important}
  .profile-action{width:40px !important;height:40px !important}
  .share-action{width:40px !important;min-width:40px !important;height:40px !important}
  .summary-tile{min-height:120px !important;padding:8px 6px !important}
  .summary-copy>span{font-size:.53rem !important}.summary-copy>strong{font-size:1.08rem !important}
  .recent-heading h2{font-size:1.08rem !important}
  .analysis-button,.view-all-button{padding:0 7px !important;font-size:.57rem !important}
  .compact-form-grid{grid-template-columns:1fr 1fr !important}
}
