/* IqamaHub: 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 {
  /* CSS copies of motion.js T.dur and T.ease, so stylesheet animations keep the pace of scripted ones; change both together */
  --m-fast: .18s; --m-normal: .35s; --m-slow: .6s; --m-ease: cubic-bezier(.22, 1, .36, 1);
  --m-pop: cubic-bezier(.34, 1.56, .64, 1); /* a small overshoot, for a switch knob or a radio dot settling into place */
  --on: #1B6B52; /* a switch, tick, radio or slider that is on: green by day, as in the approved preview (the looks' own accent is red ink) */
  --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: 99px; --radius-field: .625rem; --radius-box: 1rem; } /* DESIGN.md: fields and buttons .625rem, cards and dialogs 1rem, pills round */
body { font-feature-settings: "kern", "liga"; }
.tb-btn { border-radius: .75rem; }
.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 { border-radius: 1rem; } .au-list li, .qp-pane { border-radius: 0; }
.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); }

.dockbar { background: var(--paper); }

:root[data-theme="dark"] { --on: var(--clear); } /* at night the softer accent, so nothing glows */
:root[data-palette="eink"], :root[data-palette="contrast"] { --on: var(--ink); }
/* Brightness button: a small day/night switch. The knob carries a sun at Bright and a moon at the dimmer levels, and steps
   across one quarter per level (Bright, Soft, Dim, Darkest) while the track goes from warm daylight to night */
.dn-pill { --lv: 0; position: relative; flex: none; display: inline-block; width: 2.9rem; height: 1.55rem; border-radius: 99px; background: #E9D9A8;
  transition: background-color var(--m-slow) var(--m-ease); }
.dn-knob { position: absolute; top: .15rem; left: .15rem; display: grid; place-items: center; width: 1.25rem; height: 1.25rem; border-radius: 50%; background: #FFF8E6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .25); translate: calc(var(--lv) * .45rem) 0; transition: translate var(--m-normal) var(--m-pop), background-color var(--m-slow) var(--m-ease); }
.dn-pill .dn-knob svg { display: block; grid-area: 1 / 1; width: .9rem; height: .9rem; transition: opacity var(--m-fast), rotate var(--m-normal) var(--m-ease), scale var(--m-normal) var(--m-ease); }
.dn-pill .dn-sun { fill: none; stroke: #B07A12; stroke-width: 2.2; stroke-linecap: round; }
.dn-pill .dn-moon { fill: #E8DCBF; stroke: none; opacity: 0; rotate: -60deg; scale: .5; }
:root[data-dim="1"] .dn-pill { --lv: 1; background: #B9A57A; }
:root[data-dim="2"] .dn-pill { --lv: 2; background: #5E5240; }
:root[data-dim="3"] .dn-pill { --lv: 3; background: #24221D; }
:root[data-dim="2"] .dn-knob, :root[data-dim="3"] .dn-knob { background: #3A362D; }
:root[data-dim="1"] .dn-pill .dn-sun, :root[data-dim="2"] .dn-pill .dn-sun, :root[data-dim="3"] .dn-pill .dn-sun { opacity: 0; rotate: 90deg; scale: .5; }
:root[data-dim="1"] .dn-pill .dn-moon, :root[data-dim="2"] .dn-pill .dn-moon, :root[data-dim="3"] .dn-pill .dn-moon { opacity: 1; rotate: 0deg; scale: 1; }
:root[data-palette="eink"] .dn-pill, :root[data-palette="contrast"] .dn-pill { background: var(--line); box-shadow: inset 0 0 0 1.5px var(--ink); }
:root[data-palette="eink"] .dn-knob, :root[data-palette="contrast"] .dn-knob { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--ink); }
:root[data-palette="eink"] .dn-pill .dn-sun, :root[data-palette="contrast"] .dn-pill .dn-sun { stroke: var(--ink); }
:root[data-palette="eink"] .dn-pill .dn-moon, :root[data-palette="contrast"] .dn-pill .dn-moon { fill: var(--ink); }
.app .tb-btn .dn-pill .dn-knob svg { display: block; } /* the wide top bar hides its buttons' icons, but not this one */
@media (prefers-reduced-motion: reduce) { .dn-knob { transition: background-color var(--m-slow); } .dn-pill .dn-knob svg { transition: opacity var(--m-fast); } }
.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 */
/* the group's one column is the pane's width, so the rows wrap on a phone instead of running off the edge */
.tune-group { grid-template-columns: minmax(0, 1fr); }
.tune-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: .5rem 1.25rem; width: 100%; max-width: 40rem; }
.tune-row { display: flex; align-items: center; gap: .5rem; }
.tune-row > span:first-child { min-width: 4.2rem; font-weight: 500; }
/* Stepper (controls.js): a pill holding round − and + keys either side of the number; 44px to touch, a dip when pressed */
.stp { display: inline-flex; align-items: center; gap: .15rem; padding: .2rem; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); }
.stp[hidden] { display: none; }
.iqama .stp input[type="number"] { color: var(--ink); width: 3.4rem; min-height: 0; height: 2.5rem; padding: 0; border: 0; background: transparent; box-shadow: none; text-align: center; font: 600 1.05rem/1 var(--body);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stp input::-webkit-inner-spin-button, .stp input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stp:focus-within { border-color: var(--ink); }
.stp-btn { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; padding: 0; border: 0; border-radius: 50%; background: var(--paper); color: var(--ink);
  font: 500 1.35rem/1 var(--body); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: scale var(--m-fast) var(--m-ease), border-color var(--m-fast); }
.stp-btn:active { scale: .9; background: var(--line); }
.stp-btn:disabled { opacity: .4; cursor: default; }
@media (hover: hover) { .stp-btn:not(:disabled):hover { background: var(--line); } }
@media (prefers-reduced-motion: reduce) { .stp-btn:active { scale: none; } }
.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 */
/* Segmented choices (Settings sections, °F/°C): a pill track holding pill buttons; the chosen one fills with ink.
   One row that scrolls sideways on a phone, never wrapping onto a second row. */
.seg { position: relative; display: flex; flex-wrap: nowrap; gap: .25rem; width: auto; max-width: 100%; padding: .25rem; overflow-x: auto; scrollbar-width: none; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.seg::-webkit-scrollbar { display: none; }
/* phone: the Settings sections wrap onto two rows so all five show at once (a scrolling row hid Display and About) */
@media (max-width: 40rem) {
  #tab-settings .seg { flex-wrap: wrap; overflow: visible; justify-self: stretch; align-self: start; border-radius: 1.5rem; min-height: calc(5.75rem + 2px); } /* shortcut: the page grid sizes this row from min-height, not from the wrapped tabs; two rows of tabs, so a phone narrower than about 300px would need a third */
  #tab-settings .seg .d-tab { padding-inline: .75rem; }
}
.seg .d-tab { flex: none; height: auto; min-height: 2.5rem; padding-inline: 1rem; border-radius: 99px; font-weight: 500; color: var(--muted); background: transparent; box-shadow: none; white-space: nowrap;
  transition: background-color var(--m-normal) var(--m-ease), color var(--m-normal) var(--m-ease); }
.seg .d-tab[aria-selected="true"] { background: var(--ink); color: var(--paper); box-shadow: none; }
.wx-units { display: inline-flex; justify-self: start; width: max-content; gap: .25rem; padding: .25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 99px; }
.wx-units .d-btn { min-height: 2.5rem; height: 2.5rem; padding-inline: 1rem; border: 0; border-radius: 99px; background: transparent; color: var(--muted); box-shadow: none;
  transition: background-color var(--m-normal) var(--m-ease), color var(--m-normal) var(--m-ease); }
.wx-units .d-btn[aria-pressed="true"] { background: 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: .35rem; padding-bottom: .5rem; border-bottom: var(--rule-w) solid var(--line); }
.qp-tabs .d-btn, .qp-tabs .d-btn:hover { border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--muted); font-weight: 500; transition: background-color var(--m-normal) var(--m-ease), color var(--m-normal) var(--m-ease); }
.qp-tabs .d-btn[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: none; }
.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: ruled rows, swatches and drawn clock styles, with the controls from the approved preview (DESIGN.md):
   round switches, tick boxes and radio choices in the accent colour (--clear), each with its own small motion */

/* Switches: a round knob on a pill. Off: a pale track; on: the accent. The knob springs across; the switch dips when pressed.
   daisyUI's own toggle is a grid with the knob in ::before; everything it sets is reset here so the knob can slide freely. */
:root .d-toggle { --sw-w: 3.25rem; --sw-h: 1.95rem; --sw-k: 1.45rem; position: relative; display: inline-block; flex: none; width: var(--sw-w); height: var(--sw-h);
  padding: 0; border: 0; border-radius: 99px; background: color-mix(in srgb, var(--ink) 22%, transparent); box-shadow: none; color: inherit; vertical-align: middle;
  transition: background-color var(--m-normal) var(--m-ease), scale var(--m-fast) var(--m-ease); }
:root .d-toggle::before { content: ""; position: absolute; top: calc((var(--sw-h) - var(--sw-k)) / 2); left: calc((var(--sw-h) - var(--sw-k)) / 2); inset-inline-start: calc((var(--sw-h) - var(--sw-k)) / 2);
  width: var(--sw-k); height: var(--sw-k); margin: 0; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); opacity: 1;
  translate: 0 0; transition: translate var(--m-normal) var(--m-pop), background-color var(--m-fast); }
:root .d-toggle:checked { background: var(--on); }
:root .d-toggle:checked::before { background: var(--surface); opacity: 1; translate: calc(var(--sw-w) - var(--sw-h)) 0; }
:root[data-theme="dark"] .d-toggle:not(:checked)::before { background: var(--muted); } /* at night a dark knob would vanish on the dark track */
:root .d-toggle:active { scale: .94; }
:root .d-toggle:disabled { opacity: .45; cursor: default; }
:root .d-toggle:focus-visible { outline: 2px solid var(--on); outline-offset: 3px; }
:root .d-toggle-xs { --sw-w: 2.75rem; --sw-h: 1.6rem; --sw-k: 1.2rem; }
@supports not (color: color-mix(in srgb, red, blue)) { :root .d-toggle { background: var(--line); } :root .d-toggle:checked { background: var(--on); } }

/* Tick boxes (an alert card's At adhan, Before adhan and Before iqama): the box fills with the accent and the tick draws in */
.tick { -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 1.5rem; height: 1.5rem; margin: .6rem .1rem; border: 2px solid var(--muted); border-radius: 6px;
  background: transparent; cursor: pointer; transition: background-color var(--m-fast), border-color var(--m-fast), scale var(--m-fast) var(--m-ease); }
.tick::before { content: ""; position: absolute; inset: 0; background: var(--paper);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.5l3.5 3.5 7.5-8' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.5l3.5 3.5 7.5-8' fill='none' stroke='%23000' stroke-width='2.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  clip-path: inset(0 100% 0 0); transition: clip-path var(--m-normal) var(--m-ease); }
.tick:checked { background: var(--on); border-color: var(--on); }
.tick:checked::before { clip-path: inset(0 0 0 0); }
.tick:active { scale: .9; }
.tick:disabled { opacity: .45; cursor: default; }
.tick:focus-visible { outline: 2px solid var(--on); outline-offset: 2px; }

/* Radio choices (Night starts, the feedback form's kind): a ring, and a dot that pops into the picked one */
.choices { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; }
.choice { display: inline-flex; align-items: center; gap: .6rem; min-height: 2.75rem; cursor: pointer; }
.rad { -webkit-appearance: none; appearance: none; position: relative; flex: none; width: 1.5rem; height: 1.5rem; margin: 0; border: 2px solid var(--muted); border-radius: 50%;
  background: transparent; cursor: pointer; transition: border-color var(--m-fast), scale var(--m-fast) var(--m-ease); }
.rad::before { content: ""; position: absolute; inset: 0; margin: auto; width: .7rem; height: .7rem; border-radius: 50%; background: var(--on); scale: 0; transition: scale var(--m-normal) var(--m-pop); }
.rad:checked { border-color: var(--on); }
.rad:checked::before { scale: 1; }
.rad:active { scale: .9; }
.rad:focus-visible { outline: 2px solid var(--on); outline-offset: 2px; }

/* Other choices: a picked swatch's frame closes in round it, a picked clock style settles, and they dip when pressed */
.swatch .sw-chip { outline: 3px solid transparent; outline-offset: 0; transition: outline-offset var(--m-normal) var(--m-ease), outline-color var(--m-fast); }
.swatch, .ck-opt { transition: scale var(--m-fast) var(--m-ease), border-color var(--m-fast), background-color var(--m-fast), color var(--m-fast); }
.swatch:active, .ck-opt:active { scale: .95; }
@media (prefers-reduced-motion: reduce) { /* nothing moves or scales; colours still change */
  :root .d-toggle, :root .d-toggle::before, .tick, .rad, .rad::before { transition-property: background-color, border-color, opacity; }
  .tick::before { transition: none; }
  .rad::before { scale: 0; } .rad:checked::before { scale: 1; }
  :root .d-toggle:active, .tick:active, .rad:active, .swatch:active, .ck-opt:active { scale: none; }
  .swatch .sw-chip { transition: none; }
}

.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: .75rem; 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(--on); 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: .75rem; 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 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); }
