:root{
    --bg: #F1F4EC;
    --surface: #FFFFFF;
    --ink: #2E3A46;
    --ink-soft: #5B6B72;
    --line: #DDE3D6;
    --fern: #4F7942;
    --fern-dim: #E4ECDD;
    --carrot: #D9643A;
    --carrot-dim: #FBE6DB;
    --alert: #B23A48;
    --alert-dim: #F6E1E4;
  }

  *{ box-sizing: border-box; }

  body{
    margin:0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Karla', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
  }

  h1, h2, h3{
    font-family: 'Domine', serif;
    font-weight: 600;
    margin: 0;
  }

  .wrap{
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px 80px;
  }

  @media (max-width: 480px){
    .wrap{ padding: 24px 14px 60px; }
  }

  /* ---------- Header ---------- */
  header.top{
    display:flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
  }

  header.top h1{
    font-size: clamp(28px, 4vw, 38px);
    color: var(--ink);
  }

  header.top p{
    margin: 6px 0 0;
    color: var(--ink-soft);
    font-size: 15px;
  }

  #age-badge{
    font-size: 14px;
    color: var(--fern);
    background: var(--fern-dim);
    border-radius: 999px;
    padding: 6px 14px;
    white-space: nowrap;
    font-weight: 600;
  }

  /* ---------- Backup / sync ---------- */
  .sync-bar{
    display:flex;
    justify-content:space-between;
    align-items:center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
  }

  .sync-bar-actions{
    display:flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .user-select{
    display:flex;
    align-items:center;
    gap: 6px;
    flex-wrap: wrap;
  }

  .user-label{
    font-size: 12.5px;
    color: var(--ink-soft);
  }

  .user-btn{
    font-family: 'Karla', sans-serif;
    font-size: 12.5px;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    cursor:pointer;
  }
  .user-btn.active{
    background: var(--fern-dim);
    border-color: var(--fern);
    color: var(--fern);
    font-weight: 700;
  }
  .user-btn:hover{ border-color: var(--fern); }

  .logged-by-value{
    font-size: 13px;
    color: var(--ink);
    font-weight: 600;
  }

  .sync-toggle-btn{
    font-family: 'Karla', sans-serif;
    font-size: 12.5px;
    color: var(--ink-soft);
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px;
    cursor:pointer;
  }
  .sync-toggle-btn:hover{ border-color: var(--fern); color: var(--fern); }

  .sync-panel{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 22px;
    margin-bottom: 24px;
    font-size: 14px;
  }

  .sync-status{
    display:inline-block;
    font-size: 12.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg);
    color: var(--ink-soft);
    margin: 0 0 12px;
  }
  .sync-status.connected{ background: var(--fern-dim); color: var(--fern); }
  .sync-status.error{ background: var(--alert-dim); color: var(--alert); }

  .sync-panel ol{
    margin: 8px 0 12px;
    padding-left: 20px;
  }
  .sync-panel li{ margin-bottom: 4px; }

  .sync-warning{
    font-size: 13px;
    color: var(--alert);
    margin: 0 0 14px;
  }

  .sync-actions{
    display:flex;
    gap: 10px;
    flex-wrap: wrap;
  }

  .restore-label{
    font-family: 'Karla', sans-serif;
    font-size: 13px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 14px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
  }
  .restore-label:hover{ border-color: var(--fern); }
  .restore-label input[type="file"]{
    position:absolute;
    width:1px; height:1px;
    overflow:hidden;
    clip: rect(0,0,0,0);
  }

  /* ---------- Tabs ---------- */
  .tabs-bar{ display:none; }

  .menu-toggle{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 38px; height: 38px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap: 4px;
    cursor:pointer;
    flex-shrink:0;
  }
  .menu-toggle span{
    display:block;
    width: 18px; height: 2px;
    background: var(--ink);
    border-radius: 1px;
  }

  .current-tab-label{
    font-family: 'Domine', serif;
    font-size: 16px;
    color: var(--ink);
  }

  .tabs{
    display:flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
  }

  .tab-btn{
    font-family: 'Domine', serif;
    font-size: 15px;
    background: none;
    border: none;
    padding: 10px 4px;
    margin-right: 22px;
    color: var(--ink-soft);
    cursor: pointer;
    position: relative;
    top: 1px;
  }

  .tab-btn.active{
    color: var(--ink);
    border-bottom: 2px solid var(--fern);
  }

  .tab-btn .badge{
    font-family: 'Karla', sans-serif;
    font-size: 11px;
    background: var(--alert-dim);
    color: var(--alert);
    border-radius: 999px;
    padding: 1px 7px;
    margin-left: 6px;
    font-weight: 700;
  }

  @media (max-width: 640px){
    .tabs-bar{
      display:flex;
      align-items:center;
      gap: 12px;
      margin-bottom: 14px;
    }

    .tabs{
      display:none;
      flex-direction: column;
      gap: 2px;
      border-bottom: none;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: 10px;
      padding: 6px;
      margin-bottom: 22px;
    }

    .tabs.open{ display:flex; }

    .tab-btn{
      margin-right: 0;
      text-align:left;
      padding: 11px 12px;
      border-radius: 6px;
      top: 0;
    }

    .tab-btn.active{
      background: var(--fern-dim);
      border-bottom: none;
    }
  }

  .panel{ display:none; }
  .panel.active{ display:block; }

  /* ---------- Growth ticket ---------- */
  .ticket{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 24px 28px;
    margin-bottom: 28px;
    position: relative;
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px 32px;
  }

  .ticket::before{
    content:"";
    position:absolute;
    left: 50%;
    top: 20px;
    bottom: 20px;
    border-left: 1px dashed var(--line);
  }

  @media (max-width: 560px){
    .ticket{ grid-template-columns: 1fr; }
    .ticket::before{ display:none; }
  }

  .ticket .col{ display:flex; flex-direction:column; gap: 4px; }

  .ticket .col-label{
    font-size: 12px;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
  }

  .ticket .stat-line{
    font-family: 'Domine', serif;
    font-size: 20px;
    color: var(--ink);
  }

  .ticket .stat-sub{
    font-size: 13px;
    color: var(--ink-soft);
  }

  /* ---------- Growth chart + log ---------- */
  .chart-row{
    display:grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
  }

  .chart-empty{
    text-align:center;
    color: var(--ink-soft);
    font-size: 13px;
    padding: 40px 10px;
    margin: 0;
  }

  .chart-card{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 20px;
  }

  .chart-card h3{
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 12px;
    font-weight: 600;
  }

  .chart-card canvas{ max-height: 220px; }

  .log-table{
    width:100%;
    border-collapse: collapse;
    font-size: 14px;
  }

  .table-scroll{
    overflow-x: auto;
  }

  @media (max-width: 480px){
    .log-table{ min-width: 480px; }
  }

  .log-table th{
    text-align:left;
    font-size: 12px;
    color: var(--ink-soft);
    font-weight: 600;
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
  }

  .log-table td{
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
  }

  .log-table input[type="date"],
  .log-table input[type="number"]{
    border: 1px solid transparent;
    background: transparent;
    font-family: 'Karla', sans-serif;
    font-size: 13.5px;
    color: var(--ink);
    width: 100%;
    padding: 3px 4px;
    border-radius: 4px;
  }

  .log-table input:hover, .log-table input:focus{
    border-color: var(--line);
    background: var(--bg);
  }

  .log-table .num-col{ width: 64px; }
  .log-table .date-col{ width: 130px; }

  .row-del{
    background:none;
    border:none;
    color: var(--ink-soft);
    cursor:pointer;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
  }
  .row-del:hover{ color: var(--alert); }

  .add-entry-btn{
    margin-top: 12px;
    font-family:'Karla', sans-serif;
    font-size: 13px;
    color: var(--fern);
    background: var(--fern-dim);
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    cursor:pointer;
  }
  .add-entry-btn:hover{ filter: brightness(0.95); }

  /* ---------- Progress ---------- */
  .progress-row{
    display:flex;
    align-items:center;
    gap: 16px;
    margin-bottom: 32px;
  }

  .progress-track{
    flex:1;
    height: 10px;
    background: var(--fern-dim);
    border-radius: 999px;
    overflow:hidden;
  }

  .progress-fill{
    height:100%;
    background: var(--fern);
    border-radius: 999px;
    transition: width 0.3s ease;
    width: 0%;
  }

  .progress-count{
    font-family:'Domine', serif;
    font-size: 15px;
    white-space: nowrap;
    color: var(--ink);
  }

  /* ---------- Categories ---------- */
  .category{
    margin-bottom: 30px;
    border-left: 3px solid var(--cat-color, var(--fern));
    padding-left: 18px;
  }

  .category h2{
    font-size: 18px;
    display:flex;
    align-items:center;
    gap: 10px;
    margin-bottom: 4px;
  }

  .category h2 .dot{
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--cat-color, var(--fern));
    display:inline-block;
    flex-shrink:0;
  }

  .category .count{
    font-size: 13px;
    color: var(--ink-soft);
    font-weight: 400;
    font-family:'Karla', sans-serif;
  }

  .food-grid{
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 8px;
    margin-top: 12px;
    align-items: start;
  }

  @media (max-width: 480px){
    .food-grid{
      grid-template-columns: 1fr;
    }
  }

  .food-row{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.15s ease, background 0.15s ease;
  }

  .food-row.checked{
    background: var(--fern-dim);
    border-color: var(--fern);
  }

  .food-row.expanded{
    grid-column: 1 / -1;
  }

  .food-row.has-allergy{
    border-color: var(--alert);
  }

  .food-main{
    display:flex;
    align-items:center;
    gap: 10px;
  }

  .food-row input[type="checkbox"]{
    width: 18px; height: 18px;
    accent-color: var(--fern);
    flex-shrink:0;
    cursor:pointer;
  }

  .food-row label.food-label{
    flex:1;
    font-size: 14.5px;
    cursor:pointer;
    user-select:none;
  }

  .allergy-flag{
    font-size: 11px;
    color: var(--alert);
    background: var(--alert-dim);
    border-radius: 999px;
    padding: 2px 8px;
    font-weight: 700;
    white-space: nowrap;
  }

  .food-delete{
    background: none;
    border: none;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
  }
  .food-delete:hover{ color: var(--alert); }

  .add-food-row{
    grid-column: 1 / -1;
    display:flex;
    gap: 8px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    background: transparent;
  }

  .add-food-row input[type="text"]{
    flex:1;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
    font-family: 'Karla', sans-serif;
    font-size: 14px;
    color: var(--ink);
  }

  .add-food-row button{
    background: var(--fern);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'Karla', sans-serif;
    font-size: 13px;
    cursor:pointer;
    white-space: nowrap;
  }
  .add-food-row button:hover{ filter: brightness(0.95); }

  .food-detail{
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    display:flex;
    flex-direction: column;
    gap: 10px;
  }

  .detail-row{
    display:flex;
    align-items:center;
    gap: 10px;
    flex-wrap: wrap;
  }

  .detail-row .field-label{
    font-size: 12px;
    color: var(--ink-soft);
    width: 90px;
    flex-shrink:0;
  }

  .detail-row input[type="date"]{
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 4px 6px;
    font-family: 'Karla', sans-serif;
    color: var(--ink);
  }

  .reaction-btns{ display:flex; gap: 6px; }

  .reaction-btn{
    font-size: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 8px;
    cursor:pointer;
    line-height: 1.4;
  }

  .reaction-btn.active{
    border-color: var(--fern);
    background: var(--fern-dim);
  }

  .check-label{
    font-size: 13px;
    display:flex;
    align-items:center;
    gap: 6px;
    cursor:pointer;
    color: var(--ink);
  }

  .check-label input{ accent-color: var(--alert); cursor:pointer; }

  .allergy-note{
    font-size: 13px;
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 5px 8px;
    font-family: 'Karla', sans-serif;
    flex: 1;
    min-width: 160px;
  }

  /* ---------- Calendar tab ---------- */
  .cal-nav{
    display:flex;
    align-items:center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 16px;
  }

  .cal-nav h3{
    font-size: 17px;
    min-width: 160px;
    text-align:center;
  }

  .cal-nav-btn{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    width: 32px; height: 32px;
    font-size: 15px;
    color: var(--ink);
    cursor:pointer;
  }
  .cal-nav-btn:hover{ border-color: var(--fern); color: var(--fern); }

  .cal-weekdays{
    display:grid;
    grid-template-columns: repeat(7, 1fr);
    font-size: 12px;
    color: var(--ink-soft);
    text-align:center;
    margin-bottom: 6px;
  }

  .cal-grid{
    display:grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }

  .cal-day{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 74px;
    padding: 6px 6px;
    display:flex;
    flex-direction: column;
    gap: 4px;
  }

  .cal-day.blank{
    background: transparent;
    border-color: transparent;
  }

  .cal-day.today{
    border-color: var(--fern);
    box-shadow: 0 0 0 1px var(--fern) inset;
  }

  .cal-day .day-num{
    font-size: 12px;
    color: var(--ink-soft);
  }

  .cal-day.today .day-num{
    color: var(--fern);
    font-weight: 700;
  }

  .cal-day .day-emojis{
    display:flex;
    flex-wrap:wrap;
    gap: 2px;
    font-size: 15px;
    line-height: 1.1;
  }

  .cal-hint{
    margin-top: 16px;
    font-size: 13px;
    color: var(--ink-soft);
    text-align:center;
  }

  @media (max-width: 560px){
    .cal-day{ min-height: 52px; padding: 4px; }
    .cal-day .day-emojis{ font-size: 12px; }
  }

  /* ---------- Allergies tab ---------- */
  .allergy-item{
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--alert);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 10px;
  }

  .allergy-item .a-name{
    font-family: 'Domine', serif;
    font-size: 15.5px;
  }

  .allergy-item .a-meta{
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: 2px;
  }

  .allergy-item .a-note{
    font-size: 13.5px;
    margin-top: 6px;
    color: var(--ink);
  }

  .empty-state{
    text-align:center;
    padding: 40px 20px;
    color: var(--ink-soft);
    font-size: 14.5px;
  }

  /* ---------- Footer note ---------- */
  .note{
    margin-top: 40px;
    padding: 18px 20px;
    background: var(--carrot-dim);
    border-left: 3px solid var(--carrot);
    border-radius: 6px;
    font-size: 13.5px;
    color: var(--ink);
  }

  .note strong{ color: var(--carrot); }

  .actions{
    margin-top: 18px;
    display:flex;
    justify-content:flex-end;
  }

  .reset-btn{
    font-family:'Karla', sans-serif;
    font-size: 13px;
    color: var(--ink-soft);
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 12px;
    cursor:pointer;
  }

  .reset-btn:hover{ border-color: var(--carrot); color: var(--carrot); }

  :focus-visible{
    outline: 2px solid var(--fern);
    outline-offset: 2px;
  }

  @media (prefers-reduced-motion: reduce){
    .progress-fill{ transition:none; }
  }

  /* ---------- Stats tab ---------- */
  .stat-grid{
    display:grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
  }

  .stat-tile{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 14px;
    text-align:center;
  }

  .stat-value{
    font-family: 'Domine', serif;
    font-size: 22px;
    color: var(--fern);
  }

  .stat-label{
    font-size: 12px;
    color: var(--ink-soft);
    margin-top: 4px;
  }

  .stats-list{
    list-style:none;
    margin:0; padding:0;
    font-size: 14px;
    max-height: 220px;
    overflow-y:auto;
  }
  .stats-list li{
    padding: 5px 0;
    border-bottom: 1px solid var(--line);
  }
  .stats-list li:last-child{ border-bottom:none; }
  .stats-list .stats-empty{ color: var(--ink-soft); font-style: italic; }

  /* ---------- Print keepsake ---------- */
  .print-only{ display:none; }

  @media print{
    body *{ visibility:hidden; }
    .print-only, .print-only *{ visibility:visible; }
    .print-only{
      display:block;
      position:absolute;
      top:0; left:0;
      width:100%;
      padding: 20px;
      font-family: 'Karla', Arial, sans-serif;
      color:#000;
    }
    .print-only h1{ font-family:'Domine', Georgia, serif; font-size:22px; margin-bottom:2px; }
    .print-only h2{ font-family:'Domine', Georgia, serif; font-size:17px; margin-top:20px; border-bottom:1px solid #999; padding-bottom:4px; }
    .print-only h3{ font-size:14px; margin-top:14px; margin-bottom:4px; }
    .print-only .k-sub{ color:#555; font-size:12px; margin-top:0; }
    .print-only ul{ margin:4px 0 8px; padding-left:20px; font-size:13px; }
    .print-only li{ margin-bottom:2px; }
  }

  /* ---------- Baby catcher mascot ---------- */
  .baby-catcher{
    position: relative;
    height: 100px;
    margin-bottom: 20px;
    overflow: hidden;
  }

  .baby-mascot{
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 40px;
    animation: baby-bounce 1.4s ease-in-out infinite;
  }

  .falling-food{
    position: absolute;
    top: 0;
    font-size: 22px;
    opacity: 0;
    animation: food-fall 3.2s linear infinite;
  }

  .ff1{ left: 6%;  animation-delay: 0s; }
  .ff2{ left: 22%; animation-delay: 0.7s; }
  .ff3{ left: 40%; animation-delay: 1.4s; }
  .ff4{ left: 58%; animation-delay: 2.1s; }
  .ff5{ left: 76%; animation-delay: 2.8s; }
  .ff6{ left: 90%; animation-delay: 3.5s; }

  @keyframes food-fall{
    0%   { top: 0;    opacity: 0; transform: scale(1) rotate(0deg); }
    8%   { opacity: 1; }
    68%  { opacity: 1; }
    82%  { top: 56px; opacity: 0; transform: scale(0.5) rotate(20deg); }
    100% { top: 56px; opacity: 0; }
  }

  @keyframes baby-bounce{
    0%, 100% { transform: translateX(-50%) translateY(0) scale(1); }
    50%      { transform: translateX(-50%) translateY(-5px) scale(1.06); }
  }

  @media (prefers-reduced-motion: reduce){
    .falling-food, .baby-mascot{ animation: none; opacity: 1; top: 40px; }
  }
  .try-next-section{
    margin-bottom: 24px;
  }

  .try-next-title{
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 10px;
    font-weight: 600;
  }

  .try-next-list{
    display:flex;
    gap: 8px;
    overflow-x:auto;
    padding-bottom: 4px;
  }

  .try-next-chip{
    flex-shrink:0;
    display:flex;
    align-items:center;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    font-family: 'Karla', sans-serif;
    font-size: 13.5px;
    color: var(--ink);
    cursor:pointer;
    white-space: nowrap;
  }
  .try-next-chip:hover{ border-color: var(--fern); background: var(--fern-dim); }
  .tn-emoji{ font-size: 16px; }

  /* ---------- Timeline ---------- */
  .timeline-date{
    font-family: 'Domine', serif;
    font-size: 13px;
    color: var(--ink-soft);
    margin: 22px 0 8px;
    text-transform: none;
  }
  .timeline-date:first-child{ margin-top: 0; }

  .timeline-item{
    display:flex;
    align-items:flex-start;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 6px;
  }

  .tl-icon{ font-size: 20px; flex-shrink:0; line-height:1.3; }
  .tl-body{ flex:1; }
  .tl-text{ font-size: 14.5px; color: var(--ink); }
  .tl-sub{ font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

  /* ---------- Photo attachments ---------- */
  .photo-thumb{
    width: 72px; height: 72px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
  }

  .photo-controls{
    display:flex;
    align-items:center;
    gap: 10px;
  }

  .photo-remove-btn{
    font-family: 'Karla', sans-serif;
    font-size: 12.5px;
    color: var(--ink-soft);
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 10px;
    cursor:pointer;
  }
  .photo-remove-btn:hover{ border-color: var(--alert); color: var(--alert); }

  .photo-add-label{
    font-family: 'Karla', sans-serif;
    font-size: 13px;
    color: var(--ink);
    background: var(--bg);
    border: 1px dashed var(--line);
    border-radius: 6px;
    padding: 8px 14px;
    cursor:pointer;
    display:inline-flex;
    align-items:center;
  }
  .photo-add-label:hover{ border-color: var(--fern); }
  .photo-add-label input[type="file"]{
    position:absolute;
    width:1px; height:1px;
    overflow:hidden;
    clip: rect(0,0,0,0);
  }

  /* ---------- Birthday banner ---------- */
  .birthday-banner{
    display:none;
    text-align:center;
    font-family: 'Domine', serif;
    font-size: 14px;
    color: var(--carrot);
    background: var(--carrot-dim);
    border-radius: 999px;
    padding: 9px 16px;
    margin-bottom: 16px;
  }

  .readonly-banner{
    display:none;
    text-align:center;
    font-family: 'Karla', sans-serif;
    font-size: 13px;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 16px;
    margin-bottom: 16px;
  }

  /* ---------- Read-only (family share view) ---------- */
  body.read-only .reset-btn,
  body.read-only #sync-toggle,
  body.read-only .user-select,
  body.read-only .add-food-row,
  body.read-only .food-delete,
  body.read-only .row-del,
  body.read-only #add-entry-btn,
  body.read-only .photo-add-label,
  body.read-only .photo-remove-btn,
  body.read-only .try-next-section{
    display:none !important;
  }

  body.read-only input,
  body.read-only .reaction-btn,
  body.read-only .log-table input{
    pointer-events:none;
  }

  /* ---------- Safety tab ---------- */
  .allergen-grid{
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 26px;
  }

  .allergen-item{
    display:flex;
    align-items:center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
  }

  .allergen-item.introduced{
    border-color: var(--fern);
    background: var(--fern-dim);
  }

  .allergen-emoji{ font-size: 24px; }
  .allergen-label{ font-family: 'Domine', serif; font-size: 14px; color: var(--ink); }
  .allergen-status{ font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
  .allergen-item.introduced .allergen-status{ color: var(--fern); font-weight: 600; }

  .hazard-list{ margin-bottom: 26px; }
  .hazard-item{
    font-size: 14px;
    line-height: 1.6;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }
  .hazard-item:last-child{ border-bottom: none; }
  .hazard-item strong{ color: var(--ink); }

  /* ---------- Guide tab ---------- */
  .guide-intro{
    color: var(--ink-soft);
    font-size: 14.5px;
    margin-bottom: 20px;
  }

  #panel-guide h2{
    font-size: 17px;
    margin-top: 26px;
    margin-bottom: 8px;
  }
  #panel-guide h2:first-of-type{ margin-top: 0; }

  #panel-guide p, #panel-guide ul{
    font-size: 14.5px;
    line-height: 1.6;
    margin: 0 0 6px;
  }

  #panel-guide ul{ padding-left: 20px; }
  #panel-guide li{ margin-bottom: 8px; }

  /* ---------- Search bar ---------- */
  .search-bar{
    margin-bottom: 18px;
  }

  .search-bar input[type="search"]{
    width: 100%;
    font-family: 'Karla', sans-serif;
    font-size: 14.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 14px;
  }
  .search-bar input[type="search"]:focus{ border-color: var(--fern); }

  /* ---------- Badges ---------- */
  .stats-subheading{
    font-size: 14px;
    color: var(--ink-soft);
    margin-bottom: 10px;
    font-weight: 600;
  }

  .badge-grid{
    display:grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
  }

  .badge-tile{
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 10px;
    text-align:center;
    transition: opacity 0.2s ease;
  }

  .badge-tile.locked{
    opacity: 0.35;
    filter: grayscale(1);
  }

  .badge-icon{ font-size: 28px; line-height:1; }
  .badge-title{
    font-family: 'Domine', serif;
    font-size: 12.5px;
    margin-top: 6px;
    color: var(--ink);
  }
  .badge-desc{
    font-size: 11px;
    color: var(--ink-soft);
    margin-top: 2px;
  }

  /* ---------- Dark mode ---------- */
  body.dark{
    --bg: #1B211D;
    --surface: #232A25;
    --ink: #E7ECE4;
    --ink-soft: #93A190;
    --line: #313B34;
    --fern-dim: #26362B;
    --carrot-dim: #3A2A22;
    --alert-dim: #3A2226;
  }

  /* ---------- Accounts ---------- */
  body.auth-loading .wrap, body.signed-out .wrap{ display:none; }
  .auth-overlay{
    position: fixed; inset: 0; z-index: 1000; overflow-y: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; background: var(--bg);
  }
  .auth-overlay[hidden]{ display:none; }
  #settings-modal{ background: rgba(20,28,22,0.55); }
  .auth-card{
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  }
  .auth-logo{ font-size: 36px; text-align: center; margin-bottom: 4px; }
  .auth-card h2{ text-align: center; font-size: 22px; }
  .auth-sub{ text-align: center; color: var(--ink-soft); margin: 6px 0 16px; font-size: 14px; }
  .auth-card form{ display: flex; flex-direction: column; gap: 10px; }
  .auth-card input{
    width: 100%; padding: 12px 14px; font: inherit; font-size: 16px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--bg); color: var(--ink);
  }
  .auth-card input:focus{ outline: 2px solid var(--fern); border-color: var(--fern); }
  .auth-label{ font-size: 13px; color: var(--ink-soft); margin-bottom: -4px; }
  .auth-primary, .auth-provider, .auth-danger, .auth-close{
    width: 100%; padding: 12px 14px; font: inherit; font-weight: 600; font-size: 15px;
    border-radius: 10px; cursor: pointer; border: 1px solid var(--fern);
  }
  .auth-primary{ background: var(--fern); color: #fff; }
  .auth-primary:disabled{ opacity: .6; cursor: default; }
  .auth-provider{ background: var(--surface); color: var(--ink); border-color: var(--line); margin-bottom: 8px; }
  .auth-provider:hover{ border-color: var(--fern); }
  .auth-danger{ background: var(--alert-dim); color: var(--alert); border-color: var(--alert); margin-top: 4px; }
  .auth-close{ background: transparent; color: var(--ink-soft); border-color: var(--line); margin-top: 14px; }
  .auth-divider{ display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13px; margin: 14px 0; }
  .auth-divider::before, .auth-divider::after{ content:''; flex:1; height:1px; background: var(--line); }
  .auth-links{ display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin: 8px 0 0; }
  .auth-links a{ color: var(--fern); }
  .auth-fine{ font-size: 12px; color: var(--ink-soft); text-align: center; margin: 14px 0 0; }
  .auth-msg{ background: var(--alert-dim); color: var(--alert); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
  .auth-msg.ok{ background: var(--fern-dim); color: var(--fern); }
  .settings-h{ font-size: 15px; margin: 18px 0 8px; }
  .settings-card{ max-height: 92vh; overflow-y: auto; }

  .child-bar{ display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
  .child-bar[hidden]{ display: none; }
  .child-chip{
    font: inherit; font-weight: 600; font-size: 14px; padding: 7px 14px;
    border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
    color: var(--ink); cursor: pointer;
  }
  .child-chip.active{ background: var(--fern); border-color: var(--fern); color: #fff; }
  .child-chip.add{ border-style: dashed; color: var(--ink-soft); }

  .share-list{ list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
  .share-list li{
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
  }
  .share-list .who{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .share-list .role{ color: var(--ink-soft); font-size: 12px; margin-left: 6px; }
  .share-list button{
    font: inherit; font-size: 13px; padding: 4px 10px; border-radius: 8px;
    border: 1px solid var(--alert); background: var(--alert-dim); color: var(--alert); cursor: pointer;
  }
  .share-note{ margin: 0 0 10px; }
  .share-link-box{ margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
  #join-modal{ z-index: 1100; }

  .auth-fine a{ color: var(--fern); }
