body { min-height: 100vh; }
.app-shell { width: 100%; max-width: 560px; min-height: 100dvh; margin: 0 auto; background: var(--background); }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(env(safe-area-inset-top) + 18px) 22px 17px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); }
.topbar .eyebrow { margin-bottom: 3px; }
.avatar-button { width: 42px; height: 42px; border: 0; border-radius: 15px; background: var(--accent-soft); color: var(--accent-dark); font-weight: 800; }
main { padding: 21px 18px calc(100px + env(safe-area-inset-bottom)); }
.view { display: none; animation: appear .18s ease; }
.view.active { display: block; }
@keyframes appear { from { opacity: .5; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.greeting-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 17px; }
.greeting-row .muted { margin-bottom: 5px; font-size: 12px; }
.greeting-row h2 { font-size: 23px; }
.progress-card { padding: 19px; }
.card-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.card-heading .muted { margin-bottom: 5px; font-size: 12px; }
.big-number { font-size: 34px; letter-spacing: -1.5px; }
.progress-ring { display: grid; width: 66px; height: 66px; place-items: center; border-radius: 50%; background: conic-gradient(var(--accent) 0deg, #f1f1f3 0deg); position: relative; }
.progress-ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: white; }
.progress-ring span { position: relative; z-index: 1; font-size: 11px; font-weight: 800; }
.progress-card .split-meta { margin-top: 12px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { min-width: 0; padding: 15px; }
.stat-icon { display: inline-grid; width: 29px; height: 29px; place-items: center; margin-bottom: 12px; border-radius: 10px; color: var(--accent-dark); background: var(--accent-soft); font-weight: 900; }
.stat-card .muted { margin-bottom: 5px; font-size: 11px; }
.stat-card strong { font-size: 24px; letter-spacing: -.8px; }
.stat-card small { margin-left: 3px; color: var(--muted); font-size: 12px; }
.task-list { display: grid; gap: 9px; }
.task-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 13px; border: 1px solid var(--line); border-radius: 15px; background: white; color: var(--ink); text-align: left; }
.task-check { flex: 0 0 23px; display: grid; width: 23px; height: 23px; place-items: center; border: 1.5px solid #d6d7db; border-radius: 8px; color: white; font-size: 13px; }
.task-row.completed .task-check { border-color: var(--success); background: var(--success); }
.task-main { flex: 1; min-width: 0; }
.task-name { display: block; overflow: hidden; font-size: 13px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.task-sub { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.task-points { color: var(--accent-dark); font-size: 11px; font-weight: 800; white-space: nowrap; }
.task-row.completed .task-name { color: #858991; text-decoration: line-through; }
.full-button { margin-top: 17px; }
.full-button span { float: right; font-size: 18px; line-height: 1; }
.page-heading { margin: 2px 2px 20px; }
.page-heading .eyebrow, .page-heading .muted:first-child { margin-bottom: 7px; }
.page-heading h2 { margin-bottom: 5px; }
.page-heading p:last-child { margin-bottom: 0; font-size: 12px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: #ececef; }
.segment { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: #737780; font-size: 13px; font-weight: 750; }
.segment.active { background: white; color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.session-date { padding: 14px 2px 12px; color: var(--muted); font-size: 12px; }
.category-block { margin-bottom: 22px; }
.category-heading { display: flex; justify-content: space-between; align-items: center; margin: 3px 2px 10px; }
.category-heading h3 { font-size: 15px; }
.category-heading span { color: var(--muted); font-size: 11px; }
.team-progress-card { padding: 18px; }
.team-progress-card .progress-track { margin: 14px 0 10px; }
.team-progress-card .muted { margin-bottom: 0; }
.points-hero { padding: 24px 20px; background: linear-gradient(135deg,#fff 30%,#fff4eb); }
.points-hero .muted { margin-bottom: 7px; font-size: 12px; }
.points-total { display: flex; align-items: baseline; gap: 5px; margin-bottom: 8px; }
.points-total span { font-size: 48px; font-weight: 850; letter-spacing: -2px; }
.points-total small { color: var(--accent-dark); font-size: 17px; font-weight: 800; }
.history-list { display: grid; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: white; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-title { font-size: 13px; font-weight: 700; }
.history-date { margin-top: 4px; color: var(--muted); font-size: 10px; }
.history-points { color: var(--success); font-size: 13px; font-weight: 800; white-space: nowrap; }
.empty-state { padding: 25px 16px; color: var(--muted); font-size: 12px; text-align: center; background: white; border: 1px dashed #dedfe3; border-radius: 15px; }
.bottom-nav { position: fixed; z-index: 10; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5,1fr); max-width: 560px; margin: 0 auto; padding: 9px 7px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(16px); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 48px; padding: 2px 0; border: 0; background: transparent; color: #92959c; font-size: 9px; font-weight: 650; }
.nav-icon { font-size: 21px; line-height: 1; }
.nav-item.active { color: var(--accent-dark); }
.nav-item.active .nav-icon { transform: translateY(-1px); }
.admin-card { margin-bottom: 13px; padding: 17px; }
.admin-card h3 { margin-bottom: 13px; }
.field-label { display: block; margin: 12px 0 7px; color: #565a62; font-size: 12px; font-weight: 700; }
.text-input { display: block; width: 100%; min-height: 45px; padding: 10px 12px; border: 1px solid #e0e1e5; border-radius: 12px; background: #fff; color: var(--ink); font-size: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }
.form-field { min-width: 0; }
.admin-card .tiny { margin: 10px 0 0; }
.toast { position: fixed; z-index: 50; right: 20px; bottom: calc(88px + env(safe-area-inset-bottom)); left: 20px; max-width: 520px; margin: 0 auto; padding: 13px 16px; border-radius: 13px; background: #22252b; color: white; font-size: 12px; text-align: center; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s ease; }
.toast.show { opacity: 1; transform: none; }
.task-dialog { width: calc(100% - 32px); max-width: 430px; padding: 0; border: 0; border-radius: 22px; box-shadow: 0 20px 70px rgba(0,0,0,.2); }
.task-dialog::backdrop { background: rgba(20,22,26,.45); backdrop-filter: blur(3px); }
.dialog-content { position: relative; padding: 25px 20px 20px; }
.dialog-close { position: absolute; top: 13px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 11px; background: #f2f2f4; color: #555; font-size: 23px; }
.dialog-content h2 { padding-right: 30px; font-size: 22px; }
.dialog-content .muted { font-size: 13px; line-height: 1.7; }
.dialog-meta { display: flex; gap: 7px; margin: 16px 0; }
@media (min-width: 561px) {
  body { padding: 20px 0; }
  .app-shell { min-height: calc(100dvh - 40px); border-radius: 24px; overflow: hidden; box-shadow: 0 10px 50px rgba(0,0,0,.08); }
  .bottom-nav { bottom: 20px; border-radius: 0 0 24px 24px; }
}


/* Category accordion and template ordering controls */
.category-block { overflow: hidden; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.category-heading { display: flex; width: 100%; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 13px; border: 0; background: #fff; color: var(--ink); text-align: left; }
.category-heading-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.category-heading-main > span:last-child { display: grid; gap: 4px; min-width: 0; }
.category-heading-main strong { font-size: 14px; }
.category-heading-main small { color: var(--muted); font-size: 10px; line-height: 1.35; overflow-wrap: anywhere; }
.category-index { display: grid; flex: 0 0 32px; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent-dark); font-size: 11px; font-weight: 800; }
.category-heading-meta { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.category-chevron { color: var(--accent-dark); font-size: 16px; }
.category-task-list { padding: 0 10px 10px; }
.category-task-list[hidden] { display: none !important; }
.category-task-list .task-list { gap: 7px; }
.template-filter-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 12px 0; }
.template-filter { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; border: 1px solid var(--line); border-radius: 12px; background: #f7f7f8; color: #666; font-size: 12px; font-weight: 750; }
.template-filter.active { border-color: #fed7aa; background: var(--accent-soft); color: var(--accent-dark); }
.template-filter span { display: inline-grid; min-width: 20px; height: 20px; place-items: center; padding: 0 5px; border-radius: 999px; background: rgba(0,0,0,.06); font-size: 10px; }
.template-list { display: grid; gap: 8px; }
.template-group-heading { margin: 12px 2px 3px; color: #666; font-size: 11px; font-weight: 800; }
.template-item { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.template-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.template-item-copy { min-width: 0; flex: 1; }
.template-item-copy .history-title { overflow-wrap: anywhere; line-height: 1.45; }
.template-meta { margin-top: 5px; color: var(--muted); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.template-switch { display: flex; flex: 0 0 42px; width: 42px; height: 25px; align-items: center; padding: 3px; border: 0; border-radius: 999px; background: #d1d5db; }
.template-switch span { width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .15s ease; }
.template-switch.is-on { background: #f97316; }
.template-switch.is-on span { transform: translateX(17px); }
.template-actions { display: flex; align-items: center; gap: 7px; margin-top: 11px; }
.template-actions button { min-height: 34px; padding: 7px 10px; border: 0; border-radius: 9px; background: #f3f4f6; color: #4b5563; font-size: 11px; font-weight: 750; }
.template-actions .template-order-button { width: 34px; padding: 0; font-size: 16px; }
.template-actions button:disabled { opacity: .3; }
.task-order-row { grid-template-columns: 95px minmax(0,1fr); }
@media (max-width: 360px) {
  .category-heading { padding: 12px 10px; }
  .category-heading-main { gap: 7px; }
  .category-heading-main strong { font-size: 13px; }
  .category-heading-main small { max-width: 145px; }
  .template-actions { gap: 5px; }
  .template-actions button { padding: 7px 8px; }
}

.category-heading .category-index { color: var(--accent-dark); font-size: 11px; }

/* Mobile layout fixes: keep the navigation clear of the Netlify preview badge
   and allow long checklist names to wrap onto multiple lines. */
@media (max-width: 560px) {
  .bottom-nav {
    bottom: calc(76px + env(safe-area-inset-bottom));
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
  }
  main {
    padding-bottom: calc(176px + env(safe-area-inset-bottom));
  }
}
.task-name {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  line-height: 1.45;
}
.task-row {
  min-width: 0;
}
.task-points {
  flex-shrink: 0;
}


/* Robust phone-width override: also works when iOS Safari requests desktop layout. */
@media (max-device-width: 600px) {
  html, body { width: 100% !important; max-width: 100% !important; overflow-x: clip !important; }
  #app.app-shell { width: 100% !important; max-width: 100% !important; min-width: 0 !important; margin: 0 !important; overflow-x: clip !important; }
  main, .view, .task-list, .task-row, .task-main { min-width: 0 !important; max-width: 100% !important; }
  main { padding-left: 14px !important; padding-right: 14px !important; }
  .task-row { display: flex !important; width: 100% !important; gap: 9px !important; }
  .task-main { flex: 1 1 0 !important; }
  .task-name { display: block !important; white-space: normal !important; overflow: visible !important; text-overflow: clip !important; overflow-wrap: anywhere !important; word-break: normal !important; line-height: 1.45 !important; }
  .task-points { flex: 0 0 auto !important; white-space: nowrap !important; }
  /* Main navigation is opened from the hamburger button beside Login. */
  .bottom-nav { display: none !important; }
  body.menu-open .bottom-nav { position: fixed !important; z-index: 30 !important; top: calc(env(safe-area-inset-top) + 76px) !important; right: max(12px, calc((100vw - 536px) / 2)) !important; bottom: auto !important; left: auto !important; width: min(220px, calc(100vw - 24px)) !important; max-width: 220px !important; display: flex !important; flex-direction: column !important; gap: 4px !important; padding: 8px !important; border: 1px solid var(--line) !important; border-radius: 16px !important; box-shadow: 0 8px 28px rgba(0,0,0,.15) !important; }
  body.menu-open .nav-item { width: 100% !important; min-height: 44px !important; flex-direction: row !important; justify-content: flex-start !important; gap: 10px !important; padding: 8px 12px !important; font-size: 13px !important; }
  body.menu-open .nav-icon { width: 24px; font-size: 19px !important; }
  main { padding-bottom: calc(30px + env(safe-area-inset-bottom)) !important; }
}

/* Checklist task points doubled in size; method button sits beneath each task. */
.task-points { font-size: 22px !important; line-height: 1.15; }
.task-row-wrap { display: grid; gap: 6px; min-width: 0; }
.task-row-wrap .task-row { width: 100%; }
.task-method-button { justify-self: end; min-height: 32px; padding: 5px 12px; border: 1px solid var(--accent); border-radius: 9px; background: #fff7f1; color: var(--accent-dark); font-size: 12px; font-weight: 750; }
.method-dialog-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.7; color: var(--ink); font-size: 14px; }
@media (max-device-width: 600px) { .task-points { font-size: 22px !important; } .task-method-button { min-height: 36px; font-size: 13px; } }

.topbar-actions { display:flex; align-items:center; gap:7px; }
.team-view-label { font-size:11px; color:var(--muted); white-space:nowrap; }
.team-view-select { max-width:105px; min-height:38px; padding:7px 8px; border:1px solid var(--line); border-radius:11px; background:#fff; color:var(--ink); font-size:12px; font-weight:700; }
@media (max-width:380px) { .team-view-label { display:none; } .topbar { padding-left:14px; padding-right:14px; } }

/* Requested mobile UI: compact right-top navigation and method action inside each task card. */
@media (max-device-width: 600px) {
  .bottom-nav { display: none !important; }
}

/* Keep the checklist action button within the same bordered card as its task. */
.task-row-wrap {
  display: flex !important;
  align-items: stretch !important;
  gap: 0 !important;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
}
.task-row-wrap .task-row {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 13px 9px 13px 12px !important;
}
.task-row-wrap .task-method-button {
  flex: 0 0 auto;
  align-self: center;
  justify-self: auto;
  margin: 0 9px 0 3px;
  min-height: 34px;
  padding: 5px 8px;
  white-space: nowrap;
  font-size: 11px;
}
@media (max-device-width: 600px) {
  .task-row-wrap .task-method-button { margin-right: 8px; padding: 5px 7px; font-size: 11px; }
  .task-row-wrap .task-points { font-size: 18px !important; }
}

/* Ensure the home-screen login label stays fully inside its button on mobile. */
.topbar-actions { min-width: 0; flex-shrink: 0; }
.avatar-button {
  display: inline-flex;
  width: auto;
  min-width: 68px;
  max-width: 92px;
  min-height: 42px;
  padding: 0 12px;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  white-space: nowrap;
  line-height: 1.2;
  font-size: 13px;
  overflow: visible;
}
@media (max-width: 380px) {
  .topbar-actions { gap: 5px; }
  .team-view-select { max-width: 92px; padding-left: 6px; padding-right: 6px; }
  .avatar-button { min-width: 64px; padding: 0 9px; font-size: 12px; }
}

/* Hamburger menu sits directly beside the login/profile button in the header. */
.menu-toggle { display:inline-flex; flex:0 0 42px; width:42px; height:42px; padding:10px 9px; flex-direction:column; align-items:center; justify-content:center; gap:4px; border:1px solid var(--line); border-radius:13px; background:#fff; color:var(--ink); }
.menu-toggle span { display:block; width:21px; height:2px; border-radius:2px; background:currentColor; }
.menu-toggle[aria-expanded="true"] { border-color:#fed7aa; background:var(--accent-soft); color:var(--accent-dark); }
@media (max-width:380px) { .menu-toggle { flex-basis:38px; width:38px; height:40px; padding:8px; } }

/* Logged-out visitors can see only the public home banner; no demo data or navigation. */
body.logged-out #view-home > :not(#publicBannerWrap) { display: none !important; }
body.logged-out #view-home { min-height: 55vh; }
body.logged-out .bottom-nav [data-nav]:not([data-nav="home"]) { display: none !important; }
body.logged-out #menuToggle { display: none !important; }
body.logged-out .public-banner-wrap { display: block; margin: 18px auto; }
body.logged-out .public-banner-wrap[hidden] { display: none !important; }
.method-guide-image { display:block; width:100%; max-width:100%; height:auto; object-fit:contain; border-radius:12px; margin-top:12px; }
#profileSetupForm .text-input { width:100%; box-sizing:border-box; margin:6px 0 14px; }
