/* ===== Time-of-day themes (morning / noon / sunset / evening / night) with a slowly moving background ===== */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Heebo", "Segoe UI", sans-serif;
  --radius: 18px;
}
html[data-period] body { font-family: var(--font), -apple-system, "Heebo", sans-serif; }

/* morning: soft sunrise – peach, cream, light sky */
html[data-period="morning"] {
  --g1: #ffe3c4; --g2: #ffd1dc; --g3: #cfe8ff; --g4: #fff6e5;
  --bg: #fff7ef; --card: rgba(255,255,255,.72); --text: #2b2118; --muted: #7d6a5c; --line: rgba(120,90,60,.16);
  --accent: #e8743b; --accent-soft: rgba(232,116,59,.14); --good: #2f9e6e; --good-soft: rgba(47,158,110,.14);
  --warn: #c76b1c; --warn-soft: rgba(230,150,60,.18); --bar: #ffe3c4; color-scheme: light;
}
/* noon: bright clear sky */
html[data-period="noon"] {
  --g1: #bfe6ff; --g2: #e6f6ff; --g3: #9fd4ff; --g4: #fdfdf6;
  --bg: #eef8ff; --card: rgba(255,255,255,.75); --text: #0f2233; --muted: #557086; --line: rgba(30,80,120,.14);
  --accent: #1d7fd6; --accent-soft: rgba(29,127,214,.12); --good: #12a06a; --good-soft: rgba(18,160,106,.13);
  --warn: #c7741a; --warn-soft: rgba(230,150,60,.16); --bar: #bfe6ff; color-scheme: light;
}
/* afternoon: sunset – orange, pink, purple */
html[data-period="sunset"] {
  --g1: #ff9a5a; --g2: #ff6f91; --g3: #a66cff; --g4: #ffc46b;
  --bg: #3a2140; --card: rgba(40,18,48,.42); --text: #fff6f0; --muted: #f3cfe0; --line: rgba(255,255,255,.18);
  --accent: #ffd27a; --accent-soft: rgba(255,210,122,.18); --good: #7dffb8; --good-soft: rgba(125,255,184,.16);
  --warn: #ffd27a; --warn-soft: rgba(255,180,90,.22); --bar: #ff7f74; color-scheme: dark;
}
/* evening: dusk – deep blue/violet, still some light */
html[data-period="evening"] {
  --g1: #2b3a78; --g2: #5a3f8c; --g3: #1d2b55; --g4: #8a5a9e;
  --bg: #1d2246; --card: rgba(255,255,255,.08); --text: #eef0ff; --muted: #b9bfe6; --line: rgba(255,255,255,.14);
  --accent: #9db4ff; --accent-soft: rgba(157,180,255,.16); --good: #6ee7b7; --good-soft: rgba(110,231,183,.15);
  --warn: #ffc27a; --warn-soft: rgba(255,170,90,.2); --bar: #2b3a78; color-scheme: dark;
}
/* night: navy and indigo with a hint of teal */
html[data-period="night"] {
  --g1: #050816; --g2: #0d1640; --g3: #0a2a3a; --g4: #1a0f3a;
  --bg: #070b1c; --card: rgba(255,255,255,.06); --text: #e6ebff; --muted: #8e98c4; --line: rgba(255,255,255,.1);
  --accent: #7f9cff; --accent-soft: rgba(127,156,255,.14); --good: #4fd1a5; --good-soft: rgba(79,209,165,.13);
  --warn: #f0b35a; --warn-soft: rgba(240,179,90,.16); --bar: #050816; color-scheme: dark;
}

/* moving gradient background */
html[data-period] body { background: var(--bg); }
html[data-period] body::before {
  content: ''; position: fixed; inset: -20%; z-index: -2;
  background:
    radial-gradient(40% 35% at 20% 20%, var(--g1), transparent 70%),
    radial-gradient(45% 40% at 80% 30%, var(--g2), transparent 70%),
    radial-gradient(50% 45% at 30% 80%, var(--g3), transparent 70%),
    radial-gradient(40% 40% at 85% 85%, var(--g4), transparent 70%),
    var(--bg);
  animation: drift 28s ease-in-out infinite alternate;
  filter: saturate(1.05);
}
html[data-period="night"] body::after {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: .55;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff, transparent), radial-gradient(1px 1px at 30% 70%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff, transparent), radial-gradient(1px 1px at 75% 50%, #fff, transparent),
    radial-gradient(1px 1px at 90% 80%, #fff, transparent), radial-gradient(1.5px 1.5px at 20% 90%, #fff, transparent),
    radial-gradient(1px 1px at 65% 85%, #fff, transparent), radial-gradient(1px 1px at 45% 40%, #fff, transparent);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate(-4%, 3%) rotate(8deg) scale(1.08); }
  100% { transform: translate(3%, -3%) rotate(-6deg) scale(1.04); }
}
@keyframes twinkle { from { opacity: .35; } to { opacity: .7; } }
@media (prefers-reduced-motion: reduce) { html[data-period] body::before, html[data-period] body::after { animation: none; } }

/* glass cards */
html[data-period] .card { background: var(--card); border-color: var(--line); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); }
html[data-period] .motivation { background: linear-gradient(135deg, var(--accent-soft), var(--card)); }
html[data-period] input, html[data-period] select, html[data-period] textarea { background: color-mix(in srgb, var(--bg) 55%, transparent); }
html[data-period] .stats div, html[data-period] .insight, html[data-period] .pepper-rem, html[data-period] .howto div { background: color-mix(in srgb, var(--bg) 45%, transparent); }
html[data-period] .tabbar { background: color-mix(in srgb, var(--bar) 70%, transparent); }
html[data-period] .ring::after { background: color-mix(in srgb, var(--bg) 85%, transparent); }
html[data-period="morning"] .btn, html[data-period="noon"] .btn { color: #fff; }
html[data-period="sunset"] .btn:not(.ghost):not(.danger) { color: #3a1830; }

/* ===== time / date fields: always left-to-right and centered (fixes the "reversed" look in Hebrew) ===== */
input[type="time"], input[type="date"], input[type="datetime-local"] {
  direction: ltr; unicode-bidi: isolate; text-align: center; font-variant-numeric: tabular-nums;
  min-height: 44px; -webkit-appearance: none; appearance: none;
}
input[type="time"]::-webkit-date-and-time-value, input[type="date"]::-webkit-date-and-time-value { text-align: center; }

/* ===== back button ===== */
.backbtn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; font-size: 16px; padding: 4px 0 10px; cursor: pointer; }

/* ===== done items collapse + swipe ===== */
.donebox { margin-top: 6px; }
.donebox > summary { font-size: 13px; color: var(--muted); padding: 8px 4px; list-style: none; }
.donebox > summary::-webkit-details-marker { display: none; }
.alldone { text-align: center; color: var(--good); margin: 6px 0; font-weight: 600; }
[data-swipe] { touch-action: pan-y; position: relative; }
[data-swipe].swipe-ready { background: var(--good-soft); border-radius: 12px; }

/* ===== voice ===== */
.quick .mic { background: var(--accent-soft); color: var(--text); padding: 0 14px; font-size: 18px; }
.quick .mic.rec { background: #e5484d; color: #fff; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* ===== Face ID lock screen ===== */
#lock {
  position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text); text-align: center; padding: 24px; transition: opacity .35s ease, transform .35s ease;
}
#lock::before { content: ''; position: absolute; inset: 0; z-index: -1; background:
  radial-gradient(50% 40% at 30% 25%, var(--g1), transparent 70%), radial-gradient(50% 40% at 70% 75%, var(--g3), transparent 70%); opacity: .8; }
#lock.out { opacity: 0; transform: scale(1.04); }
.lock-logo { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
#lock h1 { font-size: 28px; margin: 6px 0 18px; }
.faceid { width: 96px; height: 96px; border-radius: 28px; border: 0; background: var(--card); color: var(--accent); cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 6px 24px rgba(0,0,0,.18); display: grid; place-items: center; }
.faceid svg { width: 56px; height: 56px; }
.faceid:active { transform: scale(.94); }
.lock-hint { color: var(--muted); margin: 0; }
.lock-err { color: #e5484d; margin: 0; }

/* ===== look page ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 99px; padding: 8px 14px; font: inherit; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.fontcard { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: start; border: 1px solid var(--line); background: transparent;
  color: var(--text); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.fontcard.on { border-color: var(--accent); background: var(--accent-soft); }
.fname { font-size: 12px; color: var(--muted); font-family: -apple-system, sans-serif; }
.fsample-big { font-size: 24px; font-weight: 700; }
.fsample { font-size: 14px; color: var(--muted); }
.money-explain ol { padding-inline-start: 20px; line-height: 1.8; font-size: 14px; margin: 6px 0; }
.lock-code { max-width: 300px; }
.lock-input { width: 100%; text-align: center; font-size: 22px; letter-spacing: 6px; direction: ltr; margin-top: 6px; }

/* ===== v5: app feel ===== */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
input, select, textarea { font-size: 16px !important; } /* stops iOS zooming into fields */
* { -webkit-user-select: none; user-select: none; }
input, textarea, .quote, .meta a, pre { -webkit-user-select: text; user-select: text; }

/* refresh button + pull indicator */
#refreshBtn { position: fixed; top: calc(env(safe-area-inset-top) + 10px); left: 14px; z-index: 50; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: grid; place-items: center; }
#refreshBtn.spin, #ptr.spin span { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#ptr { position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 50%; z-index: 60; transform: translate(-50%, -50px); opacity: 0;
  width: 40px; height: 40px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center;
  color: var(--accent); font-size: 22px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: opacity .2s; pointer-events: none; }
#ptr.ready { color: var(--good); }
#ptr.spin { transform: translate(-50%, 18px) !important; opacity: 1 !important; }
main { padding-top: 54px; }

/* floating bottom bar that blends into the background */
html[data-period] .tabbar {
  left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 8px); border-radius: 26px;
  background: color-mix(in srgb, var(--card) 85%, transparent); border: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 6px 4px;
}
html[data-period] body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
html[data-period] body::before { bottom: -20%; }
.tabbar button { border-radius: 18px; transition: background .2s; }
.tabbar button.active { background: var(--accent-soft); }
/* soft fade above the bar so content slides under it naturally */
.tabfade { position: fixed; left: 0; right: 0; bottom: 0; height: calc(110px + env(safe-area-inset-bottom)); pointer-events: none; z-index: 9;
  background: linear-gradient(to top, color-mix(in srgb, var(--bg) 85%, transparent), transparent); }
.tabbar { z-index: 10; }

/* score ring */
.ring.big { width: 74px; height: 74px; border: 0; padding: 0; cursor: pointer; background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--line) 0); }
.ring.big::after { width: 60px; height: 60px; font-size: 17px; color: var(--text); }
.scoreparts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; margin: -6px 0 12px; }
.scoreparts span { font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; }
h3.grp { font-size: 14px; margin: 14px 0 2px; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.alldone.small { font-size: 13px; margin: 4px 0; text-align: start; }

/* fitness weeks */
.weeks { display: flex; gap: 12px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--good); letter-spacing: 2px; flex-wrap: wrap; }

/* money analysis */
.monthbars { display: flex; gap: 8px; align-items: flex-end; margin: 14px 0 6px; overflow-x: auto; }
.mb { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 40px; font-size: 12px; }
.bars2 { display: flex; gap: 3px; align-items: flex-end; height: 90px; }
.bars2 i { width: 12px; height: var(--h); min-height: 2px; border-radius: 4px 4px 0 0; }
.bars2 i.in, .dot.in { background: var(--good); } .bars2 i.out, .dot.out { background: #e5484d; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline: 4px 2px; }
.mb b { font-size: 11px; }
.doclist { padding-inline-start: 0; list-style: none; margin: 8px 0; }
.doclist li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.doclist li.ok b { color: var(--good); }
.plan .step { background: color-mix(in srgb, var(--bg) 45%, transparent); border-radius: 12px; padding: 10px 12px; margin: 10px 0; }
.plan .step p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
.stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important; }
.stats b { font-size: 19px; white-space: nowrap; }

/* swipe: keep the page itself still while a row slides */
html, body { overflow-x: hidden; max-width: 100%; }
main { overflow-x: clip; }
.card { overflow: hidden; }
[data-swipe] { will-change: transform; }
.daychips { margin-bottom: 10px; }
.daychips label.chip { position: relative; display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.daychips label.chip input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

/* upload result sheet */
#uploadBox { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; padding: 12px; }
#uploadBox[hidden] { display: none; }
.ub-card { width: 100%; max-width: 520px; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 22px;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.3); animation: ubin .25s ease; text-align: center; }
.ub-card h3 { margin: 6px 0; font-size: 20px; }
.ub-card .row { margin-top: 14px; }
.ub-ok, .ub-spin { font-size: 40px; }
.ub-spin { animation: spin 1.2s linear infinite; display: inline-block; }
@keyframes ubin { from { transform: translateY(40px); opacity: 0; } }
.uploads { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.uploads .meta { margin: 0 0 4px; }
.doclist li.upl { border: 0; padding: 4px 0 10px; }
.doclist li.upl .btn { width: 100%; }

/* quick add (manual income / expense) */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: color-mix(in srgb, var(--bg) 50%, transparent); border-radius: 14px; padding: 4px; margin-bottom: 4px; }
.seg label { margin: 0; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 9px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg input[value=expense]:checked + span { background: #e5484d22; color: #e5484d; }
.seg input[value=income]:checked + span { background: var(--good-soft); color: var(--good); }
.catline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--muted); }
.catline b { color: var(--text); }
.catline .catsel { margin-inline-start: auto; max-width: 140px; }
.moredate { margin-top: 8px; }
.moredate summary { font-size: 13px; }
.moredate input { margin-top: 6px; }

/* fixed charges */
.warnc { color: #e8a23a; font-weight: 600; }
#fixedCard .stats { margin: 8px 0 12px; }
