/* Iqama Times: the printed-timetable look, the handwritten look, and four brightness levels.
   Loaded after styles.css. app.js sets on <html>:
     data-palette  paper | hand | contrast        (Settings, Display, Look)
     data-dim      0 bright, 1 soft, 2 dim, 3 darkest (the brightness button, or Auto after Isha or Maghrib)
     data-theme    light up to Dim, dark at Darkest (and from Dim in High contrast), for the rules in styles.css that only know light and dark
   Dim is a warm-light page, like an e-reader's night light: amber paper and dark ink, no blue and no white, softer contrast (about 7:1).
   A web page cannot change the screen's backlight, so the levels lower the page's own brightness and contrast. Text keeps
   4.5:1 contrast on its paper at every level except Darkest, where the muted text is kept around 4:1 on purpose so nothing glows. */

:root {
  --display: "Newsreader", "Iowan Old Style", Georgia, serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Kalam", "Segoe Print", "Bradley Hand", cursive;
  --ar: "Amiri", serif;
  --rule-w: 1px;
}

/* Printed timetable: warm paper, ink, one red */
:root, :root[data-palette="paper"] {
  --paper: #F3EDE1; --surface: #FBF8F1; --ink: #1C1914; --muted: #5F5647; --line: #CFC4AE; --clear: #A8321F; --risk: #9E1B1B;
}
:root[data-palette="paper"][data-dim="1"] { --paper: #D8CFBE; --surface: #E0D8C8; --ink: #29241C; --muted: #50483A; --line: #B3A68E; --clear: #8A2818; --risk: #7E1616; }
:root[data-palette="paper"][data-dim="2"] { --paper: #B8A07A; --surface: #C0A983; --ink: #22190F; --muted: #45351F; --line: #9A845E; --clear: #6B1D10; --risk: #6B1D10; }
:root[data-palette="paper"][data-dim="3"] { --paper: #000000; --surface: #0A0806; --ink: #A9803F; --muted: #90713F; /* 4.6:1 on black */ --line: #1E1810; --clear: #E6B05A; --risk: #C96A4E; color-scheme: dark; }

/* Handwritten: blue-black pen on a ruled sheet, red pen for what matters next */
:root[data-palette="hand"] {
  --paper: #F6F1E4; --surface: #FCFAF3; --ink: #1F2B47; --muted: #4F5A74; --line: #C3CBDA; --clear: #B0302A; --risk: #9E1B1B; --margin: #E2A49C;
  --ar: "Aref Ruqaa", "Amiri", serif;
}
:root[data-palette="hand"][data-dim="1"] { --paper: #DCD6C6; --surface: #E4DECF; --ink: #22304D; --muted: #46506A; --line: #AAB2C2; --clear: #8F2520; --margin: #C98E86; }
:root[data-palette="hand"][data-dim="2"] { --paper: #BAA582; --surface: #C2AE8C; --ink: #1C2132; --muted: #3D3A38; --line: #A08B67; --clear: #6B1D10; --risk: #6B1D10; --margin: #8E4A3A; }
:root[data-palette="hand"][data-dim="3"] { --paper: #000000; --surface: #08080A; --ink: #9E9175; --muted: #7F7664; /* 4.7:1, set well apart from the ink */ --line: #1A1A1E; --clear: #B98A5A; --risk: #C96A4E; --margin: #2A1C18; color-scheme: dark; }

/* E-ink: matte warm-grey paper and black ink, no colour at all; at night black with grey type, nothing bright.
   Measured against the page: ink 15.5 / 12.5 / 8.7 / 7.5 to 1 (Bright, Soft, Dim, Darkest), greyed times 7.9 / 7.5 / 6.3 / 4.6. */
:root[data-palette="eink"] { --paper: #F4F2EC; --surface: #F4F2EC; --ink: #1A1A1A; --muted: #4A4A4A; --line: #C9C6BE; --clear: #1A1A1A; --risk: #1A1A1A; }
:root[data-palette="eink"][data-dim="1"] { --paper: #D9D6CF; --surface: #D9D6CF; --ink: #161616; --muted: #3D3D3D; --line: #AEABA3; --clear: #161616; --risk: #161616; }
:root[data-palette="eink"][data-dim="2"] { --paper: #B3B0A8; --surface: #B3B0A8; --ink: #111111; --muted: #2E2E2E; --line: #8F8C85; --clear: #111111; --risk: #111111; }
:root[data-palette="eink"][data-dim="3"] { --paper: #000000; --surface: #000000; --ink: #9A9A9A; --muted: #767676; --line: #262626; --clear: #9A9A9A; --risk: #9A9A9A; color-scheme: dark; }
/* Settings at Darkest: set-up work needs easier reading than the clock across the room. The same black page with brighter warm
   ink (no white, no blue), so the screen still gives off little light at night. Today and the other tabs stay as they are. */
:root[data-palette="paper"][data-dim="3"][data-tab="settings"] { --ink: #D4A458; --muted: #B8924F; /* 9.3:1 and 7.3:1 on black */ }
:root[data-palette="hand"][data-dim="3"][data-tab="settings"] { --ink: #CFC2A3; --muted: #ADA38B; }
:root[data-palette="eink"][data-dim="3"][data-tab="settings"] { --ink: #C4C4C4; --muted: #A2A2A2; --clear: #C4C4C4; --risk: #C4C4C4; }

/* High contrast: white and black, and black and white from Dim */
:root[data-palette="contrast"] { --paper: #FFFFFF; --surface: #FFFFFF; --ink: #000000; --muted: #262626; --line: #595959; --clear: #0037B3; --risk: #A4001D; --rule-w: 2px; }
:root[data-palette="contrast"][data-dim="1"] { --paper: #E6E6E6; --surface: #EDEDED; }
:root[data-palette="contrast"][data-dim="2"], :root[data-palette="contrast"][data-dim="3"] { --paper: #000000; --surface: #000000; --ink: #FFFFFF; --muted: #E0E0E0; --line: #9E9E9E; --clear: #FFE14D; --risk: #FF6B6B; color-scheme: dark; }
:root[data-palette="contrast"][data-dim="3"] { --ink: #D0D0D0; --muted: #B0B0B0; }

/* The weather sky stays a faint wash over the paper, and goes away at Darkest */
:root { --sky: color-mix(in srgb, var(--sky-base) 28%, var(--paper)); --board-bg: var(--surface); --board-fg: var(--ink); }
:root[data-dim="3"] .sky-tint, :root[data-dim="3"] .sky-print, :root[data-dim="2"]:not([data-palette="contrast"]):not([data-tab="weather"]) .sky-tint, :root[data-dim="2"]:not([data-palette="contrast"]):not([data-tab="weather"]) .sky-print { display: none; } /* a still, warm page at night */
:root[data-nightsky="0"][data-dim="3"] .sky-live, :root[data-nightsky="0"][data-dim="3"] .sky-real, :root[data-nightsky="0"][data-dim="2"]:not([data-palette="contrast"]):not([data-tab="weather"]) .sky-live, :root[data-nightsky="0"][data-dim="2"]:not([data-palette="contrast"]):not([data-tab="weather"]) .sky-real { display: none; } /* a brightness you set by hand (Dim, Darkest) is a still page; the night sky shows when the realistic sky is on and night brings its own dark look */

/* Print, not app: square corners, hairlines, no filled pills */
:root { --radius-selector: 2px; --radius-field: 2px; --radius-box: 2px; }
body { font-feature-settings: "kern", "liga"; }
.tb-btn { border-radius: 2px; }
.d-btn { box-shadow: none; text-transform: none; font-weight: 500; letter-spacing: .005em; }
.d-btn-primary:not(.d-btn-soft) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.d-btn-soft.d-btn-primary { background: transparent; border: 1px solid var(--line); color: var(--ink); }
@media (hover: hover) { .d-btn-soft.d-btn-primary:hover { border-color: var(--ink); background: transparent; } }
.iq-ask, .dk, .qp-dlg-in, .au-list li, .qp-pane { border-radius: 2px; }
.iq-ask { background: transparent; border: 0; border-top: 2px solid var(--ink); border-bottom: var(--rule-w) solid var(--line); padding-inline: 0; }
.dk { background: transparent; border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding-inline: 0; }

/* Top bar: a heading set like a printed sheet */
.topbar h1 { font: 500 clamp(1.9rem, 3.6vw, 2.6rem)/1 var(--display); font-stretch: normal; letter-spacing: -.01em; }
.topbar { margin-inline: clamp(1rem, 3vw, 2.5rem); padding-inline: 0; margin-bottom: 1rem; }
#date { font-family: var(--display); font-size: 1.1rem; color: var(--ink); }

/* Side bar: a column of entries, the open one marked with a rule, not a filled block */
.tabbar { background: transparent; border-right: var(--rule-w) solid var(--line); }
.tabbar .d-menu a { border-radius: 0; font-weight: 500; color: var(--muted); }
@media (hover: hover) { .tabbar .d-menu a:hover { background: transparent; color: var(--ink); } }
.tabbar .d-menu a.d-menu-active, .tabbar .d-menu a.d-menu-active:hover { background: transparent; color: var(--ink); box-shadow: inset 3px 0 0 var(--clear); }
.brand-bg { fill: var(--ink); } .brand-sq { fill: var(--paper); } .brand-accent { fill: var(--clear); }
.dockbar { background: var(--paper); }

/* Brightness button: a sun by day, a moon at the night levels */
.dim-btn .dim-moon, :root[data-dim="2"] .dim-btn .dim-sun, :root[data-dim="3"] .dim-btn .dim-sun, :root[data-dim="1"] .dim-btn .dim-sun { display: none; }
:root[data-dim="1"] .dim-btn .dim-moon, :root[data-dim="2"] .dim-btn .dim-moon, :root[data-dim="3"] .dim-btn .dim-moon { display: inline; }
.dim-btn { display: inline-flex; align-items: center; gap: .4rem; }
.dim-btn svg { width: 1.1rem; height: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dim-range { width: 100%; max-width: 22rem; accent-color: var(--ink); }
.dim-scale { display: flex; width: 100%; justify-content: space-between; max-width: 22rem; font-size: .8rem; color: var(--muted); }
.set-group output { margin-left: .5rem; font-weight: 400; color: var(--muted); }

/* Board clock as a printed timetable: big serif time, the five prayers as ruled columns */

/* Today's table */
#today th, #today td { border-color: var(--line); }
/* Phase 1 polish: the next prayer is a solid ink bar, like a highlighter on the printed sheet, readable across a room.
   On a dark screen (Darkest, or High contrast from Dim) a light block would glare at night, so it keeps the two accent
   rules instead; the Handwritten look keeps its own marks. Times gone by fade to --muted (4.6:1 or more in every look). */
#today tr.past th, #today tr.past td { color: var(--muted); }
#today tr.next th, #today tr.next td { color: var(--paper); background: var(--ink); box-shadow: none; }
:root[data-theme="dark"] #today tr.next th, :root[data-theme="dark"] #today tr.next td,
:root[data-palette="hand"] #today tr.next th, :root[data-palette="hand"] #today tr.next td { color: var(--clear); background: transparent; box-shadow: inset 0 2px 0 var(--clear), inset 0 -2px 0 var(--clear); } /* the next prayer sits between two red rules, like the board */

/* Full screen */
.display { background: var(--paper); }
.dx-ar { font-family: var(--ar); }

/* Handwritten: the prayer times are written on a ruled sheet; the live clock stays printed so it reads from across the room */
/* a small tilt per column, the way a hand drifts across a line */
/* the next prayer is circled in red pen */
:root[data-palette="hand"] #today td, :root[data-palette="hand"] #today th { font-family: var(--hand); font-size: 1.1em; }
:root[data-palette="hand"] .topbar h1 { font-family: var(--hand); font-weight: 700; }
:root[data-palette="hand"] [lang="ar"] { font-family: var(--ar); }

/* Hijri date beside the Gregorian one */
.iq-hijri { font-family: var(--display); color: var(--muted); }

/* Adhan offsets: one short row per prayer */
.tune-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .5rem 1.25rem; width: 100%; max-width: 40rem; }
.tune-row { display: flex; align-items: center; gap: .5rem; }
.tune-row span { min-width: 4.2rem; font-weight: 500; }
.tune-row input { width: 4.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.tune-row small { color: var(--muted); }

/* The last 15 minutes before an adhan or iqama: the countdown is marked with a highlighter that flashes once a second.
   The numbers stay dark on the mark and keep the page colour between flashes, so they can always be read. */
:root { --alert: #F2CF3A; --alert-ink: #1C1914; }
:root[data-dim="1"] { --alert: #DDB92C; }
:root[data-dim="2"] { --alert: #3A2A17; --alert-ink: #D9C39B; } /* on the warm page a dark mark stands out more than yellow */
:root[data-dim="3"] { --alert: #9C7420; --alert-ink: #000000; }
:root[data-palette="contrast"] { --alert: #FFD000; --alert-ink: #000000; }
:root[data-palette="contrast"][data-dim="2"], :root[data-palette="contrast"][data-dim="3"] { --alert: #FF9F1C; }
@keyframes ck-mark { 0%, 49% { background-color: var(--alert); } 50%, 100% { background-color: transparent; } }
/* the mark: a tight highlighter behind the digits only, steady from 15 minutes out, blinking in the last 3 */
:root .ck-hl { display: inline-block; padding: .02em .16em; margin-inline: -.16em; border-radius: 2px; background-color: var(--alert); color: var(--alert-ink); }
.sh .sh-n.ck-hl { justify-self: start; }
.sh .sh-n.ck-hl i { color: inherit; }
:root .ck-hl.ck-blink { animation: ck-mark 1s infinite; opacity: 1; }
@media (prefers-reduced-motion: reduce) { :root .ck-hl.ck-blink { animation: none; color: var(--alert-ink); } }
/* E-ink: the last 15 minutes are an ink label (paper-coloured numbers on ink) that stays still; at night a ruled box, so no
   block of light appears */
:root[data-palette="eink"] { --alert: var(--ink); --alert-ink: var(--paper); }
:root[data-palette="eink"][data-dim="3"] { --alert: transparent; --alert-ink: var(--ink); }
:root[data-palette="eink"][data-dim="3"] .ck-hl { box-shadow: inset 0 0 0 2px var(--ink); }

/* E-ink: nothing moves. Every change is instant, like a page on an e-ink reader: no transitions, no flashing, no sky
   (app.js keeps the weather picture off in this look, and motion.js does not animate) */
:root[data-palette="eink"] *, :root[data-palette="eink"] *::before, :root[data-palette="eink"] *::after { transition: none !important; animation: none !important; }
:root[data-palette="eink"]::view-transition-old(root), :root[data-palette="eink"]::view-transition-new(root) { animation: none !important; }

/* Keep the top bar to one row on a tablet: the date line wraps under itself instead of pushing the buttons down */
@media (min-width: 48.01rem) {
  .topbar { flex-wrap: nowrap; align-items: flex-start; }
  .topbar-title { flex: 1 1 auto; }
  .topbar-actions { flex: none; flex-wrap: nowrap; }
}

/* ---- The other tabs, set like the same printed sheet ---- */

/* Segmented choices (°F/°C, Settings sections, Quran views): square, underlined when chosen, no filled pills */
.seg { background: transparent; border-bottom: var(--rule-w) solid var(--line); border-radius: 0; padding: 0; gap: 0; }
.seg .d-tab { border-radius: 0; font-weight: 500; padding-inline: .9rem; }
.seg .d-tab[aria-selected="true"] { background: transparent; box-shadow: inset 0 -2px 0 var(--clear); color: var(--ink); }
.wx-units { gap: 0; }
.wx-units .d-btn, .d-join .d-btn { border-radius: 0; box-shadow: none; }
.wx-units .d-btn[aria-pressed="true"], .d-join .d-btn:checked, .d-join input.d-btn:checked { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* Weather: a forecast column from a newspaper */
.wx-temp { font: 400 3.6rem/1 var(--display); font-stretch: normal; letter-spacing: -.02em; }
.wx-cond { font: 400 1.35rem/1.2 var(--display); font-style: italic; }
.wx-now svg, .wx-hours svg { stroke: currentColor; stroke-width: 1.3; }
.wx-grid { gap: 0 1.5rem; border-top: 2px solid var(--ink); padding-top: .25rem; }
.wx-grid > div { padding: .6rem 0; border-bottom: var(--rule-w) solid var(--line); }
.wx-grid dt { font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
.wx-grid dd { font: 400 1.15rem/1.3 var(--display); }
.wx-aqi strong { font: 400 1.8rem/1 var(--display); }
.wx-aqi-dot { border-radius: 0; width: .8rem; height: .8rem; }
.wx-hours ol { gap: 0; border-top: var(--rule-w) solid var(--line); border-bottom: var(--rule-w) solid var(--line); padding: 0; }
.wx-hours li { border-radius: 0; padding: .7rem .2rem; }
.wx-hours li + li { border-left: var(--rule-w) solid var(--line); }
.wx-hours li.has-prayer { background: transparent; box-shadow: inset 0 3px 0 var(--clear); }
.wx-prayer { color: var(--clear); }
.wx-t { font: 400 1.05rem/1 var(--display); }
.wx-days { gap: 0; border-top: 2px solid var(--ink); }
.wx-days li { background: transparent; border-radius: 0; border-bottom: var(--rule-w) solid var(--line); padding-inline: 0; }
.wx-dn { font-weight: 500; }
.wx-dt { font-family: var(--display); font-size: 1.05rem; }

/* Adhkar: the book's table of contents; an open chapter reads like the page */
.au-list { gap: 0; border-top: 2px solid var(--ink); max-width: 40rem; }
.au-list li { border: 0; border-bottom: var(--rule-w) solid var(--line); border-radius: 0; }
.au-row { padding-right: 0; }
.au-toggle { padding-inline: 0; }
.au-no { opacity: 1; color: var(--muted); font: 400 1rem/1 var(--display); min-width: 2.4rem; }
.au-title { font-weight: 500; }
.au-body { border-top: 0; padding-inline: 2.4rem 0; }
.au-dua + .au-dua { border-top: var(--rule-w) solid var(--line); }
.au-meta { opacity: 1; color: var(--muted); font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
.au-ar { font-family: var(--ar); font-size: 1.75rem; }
.au-tr { opacity: 1; color: var(--muted); font-family: var(--display); }
.au-en { font-family: var(--display); font-size: 1.08rem; line-height: 1.55; }
.au-row .au-play { background: transparent; color: var(--ink); border: var(--rule-w) solid var(--ink); }
.au-search, .qp-search { max-width: 40rem; }

/* Quran: sections underlined like a contents page; lists ruled, not boxed */
.qp-tabs { gap: 0; border-bottom: var(--rule-w) solid var(--line); }
.qp-tabs .d-btn, .qp-tabs .d-btn:hover { border: 0; border-radius: 0; background: transparent; color: var(--muted); font-weight: 500; }
.qp-tabs .d-btn[aria-selected="true"] { background: transparent; color: var(--ink); box-shadow: inset 0 -2px 0 var(--clear); }
.qp-pane { border: 0; border-top: 2px solid var(--ink); border-radius: 0; padding-inline: 0; background: transparent; }
.qp-panes { gap: 1.5rem; }
.qp-rows { gap: 0; }
.qp-row { border-radius: 0; border-bottom: var(--rule-w) solid var(--line); }
.qp-row.is-open { background: transparent; }
@media (hover: hover) { .qp-row:hover { background: transparent; } }
.qp-row.is-open .qp-main b { color: var(--clear); }
.qp-main, .qp-meta { border-radius: 0; }
.qp-letter { font: 400 1.4rem/1 var(--display); color: var(--muted); padding-top: .9rem; border-bottom: 0; }
.qp-no { font: 400 1rem/1 var(--display); color: var(--muted); }
.qp-h, .iqama .tab .qp-h { background: var(--paper); font: 500 .72rem/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.qp-dlg-in, .qp-pick { border-radius: 0; }

/* Month: the printed salah calendar from the masjid; Fridays in red, today marked with rules */
#month { font-variant-numeric: tabular-nums; border-collapse: collapse; }
#month thead th { font: 500 .72rem/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--ink); }
#month tbody th { font-weight: 500; }
#month td { font-family: var(--display); font-size: 1.08rem; }
#month tbody tr { border-bottom: var(--rule-w) solid var(--line); }
#month tr.friday th, #month tr.friday .mo-hijri { color: var(--clear); }
#month tr.today { background: transparent; font-weight: inherit; box-shadow: inset 0 2px 0 var(--ink), inset 0 -2px 0 var(--ink); }
#month tr.today th { font-weight: 700; }
#month .mo-hijri { color: var(--muted); white-space: nowrap; }
#month .mo-hm { font-style: italic; font-size: .85em; }

/* Handwritten: the same tabs, with the hand only where something is written in, not on controls */
:root[data-palette="hand"] #month td, :root[data-palette="hand"] .wx-t, :root[data-palette="hand"] .wx-dt, :root[data-palette="hand"] .wx-temp, :root[data-palette="hand"] .wx-grid dd { font-family: var(--hand); }
:root[data-palette="hand"] .au-no, :root[data-palette="hand"] .qp-no, :root[data-palette="hand"] .qp-letter { font-family: var(--hand); }

/* Phones: the month table keeps every column on screen; the Hijri month name gives way to the day number */
@media (max-width: 40rem) {
  #month .mo-hm, #month .mo-ap { display: none; } /* the column order (Fajr, Sunrise, Dhuhr...) already says morning or afternoon */
  #month th, #month td { padding-inline: .1rem; }
  #month td, #month tbody th { font-size: .88rem; }
  #month thead th { font-size: .7rem; letter-spacing: 0; } /* 11.2 px: the smallest size still read comfortably */
}

/* ---- Full screen, compact layout (touch screens under 800px, such as a 7-inch tablet) ---- */
/* The same printed sheet: light serif numbers, ruled lines in place of a card, a thin ink rule for progress */
.display[data-layout="times"] .dx-meta, .display .dx-meta { font-family: var(--display); color: var(--muted); }

/* Handwritten: what is "written" (the prayer, its times, the rest of the day) in the hand; the live clock stays printed */

/* Touch screens: a faint ink tint when something is tapped, in place of the browser's blue box */
:root { -webkit-tap-highlight-color: color-mix(in srgb, var(--ink) 12%, transparent); }

/* ---- Handwritten: the whole screen is the ruled sheet ---- */
/* The lines and red margin run behind everything (the app's page and full screen), not just behind the clock card */
:root[data-palette="hand"] { --rule-gap: 2rem; --margin-x: clamp(.9rem, 2.2vw, 1.6rem); }
:root[data-palette="hand"] .view, :root[data-palette="hand"] .display {
  background:
    linear-gradient(90deg, transparent calc(var(--margin-x) - 1px), var(--margin) calc(var(--margin-x) - 1px), var(--margin) var(--margin-x), transparent var(--margin-x)),
    linear-gradient(transparent calc(var(--margin-x) * 2.4), transparent calc(var(--margin-x) * 2.4)),
    repeating-linear-gradient(transparent 0 calc(var(--rule-gap) - 1px), var(--line) calc(var(--rule-gap) - 1px) var(--rule-gap)),
    var(--surface);
}
:root[data-palette="hand"] .tabbar, :root[data-palette="hand"] .dockbar { background: var(--paper); }
/* the writing sits right of the margin */
:root[data-palette="hand"] .topbar { margin-left: calc(var(--margin-x) + clamp(.9rem, 2.2vw, 1.6rem)); }
:root[data-palette="hand"] .tab { padding-left: calc(var(--margin-x) + clamp(.9rem, 2.2vw, 1.6rem)); }
:root[data-palette="hand"] .display { padding-left: max(calc(var(--margin-x) + clamp(.9rem, 2.2vw, 1.6rem)), env(safe-area-inset-left, 0px)); }
/* the clock card and the full screen card are now plain writing on the sheet */
:root[data-palette="hand"] .sky-tint, :root[data-palette="hand"] .sky-print { display: none; }
/* The masjid board sheet, written by hand */
:root[data-palette="hand"] .sh-tt th, :root[data-palette="hand"] .sh-tt td, :root[data-palette="hand"] .sh-l, :root[data-palette="hand"] .sh-at,
:root[data-palette="hand"] .sh-foot, :root[data-palette="hand"] .sh-dua-h { font-family: var(--hand); font-style: normal; letter-spacing: 0; text-transform: none; }
:root[data-palette="hand"] .sh-tt thead th { font-size: max(.95rem, calc(var(--u) * 2.6)); color: var(--ink); }
:root[data-palette="hand"] .sh-tt, :root[data-palette="hand"] .sh-dua { border-top: 0; border-bottom: 0; }
:root[data-palette="hand"] .sh-tt .sh-iq > * { border-top: 0; }
:root[data-palette="hand"] .sh-wxat, :root[data-palette="hand"] .sh-tk i, :root[data-palette="hand"] .sh-warn b, :root[data-palette="hand"] .sh-warn span { font-family: var(--hand); font-style: normal; letter-spacing: 0; }
/* the next adhan is circled in red pen */
:root[data-palette="hand"] .sh-tt tbody tr:first-child td.is-next, :root[data-palette="hand"] .sh-tt tbody tr.sh-iq td.is-next { position: relative; color: var(--ink); }
:root[data-palette="hand"] .sh-tt tbody tr:first-child td.is-next::after, :root[data-palette="hand"] .sh-tt tbody tr.sh-iq td.is-next::after {
  content: ""; position: absolute; inset: 0 8%; pointer-events: none; background: var(--clear);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 100' preserveAspectRatio='none'%3E%3Cpath d='M64 6C30 3 6 22 7 50s27 45 57 44 50-20 49-46S88 5 52 9' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 100' preserveAspectRatio='none'%3E%3Cpath d='M64 6C30 3 6 22 7 50s27 45 57 44 50-20 49-46S88 5 52 9' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}


/* Older browsers (before Chrome 111, such as Silk on a 2015 Fire 7) cannot read color-mix() or oklch().
   Where a colour uses them, these give the nearest plain colour from the look's own tokens, so borders,
   tints and highlights still show and still follow the look and brightness level. Newer browsers skip this block. */
@supports not (color: color-mix(in srgb, red, blue)) {
  :root, :root[data-night] { --sky: var(--paper); }
  :root { -webkit-tap-highlight-color: rgba(0, 0, 0, .1); }
  .d-btn:not(.d-btn-primary, .d-btn-soft, .d-btn-ghost, [aria-pressed="true"]) { border-color: var(--line); }
  .d-input, .d-select:not(.qp-riwaya), .d-textarea { border-color: var(--line); }
  .d-toggle:not(:checked) { border-color: var(--muted); color: var(--muted); }
  .ck-sky-top { stop-color: var(--sky-base); }
  .ck-ground { fill: var(--line); }
  #month tr.today, .wx-hours li.has-prayer { background: var(--surface); }
  .dk-count { background-color: var(--line); }
  .qp-row.is-open, .qp-row.is-drag, .qp-pick { background: var(--surface); }
  @media (hover: hover) { .qp-row:hover, .qp-ic:hover { background: var(--surface); } }
  .qp-ic[data-q="repeat"][aria-pressed="true"], .qp-ic[data-q="shuffle"][aria-pressed="true"] { background: var(--line); }
  @media (hover: hover) { .qp-play:hover { background: var(--ink); } }
  .qp-track::before { background: var(--line); }
  .qp-buf { background: var(--muted); }
  .d-range { --d-range-bg: var(--line); }
  .d-range::-webkit-slider-thumb { box-shadow: 0 0 0 2rem var(--surface) inset; }
}

/* Settings, set like the printed sheet: ruled rows, square ink switches, labelled square swatches, drawn clock styles */
.d-toggle { --d-input-color: var(--ink); border-radius: 2px; background: transparent; box-shadow: none; }
.d-toggle::before { border-radius: 1px; box-shadow: none; }
.d-toggle:checked, .d-toggle:has(> input:checked), .d-toggle-success:checked { --d-input-color: var(--ink); background: var(--ink); color: var(--paper); }
.d-toggle:checked::before, .d-toggle:has(> input:checked)::before { background-color: var(--paper); }
.d-toggle:not(:checked) { --d-input-color: var(--muted); }

.al-grid { grid-template-columns: minmax(0, 1fr); gap: 0; margin-top: 1rem; border-bottom: 3px double var(--ink); max-width: 44rem; }
.al-card { background: none; border: 0; border-top: var(--rule-w) solid var(--line); border-radius: 0; }
.al-card:first-child { border-top: 2px solid var(--ink); }

.ck-picker { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .75rem; width: min(100%, 38rem); }
.ck-opt { display: grid; justify-items: center; gap: .35rem; padding: .6rem .5rem .5rem; min-height: 5.5rem; background: transparent; border: 1px solid var(--line); border-radius: 2px; color: var(--muted); font: 500 .9rem/1.2 var(--body); cursor: pointer; }
.ck-opt svg { width: 4rem; height: 2.5rem; }
@media (hover: hover) { .ck-opt:hover { border-color: var(--ink); color: var(--ink); } }
.ck-opt[aria-checked="true"] { border: 2px solid var(--ink); padding: calc(.6rem - 1px) calc(.5rem - 1px) calc(.5rem - 1px); color: var(--ink); background: var(--surface); }

.sw-picker { gap: 1rem; }
.swatch { width: auto; height: auto; display: grid; justify-items: center; gap: .4rem; padding: .25rem; border-radius: 0; background: none; box-shadow: none; color: var(--muted); font: 500 .9rem/1.2 var(--body); }
.sw-chip { width: 3.5rem; height: 3.5rem; border-radius: 2px; background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%); box-shadow: inset 0 0 0 1px var(--line); }
.swatch[aria-checked="true"] { outline: 0; color: var(--ink); }
.swatch[aria-checked="true"] .sw-chip { outline: 3px solid var(--ink); outline-offset: 3px; }

.d-join .d-btn { min-height: 2.5rem; height: 2.5rem; }
.set-more { margin-top: 1rem; border-top: var(--rule-w) solid var(--line); padding-top: .5rem; }
.set-more > summary { cursor: pointer; min-height: 2.75rem; display: flex; align-items: center; font-weight: 500; color: var(--muted); }
.set-more[open] > summary { color: var(--ink); }
.set-more .set-group:first-of-type { margin-top: .4rem; }
#feedback-btn { display: none; } /* Feedback lives in Settings > About; the wall display does not need it */

/* Phase 5: 44px tap targets, placeholder contrast, phone dock alignment */
.d-btn-sm, .d-tab, .d-select, .d-input { min-height: 2.75rem; }
.d-btn-sm { height: auto; }
.link-btn { display: inline-flex; align-items: center; min-height: 2.75rem; }
.d-range { min-height: 2.75rem; }
.check { min-height: 2.75rem; }
.d-join .d-btn { min-height: 2.75rem; height: 2.75rem; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.dockbar details.more { align-self: stretch; display: flex; }
.dockbar .more summary { flex: 1; display: flex; align-items: center; justify-content: center; }
.tb-btn, .d-join-item, .link-btn { min-width: 2.75rem; }
.d-toggle-xs[type=checkbox], .d-toggle-sm[type=checkbox] { --d-size: 1.75rem; } /* 24px at least, whatever the label around it */
.dockbar .more summary { padding: 0; line-height: 1.2; }

/* Phase 6: the adhan has been called, the wait is now for the iqama */
.sh-l.is-called .sh-kind { font: 600 max(1.15rem, calc(var(--u) * 4.4))/1.25 var(--display); font-style: normal; color: var(--clear); }
.sh-l.is-called .sh-kind::before { content: ""; display: inline-block; width: .55em; height: .55em; margin-right: .5em; border-radius: 50%; background: var(--clear); vertical-align: .05em; }
.sh .sh-tt tbody tr:first-child td.is-passed { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
/* Phase 1 polish: the board's next prayer is a solid ink column (see #today above for why dark screens and Handwritten differ) */
.sh .sh-tt .is-past, .sh .sh-tt .is-past .sh-ar { color: var(--muted); }
:root:not([data-theme="dark"]):not([data-palette="hand"]) .sh .sh-tt .nx-col { background-color: var(--ink); box-shadow: none; }
:root:not([data-theme="dark"]):not([data-palette="hand"]) .sh .sh-tt .nx-col,
:root:not([data-theme="dark"]):not([data-palette="hand"]) .sh .sh-tt .nx-col .sh-ar,
:root:not([data-theme="dark"]):not([data-palette="hand"]) .sh .sh-tt tbody tr:first-child td.nx-col.is-passed,
:root:not([data-theme="dark"]):not([data-palette="hand"]) .sh .sh-tt .nx-col em { color: var(--paper); }
:root[data-palette="hand"] .sh-l.is-called .sh-kind { font-family: var(--hand); font-weight: 400; }

/* Phase 8: the other clock styles speak the board's language (name in English and Arabic, adhan called, countdown, adhan and iqama) */
.ck-head { --u: .17rem; display: grid; justify-items: center; gap: .35rem; text-align: center; }
.ck-head .sh-l { justify-content: center; color: var(--clear); }
.ck-head .sh-kind { text-align: center; }
.ck-head .sh-at { font-size: 1rem; color: var(--muted); }
.ck-head .sh-at b { color: var(--ink); }
.ck-center .sh-at { display: none; } /* the dial's centre is small: its table carries the times */
.ck-count i { font-size: .48em; font-weight: 400; color: var(--muted); margin-left: .04em; }
.ck-count.ck-hl i { color: inherit; }
.ck-tl-head.ck-head { justify-items: start; text-align: left; }
.ck-tl-head .sh-l { justify-content: flex-start; }
.ck-tl-head .sh-kind { text-align: left; }
.ck-bed-ar { font: 400 2rem/1.6 var(--ar, "Amiri"), serif; color: #D9A04A; }
/* bedside: a printed card turned dark, not a rounded app tile */
.ck-bedside { border-radius: 0; outline: 1px solid #6B5836; outline-offset: -8px; }

/* Phase 9: the dock's four labels share one box, so More sits on the same line as the others */
.dockbar .d-dock-label { display: block; line-height: 1.25rem; }
.dockbar details.more { align-self: auto; height: 55px; } /* the same box as its neighbours, so the labels share a baseline */
.seg { margin-bottom: .75rem; }

/* Phase 10: phone Settings tabs sit in a steady grid (three, then two) instead of a ragged wrap */
@media (max-width: 40rem) {
  .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); justify-self: stretch; }
  .seg .d-tab { justify-content: center; text-align: center; padding-inline: .25rem; white-space: normal; line-height: 1.15; }
}

/* Phase 11: the dock's More item is as wide as a tap target needs */
.dockbar details.more { min-width: 4rem; }

/* Burn-in care at night (any dark screen: Darkest, Black, High contrast from Dim). The rules that never move fade to the
   faint line colour, so no bright line sits in one place all night; app.js also moves the page up to 6 px. Times that have
   passed drop to regular weight as well as grey, since at Darkest the grey cannot go lower and stay readable. */
:root[data-theme="dark"] .app .topbar, :root[data-theme="dark"] .display .dx-top { border-bottom-color: var(--line); }
:root[data-theme="dark"] .app > .tabbar { border-top-color: var(--line); }
:root[data-theme="dark"] .sh .sh-tt { border-top-color: var(--line); border-bottom-color: var(--line); }
:root[data-theme="dark"] .sh-next, :root[data-theme="dark"] .sh-dua, :root[data-theme="dark"] #clock .sh-fold { border-color: var(--line); }
:root[data-theme="dark"] .sh .sh-tt .is-past { font-weight: 400; }

/* Quran artwork in ink and paper where colour is off */
:root[data-palette="eink"] .qa-bg, :root[data-palette="contrast"] .qa-bg { fill: var(--ink); }
:root[data-palette="eink"] .qa-fg, :root[data-palette="contrast"] .qa-fg { fill: var(--paper); }
:root[data-palette="eink"] .qa-line, :root[data-palette="eink"] .qa-edge, :root[data-palette="contrast"] .qa-line, :root[data-palette="contrast"] .qa-edge { stroke: var(--paper); }
