:root {
  --bg: #fff7ed;
  --card: rgba(255,255,255,.94);
  --text: #2d1b4e;
  --muted: #7c6f8b;
  --primary: #7c3aed;
  --pink: #ec4899;
  --primary-light: #ede9fe;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #f59e0b;
  --border: #eadff5;
  --shadow: 0 16px 38px rgba(80, 35, 130, 0.11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, #fde68a 0, transparent 28%),
    radial-gradient(circle at top right, #ddd6fe 0, transparent 26%),
    var(--bg);
  color: var(--text);
}

.app-shell { width: min(1180px, 94vw); margin: 18px auto; }

.hero {
  background: linear-gradient(135deg, var(--primary), var(--pink));
  color: white;
  border-radius: 24px;
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  animation: rise .28s ease both;
}

.eyebrow {
  margin: 0 0 8px;
  opacity: .85;
  font-weight: 850;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
}

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: .95;
  margin-bottom: 8px;
}

.subtitle { margin-bottom: 0; font-size: 15px; opacity: .92; }

.level-card {
  width: 150px;
  min-height: 112px;
  border-radius: 22px;
  background: rgba(255,255,255,.22);
  display: grid;
  place-items: center;
  padding: 12px;
  text-align: center;
  flex: 0 0 auto;
}

.level-card span { font-size: 36px; }
.level-card strong { display: block; font-size: 15px; }
.level-card small { opacity: .9; }

.xp-panel, .summary-card, .parent-panel, .task-card, .settings-card {
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.xp-panel { padding: 16px; margin: 14px 0; animation: rise .32s ease both; }

.xp-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.xp-top strong { font-size: 17px; }
.xp-top p { color: var(--muted); margin: 4px 0 0; font-weight: 800; font-size: 13px; }
.xp-top span { color: var(--primary); font-weight: 950; }

.xp-bar {
  height: 16px;
  background: #f1e7ff;
  border-radius: 999px;
  overflow: hidden;
}

#xpFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--pink), var(--amber));
  border-radius: 999px;
  transition: width .35s ease;
}

.level-timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

.timeline-item {
  display: grid;
  justify-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  min-width: 44px;
}

.timeline-emoji {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
}

.timeline-item.current .timeline-emoji {
  background: var(--primary-light);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(124, 58, 237, .18);
}

.timeline-item.done { color: var(--green); }
.timeline-item.current { color: var(--primary); }

.summary-grid {
  display: grid;
  gap: 10px;
  margin: 14px 0;
  animation: rise .36s ease both;
}

.summary-grid.five { grid-template-columns: repeat(5, 1fr); }

.summary-card { padding: 13px 14px; transition: transform .18s ease; }
.summary-card:hover { transform: translateY(-2px); }

.summary-card span {
  color: var(--muted);
  font-weight: 850;
  font-size: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.summary-card.bad strong { color: #991b1b; }
.money strong { color: var(--green); }

.week-nav {
  display: flex;
  gap: 10px;
  margin: 12px 0 16px;
  flex-wrap: wrap;
}

.week-nav button, .ghost-btn, .task-card button, .admin-link, #addActivityBtn {
  border: 0;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.week-nav button, .admin-link {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  text-decoration: none;
}

.ghost-btn { color: var(--primary); background: var(--primary-light); }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 8px;
}

.section-title h2 { margin-bottom: 4px; }
.section-title p { margin: 0; color: var(--muted); }

.columns-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(330px, .75fr);
  gap: 16px;
  align-items: start;
}

.missions-column, .bad-column {
  background: rgba(255,255,255,.42);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 14px;
}

.bad-column { background: rgba(254, 226, 226, .32); }

.group-title { margin: 4px 0 6px; }
.subgroup-title { margin: 12px 0 8px; font-size: 14px; color: var(--muted); }
.helper { color: var(--muted); margin: -2px 0 10px; font-size: 13px; }

.task-list { display: grid; gap: 8px; }

.task-card {
  padding: 12px 14px;
  border-radius: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  animation: rise .24s ease both;
}

.task-main { display: flex; align-items: center; gap: 12px; }

.icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #fef3c7;
  display: grid;
  place-items: center;
  font-size: 22px;
  flex: 0 0 auto;
}

.task-title { margin: 0; font-size: 16px; font-weight: 950; }
.task-meta { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-weight: 900;
  font-size: 11px;
  margin-left: 4px;
}

.pending { background: #ffedd5; color: #9a3412; }
.completed { background: #dbeafe; color: #1d4ed8; }
.approved { background: #dcfce7; color: #166534; }
.late { background: #fee2e2; color: #991b1b; }

.actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }

.counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 9px;
  font-weight: 900;
  font-size: 12px;
}

.counter-btn, .quick-check-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 !important;
  display: inline-grid;
  place-items: center;
  font-size: 18px !important;
  line-height: 1;
}

.quick-check-btn, .plus-btn { background: #dcfce7; color: #166534; }
.minus-btn, .undo-btn, .penalty-btn { background: #fee2e2; color: #991b1b; }
.approve-inline { background: #ede9fe; color: #5b21b6; }
.disabled-btn { background: #e5e7eb; color: #6b7280; cursor: not-allowed !important; }

.day-row {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
  margin-top: 0;
}

.day-pill {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  min-width: 34px;
  height: 30px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}

.day-pill:hover { transform: scale(1.04); }
.day-pill.done { background: #dbeafe; color: #1d4ed8; }
.day-pill.approved { background: #dcfce7; color: #166534; }
.day-pill.locked { cursor: not-allowed; opacity: .65; }

.daily-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.daily-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.mini-action {
  border: 0;
  border-radius: 999px;
  padding: 7px 10px !important;
  font-size: 12px !important;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.approve-all { background: #ede9fe; color: #5b21b6; }
.clear-all { background: #fee2e2; color: #991b1b; }

.penalty .task-title { color: #991b1b; }

.hidden { display: none !important; }

.parent-panel { margin-top: 20px; padding: 20px; }
.admin-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.settings-card { padding: 16px; margin-top: 14px; }

.settings input, .admin-form input, .admin-form select, .admin-row input, .admin-row select {
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}

.settings-card label { display: inline-block; margin-right: 8px; }

.admin-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 80px 100px 130px auto;
  gap: 8px;
}

#addActivityBtn { background: var(--primary); color: white; }

.admin-list { display: grid; gap: 8px; }

.admin-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 70px 90px 120px auto;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
}

.admin-row button { border: 0; border-radius: 999px; padding: 8px 12px; font-weight: 900; cursor: pointer; }
.save-btn { background: #dcfce7; color: #166534; border: 0; border-radius: 999px; padding: 8px 12px; font-weight: 900; cursor: pointer; }
.delete-btn { background: #fee2e2; color: #991b1b; }
.save-status { display: inline-flex; margin-left: 8px; font-size: 13px; font-weight: 900; color: var(--green); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1020px) {
  .summary-grid.five { grid-template-columns: repeat(3, 1fr); }
  .columns-layout { grid-template-columns: 1fr; }
  .admin-form, .admin-row { grid-template-columns: 1fr 70px 90px; }
}

@media (max-width: 760px) {
  .daily-inline { grid-template-columns: 1fr; }
  .day-row { flex-wrap: wrap; }
  .daily-actions { justify-content: flex-start; flex-wrap: wrap; }
}

@media (max-width: 680px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .level-card { width: 100%; }
  .summary-grid.five { grid-template-columns: repeat(2, 1fr); }
  .task-card { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}


/* v8.1: stronger visual check for level progress */
.xp-panel::after {
  content: "v10.1";
  display: inline-block;
  margin-top: 8px;
  font-size: 10px;
  font-weight: 800;
  color: rgba(124, 58, 237, .35);
}
.timeline-item.current .timeline-emoji {
  transform: scale(1.12);
}


/* v8.2 definitive level bar */
.xp-bar {
  position: relative;
  height: 16px;
  background: #f1e7ff;
  border-radius: 999px;
  overflow: hidden;
}

#xpFill {
  height: 100%;
  min-width: 0;
  background: linear-gradient(90deg, #7c3aed, #ec4899, #f59e0b);
  border-radius: 999px;
  transition: width .35s ease;
}

.xp-panel::after {
  content: "v10.1";
}


/* v8.3 - ruler only: proportional 0 -> 7000 scale */
.xp-bar {
  position: relative;
  height: 16px;
  background: #f1e7ff;
  border-radius: 999px;
  overflow: hidden;
}

#xpFill {
  height: 100%;
  min-width: 0;
  background: linear-gradient(90deg, #7c3aed, #ec4899, #f59e0b);
  border-radius: 999px;
  transition: width .35s ease;
}

.level-timeline {
  position: relative;
  height: 54px;
  display: block;
  margin-top: 12px;
}

.timeline-item {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  min-width: 44px;
}

.timeline-item:first-child {
  transform: translateX(0);
}

.timeline-item:last-child {
  transform: translateX(-100%);
}

.xp-panel::after {
  content: "v10.1";
}


/* v8.5 - journey visibility */
.journey-summary {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

#journeyText {
  color: var(--text);
  font-weight: 900;
  font-size: 13px;
}

.levels-btn {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  background: var(--primary-light);
  color: var(--primary);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(45, 27, 78, .38);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 18px;
}

.levels-modal {
  width: min(520px, 94vw);
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  border-radius: 26px;
  box-shadow: 0 28px 80px rgba(45, 27, 78, .25);
  border: 1px solid var(--border);
  padding: 20px;
  animation: rise .2s ease both;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.modal-head h2 { margin-bottom: 0; }

.modal-close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
}

.modal-subtitle {
  color: var(--muted);
  margin: 8px 0 14px;
}

.levels-list {
  display: grid;
  gap: 8px;
}

.level-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  background: #faf7ff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 10px 12px;
}

.level-row.current {
  background: var(--primary-light);
  border-color: rgba(124, 58, 237, .35);
}

.level-row.done {
  background: #f0fdf4;
  border-color: rgba(22, 163, 74, .22);
}

.level-row .level-emoji {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  font-size: 20px;
}

.level-row strong {
  display: block;
  font-size: 14px;
}

.level-row span {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.level-row .level-points {
  font-weight: 950;
  color: var(--primary);
  white-space: nowrap;
}

@media (max-width: 680px) {
  .journey-summary { align-items: flex-start; }
}

.money.negative strong{color:#991b1b!important;}
@media (max-width:768px){
.summary-grid.five{grid-template-columns:repeat(2,1fr)!important;}
.hero{padding:18px}
.level-card{width:100%}
.columns-layout{grid-template-columns:1fr!important}
.task-card{grid-template-columns:1fr!important}
.daily-actions{justify-content:flex-start;flex-wrap:wrap}
.day-row{flex-wrap:wrap}
}


/* V9 - Mobile-first UX polish without changing functionality */
:root {
  --tap: 46px;
}

html {
  scroll-behavior: smooth;
}

body {
  -webkit-tap-highlight-color: rgba(124, 58, 237, 0.12);
}

button, a, input, select {
  touch-action: manipulation;
}

.mobile-bottom-nav {
  display: none;
}

@media (max-width: 820px) {
  body {
    padding-bottom: 86px;
    background:
      radial-gradient(circle at top left, #fde68a 0, transparent 24%),
      radial-gradient(circle at top right, #ddd6fe 0, transparent 22%),
      var(--bg);
  }

  .app-shell {
    width: min(100% - 24px, 720px);
    margin: 12px auto 28px;
  }

  .hero {
    border-radius: 22px;
    padding: 18px;
    gap: 14px;
  }

  .hero h1 {
    font-size: clamp(30px, 8vw, 42px);
    line-height: 1;
  }

  .subtitle {
    font-size: 14px;
  }

  .level-card {
    min-height: 96px;
    border-radius: 20px;
  }

  .xp-panel {
    border-radius: 22px;
    padding: 15px;
    margin: 12px 0;
  }

  .xp-top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 10px;
  }

  .xp-top strong {
    font-size: 16px;
  }

  .xp-top p {
    font-size: 12px;
    line-height: 1.25;
  }

  .xp-bar {
    height: 18px;
  }

  .level-timeline {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 2px 2px;
    height: 64px;
    scrollbar-width: none;
  }

  .level-timeline::-webkit-scrollbar {
    display: none;
  }

  .timeline-item {
    min-width: 42px;
  }

  .timeline-emoji {
    width: 34px;
    height: 34px;
  }

  .summary-grid.five {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .summary-card {
    padding: 14px;
    border-radius: 20px;
    min-height: 78px;
  }

  .summary-card span {
    font-size: 11px;
  }

  .summary-card strong {
    font-size: 24px;
  }

  .summary-card.money {
    grid-column: span 2;
  }

  .week-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .week-nav button {
    min-height: var(--tap);
    padding: 10px 12px;
  }

  #currentWeekBtn {
    grid-column: span 2;
  }

  .section-title {
    background: rgba(255,255,255,.72);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 12px;
  }

  .section-title h2 {
    font-size: 20px;
  }

  .section-title p {
    font-size: 13px;
  }

  .ghost-btn {
    min-height: var(--tap);
  }

  .columns-layout {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .missions-column, .bad-column {
    padding: 12px;
    border-radius: 22px;
  }

  .group-title {
    font-size: 20px;
  }

  .subgroup-title {
    font-size: 15px;
  }

  .task-card {
    grid-template-columns: 1fr !important;
    padding: 14px;
    border-radius: 22px;
    gap: 12px;
  }

  .task-main {
    gap: 12px;
  }

  .icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 24px;
  }

  .task-title {
    font-size: 17px;
  }

  .task-meta {
    font-size: 12px;
    line-height: 1.55;
  }

  .daily-inline {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .daily-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 8px;
  }

  .day-row {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
  }

  .day-pill {
    min-width: 0;
    height: 40px;
    padding: 0;
    font-size: 11px;
    border-radius: 14px;
  }

  .mini-action, .approve-inline, .undo-btn, .disabled-btn {
    min-height: 40px;
  }

  .counter-btn, .quick-check-btn {
    min-width: var(--tap);
    height: var(--tap);
  }

  .counter {
    min-height: var(--tap);
    padding: 0 13px;
  }

  .actions {
    justify-content: flex-start;
    gap: 8px;
  }

  .journey-summary {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }

  #journeyText {
    font-size: 12px;
    line-height: 1.35;
  }

  .levels-btn {
    min-height: 40px;
  }

  .levels-modal {
    width: min(96vw, 520px);
    max-height: 82vh;
    border-radius: 24px;
    padding: 16px;
  }

  .level-row {
    grid-template-columns: 42px 1fr auto;
    padding: 10px;
  }

  .level-row .level-points {
    font-size: 12px;
  }

  .parent-panel {
    border-radius: 22px;
    padding: 16px;
  }

  .admin-head {
    display: grid;
    gap: 10px;
  }

  .settings-card {
    border-radius: 20px;
    padding: 14px;
  }

  .admin-form {
    grid-template-columns: 1fr !important;
  }

  .admin-form input,
  .admin-form select,
  .settings input {
    width: 100%;
    min-height: var(--tap);
  }

  #addActivityBtn,
  .save-btn,
  .delete-btn,
  .admin-link {
    min-height: var(--tap);
  }

  .admin-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
    padding: 12px;
    border-radius: 18px;
  }

  .admin-row input,
  .admin-row select {
    min-height: var(--tap);
    width: 100%;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 900;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: rgba(255,255,255,.86);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    box-shadow: 0 18px 40px rgba(45, 27, 78, .18);
    border-radius: 24px;
    padding: 8px;
  }

  .mobile-nav-item {
    border: 0;
    background: transparent;
    color: var(--primary);
    text-decoration: none;
    font-weight: 950;
    font-size: 18px;
    display: grid;
    gap: 2px;
    place-items: center;
    min-height: 48px;
    border-radius: 18px;
    cursor: pointer;
  }

  .mobile-nav-item span {
    font-size: 11px;
  }

  .mobile-nav-item:active {
    background: var(--primary-light);
    transform: scale(.98);
  }
}

@media (min-width: 821px) {
  .app-shell {
    padding-bottom: 20px;
  }
}


/* V9.1 - Mobile ruler cleanup only */
@media (max-width: 820px) {
  .mobile-bottom-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .level-timeline {
    height: 46px;
    overflow: visible;
    margin-top: 10px;
  }

  .timeline-item {
    min-width: 22px;
    transform: translateX(-50%) scale(.86);
  }

  .timeline-item:first-child {
    transform: translateX(0) scale(.86);
  }

  .timeline-item:last-child {
    transform: translateX(-100%) scale(.86);
  }

  .timeline-item span:last-child {
    display: none;
  }

  .timeline-emoji,
  .timeline-item .timeline-emoji {
    width: 26px;
    height: 26px;
    font-size: 15px;
  }

  .timeline-item.current .timeline-emoji {
    width: 30px;
    height: 30px;
    font-size: 17px;
    box-shadow: 0 5px 14px rgba(124, 58, 237, .22);
  }
}

@media (max-width: 420px) {
  .timeline-item {
    transform: translateX(-50%) scale(.76);
  }

  .timeline-item:first-child {
    transform: translateX(0) scale(.76);
  }

  .timeline-item:last-child {
    transform: translateX(-100%) scale(.76);
  }
}
