@font-face { font-family: V; src: url(fonts/r.ttf); font-weight: 400; font-display: swap; }
@font-face { font-family: V; src: url(fonts/m.ttf); font-weight: 500; font-display: swap; }
@font-face { font-family: V; src: url(fonts/b.ttf); font-weight: 700; font-display: swap; }
:root {
  --bg: #F2F2F7; --card: #FFFFFF; --sheet: #F9F9FB; --ink: #1C1C1E; --sub: #6E6E73; --faint: #AEAEB2; --chip: #EBEBF0; --line: #E5E5EA;
  --green: #1E9E4A; --red: #E5352B; --red-bg: #FDEBEA; --accent: #0A6CFF; --accent-bg: #E6F0FF; --amber: #F08C00;
  --glass: rgba(255,255,255,.38); --glass-line: rgba(255,255,255,.5); --press: rgba(0,0,0,.06); --tab-on: rgba(10,108,255,.08);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 1px rgba(0,0,0,.04);
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --spring: cubic-bezier(.34, 1.36, .64, 1);
}
[data-theme=dark] {
  --bg: #0B0B0D; --card: #1C1C1E; --sheet: #1E1E21; --ink: #F5F5F7; --sub: #A1A1A8; --faint: #636366; --chip: #2C2C2E; --line: #333336;
  --green: #32D46B; --red: #FF5A50; --red-bg: #3A1A1C; --accent: #4C9BFF; --accent-bg: #1A2B44; --amber: #FFAA33;
  --glass: rgba(28,28,30,.35); --glass-line: rgba(255,255,255,.12); --press: rgba(255,255,255,.08); --tab-on: rgba(255,255,255,.12);
  --shadow: none;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: V, system-ui, sans-serif; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-text-size-adjust: 100%; }
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
svg.i { width: 22px; height: 22px; flex: none; display: block; }
#app { position: fixed; inset: 0; overflow: hidden; transition: filter .3s; }
#pages { position: absolute; inset: 0; }
.page { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: calc(var(--st) + 8px) 16px calc(var(--sb) + 110px); scrollbar-width: none; }
.page::-webkit-scrollbar { display: none; }
.page.hidden { display: none; }
.overlay { background: var(--bg); z-index: 5; animation: slidein .32s var(--spring); }
@keyframes slidein { from { transform: translateX(-30%); opacity: 0; } to { transform: none; opacity: 1; } }
.fade { position: absolute; left: 0; right: 0; pointer-events: none; z-index: 6; }
.fade.top { top: 0; height: calc(var(--st) + 24px); background: linear-gradient(var(--bg), color-mix(in srgb, var(--bg) 0%, transparent)); }
.fade.bot { bottom: 0; height: calc(var(--sb) + 96px); background: linear-gradient(color-mix(in srgb, var(--bg) 0%, transparent), var(--bg) 85%); }

/* glass: nav + popups */
.glass { background: var(--glass); -webkit-backdrop-filter: blur(36px) saturate(1.25); backdrop-filter: blur(36px) saturate(1.25); box-shadow: inset 0 0 0 1px var(--glass-line); }
#nav { position: absolute; z-index: 8; left: 14px; right: 14px; bottom: calc(var(--sb) + 12px); height: 62px; border-radius: 31px; display: flex; padding: 5px; }
#nav button { flex: 1; height: 52px; border-radius: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--sub); transition: transform .25s var(--spring), background .2s; }
#nav button svg { width: 24px; height: 24px; }
#nav button span { font-size: 10.5px; font-weight: 500; margin-top: 3px; line-height: 1; }
#nav button.on { color: var(--accent); background: var(--tab-on); }
#nav button:active { transform: scale(.94); }
#snack { position: absolute; z-index: 9; left: 20px; right: 20px; bottom: calc(var(--sb) + 86px); border-radius: 18px; padding: 13px 16px; font-size: 14px; font-weight: 500; opacity: 0; transform: translateY(10px) scale(.96); transition: .3s var(--spring); pointer-events: none; display: flex; }
#snack.show { opacity: 1; transform: none; pointer-events: auto; }
#snack b { color: var(--accent); margin-right: auto; font-weight: 500; }

/* header */
.head { display: flex; align-items: center; gap: 8px; padding: 8px 4px 14px; }
.head .t { flex: 1; font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home .head .t { font-size: 24px; }
.circle { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--card); color: var(--ink); box-shadow: var(--shadow); flex: none; transition: transform .3s var(--spring); position: relative; overflow: hidden; }
[data-theme=dark] .circle { background: var(--chip); }
.circle.acc { color: var(--accent); }
.circle.ok { background: var(--accent) !important; color: #fff; }
.circle:active { transform: scale(.94); }
.circle svg { width: 22px; height: 22px; }
.wchip { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 18px; direction: ltr; font-weight: 700; font-size: 17px; }
.wchip svg { width: 24px; height: 24px; }
.wchip:active { background: var(--press); }

/* cards + items */
.card { background: var(--card); border-radius: 22px; padding: 16px; margin-bottom: 12px; }
.item { background: var(--card); border-radius: 18px; padding: 12px 14px; margin-bottom: 9px; display: flex; align-items: center; gap: 12px; position: relative; overflow: hidden; transition: transform .3s var(--spring); }
.item::after, .press::after { content: ''; position: absolute; inset: 0; background: var(--press); opacity: 0; transition: opacity .15s; pointer-events: none; border-radius: inherit; }
.item:active::after, .press:active::after { opacity: 1; }
.item:active { transform: scale(.985); }
.item .col { flex: 1; min-width: 0; }
.item .tt { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .st { font-size: 12px; color: var(--sub); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .side { font-size: 13px; color: var(--sub); font-weight: 500; direction: ltr; }
.item .side.late { color: var(--red); }
.sec { display: flex; align-items: center; gap: 6px; padding: 4px 8px 8px; color: var(--sub); font-size: 14px; font-weight: 500; }
.sec svg { width: 15px; height: 15px; }
.sec .g { flex: 1; }
.empty { background: var(--card); border-radius: 18px; padding: 16px; text-align: center; color: var(--sub); font-size: 13px; margin-bottom: 9px; }
.dayh { font-size: 16px; font-weight: 700; padding: 0 4px 8px; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--faint); flex: none; display: grid; place-items: center; transition: .25s var(--spring); }
.check.on { background: var(--green); border-color: var(--green); color: #fff; }
.check.on svg { width: 15px; height: 15px; }
.item.done .tt { color: var(--sub); text-decoration: line-through; }
.stat { display: flex; align-items: center; gap: 12px; }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--sub); }
.bub { width: 40px; height: 40px; border-radius: 14px; background: var(--chip); display: grid; place-items: center; }

/* calendar card */
.cal { background: var(--card); border-radius: 22px; padding: 8px 8px 2px; margin-bottom: 12px; }
.strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; direction: rtl; }
.strip::-webkit-scrollbar { display: none; }
.strip .d { flex: 0 0 calc(100% / 7); scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; padding: 4px 0 6px; }
.strip .d.past { opacity: .4; }
.strip .w { font-size: 11px; color: var(--sub); font-weight: 500; }
.strip .n { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 16px; font-weight: 500; margin-top: 2px; }
.strip .d.today .n { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.4px var(--accent); }
.strip .d.sel .n { background: var(--accent); color: #fff; font-weight: 700; box-shadow: none; }
.strip .d.sel .w { color: var(--accent); }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); margin-top: 3px; visibility: hidden; }
.dot.on { visibility: visible; }
.sel .dot { background: #fff; }
.fold { overflow: hidden; transition: height .5s var(--spring), opacity .3s; }
.chev { display: grid; place-items: center; width: 64px; height: 28px; margin: 0 auto; color: var(--sub); border-radius: 14px; position: relative; }
.chev svg { width: 18px; height: 18px; transition: transform .45s var(--spring); }
.chev.open svg { transform: rotate(180deg); }
.pager { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; direction: rtl; align-items: flex-start; }
.pager::-webkit-scrollbar { display: none; }
.mpage { flex: 0 0 100%; scroll-snap-align: start; scroll-snap-stop: always; }
.mt { text-align: center; color: var(--sub); font-size: 14px; font-weight: 500; margin: 8px 0 2px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); direction: rtl; }
.grid .h { height: 30px; display: grid; place-items: center; font-size: 12px; color: var(--sub); font-weight: 500; }
.grid .h.fri, .grid .c.fri .num { color: var(--red); }
.grid .c { height: 54px; display: flex; flex-direction: column; align-items: center; }
.grid .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; font-weight: 500; margin-top: 2px; }
.grid .c.past { opacity: .4; }
.grid .c.today .num { box-shadow: inset 0 0 0 1.6px var(--accent); font-weight: 700; }
.grid .c.sel .num { background: var(--accent); color: #fff !important; font-weight: 700; box-shadow: none; }
.grid .dots { display: flex; gap: 2px; margin-top: 4px; }
.grid .dots i { width: 5px; height: 5px; border-radius: 50%; }

/* weather */
.wblock { background: var(--card); border-radius: 22px; padding: 12px 14px; position: relative; overflow: hidden; }
.wtop { display: flex; align-items: center; gap: 10px; }
.wtop .tmp { font-size: 30px; font-weight: 700; direction: ltr; }
.wtop .pl { font-size: 13.5px; font-weight: 500; }
.wtop .hl { font-size: 12.5px; color: var(--sub); direction: ltr; text-align: right; font-weight: 500; }
.w5 { display: flex; margin-top: 10px; }
.w5 > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--sub); font-weight: 500; }
.w5 svg { width: 20px; height: 20px; color: var(--ink); }
.w5 .r { font-size: 11.5px; direction: ltr; font-weight: 400; }

/* rolling digits */
.digits { display: inline-flex; direction: ltr; align-items: center; font-weight: 700; flex: none; }
.digits .cell { position: relative; overflow: hidden; display: inline-block; text-align: center; border-radius: 5px; margin: 0 .75px; height: 1.3em; line-height: 1.3em; }
.digits .cell span { position: absolute; inset: 0; }
.digits .cell span.in { animation: din .38s var(--spring); }
.digits .cell span.out { animation: dout .38s ease forwards; }
.digits .sep { margin: 0 1px; font-size: .78em; opacity: .8; }
@keyframes din { from { transform: translateY(100%); } to { transform: none; } }
@keyframes dout { to { transform: translateY(-100%); opacity: 0; } }

/* chips, inputs, segments, toggles */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 6px 12px; border-radius: 17px; background: var(--chip); font-size: 13px; font-weight: 500; position: relative; overflow: hidden; }
.chip svg { width: 15px; height: 15px; color: var(--sub); }
.chip.on { background: var(--accent-bg); color: var(--accent); }
.chip.on svg { color: var(--accent); }
.inp { width: 100%; height: 48px; border-radius: 14px; border: 0; outline: 0; background: var(--chip); color: var(--ink); font: 500 16px V, sans-serif; padding: 0 14px; direction: rtl; }
.inp::placeholder { color: var(--faint); }
.search { position: relative; margin-bottom: 12px; }
.search svg { position: absolute; right: 14px; top: 13px; color: var(--sub); }
.search .inp { padding-right: 44px; background: var(--card); }
.seg { display: flex; background: var(--chip); border-radius: 14px; padding: 3px; }
.seg button { flex: 1; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; font-weight: 500; color: var(--sub); }
.seg button svg { width: 17px; height: 17px; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.row .g { flex: 1; font-size: 15px; font-weight: 500; }
.row svg { color: var(--sub); }
.tog { width: 51px; height: 31px; border-radius: 16px; background: var(--line); position: relative; transition: background .25s; flex: none; }
.tog::after { content: ''; position: absolute; top: 2px; right: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .3s var(--spring); }
.tog.on { background: var(--green); }
.tog.on::after { transform: translateX(-20px); }
.lbl { font-size: 13px; color: var(--sub); padding: 14px 8px 8px; font-weight: 500; }
.link { color: var(--accent); font-size: 14px; font-weight: 500; padding: 10px; }
.emptyst { display: flex; flex-direction: column; align-items: center; padding: 60px 0; color: var(--sub); gap: 10px; font-size: 14px; }
.emptyst svg { width: 44px; height: 44px; color: var(--faint); }

/* popup */
#layer { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.scrim { position: absolute; inset: 0; background: rgba(0,0,0,.11); -webkit-backdrop-filter: blur(36px) saturate(1.25); backdrop-filter: blur(36px) saturate(1.25); display: flex; align-items: center; justify-content: center; padding: calc(var(--st) + 16px) 16px calc(var(--sb) + 16px); pointer-events: auto; opacity: 0; transition: opacity .22s; }
.scrim.show { opacity: 1; }
.pop { width: min(100%, 420px); max-height: 100%; display: flex; flex-direction: column; border-radius: 28px; padding: 14px 16px 16px; transform: scale(.9); opacity: 0; transition: transform .45s var(--spring), opacity .2s; }
.scrim.show .pop { transform: none; opacity: 1; }
.scrim.out .pop { transform: scale(.94); opacity: 0; transition: .17s; }
.pop .ph { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.pop .ph .t { flex: 1; text-align: center; font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop .ph .circle, .pop .ph .slot { width: 40px; height: 40px; box-shadow: none; }
.pop .ph .slot { visibility: hidden; }
.pop .pb { overflow-y: auto; scrollbar-width: none; }
.pop .pb > * + * { margin-top: 10px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; font-size: 15px; font-weight: 500; position: relative; overflow: hidden; width: 100%; text-align: right; }
.opt svg { width: 20px; height: 20px; }
.opt.sel { background: var(--accent-bg); }
.opt.danger { color: var(--red); }
.opt .g { flex: 1; }
.colors { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.colors i { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.colors i.on { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; }

/* wheel */
.wheels { position: relative; display: flex; direction: ltr; height: 200px; }
.wheels::before, .wheels::after { content: ''; position: absolute; left: 0; right: 0; height: 1px; background: var(--accent); pointer-events: none; z-index: 2; }
.wheels::before { top: 80px; } .wheels::after { top: 120px; }
.wheel { flex: 1; height: 200px; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; padding: 80px 0; overscroll-behavior: contain; }
.wheel::-webkit-scrollbar { display: none; }
.wheel div { height: 40px; line-height: 40px; text-align: center; scroll-snap-align: center; font-size: 19px; font-weight: 500; white-space: nowrap; transform-origin: center; will-change: transform, opacity; }
.wheel.day div { font-size: 16px; direction: rtl; }
.pills { display: flex; justify-content: center; }
