/* =========================
   /* =========================================================
   shared.css
   Family Chores & Points App – Shared UI System

   Purpose:
   - Buttons
   - Modals
   - Cards / panels
   - Layout helpers
   - Accessibility helpers

   Do NOT put page layout or theme wiring here.
   ========================================================= */

   /*========================= */
  /* --- Base --- */
  * { box-sizing: border-box; }

  body { 
    font-family: "Chalkboard SE", "Comic Sans MS", system-ui, sans-serif; 
    margin: 0; 
    padding: 25px;
    padding-top: 10px;

    color: #000;
    background-color: #b8d3dc;

    background-image:
        linear-gradient(
            45deg,
            rgba(255,255,255,.08) 25%,
            transparent 25%,
            transparent 75%,
            rgba(255,255,255,.08) 75%
        ),
        linear-gradient(
            45deg,
            rgba(0,0,0,.04) 25%,
            transparent 25%,
            transparent 75%,
            rgba(0,0,0,.04) 75%
        );

    background-size: 140px 140px;
    background-position: 0 0, 70px 70px;
    background-attachment: fixed;
}
  } 

  *, *::before, *::after { box-sizing: border-box; }

  button, input, select, textarea {
    font-family: inherit;
  }

  .modal {
    z-index: 20000;
  }

  .page-header.shared-sticky-nav,
  header.topbar {
    z-index: 8000;
  }

  h2 {              /*modal titles*/
    margin: 10px;
    font-size: clamp(1rem, 6.5cqi, 2rem);
  }

  /*-------- Page Sections and Max Sizing --------*/
  .page-content {
    max-width: 960px;
    margin: 0 auto;
  }

  .section {
    margin-bottom: 20px;
    padding: 0;
  }

  /* "panel/section-box" surface */
  .section-box {
    border-radius: 30px;
    padding: clamp(10px, 3vw, 18px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.50);
    box-sizing: border-box;
    container-type: inline-size;
    color: #FFF9EF;
    background-image: linear-gradient(
      to top right, #2A3958, #121926);

    /* critical: keeps mobile from shrinking */
    width: 100%;
    /* desktop constraint */
    max-width: 960px;
  }

  .section-title{
      margin-top: 8px;
      margin-bottom: 5px;
      font-size: clamp(0.85rem, 5vw, 1.65rem);
      font-weight: 750;
    }

  .helper-text {
    margin: 0;
    font-size: 0.95rem;
    color: #555;
  } 

  :root{
    --choreTextScale: 1;
  }

  /* grow text slightly as screens get bigger */
  @media (min-width: 700px){
    :root{ --choreTextScale: 1.12; }
  }
  @media (min-width: 1000px){
    :root{ --choreTextScale: 1.22; }
  }
  @media (min-width: 1400px){
    :root{ --choreTextScale: 1.32; }
  }

  /* =========================
     Nav buttons (shared)
     ========================= */
  .nav-btn {
    padding: clamp(5px, 1.6vw, 8px) clamp(8px, 3vw, 12px);
    border-radius: clamp(8px, 2.5vw, 12px);
    border: 2.5px solid #000;
    background: #fff;
    cursor: pointer;

    font-size: clamp(.75rem, 3vw, 1rem);
    font-weight: 600;
    line-height: 1.15;
    color: #000;

    max-width: clamp(90px, 24vw, 190px);
    white-space: nowrap;
    min-height: 38px;
  }

  /* hover is opt-in to avoid surprising some pages */
  .nav-btn.hover-pop:hover {
    transform: scale(1.03);
    border: 3px solid #000;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  }

  .dashboard-heading {
    text-align: center;
    min-width: 0;
    margin-bottom: 16px;
  }

  .dashboard-title {
    text-align: center;
    font-weight: 700;
    line-height: 1.15;
    margin: 15px;
    font-size: clamp(1.8rem, 7vw, 3rem);
  }

  .header-subtitle{
    margin: 0 0 13px;
    font-size: clamp(0.93rem, 2.5vw, 1.5rem);
    opacity: 0.85;
    white-space: normal;
    word-break: break-word;
  }

  /* Responsive labels inside shared nav buttons */
  .short-label {
    display: none;
  }

  .full-label {
    display: inline;
  }

  #parentBtn {
    padding-left: 8px;
    padding-right: 8px;
    font-size: .9rem;
  }

  body.modal-open .page-header,
  body.modal-open .shared-sticky-nav,
  body.modal-open header.topbar,
  body.modal-open .topbar {
    pointer-events: none;
  }

  body.modal-open .page-header button,
  body.modal-open .shared-sticky-nav button,
  body.modal-open header.topbar button,
  body.modal-open .topbar button {
    opacity: 0.45;
  }

  @media (max-width: 600px) {
    .full-label {
      display: none;
    }

    .short-label {
      display: inline;
    }
  }

  /*---------- Sticky top ----------*/
  .page-header.shared-sticky-nav {
    position: sticky;
    top: 0;
    z-index: 8000;
    backdrop-filter: blur(4px);

    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border-radius: 0 0 22px 22px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
  }

  /* Row with Back / Parent / Home */
  .shared-nav-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
  }

  .shared-nav-left {
    justify-self: start;
    display: flex;
    gap: 14px;
    align-items: center;
  }

  .shared-nav-right {
    justify-self: end;
    display: flex;
    gap: 10px;
    align-items: center;
  }

  /* =========================
     Modals (shared)
     ========================= */
  .modal {
    display: flex;              /* ✅ default is flex */
    position: fixed;
    inset: 0;
    box-sizing: border-box;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    color: #000;
    overflow-x: hidden;
    padding: 16px;
  }

  /* Default modal size = your parent.html version */
  .modal .modal-content {
    background: linear-gradient(
      to bottom, #ffffff, #F4FAF9);
    padding: 14px;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow:
      0 10px 25px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);

    width: min(500px, calc(100% - 16px));     /*Do not change, necessary for mobile access*/
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;

    justify-items: center;
    gap: 14px;
    text-align: center;
    position: relative;
    z-index: 20000;
  }

  /* Modifier for smaller/compact modals (parent-child can use this) */
  .modal .modal-content.compact {
    background: linear-gradient(
      to bottom, #ffffff, #F4FAF9);
    padding: 14px;
    border-radius: 17px;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow:
      0 10px 25px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);

    width: clamp(240px, 88vw, 275px);
    max-height: min(85vh, 370px);
    overflow: auto;

    justify-items: center;
    text-align: center;
    z-index: 30000 !important;
  }

  .modal .modal-content .hint {
    opacity: 0.8;
    font-size: 0.95rem;
    margin-bottom: 15px;
  }

  /* Modal actions (column by default, matches your parent-chores HTML) */
  .modal .modal-actions {
    display: inline-block;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
  }

  /* Optional row layout when you need Back/Next side-by-side */
  .modal .modal-actions.row {
    flex-direction: row;
    justify-content: space-between;
  }

  /* If you're using row mode, let them share space */
  .modal .modal-actions.row > button {
    flex: 1;
  }

  /* PIN modal error hint */
  .hint.pin-error {
    color: #b91c1c;              /* deep red */
    background: #fee2e2;         /* soft red background */
    border: 1px solid #fca5a5;
    opacity: 1;
  }

  .hint.error {
    color: #b91c1c;
    background: #fee2e2;
    border: 1px solid #fca5a5;
    margin-bottom: 10px;
  }

  .modal .modal-content input {
    padding: 12px;
    border-radius: 12px;
    border: 1px solid #ccc;
    margin-bottom: 10px;
    font-size: 1rem;
    width: 100%;
    max-width: 260px;
  }

  .modal-close {        /*X Close*/
    position: absolute;
    top: 12px;
    right: 14px;

    width: 25px;
    height: 25px;

    background: transparent;
    border: none;
    border-radius: 50%;

    font-size: 1.25rem;
    line-height: 1;
    color: #555;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  }

  .modal-close:hover {
    background: rgba(0,0,0,0.08);
    color: #000;
    transform: scale(1.05);
  }

  .modal-close:focus-visible {
    outline: 3px solid #000;
    outline-offset: 3px;
  }

  /* =========================
     Parent PIN field (shared)
     ========================= */
  #pinModal {
    z-index: 30500;
  }

  .pin-field {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .pin-field input { 
    flex: 1;
    max-width: 170px;
    height: 38px;
    margin-bottom: 5px;
  }

  .pin-toggle {
    border: 1px solid #cfd3da;
    background: #fff;
    border-radius: 10px;
    padding: 8px 8px;
    cursor: pointer;
    line-height: 1;
    height: 38px;
    font-size: 20px;
    margin-bottom: 10px;
  }

  #pinModalTitle {
    margin-bottom: 0;
    font-size: 1.2rem;
  }

  #pinModalHint {
    margin-top: 10px;
    margin-bottom: 8px;
  }

  /*------------ Forgot PIN ------------*/
  #forgotPinBtn {
    align-self: center;
    margin-bottom: 15px;
    margin-top: 0;
    padding: 4px 8px;

    border: 0;
    background: transparent;
    color: #245f91;

    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
  }

  #forgotPinBtn:hover,
  #forgotPinBtn:focus-visible {
    text-decoration-thickness: 2px;
  }

  #forgotPinError.hidden {
    display: none;
  }

  /* ===================================================
                    Child Icon PIN
  =================================================== */
  #childPinModal {
    z-index: 20000;
  }

  #childPinModal .modal-content {
    position: relative;
    z-index: 20001;
  }

  .child-pin-modal {
    width: min(520px, calc(100% - 24px));
    max-height: 88vh;
    overflow-y: auto;
    text-align: center;
  }

  .child-pin-slots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin: 18px 0;
  }

  .child-pin-slot {
    width: clamp(42px, 11cqi, 62px);
    height: clamp(47px, 11cqi, 67px);
    border: 2px dashed #9ca3af;
    border-radius: 16px;
    background: #f3f4f6;

    display: grid;
    place-items: center;

    font-size: 30px;
    line-height: 1;
  }

  .child-pin-icon-image {
    width: clamp(40px, 12cqi, 75px);
    padding: 3px;
  }

  .child-pin-slot-image {
    width: clamp(38px, 10cqi, 60px);
    padding: 5px;
  }

  .child-pin-slot.filled {
    border-style: solid;
    border-color: #111827;
    background: #fff;
  }

  .child-pin-icon-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
    margin: 18px 0;
  }

  .child-pin-icon-btn {
    min-width: 48px;
    min-height: 52px;
    border: 2px solid #d1d5db;
    border-radius: 14px;

    display: grid;
    place-items: center;

    line-height: 1;
    cursor: pointer;
    background: #f0f5f5;
    box-shadow:
      0 10px 25px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);
  }

  .child-pin-icon-btn:hover,
  .child-pin-icon-btn:focus-visible {
    border-color: #111827;
    transform: translateY(-1px);
  }

  .child-pin-error {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid #fca5a5;
    border-radius: 12px;
    background: #fee2e2;
    color: #7f1d1d;
    font-weight: 600;
  }

  .child-pin-error.hidden {
    display: none !important;
  }

  .child-pin-shake {
    animation: childPinShake 0.28s ease-in-out;
  }

  @keyframes childPinShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-7px); }
    75% { transform: translateX(7px); }
  }

  @media (max-width: 420px) {
    .child-pin-icon-grid {
      grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .child-pin-slot {
      width: 52px;
      height: 52px;
      font-size: 27px;
    }
  }

  /* =========================
     Buttons (shared)
     ========================= */
  button {
    cursor: pointer;
    border-radius: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    
    border: none;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.4);  
  }

  /*---------- Button Sizes ----------*/
  .btn {                       
    min-height: 50px;
    min-width: 160px;
    padding: 8px 12px;
    font-size: .95rem;
    margin-top: 8px;
    border: 2px solid #000;
  }

  .medium {
    padding: 7px 10px;
    font-size: .9rem;
    min-height: 43px;
    min-width: 125px;
    max-width: 135px;
    border: 2px solid #000;
    margin-bottom: 5px;
  }

   .small {                      
    margin-bottom: 8px;
    padding: 6px 8px;
    font-size: .85rem;
    min-height: 35px;
    min-width: 90px;
    max-width: 135px;
    border: 2px solid #000;
    border-radius: 12px;
  }

  /*---------- Button Colors ----------*/
  .primary { 
    /* Deep Cosmic Purple instead of boring black */
    background: linear-gradient(180deg, #4A154B 0%, #2C062D 100%); 
    color: #FFFFFF; 
    border: 3px solid #1E0020;
    box-shadow: 0 6px 10px rgba(44, 6, 45, 0.4), inset 0 3px 0 rgba(255, 255, 255, 0.3);
  }

  .secondary {
    /* Soft Plum */
    background: linear-gradient(
      180deg, #E8D8F5 0%, #C7A5E3 100%);
    color: #2D163C;
    border: 3px solid #8A63B3;
    box-shadow:
      0 6px 10px rgba(138, 99, 179, 0.28),
      inset 0 3px 0 rgba(255, 255, 255, 0.65);
  }

  .pale {
    /* Warm polished stone */
    color: #3A260F;
    text-shadow:
      0 1px 0 rgba(255, 255, 255, 0.55);

    background: linear-gradient(180deg, #FFF4D5 0%, #D9AE59 100%);
    border:3px solid #7A5528;
    box-shadow:
      0 6px 10px rgba(122,85,40,.35),
      inset 0 3px 0 rgba(255,255,255,.55);
  }

  .blue { 
    /* High-energy Electric Cyan to Deep Blue */
    background: linear-gradient(180deg, #00D2FF 0%, #0066FF 100%); 
    color: #FFFFFF; 
    border: 3px solid #0044CC;
    /* Outer glow shadow + White inner reflection line */
    box-shadow: 0 6px 10px rgba(0, 102, 255, 0.4), inset 0 3px 0 rgba(255, 255, 255, 0.5);
  }

  .green { 
    /* Neon Lime to Rich Emerald */
    background: linear-gradient(180deg, #A3FF00 0%, #10B981 100%); 
    color: #FFFFFF; 
    border: 3px solid #065F46;
    box-shadow: 0 6px 10px rgba(16, 185, 129, 0.4), inset 0 3px 0 rgba(255, 255, 255, 0.6);
  }

  .danger { 
    /* Rocket Blast Orange-Red to Deep Crimson */
    background: linear-gradient(180deg, #FF5E62 0%, #FF1E27 100%); 
    color: #FFFFFF; 
    border: 3px solid #990000;
    box-shadow: 0 6px 10px rgba(255, 30, 39, 0.4), inset 0 3px 0 rgba(255, 255, 255, 0.5);
  }

  .btn:disabled { 
    opacity:0.5; 
    cursor:not-allowed;
    border-color: #999;
    transform: none; 
  }

  .medium:disabled {
    opacity:0.5; 
    cursor:not-allowed;
    border-color: #999;
    transform: none;
  }

  .small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: #999;
    transform: none;
  }

  /* Parent-child style button chrome (borderless + pillier) */
  .btn-pill {
    border: none;
    border-radius: 16px;
    padding: 14px 22px;
    font-size: 1rem;
  }

  .wrap-btn {
    white-space: normal;        /* allow line wrapping */
    overflow-wrap: anywhere;   /* break long words if needed */
    word-break: break-word;
    text-align: center;        /* optional, usually looks better */
  }

  /* ===== Modal layout helpers (generic; safe names) ===== */
  .modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .modal-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex-wrap: wrap;
  }

  .modal-row.left {
    justify-content: flex-start;
  }

  .modal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  /* Reward rows: single column, not two columns */
  .modal-card {
    display: flex;
    flex-direction: column;
    gap: 10px;

    padding: 12px 14px;
    border: 2px solid rgba(0,0,0,0.12);
    border-radius: 16px;
    background: rgba(255,255,255,0.92);
  }

  /* Within a reward row: top line becomes inline */
  .modal-card .reward-top {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
  }

  .modal-card .reward-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
  }

  .modal-card .fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .modal-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
  }

  .modal-inline label {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 0.95rem;
  }

  /* General icon button (usable in modals too) */
  .icon-btn {
    border-radius: 14px;
    padding: 10px 12px;
    cursor: pointer;
    line-height: 1;
    font-size: 18px;
    margin: .5px;
    border: none;
    background: #fff;
  }

  /* Confirm modal buttons: 2 on top, 1 centered below (like checklists) */
  #confirmGenericModal .modal-buttons{
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
  }

  #confirmGenericRightBtn {
    max-width: 160px;
  }

  #confirmGenericTitle {
    font-size: 1.25rem;
  }

  /* ===============================
   Rewards Manager Modal (Grid)
  =============================== */
  #rewardsManagerModal .modal-content input {
    max-width: none;
  }

  #rewardsManagerModal .modal-content {
    overflow: auto;
  }

  .rewards-content {
    margin-bottom: 10px;
    border-radius: 18px;
    padding-top: 15px;
    padding-bottom: 8px;
    padding-left: 10px;
    padding-right: 10px;
    border: 3px dotted #e1e5e5;
    box-shadow:
      0 10px 25px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);
  }

  /* Menu button top-left */
  #rewardsManagerModal .modal-menu-btn {
    position: absolute;
    top: 12px;
    left: 14px;

    width: 36px;
    height: 36px;

    background: transparent;
    border: none;
    border-radius: 50%;

    font-size: 1.5rem;
    line-height: 1;
    color: #555;

    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  }

  #rewardsManagerModal .modal-menu-btn:hover {
    background: rgba(0,0,0,0.08);
    color: #000;
    transform: scale(1.05);
  }

  #rewardsManagerModal .modal-menu-btn:focus-visible {
    outline: 3px solid #000;
    outline-offset: 3px;
  }

  #rewardsManagerModal .addStepBtn {
    padding: 8px 12px;
    width: 250px;
    font-size: .9rem;
  }

  /* Simple menu list */
  #rewardsManagerModal .rewards-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
  }

  /* Grid wrapper */
  #rewardsManagerModal .rewards-grid {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #rewardsManagerModal .rewards-head {
    display: grid;
    grid-template-columns: 42px 64px 30px 1fr 60px; /* shared | cost | emoji | name | archive */
    gap: 4px;
    align-items: center;
  }

  /* Header styling */
  #rewardsManagerModal .rewards-head {
    font-weight: 700;
    font-size: 0.85rem;
    opacity: 0.85;
    padding: 0 4px;

    text-align: left;        /* ✅ important */
    justify-items: stretch;
  }

  /* Align header text to match columns */
  #rewardsManagerModal .rewards-head .h-shared,
  #rewardsManagerModal .rewards-head .h-cost,
  #rewardsManagerModal .rewards-head .h-emoji,
  #rewardsManagerModal .rewards-head .h-arch {
    text-align: center;
  }

  #rewardsManagerModal .rewards-head .h-name {
    text-align: center;
  }

  #rewardsManagerModal .reward-row {
    display: grid;
    grid-template-columns: 38px 55px 44px 1fr 40px; /* shared | cost | emoji | name | archive */
    gap: 4px;
    align-items: center;

    padding: 8px 10px;
    border: 2px solid rgba(0,0,0,0.12);
    border-radius: 14px;
    background: rgba(255,255,255,0.92);
    margin-bottom: 5px;
    background: #fafafa;
    box-shadow:
      0 10px 10px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);
  }

  /* Cells */
  #rewardsManagerModal .cell-center {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #rewardsManagerModal .cell-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
  }

  #rewardsManagerModal .cell-right .icon-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    font-size: min(5cqi, 20px);
    justify-content: center;
  }

  /* Inputs sized for 3-digit cost + small emoji */
  #rewardsManagerModal input.reward-cost {
    width: 60px;
    max-width: 60px;
    text-align: center;
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Make inputs fill their grid tracks (no leftover side space) */
  #rewardsManagerModal .cell-cost input.reward-cost,
  #rewardsManagerModal .cell-emoji input.reward-emoji {
    width: 100%;
    max-width: 100%;
  }

  /* Remove number spinners (Chrome, Edge, Safari) */
  #rewardsManagerModal input[type="number"]::-webkit-inner-spin-button,
  #rewardsManagerModal input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
  }

  /* Remove number spinners (Firefox) */
  #rewardsManagerModal input[type="number"] {
    -moz-appearance: textfield;
  }

  #rewardsManagerModal input.reward-emoji {
    width: 44px;
    max-width: 44px;
    text-align: center;
    padding-left: 6px;
    padding-right: 6px;
    font-size: 18px;
  }

  /* Name uses all remaining space */
  #rewardsManagerModal input.reward-name {
    width: 100%;
    max-width: none;
  }

  /* Checkbox: ensure it’s not tiny on desktop */
  #rewardsManagerModal .cell-shared input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  #rewardsManagerModal .reward-row input {
    margin-bottom: 0 !important;
  }

 /* ===== Rewards: mobile layout (2-row grid) ===== */
  @media (max-width: 510px) {
    #rewardsManagerModal .cell-shared {
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #rewardsManagerModal .cell-shared::after {
      left: 50%;
      transform: translateX(-50%);
      width: auto;
      white-space: nowrap;
    }

    /* Hide the header row on mobile */
    #rewardsManagerModal .rewards-head {
      display: none;
    }

    #rewardsManagerModal .reward-row {
      display: grid;
      grid-template-columns: 44px 55px 40px 1fr 40px;
      grid-template-rows: auto auto;
      row-gap: 6px;
      column-gap: 8px;
      align-items: center;
    }

    /* Place the cells */
    #rewardsManagerModal .cell-shared { grid-column: 1; grid-row: 1; justify-content: center; }
    #rewardsManagerModal .cell-cost   { grid-column: 2; grid-row: 1; }
    #rewardsManagerModal .cell-emoji  { grid-column: 3; grid-row: 1; }

    /* Name spans across (row 2) */
    #rewardsManagerModal .reward-row > :nth-child(4) {  /* name cell */
      grid-column: 1 / 5;
      grid-row: 2;
    }

    /* Archive stays on far right (row 2) */
    #rewardsManagerModal .cell-right {
      grid-column: 5;
      grid-row: 2;
      justify-content: flex-end;
      align-self: center;
    }

    /* Prevent cost/emoji from expanding full-width */
    #rewardsManagerModal input.reward-cost {
      width: 88px;
      max-width: 88px;
      text-align: left;
    }

    #rewardsManagerModal input.reward-emoji {
      width: 56px;
      max-width: 56px;
      text-align: center;
    }

    /* Mobile-only label for shared checkbox */
    #rewardsManagerModal .cell-shared {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    #rewardsManagerModal .cell-shared::after {
      content: "Shared";
      position: absolute;
      top: -16px;
      left: 50%;
      transform: translateX(-50%);
      font-size: 0.72rem;
      opacity: 0.75;
      white-space: nowrap;
      pointer-events: none;
    }
  }

/* =========================
     Child Profile Cards
     ========================= */
 /* Child profile card must be the container */
  .kid-card {
    container-type: inline-size; /* enables cqi units based on THIS card width */
  }

 .kid-grid { 
    justify-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 22vw, 200px), 1fr));
    justify-content: stretch;
    align-items: stretch;
  }

  .kid-card { 
    background: #fff;
    border: 3.5px solid #000;
    border-radius: clamp(12px, 6cqi, 18px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    
    display: flex;
    flex-direction: column;
    padding: clamp(10px, 5cqi, 16px);
    margin-top: 8px;

    gap: 10px;
    position: relative;
    overflow: hidden;

    text-align: center;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    justify-self: center;
    
    width: 100%;
    max-width: 175px;
    aspect-ratio: 6.5 / 8;
    box-sizing: border-box;

    /* gentle scale knob so internals resize with the card */
    --cardScale: 1;
  }

  .kid-card .kid-points,
  .kid-card .kid-sub {
    font-size: clamp(11px, 13cqi, 14px);
    position: absolute;
    bottom: 10px;
    color: #000;
  }

  .kid-card .kid-icon { 
    line-height: 1; 
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: absolute;
  }

  .kid-icon .child-icon-image {
    display: block;
    object-fit: contain;
  }

  .child-icon-image {
    display: block;
    width: 1em;
    height: 1em;
    object-fit: contain;
  }

  .kid-card .kid-name { 
    font-size: clamp(15px, 15cqi, 25px);
    font-weight: 800;
    line-height: 1.2;
    position: absolute;
    bottom: clamp(20px, 28cqi, 45px);
    color: #000;
  }

  .kid-card .kid-stripe {
    position: absolute !important;
    top: 0; left: 0; right: 0;
    height: 18px !important;
  }

  .kid-card .corner-actions {
    position: absolute;
    top: clamp(20px, 13cqi, 25px);            /* sits below stripe nicely with homepage padding */
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    display: inline-flex;
    align-items: center;
  }

  .kid-card .icon-btn {              /*Edit Button & Trashcan*/
    border-radius: clamp(10px, 6cqi, 14px);
    padding: clamp(4px, 4cqi, 10px);
    cursor: pointer;
    line-height: 1;
    font-size: clamp(15px, 15cqi, 30px);
    margin: .5px;
    border: none;
    background: transparent;
    z-index: 1000;
  }

  .kid-card:hover,
  button:not(:disabled):hover {
    transform: scale(1.03) translateY(-3px); /* Bulges outward and floats up slightly */
    filter: brightness(1.1); /* Instantly lights up the candy colors */
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  }

  /*-------- Chore Cards ----------*/
  .chore-grid{
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 22vw, 200px), 1fr));
    justify-content: stretch;
    align-items: stretch;
  }

  .chore-card.filled {
    border: 3px solid #000;
  }

  .chore-card {
    position: relative;
    overflow: hidden;
    container-type: inline-size;
    justify-self: center;

    display: flex;
    flex-direction: column;
    align-items: center;

    width: 100%;                /* grid controls width */
    max-width: 160px;
    aspect-ratio: 7 / 8;    /* keeps your proportion */
    min-width: 0;
    box-sizing: border-box;

    background: #fff;
    border-radius: 24px;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border 0.2s;
    user-select: none;

    /* gentle scale knob so internals resize with the card */
    --cardScale: 1;
  }

  .chore-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;

    flex: 1 1 auto;
    min-height: 0;

    width: 100%;
    padding-top: clamp(6px, 8cqi, 20px);
    padding-bottom: clamp(6px, 3cqi, 12px);
  }

  .chore-card .chore-name {
    font-size: clamp( 10px, 10cqi, 17px );
    color: #000;
    text-align: center;

    position: absolute;
    bottom: clamp(30px, 25cqi, 60px);
    margin-left: 2px;
    margin-right: 2px;

    font-weight: 700;
    line-height: 1.12;

    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
  }

  .chore-card .chore-points{
    position: absolute;
    /* vertical position: scale, but stop */
    bottom: clamp(15px, 12cqi, 30px);
    /* text size: scale, but stop */
    font-size: min(12cqi, 14px);

    line-height: 1.05;
    opacity: 0.9;
    text-align: center;
    width: 100%;
    color: #000;

    pointer-events: none; /* prevents tap conflicts */
  }

  /*------------ Icon size ------------*/
  .chore-card .chore-icon{
    line-height: 1;
  }

  .chore-card .custom .chore-icon {
    font-size: min(32cqi, 55px);
    line-height: 1;
    margin-bottom: min(8cqi, 14px);
  }

  .chore-icon-image {
    display: block;
    width: 1em;
    height: 1em;
    object-fit: contain;
  }

  /*---------- Center Checkmark Overlay ----------*/
  .checkmark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index:5000;
    margin-top: 7px;

    font-size: clamp(3.5rem, 10vw, 6rem);
    font-weight: bold;
    color: #39eb1e;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: scale(0.8);
  }

  .chore-card.selected .checkmark {
    opacity: .8;
    transform: scale(1);
  }

  .chore-card.custom.add-slot {
    background: #f7dcd7;
  }

  /*-------- Card colors ----------*/
  .chore-card.custom {
    background: #FA8072;
  }

  .chore-card.pre-created {
    background: #fff;
  }

  /*---------------- Edit Button ------------------*/
  .edit-btn {
    position: absolute;
    /* position: small scale, hard stop */
    top: clamp(4px, 0.5em, 8px);
    right: clamp(4px, 0.5em, 8px);

    /* size: scale with container, never exceed */
    width: min(18cqi, 28px);
    height: min(18cqi, 28px);

    /* icon size inside */
    font-size: min(15cqi, 25px);
    line-height: 1;

    padding: 0;
    background: none;
    border: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .edit-btn:hover {
    transform: scale(1.1);
  }

  /* -------- Checklist badge (top-left) -------- */
  .checklist-badge,
  .weekly-badge {
    position: absolute;
    top: clamp(4.5px, 0.5em, 8px);

    width: clamp(18px, 15.5cqi, 25px);
    aspect-ratio: 1;

    align-items: center;
    justify-content: center;

    background: transparent;
    border: none;
    border-radius: 0;
    pointer-events: none;
  }

  .checklist-badge .meta-icon-img,
  .weekly-badge .meta-icon-img {
    display: block;

    width: 100%;
    height: 100%;
    object-fit: contain;

    background: transparent;
    border: none;
    border-radius: 0;
    pointer-events: none;
  }

  .weekly-badge {
    display: flex;
    right: clamp(4px, 0.5em, 8px);
  }

  .checklist-badge {
    display: none;
    left: clamp(4px, 0.5em, 8px);
  }

  .chore-card.has-checklist .checklist-badge {
    display: flex;
  }

  /* ---------- Chore Meta Container ---------- */
  .chore-meta{
    display: flex;
    justify-content: center;
    align-items: center;

    width: 100%;

    gap: min(3.5cqi, 15px);
    padding-bottom: min(7cqi, 12px);
    padding-left: 10px;
    padding-right: 10px;
  }

  .chore-meta .meta-btn{
    position: relative;
    background: transparent;
    border: none;
    padding: 0;
    line-height: 1;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: min(22cqi, 50px);
    height: min(20cqi, 50px);

    font-size: min(12cqi, 25px);
  }

  .chore-meta .meta-divider{
    width: 3px;
    background: rgba(0, 0, 0, 0.15);

    height: min(1.5em, 25px);
    margin: 0 min(0.25em, 5px);
  }

  /* The highlight “box” */
  .chore-meta .meta-btn::before{
    content: "";
    position: absolute;
    inset: clamp(
      calc(2px * var(--choreTextScale)),
      calc(0.18em * var(--choreTextScale)),
      calc(4px * var(--choreTextScale))
    );
    border-radius: inherit;
    background: transparent;
    transition: background-color 0.12s ease, transform 0.12s ease;
    pointer-events: none;
  }

  /* Turn highlight on for the selected state(s)
     Keep whichever selector matches your actual state */
  .chore-meta .meta-btn.active::before,
  .chore-meta .meta-btn.selected::before,
  .chore-meta .meta-btn[aria-pressed="true"]::before{
    background: rgba(0, 0, 0, 0.12);
  }

  @media (max-width: 640px){
    .chore-meta .meta-btn.active::before,
    .chore-meta .meta-btn.selected::before,
    .chore-meta .meta-btn[aria-pressed="true"]::before{
      background: rgba(0,0,0,.22);
    }
  }
  
  /*-------- Card hover effects ----------*/
  .chore-card:hover {
    transform: scale(1.05);
    border: 3px solid #000;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
  }

  /*-------- Selected state ----------*/
  .chore-card.selected {
    cursor: default;
    border: 3px solid #000;
  }

  .chore-card.custom.selected {
    background: #fff;
  }

  /*---------- Force gray even when has-checklist is present ----------*/
  .chore-card.pre-created.has-checklist.is-unselected {
    opacity: 0.9;
    filter: grayscale(80%);
  }

  /*---------- Gray-out only pre-created chores when unselected ----------*/
  .chore-card.pre-created.is-unselected, 
    .chore-card.custom.filled.is-unselected {
    opacity: 0.65;
    filter: grayscale(50%);
    transition: none;
    border: none;
  }

  /* Ensure selected wins */
  .chore-card.pre-created.selected {
    opacity: 1;
    filter: none;
  }

  /* ---------- Unselected Card State ---------- */
  /* Visible but muted and non-interactive */
  .chore-card:not(.selected) .meta-btn {
    opacity: 0.35;
    pointer-events: none;
  }

  /* ---------- Selected Card State ---------- */
  .chore-card.selected .meta-btn {
    opacity: 1;
    pointer-events: auto;
  }

  /* Hover (selected only) */
  .chore-card.selected .meta-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(1.08);
  }

  .chore-card.custom:not(.filled) {
    cursor: pointer;
  }

  .chore-card.custom.filled {
    cursor: pointer;
  }

  /* ---------- Active / Selected Meta State ---------- */
  .meta-btn.active {
    background: rgba(0, 0, 0, 0.18);
    transform: scale(1.12);
  }

  /* ---------- Frequency Buttons (slightly stronger emphasis) ---------- */
  .meta-btn.freq.active {
    background: rgba(0, 0, 0, 0.25);
  }

  /* ---------- Accessibility ---------- */
  .meta-btn:focus {
    outline: none;
  }

  .meta-btn:focus-visible {
    outline: 2px solid #000;
    outline-offset: 2px;
  }

  /* ========== Appearance Wizard ==========*/
  .wizard-btn {
    cursor: pointer;
    padding: 12px 14px;
    border: 2px solid #000;
    font-size: .85rem;
    background: #caccca;
    max-height: 10px;
    margin-top: 3px;
    margin-bottom: 3px;
    justify-self: start;
  }

  .wizard-btn-secondary {
    color: #000;
    justify-self: flex-end;
    border: 2px solid #000;
  }

  .btnrow {
    align-items: center;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .wizard-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(0,0,0,0.15);
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }

  .wizard-footer-left,
  .wizard-footer-right {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .wizard-btn:not(:disabled):hover {
    filter: brightness(0.95);
  }

  /* Icon chooser */
  .wzdIconGrid {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px !important;
    margin-top: 10px;
    padding: 4px;
    box-sizing: border-box;
  }

  .wzdIconBtn {
    margin: 3px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;
    border-color: #fff;
    background: #fafafa;
    box-shadow:
      0 10px 25px rgba(0,0,0,.15),
      inset 0 1px rgba(255,255,255,.8);
  }

  .wzdIconImage {
    display: block;

    width: 90%;
    height: 90%;

    object-fit: contain;
    pointer-events: none;
  }

  .wzdIconBtn.selected {
    outline: 3.5px solid #111827;
    outline-offset: 2px;
  }

  /* Theme swatches */
  .themeGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
  }

  .themeCard {
    border: 1.5px solid #e6e8ee;
    border-radius: 12px;
    cursor: pointer;
    overflow: hidden;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 4px;
    box-sizing: border-box;
    margin: 5px;
  }

  .themeCard.selected {
    outline: 3.5px solid #111827;
    outline-offset: 2px;
  }

  .swatchPreview {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    border-radius: 0;
    padding: 10px;
  }

  .swatchRow {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .swatchBox {
    border: none;
    border-radius: 6px;
    padding: 0;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
  }

  .wizard-error {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #fecaca;
    background: #fee2e2;
    color: #7f1d1d;
    font-size: 0.95rem;
    text-align: left;
  }

  .wizard-error.hidden {
    display: none !important;
  }

  .child-customize-wizard {
    width: min(520px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .child-customize-wizard .wizard-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
    flex: 1 1 auto;
  }

  /* --- Wizard modal scrolling fix --- */
  #childWizardModal {
    position: fixed;
    inset: 0;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #childWizardModal .modal-content.child-wizard {
    width: min(520px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;           /* important: body scrolls, not the whole box */
    z-index: 20000;
    gap: 0;
  }

  /* The scrollable area */
  #childWizardModal .wizard-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;         /* avoids scrollbar overlay */
    flex: 1 1 auto;
  }

  #childWizardHint {
    margin: 5px;
  }

  @media (max-width: 420px) {
    .swatchBox {
      height: 32px;
      font-size: 11px;
    }

    .wzdIconGrid {
      grid-template-columns: repeat(3, minmax(0, 1fr));
    }
  }

  @media (max-width: 480px) {
    .wizard-footer {
      gap: 10px;
    }

    .kid-card {
      width: 100%; /* fill the column */
    }

    .wizard-footer {
      gap: 10px;
    }
  }

/* =========================
   Shared text helpers
   ========================= */
  .muted {
    color: #6b7280;
    font-size: 13px;
  }

  .pin-error {
    color: #e11d48;           /* rose / pink-red */
    font-weight: 600;
  }

  .hidden { display: none !important; }

  .show { display: flex; }

  .modal.show { display:flex; }
  .modal.hidden { display: none !important; }

  .offline-banner {
    background: #fee2e2;
    color: #7f1d1d;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 14px;
  }

  .offline-banner.hidden {
    display: none;
  }
  
  .offline-banner.offline {
    background: #fee2e2;
    color: #7f1d1d;
  }

  .offline-banner.online {
    background: #dcfce7;
    color: #14532d;
  }

/* ====================================
          Inactivity Timeout
==================================== */
.inactivity-notice {
  position: fixed;
  inset: 0;
  z-index: 40000;

  display: grid;
  place-items: center;

  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
}

.inactivity-notice.hidden {
  display: none;
}

.inactivity-notice-card {
  width: min(100%, 420px);
  padding: 28px;

  text-align: center;

  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.25);
}

.inactivity-notice-card h2 {
  margin: 0 0 12px;
}

.inactivity-notice-card p {
  margin: 8px 0;
}

#stayOnPageBtn {
  margin-top: 16px;
}

/*======================================
      Bug Report Footer on each page
======================================*/
  .beta-footer {
    margin-top: 28px;
    padding-bottom: 20px;
    text-align: center;
  }

  /* The visible background lives HERE */
  .beta-links {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 30px; 

    background: #fff;
    backdrop-filter: blur(4px);

    font-size: 0.85rem;
  }

  .beta-bug-link {
    color: #b91c1c;
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.2px;
  }

  .beta-bug-link:hover {
    text-decoration: underline;
    opacity: 1;
  }

  .beta-feedback-link {
    color: #2563eb; /* calm blue contrast */
    font-weight: 600;
    text-decoration: none;
  }

  .beta-feedback-link:hover {
    text-decoration: underline;
    opacity: 1;
  }

  /* =========================
      Beta footer divider
   ========================= */
  .beta-footer {
    margin-top: 28px;
    padding: 16px 8px 18px;
    text-align: center;
    font-size: 1rem;
    opacity: 0.78;
    position: relative;
  }

  /* Soft divider line above footer */
  .beta-footer::before {
    content: "";
    display: block;
    width: min(420px, 80%);
    height: 3px;
    margin: 0 auto 14px;
    background: linear-gradient(
      to right,
      transparent,
      rgba(0, 0, 0, 0.18),
      transparent
    );
  }

  @media (max-width: 600px) {
    .modal input,
    .modal select,
    .modal textarea {
      font-size: 16px !important;
    }
  }

  /* ========= Stack wizard buttons on small modal widths ========= */
  @media (max-width: 488px) {

    /* Common “footer row” patterns across your wizards */
    .modal .modalFooter.modal-actions.row,
    .modal .modal-actions.row,
    .modal .modal-row,
    .modal .modal-buttons {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      gap: 10px;
    }
  }


