/* Frivy's Gig Board — warm and playful, light & dark. Each kid's colour is --kid. */

:root {
  --bg: #FBF6EE;
  --surface: #FFFFFF;
  --surface-2: #F3EBDF;
  --ink: #2B2118;
  --ink-2: #6E6155;
  --line: #E6DACB;
  --accent: #C2502E;
  --accent-ink: #FFFFFF;
  --accent-soft: #F7E1D7;
  --good: #3E7D3A;
  --danger: #B3261E;
  --gold: #D9A21B;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Charter, Georgia, ui-serif, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --round: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --kid: var(--accent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1A1512;
    --surface: #241D18;
    --surface-2: #2E2620;
    --ink: #F3EAE0;
    --ink-2: #B7A897;
    --line: #3A3029;
    --accent: #E2744F;
    --accent-ink: #1A1512;
    --accent-soft: #3D2A21;
    --good: #8BC77F;
    --danger: #F2847B;
    --gold: #F0C04A;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { font-size: 1.25rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 4px; align-items: center; }
.brand { font-size: 1.4rem; }
.brand::first-letter { color: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 42px; height: 42px; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; text-decoration: none; font-size: 1.2rem;
}
.icon-btn:hover { background: var(--surface-2); }
.chev { font-size: 2rem; line-height: 1; margin-top: -4px; }
.kid-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.money-pill {
  text-decoration: none; font-weight: 700; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--kid) 18%, var(--surface)); border: 2px solid var(--kid);
}

/* ---------- basics ---------- */
.page { max-width: 760px; margin: 0 auto; padding: 8px 16px calc(40px + var(--safe-bottom)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; box-shadow: var(--shadow); }
.section-title { font-size: 1.1rem; margin: 22px 0 8px; }
.card .section-title { margin-top: 0; }
.section-sub { margin: -4px 0 10px; }
.intro { color: var(--ink-2); margin: 8px 0 4px; }
.empty { text-align: center; color: var(--ink-2); padding: 28px 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.row-between { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.emo { font-size: 1.7rem; line-height: 1; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
  text-decoration: none; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--kid); border-color: var(--kid); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { display: flex; width: 100%; margin-top: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.small-btn { min-height: 34px; padding: 4px 12px; font-size: .9rem; }

.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field > span { font-size: .9rem; color: var(--ink-2); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); min-height: 46px;
}
.field input[type=color] { padding: 4px; }
.field input:focus, .field select:focus, .field textarea:focus, .amount-field input:focus { outline: 2px solid var(--kid); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 480px) { .grid-2 { grid-template-columns: 1fr; } }
.form-error { color: var(--danger); font-weight: 600; margin: 8px 0 0; }
.switch { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer;
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.lang-row { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.4rem;
  background: color-mix(in srgb, var(--kid) 25%, var(--surface)); border: 2px solid var(--kid);
}
.avatar.xl { width: 92px; height: 92px; font-size: 3.2rem; border-width: 3px; }
.avatar.xs { width: 22px; height: 22px; font-size: .8rem; border-width: 1px; vertical-align: -5px; }

.bar { display: block; width: 100%; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar.big { height: 16px; margin: 12px 0 6px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--kid); transition: width .4s; }

.loading { display: grid; place-items: center; min-height: 40vh; }
.loading.small { min-height: 80px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login / setup ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card .field { text-align: left; }
.logo { font-size: 3.4rem; margin-bottom: 8px; }
.login-card .brand { font-size: 1.7rem; margin-bottom: 6px; }

/* ---------- home ---------- */
.hello { font-size: 1.6rem; margin: 10px 0 14px; text-align: center; }
.kid-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kid-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 22px 16px 18px; border-radius: 24px; text-decoration: none;
  background: linear-gradient(170deg, color-mix(in srgb, var(--kid) 22%, var(--surface)), var(--surface) 70%);
  border: 2px solid color-mix(in srgb, var(--kid) 55%, transparent); box-shadow: var(--shadow);
  transition: transform .15s;
}
.kid-card:active { transform: scale(.98); }
.kid-name { font-family: var(--round); font-size: 1.6rem; font-weight: 800; }
.kid-money { font-size: 1.25rem; font-weight: 700; }
.kid-card .bar { max-width: 200px; }
.badge { font-size: .85rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); }
.check-link {
  display: flex; justify-content: space-between; align-items: center; margin-top: 20px;
  padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; font-weight: 700;
}
.check-link .count { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 999px; background: var(--surface-2); }
.check-link.has .count { background: var(--accent); color: var(--accent-ink); }

/* ---------- kid page ---------- */
.tabs {
  position: sticky; top: calc(62px + var(--safe-top)); z-index: 9;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-width: 760px; margin: 0 auto; padding: 4px 16px 8px; background: var(--bg);
}
.tabs a {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 6px; border-radius: 14px; text-decoration: none; font-weight: 700; font-size: .95rem;
  background: var(--surface); border: 2px solid var(--line);
}
.tabs a.active { border-color: var(--kid); background: color-mix(in srgb, var(--kid) 18%, var(--surface)); }
.tab-emo { font-size: 1.2rem; }
.tabs-big a { flex-direction: column; gap: 2px; padding: 8px 4px; }
.tabs-big .tab-emo { font-size: 2rem; }

.progress-card { display: flex; align-items: center; gap: 16px; padding: 14px 0 6px; }
.big-line { font-family: var(--round); font-size: 1.2rem; font-weight: 800; margin: 0 0 2px; }
.ring {
  --p: 0; flex: none; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--kid) calc(var(--p) * 360deg), var(--surface-2) 0);
}
.ring span { width: 58px; height: 58px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-weight: 800; }

.check-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.check-row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border-radius: var(--radius); cursor: pointer;
  background: var(--surface); border: 2px solid var(--line); box-shadow: var(--shadow);
}
.check-row .label { flex: 1; font-weight: 600; font-size: 1.05rem; }
.tick {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); font-weight: 900; color: #fff;
}
.is-done { border-color: color-mix(in srgb, var(--kid) 60%, transparent); background: color-mix(in srgb, var(--kid) 12%, var(--surface)); }
.is-done .tick { background: var(--kid); border-color: var(--kid); animation: pop .3s; }
.check-row.is-done .label { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--ink-2); }
@keyframes pop { 50% { transform: scale(1.3); } }

/* Big picture tiles for the little one */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 10px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 160px; padding: 16px 10px; border-radius: 24px; cursor: pointer; text-align: center;
  background: var(--surface); border: 3px solid var(--line); box-shadow: var(--shadow);
}
.tile .emo { font-size: 3.4rem; }
.tile .label { font-weight: 700; font-family: var(--round); line-height: 1.25; }
.tile .tick { position: absolute; top: 10px; right: 10px; }
.tile:not(.is-done) .tick { display: none; }
.tile .coin {
  font-weight: 800; padding: 2px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--gold) 30%, var(--surface)); border: 2px solid var(--gold);
}
.tile-flag { position: absolute; top: 8px; right: 10px; font-size: 1.6rem; }
.gig-tile.st-pending { border-color: var(--gold); border-style: dashed; }
.gig-tile.st-blocked { opacity: .5; }

.week { display: flex; justify-content: space-between; gap: 6px; max-width: 420px; }
.dot-day { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1; }
.dot-day i {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-style: normal;
  border: 2px dashed var(--line);
}
.dot-day.part i { border-style: solid; border-color: var(--kid); background: color-mix(in srgb, var(--kid) 15%, transparent); }
.dot-day.full i { border-style: solid; border-color: var(--gold); background: color-mix(in srgb, var(--gold) 25%, transparent); }
.dot-day.none i { border-style: solid; }
.dot-day small { color: var(--ink-2); font-weight: 700; }

/* Gig cards */
.gig-list { display: flex; flex-direction: column; gap: 12px; }
.gig { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.gig-top { display: flex; gap: 12px; align-items: flex-start; }
.gig-text { flex: 1; min-width: 0; }
.gig h4 { font-family: var(--sans); font-size: 1.05rem; font-weight: 700; }
.gig-meta { margin: 2px 0 0; font-size: .875rem; color: var(--ink-2); }
.stars { color: var(--gold); letter-spacing: 1px; }
.value {
  flex: none; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: color-mix(in srgb, var(--gold) 25%, var(--surface)); border: 1.5px solid var(--gold);
}
.standard { margin: 10px 0 0; font-size: .92rem; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.not-yet { margin: 10px 0 0; font-weight: 700; color: var(--accent); }
.gig-action { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.gig-action .btn.primary { min-width: 150px; }
.waiting { font-weight: 700; color: var(--ink-2); }
.done-label { font-weight: 700; color: var(--good); }
.gig.st-pending { border-color: var(--gold); border-style: dashed; }
.gig.st-blocked { opacity: .6; box-shadow: none; }
.gig.claim { border-left: 6px solid var(--kid); }
.claim-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.amount-field {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 10px; min-height: 44px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); margin-right: auto;
}
.amount-field input { width: 90px; border: 0; background: transparent; padding: 8px 0; outline: none; }

/* Piggy bank */
.piggy { text-align: center; padding: 18px 0 6px; }
.piggy-emo { font-size: 4.5rem; line-height: 1; animation: bob 3s ease-in-out infinite; }
.piggy-amount { font-family: var(--round); font-size: 2.8rem; font-weight: 900; color: var(--kid); }
.piggy p { margin: 0; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
.goal-row { display: flex; align-items: center; gap: 12px; }
.goal-row .emo { font-size: 2.4rem; }
.goal p { margin: 4px 0 0; }
.parent-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 8px 0; }
.parent-actions .btn { min-height: 40px; padding: 6px 14px; font-size: .92rem; }
.expense-list { margin: 0; padding-left: 20px; }
.history { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.history li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history .emo { font-size: 1.3rem; }
.h-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.h-text b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.amount { font-weight: 800; white-space: nowrap; }
.amount.pos { color: var(--good); }
.amount.neg { color: var(--danger); }
.small-x { width: 32px; height: 32px; font-size: 1.3rem; color: var(--ink-2); }

/* Settings & editor */
.list-link { display: flex; align-items: center; gap: 12px; padding: 10px 0; text-decoration: none; border-top: 1px solid var(--line); }
.list-link:first-of-type { border-top: 0; }
.list-link > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.how summary { cursor: pointer; list-style: none; }
.how summary::-webkit-details-marker { display: none; }
.how summary h3::after { content: ' ▾'; color: var(--ink-2); }
.how[open] summary { margin-bottom: 8px; }
.how ul { padding-left: 20px; }
.task-group h4 { font-family: var(--sans); font-size: 1rem; }
.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; text-decoration: none; border-top: 1px solid var(--line); }
.task-row:first-of-type { margin-top: 8px; }
.task-row .emo { font-size: 1.3rem; }
.task-name { flex: 1; min-width: 0; }
.task-row .value { font-size: .85rem; }
.task-row.archived { opacity: .5; }

/* Dialogs */
dialog.sheet {
  width: min(420px, calc(100vw - 32px)); border: 0; border-radius: 22px; padding: 20px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog.sheet::backdrop { background: rgba(20, 12, 6, .45); }
dialog.sheet h2 { font-size: 1.3rem; margin-bottom: 8px; }
dialog .field input { background: var(--bg); }
.pin-input {
  display: block; width: 100%; margin-top: 8px; padding: 12px; text-align: center;
  font-size: 1.8rem; letter-spacing: .5em; border-radius: 14px; border: 1px solid var(--line); background: var(--bg);
}

/* Toast & confetti */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; transition: .25s; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti span { position: absolute; bottom: -60px; animation: rise 1.7s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes rise {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(-85vh) rotate(200deg); opacity: 0; }
}
