@font-face { font-family: 'Readex Pro'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/readex-pro-arabic.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: 'Readex Pro'; font-style: normal; font-weight: 300 700; font-display: swap; src: url(../fonts/readex-pro-latin.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #F2F5F9;
  --card: #FFFFFF;
  --card2: #F4F7FB;
  --ink: #0D1B2E;
  --ink2: #3D4D65;
  --mute: #7A889E;
  --line: #E3E9F1;
  --pri: #0DA99C;
  --pri2: #0A7FA0;
  --pri-soft: #E2F6F3;
  --grad: linear-gradient(135deg, #1CC8B4 0%, #0A7FA0 100%);
  --navy: #0B1C36;
  --navy2: #143566;
  --coral: #FF6F59;
  --coral-soft: #FFECE8;
  --amber: #F2A21B;
  --amber-soft: #FFF4DE;
  --green: #14B26B;
  --green-soft: #E3F7EC;
  --red: #E54545;
  --track: #E7EDF4;
  --shadow: 0 1px 2px rgba(13, 27, 46, .04), 0 6px 22px rgba(13, 27, 46, .06);
  --shadow-up: 0 10px 30px rgba(13, 27, 46, .12);
  --r: 22px;
  --font: 'Readex Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Tahoma, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070E1A;
    --card: #0F1A2C;
    --card2: #15223A;
    --ink: #EAF1FA;
    --ink2: #B6C3D6;
    --mute: #7F8EA6;
    --line: #1D2A42;
    --pri-soft: #0C2F33;
    --coral-soft: #3A1C1A;
    --amber-soft: #36290F;
    --green-soft: #0E2E22;
    --track: #1E2B44;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-up: 0 12px 36px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: 340px;
  background:
    radial-gradient(60% 80% at 85% -10%, rgba(28, 200, 180, .18), transparent 70%),
    radial-gradient(50% 70% at 0% 0%, rgba(10, 127, 160, .12), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
body.locked { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--pri); }
.ic { flex: none; display: block; }
[dir=rtl] .b-go .ic, [dir=rtl] .flip { transform: scaleX(-1); }
small { font-size: 13px; }
.mut { color: var(--mute); }
.center { text-align: center; }

/* ---------- shell ---------- */
#app { position: relative; z-index: 1; }
.shell {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--st) + 16px) 18px calc(var(--sb) + 112px);
}
.desk-note {
  display: flex; gap: 8px; align-items: center; justify-content: center;
  margin-bottom: 14px; padding: 10px 14px; border-radius: 14px;
  background: var(--pri-soft); color: var(--pri2); font-size: 14px;
}
.view.enter > * { animation: up .45s cubic-bezier(.2, .8, .2, 1) both; }
.view.enter > *:nth-child(2) { animation-delay: .04s; }
.view.enter > *:nth-child(3) { animation-delay: .08s; }
.view.enter > *:nth-child(4) { animation-delay: .12s; }
.view.enter > *:nth-child(5) { animation-delay: .16s; }
@keyframes up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 2px 16px; }
.top h1 { margin: 0; font-size: 25px; font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
.hello { color: var(--mute); font-size: 14px; }

.rchip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 8px 12px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.rchip.ok { background: var(--green-soft); color: var(--green); }
.rchip.off { background: var(--coral-soft); color: var(--coral); animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 85%, 100% { transform: none; } 90% { transform: rotate(-4deg); } 95% { transform: rotate(4deg); } }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.wd {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 0 10px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  transition: transform .15s;
}
.wd:active { transform: scale(.94); }
.wd-n { font-size: 11px; color: var(--mute); white-space: nowrap; overflow: hidden; max-width: 100%; }
.wd-d { font-size: 17px; font-weight: 600; }
.wd-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 2px; background: transparent; }
.dot-full { background: var(--green) !important; }
.dot-part { background: var(--amber) !important; }
.dot-miss { background: var(--coral) !important; }
.dot-todo { background: var(--track) !important; }
.wd.on .dot-todo { background: rgba(255, 255, 255, .3) !important; }
.wd.is-today .wd-n { color: var(--pri); font-weight: 600; }
.wd.on { background: linear-gradient(160deg, var(--navy2), var(--navy)); color: #fff; box-shadow: 0 8px 20px rgba(11, 28, 54, .28); }
.wd.on .wd-n { color: rgba(255, 255, 255, .7); }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 18px; border-radius: 26px; color: #fff;
  background: linear-gradient(150deg, #173B6E 0%, #0B1C36 70%);
  box-shadow: 0 14px 34px rgba(11, 28, 54, .3);
  margin-bottom: 14px;
}
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::before { width: 220px; height: 220px; inset-inline-end: -70px; top: -90px; background: radial-gradient(circle, rgba(28, 200, 180, .45), transparent 70%); }
.hero::after { width: 160px; height: 160px; inset-inline-start: -60px; bottom: -80px; background: radial-gradient(circle, rgba(34, 211, 238, .25), transparent 70%); }
.hero-top { position: relative; display: flex; align-items: center; gap: 16px; }
.ring { position: relative; flex: none; width: 92px; height: 92px; }
.ring-svg .track { stroke: var(--track); }
.hero .ring-svg .track { stroke: rgba(255, 255, 255, .13); }
.ring-val { animation: ring 1s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes ring { from { stroke-dashoffset: var(--c); } }
.ring-in { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 28px; direction: ltr; }
.ring-in b { font-size: 28px; font-weight: 600; }
.ring-in span { font-size: 15px; opacity: .65; }
.hero-label { font-size: 13px; opacity: .72; }
.hero-big { font-size: 20px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.hero-next {
  position: relative; display: flex; align-items: center; gap: 10px; margin-top: 14px;
  padding: 10px 12px; border-radius: 18px; background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .1); cursor: pointer;
}
.hn-art { width: 38px; height: 38px; border-radius: 12px; background: rgba(255, 255, 255, .92); display: grid; place-items: center; flex: none; }
.hn-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hn-txt small { opacity: .7; font-size: 12px; }
.hn-txt b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hn-time { display: flex; flex-direction: column; align-items: flex-end; text-align: end; }
.hn-time b { font-size: 18px; font-weight: 600; direction: ltr; }
.hn-time small { font-size: 12px; color: #7FF0DF; }

/* ---------- banners ---------- */
.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-bottom: 10px;
  border-radius: 20px; background: var(--card); box-shadow: var(--shadow); cursor: pointer;
}
.banner > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.banner b { font-weight: 600; font-size: 15px; }
.banner small { color: var(--mute); }
.b-ic { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.banner.warn .b-ic { background: var(--coral-soft); color: var(--coral); }
.banner.apk .b-ic { background: var(--pri-soft); color: var(--pri); }
.banner.stock .b-ic { background: var(--amber-soft); color: var(--amber); }
.b-go { color: var(--mute); }
.b-x { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: var(--mute); }

/* ---------- doses ---------- */
.period { margin-top: 18px; }
.period h3 { display: flex; align-items: center; gap: 9px; margin: 0 4px 10px; font-size: 16px; font-weight: 600; }
.period h3 em { margin-inline-start: auto; font-style: normal; font-size: 13px; color: var(--mute); font-weight: 500; direction: ltr; }
.p-ic { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
.p-morning .p-ic { background: linear-gradient(135deg, #FFC46B, #FF7A59); }
.p-noon .p-ic { background: linear-gradient(135deg, #4CC9F0, #3B82F6); }
.p-evening .p-ic { background: linear-gradient(135deg, #B794F6, #EC4899); }
.p-night .p-ic { background: linear-gradient(135deg, #6D7CFF, #1E2A78); }

.dose {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 12px 12px; margin-bottom: 10px; border-radius: 22px;
  background: var(--card); box-shadow: var(--shadow); cursor: pointer;
  transition: transform .15s, opacity .2s;
}
.dose:active { transform: scale(.985); }
.dose-art, .med-art, .h-art, .al-i-art {
  position: relative; flex: none; display: grid; place-items: center; border-radius: 16px; isolation: isolate;
}
.dose-art::before, .med-art::before, .big-art::before, .ed-art::before, .al-i-art::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--c); opacity: .14; z-index: -1;
}
.dose-art { width: 52px; height: 52px; }
.dose-main { flex: 1; min-width: 0; }
.dose-name { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dose-line { font-size: 13.5px; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dose-meta { margin-top: 3px; font-size: 12.5px; }
.dose-meta span { display: inline-flex; align-items: center; gap: 4px; }
.dose-meta .ok { color: var(--green); }
.dose-meta .bad { color: var(--coral); font-weight: 500; }
.dose-meta .due { color: var(--coral); font-weight: 600; }
.dose-side { display: flex; align-items: center; gap: 10px; flex: none; }
.dose-time { font-size: 17px; font-weight: 600; direction: ltr; color: var(--ink2); }
.tick {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--line); color: var(--line); background: var(--card);
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}
.tick:active { transform: scale(.88); }
.tick.fut { opacity: .45; }
.st-taken .tick { background: var(--green); border-color: var(--green); color: #fff; }
.st-taken .dose-name { color: var(--ink2); }
.st-taken .dose-art { opacity: .75; }
.st-skipped { opacity: .6; }
.st-skipped .tick { color: var(--mute); border-color: var(--line); background: var(--card2); }
.st-missed .tick { border-color: var(--coral); color: var(--coral); opacity: .7; }
.st-due { box-shadow: 0 0 0 2px var(--coral), var(--shadow); }
.st-due .tick { border-color: var(--coral); color: var(--coral); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 111, 89, .45); } 70% { box-shadow: 0 0 0 12px rgba(255, 111, 89, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 111, 89, 0); } }
.dose.just .tick { animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }

.none { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 20px; color: var(--mute); text-align: center; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 18px 10px 30px; }
.empty-art { position: relative; height: 150px; margin: 10px auto 8px; width: 240px; }
.empty-art span {
  position: absolute; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 30px;
  background: var(--card); box-shadow: var(--shadow-up); isolation: isolate; animation: float 5s ease-in-out infinite;
}
.empty-art span::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--c); opacity: .12; z-index: -1; }
.empty-art span:nth-child(1) { left: 74px; top: 6px; z-index: 2; }
.empty-art span:nth-child(2) { left: 8px; top: 52px; transform: rotate(-10deg); animation-delay: -1.5s; }
.empty-art span:nth-child(3) { right: 8px; top: 48px; transform: rotate(9deg); animation-delay: -3s; }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.empty h2 { margin: 8px 0 6px; font-size: 21px; font-weight: 600; }
.empty p { margin: 0 auto 20px; max-width: 320px; color: var(--mute); }

/* ---------- medicines ---------- */
.meds { display: flex; flex-direction: column; gap: 10px; }
.med {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 22px;
  background: var(--card); box-shadow: var(--shadow); cursor: pointer; transition: opacity .2s;
}
.med.off { opacity: .55; }
.med-art { width: 56px; height: 56px; border-radius: 18px; }
.med-main { flex: 1; min-width: 0; }
.med-name { font-weight: 600; font-size: 17px; }
.med-line { font-size: 13.5px; color: var(--mute); }
.med-times { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; direction: ltr; justify-content: flex-end; }
[dir=ltr] .med-times { justify-content: flex-start; }
.med-times span { padding: 3px 9px; border-radius: 9px; background: var(--card2); font-size: 13px; font-weight: 600; color: var(--ink2); border: 1px solid var(--line); }
.med-tags { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 12.5px; color: var(--mute); }
.med-tags span { display: inline-flex; align-items: center; gap: 4px; }
.med-tags .warn { color: var(--amber); font-weight: 600; }

.switch { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--track); flex: none; transition: background .2s; }
.switch i { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.switch.on { background: var(--pri); }
.switch.on i { transform: translateX(20px); }
[dir=rtl] .switch.on i { transform: translateX(-20px); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; z-index: 20; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 520px; display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: end;
  padding: 6px 8px calc(var(--sb) + 8px);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.6); backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) { .tabbar { background: var(--card); } }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 2px; color: var(--mute); font-size: 11px; font-weight: 500; }
.tab span { white-space: nowrap; }
.tab.on { color: var(--pri); }
.tab.on .ic { animation: bounce .35s; }
@keyframes bounce { 50% { transform: translateY(-3px); } }
.fab {
  justify-self: center; width: 62px; height: 62px; margin-top: -30px; border-radius: 22px;
  display: grid; place-items: center; color: #fff; background: var(--grad);
  box-shadow: 0 10px 24px rgba(10, 127, 160, .4), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .15s;
}
.fab:active { transform: scale(.92) rotate(90deg); }
.round { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none; }
.round.pri { background: var(--grad); color: #fff; box-shadow: 0 8px 18px rgba(10, 127, 160, .3); }
.round.ghost { background: var(--card2); }
.round.soft { background: var(--pri-soft); color: var(--pri); }
.round.sm { width: 34px; height: 34px; border-radius: 11px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: 16px; font-weight: 600; font-size: 15px; text-decoration: none;
  transition: transform .12s, opacity .2s; text-align: center;
}
.btn:active { transform: scale(.97); }
.btn.pri { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(10, 127, 160, .28); }
.btn.soft { background: var(--card2); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost { color: var(--pri); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--red); }
.btn.big { padding: 16px 22px; font-size: 17px; border-radius: 18px; }
.btn.sm { padding: 9px 13px; font-size: 14px; border-radius: 13px; }
.btn.xs { padding: 7px 12px; font-size: 13px; border-radius: 11px; }
.btn.full { width: 100%; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.inp {
  width: 100%; padding: 13px 14px; font-size: 16px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--card2); outline: none; transition: border-color .15s, box-shadow .15s;
}
.inp:focus { border-color: var(--pri); box-shadow: 0 0 0 4px rgba(13, 169, 156, .14); background: var(--card); }
.inp.big { font-size: 19px; font-weight: 600; padding: 15px 16px; }
textarea.inp { resize: none; }
select.inp { appearance: none; -webkit-appearance: none; background-image: none; }

/* ---------- sheets ---------- */
#sheets { position: relative; z-index: 60; }
.sheet-wrap { position: fixed; inset: 0; z-index: 60; }
.sheet-bg { position: absolute; inset: 0; background: rgba(5, 12, 24, .5); opacity: 0; transition: opacity .3s; }
.sheet {
  position: absolute; left: 50%; bottom: 0; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  transform: translate(-50%, 104%); transition: transform .34s cubic-bezier(.2, .8, .2, 1);
  background: var(--card); border-radius: 28px 28px 0 0; padding: 6px 20px calc(var(--sb) + 22px);
  box-shadow: var(--shadow-up); overscroll-behavior: contain;
}
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-wrap.open .sheet { transform: translate(-50%, 0); }
.grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 6px auto 12px; }
.sheet-wrap.full .sheet { top: calc(var(--st) + 10px); max-height: none; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.sheet-wrap.full .grab { display: none; }

.confirm { text-align: center; padding: 4px 4px 0; }
.confirm h2 { margin: 6px 0 6px; font-size: 20px; font-weight: 600; }
.confirm p { margin: 0 0 18px; color: var(--mute); }
.en-ic { width: 72px; height: 72px; margin: 6px auto 4px; border-radius: 24px; display: grid; place-items: center; background: var(--pri-soft); color: var(--pri); }

/* dose sheet */
.dose-sheet { text-align: center; }
.big-art { position: relative; isolation: isolate; width: 104px; height: 104px; border-radius: 34px; margin: 4px auto 10px; display: grid; place-items: center; }
.dose-sheet h2 { margin: 0; font-size: 22px; font-weight: 600; }
.dose-sheet .mut { margin: 2px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 12px; background: var(--card2); font-size: 14px; color: var(--ink2); }
.note { display: flex; gap: 8px; align-items: flex-start; justify-content: center; margin: 0 0 12px; color: var(--ink2); font-size: 14px; }
.st-pill { display: inline-block; margin-bottom: 18px; padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 500; background: var(--card2); color: var(--ink2); }
.st-pill.st-taken { background: var(--green-soft); color: var(--green); }
.st-pill.st-missed, .st-pill.st-due { background: var(--coral-soft); color: var(--coral); }

/* ---------- editor ---------- */
.ed-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  background: var(--card);
}
.ed-head h2 { flex: 1; margin: 0; font-size: 18px; font-weight: 600; text-align: center; }
.ed-body { flex: 1; overflow-y: auto; padding: 8px 20px calc(var(--sb) + 30px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.ed-preview { display: grid; place-items: center; padding: 10px 0 4px; }
.ed-art { position: relative; isolation: isolate; width: 108px; height: 108px; border-radius: 36px; display: grid; place-items: center; transition: transform .2s; }
.ed-art .pill-art { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .12)); }
.field { display: block; margin: 20px 0; }
.f-label { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.f-label em { font-style: normal; font-weight: 400; color: var(--mute); font-size: 12.5px; }
.hint { margin-top: 6px; font-size: 13px; color: var(--mute); }
.forms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.form-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px 8px;
  border-radius: 16px; background: var(--card2); border: 1.5px solid transparent; transition: border-color .15s, background .15s;
}
.form-opt small { font-size: 12px; color: var(--ink2); }
.form-opt.on { border-color: var(--pri); background: var(--pri-soft); }
.colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; justify-items: center; }
.color { width: 32px; height: 32px; border-radius: 50%; background: var(--c); transition: transform .15s; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); }
.color.on { box-shadow: 0 0 0 3px var(--card), 0 0 0 5.5px var(--c); transform: scale(1.06); }
.dose-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.dose-row .inp { flex: 1; }
.stepper { display: inline-flex; align-items: center; border-radius: 14px; background: var(--card2); border: 1.5px solid var(--line); flex: none; direction: ltr; }
.stepper button { width: 46px; height: 46px; font-size: 22px; color: var(--pri); }
.stepper b { min-width: 46px; text-align: center; font-size: 18px; font-weight: 600; }
.times { display: flex; flex-wrap: wrap; gap: 8px; }
.time-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 14px;
  background: var(--card2); border: 1.5px solid var(--line); color: var(--pri); direction: ltr;
}
.time-chip input { border: 0; background: transparent; font-size: 19px; font-weight: 600; color: var(--ink); padding: 6px 2px; min-width: 84px; outline: none; }
.time-chip input::-webkit-calendar-picker-indicator { display: none; }
.time-chip button { width: 30px; height: 30px; display: grid; place-items: center; color: var(--mute); border-radius: 9px; }
.time-add { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 14px; border: 1.5px dashed var(--pri); color: var(--pri); font-weight: 600; font-size: 14px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pchip { padding: 6px 11px; border-radius: 999px; background: var(--card2); font-size: 13px; color: var(--ink2); border: 1px solid var(--line); }
.pchip b { font-weight: 600; direction: ltr; display: inline-block; }
.pchip.on { background: var(--pri-soft); color: var(--pri); border-color: var(--pri); }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 15px; background: var(--card2); border: 1px solid var(--line); }
.seg button { flex: 1; padding: 9px 8px; border-radius: 11px; font-size: 14px; font-weight: 500; color: var(--ink2); transition: background .15s, color .15s; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--pri); font-weight: 600; box-shadow: 0 1px 6px rgba(13, 27, 46, .1); }
.seg.wrap { flex-wrap: wrap; background: none; border: 0; padding: 0; gap: 7px; }
.seg.wrap button { flex: none; background: var(--card2); border: 1px solid var(--line); padding: 8px 13px; }
.seg.wrap button.on { background: var(--pri-soft); border-color: var(--pri); box-shadow: none; }
.seg.sm button { padding: 6px 12px; min-width: 42px; }
.seg.full { width: 100%; }
.wdays { display: flex; justify-content: space-between; gap: 4px; margin-top: 10px; }
.wdays button { width: 42px; height: 42px; border-radius: 50%; background: var(--card2); border: 1.5px solid var(--line); font-weight: 600; color: var(--ink2); }
.wdays button.on { background: var(--grad); border-color: transparent; color: #fff; }
.mini { display: block; margin-bottom: 10px; }
.mini small { display: block; margin-bottom: 4px; color: var(--mute); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check-row input { position: absolute; opacity: 0; pointer-events: none; }
.check-row i { position: relative; width: 48px; height: 28px; border-radius: 999px; background: var(--track); flex: none; transition: background .2s; }
.check-row i::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); transition: transform .2s; }
.check-row input:checked + i { background: var(--pri); }
.check-row input:checked + i::after { transform: translateX(20px); }
[dir=rtl] .check-row input:checked + i::after { transform: translateX(-20px); }
.sound-box { padding: 12px; border-radius: 16px; background: var(--card2); border: 1px solid var(--line); }
.sound-cur { display: flex; align-items: center; gap: 10px; color: var(--pri); }
.sound-cur span { flex: 1; color: var(--ink); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sound-box .btn-row { margin-top: 10px; }
.ed-space { height: 20px; }

/* ---------- history ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); text-align: center; }
.stat small { color: var(--mute); font-size: 12px; line-height: 1.3; }
.stat-ring { position: relative; width: 64px; height: 64px; }
.stat-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 15px; font-weight: 600; direction: ltr; }
.streak-n { height: 64px; display: flex; align-items: center; gap: 4px; color: var(--coral); }
.streak-n b { font-size: 28px; font-weight: 600; color: var(--ink); }
.card { padding: 16px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow); margin-bottom: 12px; }
.card h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 16px; font-weight: 600; }
.bars { display: flex; gap: 5px; align-items: flex-end; height: 130px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.bar-col { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 7px; overflow: hidden; min-height: 0; animation: grow .6s cubic-bezier(.2, .8, .2, 1) both; transform-origin: bottom; }
@keyframes grow { from { transform: scaleY(0); } }
.bar-stack i { display: block; min-height: 3px; }
.bar span { font-size: 11px; color: var(--mute); }
.bar.is-today span { color: var(--pri); font-weight: 600; }
.b-tk { background: linear-gradient(180deg, #2DD4BF, #0DA99C); }
.b-ms { background: var(--coral); }
.b-sk { background: #A9B5C6; }
.b-up { background: var(--track); }
.legend { display: flex; gap: 14px; margin-top: 12px; font-size: 12.5px; color: var(--mute); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: block; }
.hday { margin-bottom: 14px; }
.hday h4 { display: flex; justify-content: space-between; margin: 0 4px 8px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.hday h4 em { font-style: normal; color: var(--mute); direction: ltr; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); cursor: pointer; }
.h-art { width: 36px; height: 36px; border-radius: 12px; background: var(--card2); }
.h-name { flex: 1; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-time { direction: ltr; color: var(--mute); font-size: 14px; }
.h-st { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--card2); color: var(--mute); }
.hrow.st-taken .h-st { background: var(--green); color: #fff; }
.hrow.st-missed .h-st { background: var(--coral-soft); color: var(--coral); }
.hrow.st-due .h-st { background: var(--coral); color: #fff; }

/* ---------- settings ---------- */
.set p { margin: 0 0 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: 0; }
.set-row > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.set-row small { color: var(--mute); display: flex; align-items: center; gap: 4px; }
.set-row.col { flex-direction: column; align-items: stretch; }
.okdot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--green); color: #fff; flex: none; }
.perms { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.perm { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 16px; background: var(--coral-soft); }
.perm b { flex: 1; font-weight: 500; font-size: 14.5px; }
.perm em { font-style: normal; font-size: 13px; color: var(--green); font-weight: 600; }
.perm-ic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--coral); color: #fff; flex: none; }
.perm.ok { background: var(--card2); }
.perm.ok .perm-ic { background: var(--green); }
.set > .btn.full { margin-top: 12px; }
.tip { display: flex; gap: 8px; align-items: flex-start; margin: 12px 0 0 !important; padding: 10px 12px; border-radius: 14px; background: var(--card2); color: var(--ink2); font-size: 13px; }
.tip .ic { margin-top: 2px; color: var(--pri); }
.sub { padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }
.sub b { display: block; }
.sub small { display: block; color: var(--mute); margin-bottom: 10px; }
.ios-guide { padding: 14px; border-radius: 18px; background: var(--pri-soft); margin-bottom: 12px; text-align: start; }
.ios-guide b { color: var(--pri2); }
.ios-guide p { margin: 4px 0 8px; color: var(--ink2); font-size: 14px; }
.ios-guide ol { margin: 0; padding-inline-start: 22px; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.inline-ic { display: inline-grid; place-items: center; vertical-align: middle; width: 28px; height: 28px; border-radius: 8px; background: var(--card); color: #0A84FF; margin: 0 2px; }
.about { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 20px 10px; text-align: center; color: var(--mute); }
.about b { color: var(--ink); font-weight: 600; font-size: 17px; margin-top: 6px; }
.about p { font-size: 13px; max-width: 340px; margin: 6px 0 0; }
.apk-card { border: 1.5px solid var(--pri); }

/* ---------- toast ---------- */
#toast { position: fixed; z-index: 120; left: 0; right: 0; bottom: calc(var(--sb) + 96px); display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 14px; max-width: 480px; padding: 12px 16px; border-radius: 16px;
  background: #0E1C31; color: #fff; font-size: 14.5px; box-shadow: 0 12px 30px rgba(0, 0, 0, .3);
  opacity: 0; transform: translateY(12px) scale(.98); transition: opacity .25s, transform .25s; pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }
.toast.warn { background: #7A2318; }
.toast button { color: #5EEAD4; font-weight: 600; flex: none; }

/* ---------- alarm ---------- */
#alarm { position: fixed; inset: 0; z-index: 100; display: none; color: #fff; }
#alarm.open { display: block; animation: fade .3s both; }
@keyframes fade { from { opacity: 0; } }
.al-bg { position: absolute; inset: 0; background: linear-gradient(170deg, #12305E 0%, #081427 60%, #050B16 100%); overflow: hidden; }
.al-bg::before, .al-bg::after { content: ''; position: absolute; border-radius: 50%; filter: blur(10px); }
.al-bg::before { width: 130vw; height: 130vw; left: -15vw; top: -40vw; background: radial-gradient(circle, var(--c), transparent 62%); opacity: .45; animation: breathe 6s ease-in-out infinite; }
.al-bg::after { width: 90vw; height: 90vw; right: -30vw; bottom: -20vw; background: radial-gradient(circle, #22D3EE, transparent 65%); opacity: .18; animation: breathe 7s ease-in-out infinite reverse; }
@keyframes breathe { 50% { transform: scale(1.12); } }
.al-in {
  position: relative; height: 100%; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; align-items: center;
  padding: calc(var(--st) + 26px) 22px calc(var(--sb) + 22px); overflow-y: auto;
}
.al-clock { font-size: 64px; font-weight: 300; letter-spacing: -.02em; line-height: 1; direction: ltr; }
.al-title { margin-top: 10px; font-size: 19px; font-weight: 500; opacity: .9; text-align: center; }
.al-ripple { position: relative; width: 210px; height: 210px; margin: 22px 0 18px; display: grid; place-items: center; flex: none; }
.al-ripple span { position: absolute; inset: 30px; border-radius: 50%; border: 2px solid var(--c); opacity: 0; animation: ripple 2.7s cubic-bezier(.2, .6, .3, 1) infinite; }
.al-ripple span:nth-child(2) { animation-delay: .9s; }
.al-ripple span:nth-child(3) { animation-delay: 1.8s; }
@keyframes ripple { 0% { transform: scale(.75); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }
.al-pill { width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; background: #fff; box-shadow: 0 18px 50px rgba(0, 0, 0, .35), 0 0 0 10px rgba(255, 255, 255, .08); animation: wiggle 2.7s ease-in-out infinite; }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-9deg); } 82% { transform: rotate(8deg); } 89% { transform: rotate(-5deg); } }
.al-list { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.al-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 20px; background: rgba(255, 255, 255, .09); border: 1px solid rgba(255, 255, 255, .1); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.al-i-art { width: 44px; height: 44px; border-radius: 14px; background: rgba(255, 255, 255, .92); }
.al-i-art::before { display: none; }
.al-i-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.al-i-txt b { font-size: 18px; font-weight: 600; }
.al-i-txt small { opacity: .75; }
.al-note { color: #FFD7A8; opacity: 1 !important; }
.al-time { font-size: 18px; font-weight: 600; direction: ltr; opacity: .85; }
.al-actions { width: 100%; margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.al-take {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 20px; border-radius: 24px;
  background: #fff; color: #0B6E7C; font-size: 19px; font-weight: 700; box-shadow: 0 14px 36px rgba(0, 0, 0, .35);
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 14px 36px rgba(0, 0, 0, .35), 0 0 0 8px rgba(255, 255, 255, .12); } }
.al-take:active { transform: scale(.98); }
.al-row { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.al-row button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 15px 10px; border-radius: 20px; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .14); color: #fff; font-weight: 600; font-size: 15px; }
body.alarm-mode { background: #081427; }
body.alarm-mode::before { display: none; }

/* ---------- onboarding ---------- */
.onb {
  position: relative; min-height: 100vh; overflow: hidden; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(var(--st) + 50px) 26px calc(var(--sb) + 26px); color: #fff;
  background: linear-gradient(165deg, #12396B 0%, #0B1C36 55%, #06101F 100%);
}
.onb-glow { position: absolute; width: 520px; height: 520px; top: -200px; left: 50%; transform: translateX(-50%); background: radial-gradient(circle, rgba(28, 200, 180, .5), transparent 65%); pointer-events: none; }
.onb > *:not(.onb-glow) { position: relative; }
.onb-logo { filter: drop-shadow(0 18px 40px rgba(28, 200, 180, .45)); animation: float 5s ease-in-out infinite; }
.onb h1 { margin: 18px 0 4px; font-size: 38px; font-weight: 700; letter-spacing: -.01em; }
.onb-tag { margin: 0; font-size: 17px; opacity: .85; max-width: 320px; }
.onb-points { list-style: none; padding: 0; margin: 30px 0; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; text-align: start; }
.onb-points li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .09); font-size: 15px; }
.onb-points span { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(28, 200, 180, .22); color: #5EEAD4; flex: none; }
.onb-lang { width: 100%; max-width: 380px; margin-top: auto; margin-bottom: 14px; }
.onb-lang small { display: block; opacity: .7; margin-bottom: 8px; }
.onb .seg { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .12); }
.onb .seg button { color: rgba(255, 255, 255, .8); padding: 12px; font-size: 16px; }
.onb .seg button.on { background: #fff; color: #0B6E7C; }
.onb .btn.pri { max-width: 380px; background: linear-gradient(135deg, #2DE0C8, #12A0BC); }

/* small phones */
@media (max-width: 360px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .wd-n { font-size: 10px; }
  .dose-art { width: 44px; height: 44px; }
  .forms { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .al-clock { font-size: 52px; }
}
/* desktop: keep the phone layout in the middle */
body.desk .shell { padding-top: 24px; }
