:root {
    --bg: #0a2e2f; --bg2: #041718; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #ecfbfa; --muted: #a9d6d4; --accent: #5fd3cf; --accent-ink: #032223; --field: rgba(255,255,255,.08);
    --soft: rgba(95,211,207,.15); --good: #8ce99a; --good-bg: rgba(140,233,154,.12); --warn: #ffd43b; --warn-bg: rgba(255,212,59,.13); --bad: #ffa8a8; --bad-bg: rgba(255,168,168,.13);
    --gold: #fcd34d;
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #f1fafa; --bg2: #dff1f1; --card: #fff; --line: #bfdcdc; --ink: #062728; --muted: #3c6667; --accent: #0b7476; --accent-ink: #fff; --field: #f8fdfd; --soft: #dcf2f2; --good: #2b8a3e; --good-bg: #ebfbee; --warn: #995c00; --warn-bg: #fff3d6; --bad: #c92a2a; --bad-bg: #fff0f0; --gold: #b7791f; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #f1fafa; --bg2: #dff1f1; --card: #fff; --line: #bfdcdc; --ink: #062728; --muted: #3c6667; --accent: #0b7476; --accent-ink: #fff; --field: #f8fdfd; --soft: #dcf2f2; --good: #2b8a3e; --good-bg: #ebfbee; --warn: #995c00; --warn-bg: #fff3d6; --bad: #c92a2a; --bad-bg: #fff0f0; --gold: #b7791f; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #0a2e2f; --bg2: #041718; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #ecfbfa; --muted: #a9d6d4; --accent: #5fd3cf; --accent-ink: #032223; --field: rgba(255,255,255,.08);
    --soft: rgba(95,211,207,.15); --good: #8ce99a; --good-bg: rgba(140,233,154,.12); --warn: #ffd43b; --warn-bg: rgba(255,212,59,.13); --bad: #ffa8a8; --bad-bg: rgba(255,168,168,.13);
    --gold: #fcd34d;
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-main, .col-side { display: contents; }
.app > .topbar, .app > .back { order: 0; }
.app > header, .warn-box { order: 1; }
.counter { order: 2; }
.list { order: 3; }
.edit { order: 4; }
.hist { order: 5; }
.settings { order: 6; }
.app > .faq { order: 7; }
.app > footer { order: 8; }

header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .7rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label, legend { display: block; margin: .9rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
input[type=text], input[type=date], select { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
select, input[type=date] { -webkit-appearance: auto; appearance: auto; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
select option { color: #111; background: #fff; }
input:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
.hint { margin: .45rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.hint.top { margin-top: .9rem; }
[hidden] { display: none !important; }
.warn-box { margin: 0 0 .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--warn-bg); border-left: 5px solid var(--warn); font-weight: 600; }
.arabic, .ar-in, .f-ar { font-family: "Noto Naskh Arabic", "Amiri", "Scheherazade New", "Geeza Pro", "Arial", serif; }

/* buttons */
.primary, .secondary, .danger { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .8rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); }
.secondary { border: 1px solid var(--line); background: var(--field); color: var(--ink); font-weight: 600; }
.danger { border: 1px solid var(--bad); background: transparent; color: var(--bad); font-weight: 600; margin-top: .9rem; }
.link { display: block; min-height: 44px; margin-top: .3rem; padding: 0 .1rem; border: 0; background: none; color: var(--accent); font: inherit; font-size: .95rem; font-weight: 600; text-align: left; cursor: pointer; }
.err { margin: .4rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.err:empty { margin: 0; }
.msg { margin: 0; color: var(--muted); font-size: .95rem; overflow-wrap: anywhere; }
.msg.show { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .8rem; margin: .8rem 0 0; padding: .5rem .75rem; border-radius: 12px; background: var(--soft); color: var(--ink); }
.msg .undo { min-height: 40px; padding: 0 .9rem; border: 1px solid var(--accent); border-radius: 10px; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; }
.list .msg.show { margin: 0 0 .8rem; }
.row-btns { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.1rem; }
.row-btns > * { flex: 1 1 9rem; width: auto; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; margin-top: .6rem; }
.gap-top { margin-top: 1.1rem; }
.empty { margin: .4rem 0 .8rem; color: var(--muted); }

/* what are you counting */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chips:empty { display: none; }
.chip { min-height: 44px; max-width: 100%; padding: .3rem .9rem; border: 1px solid var(--line); border-radius: 999px; background: var(--field); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; text-align: left; line-height: 1.2; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .ok { margin-left: .3rem; font-weight: 800; }

/* the counter */
#cur { text-align: center; margin-top: 1rem; }
#cur h2 { margin: 0; font-size: 1.25rem; }
.arabic { margin: .35rem 0 0; font-size: 1.75rem; line-height: 1.6; overflow-wrap: anywhere; }
.arabic:empty, .cur-step:empty, .sub-line:empty { display: none; }
.cur-step { margin: .3rem 0 0; font-weight: 700; color: var(--accent); overflow-wrap: anywhere; }
.tap { display: flex; flex-direction: column; align-items: center; justify-content: center; width: min(240px, 72vw); aspect-ratio: 1; margin: 1rem auto .4rem; padding: 1rem;
       border: 6px solid var(--accent); border-radius: 50%; background: radial-gradient(circle at 50% 35%, var(--soft), var(--field) 70%); color: var(--ink);
       font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; transition: transform .06s, box-shadow .3s; }
.tap:active { transform: scale(.97); }
.tap:disabled { opacity: .5; cursor: default; }
.tap-n { font-size: clamp(3rem, 15vw, 4.2rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tap-sub { margin-top: .3rem; font-size: 1.05rem; font-weight: 700; color: var(--muted); }
.tap-sub:empty { display: none; }
.tap-hint { margin-top: .35rem; font-size: .82rem; color: var(--muted); }
.tap.flash { box-shadow: 0 0 0 10px var(--soft), 0 0 30px 6px var(--accent); }
.tap.done { border-color: var(--good); }
.tap.goal { box-shadow: 0 0 0 14px var(--good-bg), 0 0 40px 10px var(--good); }
.state { margin: .6rem 0 0; padding: .45rem .7rem; border-radius: 10px; font-weight: 700; overflow-wrap: anywhere; background: var(--soft); }
.state.good { background: var(--good-bg); color: var(--good); }
.state.none { background: var(--field); color: var(--muted); }
.bar { height: 12px; border-radius: 999px; background: var(--field); border: 1px solid var(--line); overflow: hidden; margin: .5rem 0 .2rem; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.bar.good span { background: var(--good); }
.sub-line { margin: .45rem 0 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; }
.c-btns { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.1fr) minmax(0, 1.1fr); gap: .4rem; margin-top: .8rem; }
.c-btns #minus { font-size: 1.15rem; }
.sub-box { margin-top: .7rem; padding: .1rem .8rem .8rem; border: 1px dashed var(--line); border-radius: 12px; text-align: left; }
.sub-box > label:first-child { margin-top: .6rem; }
#fix-round { margin-top: .5rem; }
.keys { margin-top: .9rem; text-align: center; }

/* my dhikr */
.box-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .6rem; }
.box-list:empty { display: none; }
.box { border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: .7rem .8rem .75rem; background: var(--field); min-width: 0; }
.box.done { border-left-color: var(--good); }
.box.on { outline: 2px solid var(--accent); outline-offset: -1px; }
.b-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .2rem .5rem; flex-wrap: wrap; min-width: 0; }
.b-name { margin: 0; font-size: 1.05rem; overflow-wrap: anywhere; min-width: 0; }
.badge { font-size: .78rem; font-weight: 700; padding: .1rem .6rem; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); white-space: nowrap; }
.b-ar { margin: .15rem 0 0; font-size: 1.2rem; line-height: 1.6; overflow-wrap: anywhere; }
.b-line { margin: .25rem 0 0; font-weight: 700; overflow-wrap: anywhere; }
.box.done .b-line { color: var(--good); }
.b-sub { margin: .15rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.b-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin-top: .6rem; }
.mini { min-height: 44px; padding: 0 .5rem; border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--accent); font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; min-width: 0; line-height: 1.15; overflow-wrap: normal; }
.mini:disabled { opacity: .45; cursor: default; }
.mini.del { color: var(--bad); }

/* add or change a dhikr */
.edit { border: 2px solid var(--accent); }
.choice { border: 0; margin: .5rem 0 0; padding: 0; min-width: 0; }
.edit form > .choice:first-child { margin-top: 0; }
.edit form > .choice:first-child legend { margin-top: 0; }
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.seg.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label { margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; min-height: 52px; padding: .35rem .3rem; border: 1px solid var(--line);
       border-radius: 12px; background: var(--field); color: var(--ink); font-size: .95rem; font-weight: 700; line-height: 1.2; cursor: pointer; overflow-wrap: normal; }
.seg label small { font-size: .74rem; font-weight: 500; color: var(--muted); margin-top: .15rem; }
.seg input:checked + label { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg input:checked + label small { color: var(--accent-ink); opacity: .85; }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt { min-width: 0; }
.wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; margin-top: .6rem; }
.wk button { min-height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--field); color: var(--ink); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; min-width: 0; }
.wk button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps { list-style: none; margin: .6rem 0 0; padding: 0; display: grid; gap: .5rem; }
.step { border: 1px solid var(--line); border-left: 6px solid var(--gold); border-radius: 12px; padding: .1rem .7rem .7rem; background: var(--field); min-width: 0; }
.step-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .5rem; }
.step-top h3 { margin: 0; font-size: .95rem; }
.step label { margin-top: .5rem; }
.step-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem; gap: .5rem; align-items: end; }
.step-row > div { min-width: 0; }
.step .err:empty { display: none; }
#step-add { margin-top: .6rem; }
.edit .danger { margin-top: 1rem; }

/* last 7 days */
.week, .days { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.week:empty, .days:empty { display: none; }
.week li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 .6rem; padding: .45rem .7rem; border: 1px solid var(--line); border-left: 5px solid var(--accent); border-radius: 10px; background: var(--field); min-width: 0; }
.week .k { font-weight: 700; overflow-wrap: anywhere; min-width: 0; }
.week .v { font-weight: 700; color: var(--accent); }
.week .d { flex-basis: 100%; color: var(--muted); font-size: .86rem; }
.days { margin-top: .8rem; }
.days li { padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 10px; min-width: 0; font-size: .92rem; }
.days .day { font-weight: 700; margin-right: .4rem; }
.days .c { color: var(--muted); overflow-wrap: anywhere; }
.days .c b { color: var(--ink); }

/* full screen counting: always dark, the whole screen is the button */
.focus { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; background: #020d0e; color: #dff5f4; padding: max(.8rem, env(safe-area-inset-top)) .8rem max(.8rem, env(safe-area-inset-bottom)); }
.f-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.f-name { margin: 0; flex: 1 1 auto; min-width: 0; text-align: center; font-weight: 700; color: #8fc9c6; overflow-wrap: anywhere; }
.f-btn { min-height: 48px; min-width: 64px; padding: 0 1rem; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; background: transparent; color: #dff5f4; font: inherit; font-weight: 700; cursor: pointer; }
.f-tap { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; margin-top: .8rem; border: 0; border-radius: 20px;
       background: radial-gradient(circle at 50% 45%, rgba(95,211,207,.10), transparent 65%); color: #dff5f4; font: inherit; cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; padding: 1rem; min-height: 0; }
.f-ar { font-size: clamp(1.6rem, 7vw, 2.6rem); line-height: 1.6; color: #b8e6e3; max-width: 100%; overflow-wrap: anywhere; }
.f-step { font-weight: 700; color: #5fd3cf; }
.f-step:empty, .f-ar:empty { display: none; }
.f-n { font-size: clamp(5rem, 30vw, 10rem); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.f-line { color: #8fc9c6; font-weight: 600; text-align: center; }
.f-hint { color: #5d8886; font-size: .9rem; }
.f-tap.flash { background: radial-gradient(circle at 50% 45%, rgba(95,211,207,.35), transparent 70%); }
.f-tap:focus-visible, .f-btn:focus-visible { outline: 3px solid #5fd3cf; outline-offset: 2px; }

/* questions */
.faq { margin-top: 1.2rem; }
.faq details { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 .5rem; background: var(--card); }
.faq summary { cursor: pointer; padding: .75rem .9rem; font-weight: 600; min-height: 44px; }
.faq details p { margin: 0; padding: 0 .9rem .8rem; color: var(--muted); }
footer { margin-top: 1.4rem; text-align: center; font-size: .9rem; }
footer a { color: var(--muted); }

/* back to the list of all apps */
.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }
@media print { .back, .focus { display: none; } }

/* narrow phones */
@media (max-width: 420px) {
    .card { padding: 1rem .8rem; }
    .box { padding: .65rem .65rem .7rem; }
    .tool-grid { grid-template-columns: minmax(0, 1fr); }
    .row-btns > * { flex-basis: 100%; }
    h1 { font-size: 1.45rem; }
    .seg label { font-size: .88rem; padding: .35rem .2rem; }
    .seg.three label small { font-size: .7rem; }
    .wk button { font-size: .78rem; }
}
@media (max-width: 360px) {
    .topbar .theme-toggle { padding: 0; width: 44px; justify-content: center; }
    .topbar .theme-toggle span { display: none; }
    .seg.three { grid-template-columns: minmax(0, 1fr); }
    .seg.three label { flex-direction: row; gap: .4rem; justify-content: center; }
    .seg.three label small { margin-top: 0; }
    .step-row { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .c-btns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .c-btns #minus { grid-column: 1 / -1; }
}

/* laptops and desktops: the counter and the last 7 days on the left, the list, settings and backup on the right */
@media (min-width: 900px) {
    .app { width: min(1140px, 100%); display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .col-main, .col-side { display: block; min-width: 0; }
    .app > .topbar { grid-row: 1; }
    .app > header { grid-row: 2; }
    .app > .warn-box { grid-row: 3; }
    .app > .col-main { grid-column: 1; grid-row: 4; }
    .app > .col-side { grid-column: 2; grid-row: 4; }
    .app > .faq { grid-row: 5; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.2rem; }
    .tap { width: 270px; }
    #cur-ar { font-size: 2rem; }
}
