  /* Theme colors. The Settings tab overrides the primary and secondary values at runtime (app.js). */
  :root {
    --primary: #d6578a;
    --primary-rgb: 214, 87, 138;
    --primary-light: #de79a1;
    --primary-soft: #f2ccdb;
    --primary-mid: #e9a3bf;
    --primary-line: #f0c2d3;
    --primary-blush: #fde7ef;
    --primary-faint: #fff7fa;

    --secondary: #8e6bbf;
    --secondary-rgb: 142, 107, 191;
    --secondary-tint: #f1e8ff;
    --secondary-faint: #fbf6ff;

    --cream: #fffafc;
    --ink: #4d2a40;
    --muted: #8a6478;
    --white: #ffffff;
  }

  * { box-sizing: border-box; }
  html, body { margin: 0; }

  body {
    font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
    color: var(--ink);
    background-color: var(--primary-blush);
    background-image: linear-gradient(180deg, var(--primary-blush) 0%, var(--secondary-faint) 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }

  [hidden] { display: none !important; }

  .wrap { max-width: 1120px; margin: 0 auto; padding: 16px 16px 130px; }

  /* ---------- Hero ---------- */
  .hero { text-align: center; padding: 14px 0 4px; }
  .flower { width: 52px; height: 52px; display: inline-block; }
  .flower .petal { fill: var(--primary-soft); }
  .flower .center { fill: var(--primary); }
  .hero h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(28px, 7vw, 40px);
    margin: 4px 0 2px;
    color: var(--primary);
  }
  .hero .sub {
    margin: 0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--secondary);
  }
  .hero .hint { margin: 12px 0 0; font-size: 14px; color: var(--muted); }

  /* ---------- Shared bits ---------- */
  .card {
    background: var(--white);
    border: 1.5px solid var(--primary-line);
    border-radius: 24px;
    box-shadow: 0 10px 26px -14px rgba(var(--primary-rgb), 0.45);
    padding: 18px;
  }
  .section-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 21px;
    margin: 26px 4px 12px;
  }

  /* ---------- Progress ---------- */
  .progress { margin: 26px 0 4px; }
  .progress-track {
    height: 12px;
    background: var(--primary-blush);
    border: 1px solid var(--primary-line);
    border-radius: 999px;
    overflow: hidden;
  }
  .progress-fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary-light), var(--primary));
    transition: width 0.35s ease;
  }
  .progress-text {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
  }

  /* ---------- Tabs ---------- */
  .tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin: 22px auto 0;
    padding: 5px;
    width: fit-content;
    max-width: 100%;
    background: var(--white);
    border: 1.5px solid var(--primary-line);
    border-radius: 999px;
    box-shadow: 0 8px 20px -14px rgba(var(--primary-rgb), 0.5);
  }
  .tab {
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    min-height: 44px;
    padding: 10px 24px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
  }
  .tab[aria-selected="true"] {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 6px 14px -6px rgba(var(--primary-rgb), 0.8);
  }
  .tab:focus-visible { outline: 3px solid rgba(var(--primary-rgb), 0.4); outline-offset: 2px; }

  /* ---------- Form fields ---------- */
  .fields { display: grid; grid-template-columns: 1fr; gap: 14px; }
  @media (min-width: 640px) { .fields { grid-template-columns: 1fr 1fr; } }
  .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }
  .field input,
  .field textarea,
  .field select {
    width: 100%;
    font: inherit;
    font-size: 16px; /* 16px stops iOS from zooming on focus */
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    color: var(--ink);
    background: var(--cream);
    border: 1.5px solid var(--primary-line);
    border-radius: 14px;
    padding: 12px 14px;
    min-height: 48px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .field textarea { resize: vertical; min-height: 92px; }
  .field input:focus,
  .field textarea:focus,
  .field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15);
  }

  /* ---------- Day cards ---------- */
  .days { display: grid; grid-template-columns: 1fr; gap: 14px; }
  @media (min-width: 720px) { .days { grid-template-columns: 1fr 1fr; } }
  @media (min-width: 1040px) { .days { grid-template-columns: 1fr 1fr 1fr; } }
  /* Tilawah has one row, so its card spans the full width. */
  #panel-tilawah .days { grid-template-columns: 1fr; }

  .day { padding: 0; overflow: hidden; }
  .day-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(90deg, var(--primary-blush), var(--secondary-tint));
    border-bottom: 1.5px solid var(--primary-line);
  }
  .day-name {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 19px;
    font-weight: 700;
  }
  .day-num {
    margin-left: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--white);
    font-size: 12px;
    font-weight: 800;
    color: var(--secondary);
  }
  .day-count { font-size: 13px; font-weight: 800; color: var(--primary); }

  .tasks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
  .task {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 8px 10px;
    border: 1.5px solid var(--primary-line);
    border-radius: 16px;
    background: var(--cream);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s, border-color 0.2s, transform 0.1s;
  }
  .task:active { transform: scale(0.98); }
  .task:focus-within { box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.3); }
  .task input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .box {
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 2px solid var(--primary-mid);
    border-radius: 9px;
    background: var(--white);
    color: transparent;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
  }
  .task.on { background: linear-gradient(135deg, var(--primary-blush), var(--secondary-tint)); border-color: var(--primary); }
  .task.on .box { background: var(--primary); border-color: var(--primary); color: #fff; }

  /* Tilawah Page No field (inside the row header) */
  .row-page {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
  }
  .row-page span {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
  }
  .row-page input {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    background: var(--white);
    border: 1.5px solid var(--primary-line);
    border-radius: 12px;
    padding: 8px 12px;
    min-height: 40px;
    outline: none;
  }
  .row-page input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.15);
  }

  /* ---------- Notices and settings ---------- */
  .notice {
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--muted);
    padding: 24px 18px;
  }
  .notice strong { color: var(--primary); }

  .settings-card { margin-top: 0; }
  .setting { display: flex; flex-direction: column; gap: 8px; }
  .setting + .setting { margin-top: 18px; }
  .setting-label { font-weight: 800; font-size: 15px; }
  .setting-help { font-size: 13px; color: var(--muted); margin: 0; }
  .color-row { display: flex; align-items: center; gap: 12px; }
  .color-row input[type="color"] {
    width: 56px;
    height: 44px;
    padding: 0;
    border: 1.5px solid var(--primary-line);
    border-radius: 12px;
    background: none;
    cursor: pointer;
  }
  .color-row code { font-size: 14px; font-weight: 700; color: var(--muted); }
  .setting select { max-width: 320px; }

  .comment-card { margin-top: 18px; }
  .comment-card .field textarea { min-height: 110px; }

  .foot {
    margin: 22px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
  }

  /* ---------- Sticky action bar ---------- */
  .actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--primary-blush);
    border-top: 1px solid var(--primary-line);
  }
  .btn {
    font: inherit;
    font-size: 15px;
    font-weight: 800;
    border-radius: 999px;
    padding: 13px 20px;
    min-height: 48px;
    cursor: pointer;
    border: 0;
  }
  .btn-primary {
    flex: 1;
    max-width: 320px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    box-shadow: 0 8px 18px -8px rgba(var(--primary-rgb), 0.8);
  }
  .btn-ghost {
    color: var(--primary);
    background: var(--white);
    border: 1.5px solid var(--primary-soft);
  }
  .btn:disabled { opacity: 0.6; cursor: wait; }
  .btn:focus-visible { outline: 3px solid rgba(var(--primary-rgb), 0.4); outline-offset: 2px; }

  /* ---------- Export sheet (captured as the image) ----------
     Kept off-screen. Fixed desktop width so the PNG always matches
     the printed PDF layout, no matter the phone or screen size. */
  .sheet-wrap { position: absolute; left: -12000px; top: 0; }
  .sheet {
    width: 1100px;
    padding: 44px 48px 40px;
    background: var(--cream);
    color: #3b1f30;
    font-family: 'Nunito', sans-serif;
    border: 10px solid var(--primary-soft);
    border-radius: 28px;
  }
  .sheet-title { text-align: center; }
  .sheet-title .flower { width: 46px; height: 46px; }
  .sheet-title h1 {
    margin: 4px 0 0;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 40px;
    color: var(--primary);
  }
  .sheet-title h2 {
    margin: 6px 0 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--secondary);
  }
  .sheet-hint { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }
  .sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--white); }
  .sheet th,
  .sheet td {
    border: 1.5px solid var(--primary-mid);
    text-align: center;
    vertical-align: middle;
  }
  .sheet th {
    padding: 12px 6px;
    background: var(--primary-blush);
    font-size: 15px;
    font-weight: 800;
    line-height: 1.25;
  }
  .sheet th:first-child { width: 150px; }
  .sheet td { height: 52px; }
  .sheet td.day-cell { font-size: 15px; font-weight: 800; background: var(--primary-faint); }
  .sheet .box { margin: 0 auto; color: transparent; }
  .sheet .box.on { background: var(--primary); border-color: var(--primary); color: #fff; }

  .sheet-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 40px;
    margin-top: 28px;
    font-size: 16px;
  }
  .sheet-info .f { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
  .sheet-info .lbl { font-weight: 800; white-space: nowrap; }
  .sheet-info .val {
    flex: 1;
    min-height: 26px;
    padding: 0 4px 2px;
    font-weight: 600;
    border-bottom: 1.5px dashed var(--primary-mid);
    overflow-wrap: anywhere;
  }
  .sheet-info .wide { grid-column: 1 / -1; }

  /* ---------- Print preview ----------
     Prints only the sheet, styled like the downloadable image, filling the
     page width and centered. Landscape A4: one sheet per page. Portrait A4:
     two sheets stacked on one page. Type and row heights are tightened so the
     sheet fits the page height. The print dialog decides the orientation. */
  @media print {
    @page { margin: 6mm; }

    * {
      -webkit-print-color-adjust: exact;
      print-color-adjust: exact;
    }

    body { background: var(--cream); }
    .wrap,
    .actions { display: none !important; }

    .sheet-wrap {
      position: static;
      left: auto;
      width: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    .sheet {
      width: 100%;
      padding: 20px 24px;
      border: none;
      border-radius: 0;
      box-shadow: none;
      break-inside: avoid;
    }

    .sheet-title .flower { width: 36px; height: 36px; }
    .sheet-title h1 { font-size: 32px; }
    .sheet-title h2 { margin-top: 4px; font-size: 15px; }
    .sheet-hint { margin: 12px 0 6px; font-size: 14px; }

    .sheet th { padding: 8px 6px; font-size: 14px; }
    .sheet th:first-child { width: 150px; }
    .sheet td { height: 42px; }
    .sheet td.day-cell { font-size: 14px; }
    .sheet .box { width: 22px; height: 22px; font-size: 13px; }

    .sheet-info { margin-top: 18px; gap: 10px 32px; font-size: 15px; }
    .sheet-info .val { min-height: 22px; }

    .sheet-copy { display: none; }
    .sheet-wrap:not(.is-active) { display: none; }
  }

  @media print and (orientation: portrait) {
    .sheet { padding: 16px 20px; }
    .sheet-title h1 { font-size: 26px; }
    .sheet th { padding: 6px 4px; font-size: 13px; }
    .sheet th:first-child { width: 110px; }
    .sheet td { height: 24px; }
    .sheet td.day-cell { font-size: 13px; }
    .sheet .box { width: 20px; height: 20px; font-size: 12px; }
    .sheet-info { margin-top: 12px; gap: 8px 24px; font-size: 14px; }
    .sheet-info .val { min-height: 20px; }

    .sheet-copy {
      display: block;
      margin-top: 10mm;
    }
  }
