/* Scope every rule: no reader, page image, source text, or audio selectors. */
.prayer-tools { --pt-green: #37663e; --pt-dark: #24482c; --pt-gold: #b08737; --pt-paper: #f5f0e7; --pt-ink: #343b30; box-sizing: border-box; color: var(--pt-ink); background: var(--pt-paper); width: 100%; max-width: 680px; margin: auto; border-radius: 20px; overflow: hidden; font-family: system-ui, sans-serif; line-height: 1.6; }
.prayer-tools *, .prayer-tools *::before, .prayer-tools *::after { box-sizing: border-box; }
.prayer-tools[hidden], .prayer-tools [hidden] { display: none !important; }
.prayer-tools .pt-header { padding: 15px 18px; background: var(--pt-green); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prayer-tools .pt-header h2 { font-size: calc(1.25rem * var(--ui-text-scale,1)); margin: 0; }
.prayer-tools .pt-header button { padding: 6px 10px; color: #fff; background: transparent; min-width: 44px; }
.prayer-tools .pt-body { padding: clamp(14px, 4vw, 28px); }
.prayer-tools button, .prayer-tools input, .prayer-tools select { font: inherit; }
.prayer-tools button { background: var(--pt-green); color: #fff; border: 0; border-radius: 10px; padding: 11px 17px; min-height: 44px; cursor: pointer; }
.prayer-tools button:disabled { opacity: .6; cursor: wait; }
.prayer-tools :focus-visible { outline: 3px solid #c19c46; outline-offset: 3px; }
.prayer-tools h2:focus { outline: none; }
.prayer-tools .pt-location { text-align: center; font-weight: 600; overflow-wrap: anywhere; margin: 0 0 18px; }
.prayer-tools .pt-location-panel, .prayer-tools .pt-calculation { background: #fffaf2; border: 1px solid #ded5c3; padding: 16px; border-radius: 14px; margin-bottom: 18px; }
.prayer-tools form { display: grid; gap: 13px; margin-top: 12px; }
.prayer-tools label { display: grid; gap: 5px; font-size: calc(.92rem * var(--ui-text-scale,1)); }
.prayer-tools input, .prayer-tools select { min-width: 0; width: 100%; min-height: 46px; border: 1px solid #c6c6b5; background: #fff; color: #29332b; border-radius: 8px; padding: 9px; }
.prayer-tools input { font-size: calc(16px * var(--ui-text-scale,1)); }
.prayer-tools .pt-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prayer-tools .pt-secondary { margin-top: 16px; background: #e6ecdf; color: var(--pt-dark); }
.prayer-tools .pt-text { color: var(--pt-dark); background: transparent; text-decoration: underline; }
.prayer-tools .pt-note { font-size: calc(.83rem * var(--ui-text-scale,1)); line-height: 1.8; color: #66695d; margin: 13px 0; overflow-wrap: anywhere; }
.prayer-tools .pt-status { color: var(--pt-dark); font-size: calc(.9rem * var(--ui-text-scale,1)); }
.prayer-tools .pt-status:empty { display: none; }
.prayer-tools .pt-countdown { border-radius: 16px; background: linear-gradient(135deg, var(--pt-dark), #4f7542); color: #fff; text-align: center; padding: 28px 12px; }
.prayer-tools .pt-countdown p { margin: 0 0 6px; }
.prayer-tools .pt-countdown strong { display: block; font-variant-numeric: tabular-nums; font-size: clamp(2.2rem, 9vw, 4.2rem); letter-spacing: .03em; line-height: 1.3; }
.prayer-tools .pt-countdown .pt-next-at { font-size: calc(.85rem * var(--ui-text-scale,1)); opacity: .85; margin-top: 8px; }
.prayer-tools .pt-date { text-align: center; font-size: calc(.85rem * var(--ui-text-scale,1)); margin: 18px 0 10px; overflow-wrap: anywhere; }
.prayer-tools .pt-times { list-style: none; margin: 0 0 20px; padding: 0; border: 1px solid #dfdccf; border-radius: 14px; overflow: hidden; background: #fffdfa; }
.prayer-tools .pt-times:empty { display: none; }
.prayer-tools .pt-times li { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; gap: 10px; border-bottom: 1px solid #eeece3; font-weight: 600; }
.prayer-tools .pt-times li:last-child { border-bottom: 0; }
.prayer-tools .pt-times .pt-next { color: var(--pt-dark); background: #e4eddc; }
.prayer-tools .pt-times small { font-size: calc(.7rem * var(--ui-text-scale,1)); color: #777; font-weight: 400; }
.prayer-tools .pt-times time { font-variant-numeric: tabular-nums; }
.prayer-tools .pt-warning { color: #825b15; font-size: calc(.9rem * var(--ui-text-scale,1)); }
.prayer-tools fieldset { border: 1px solid #ddd4c1; border-radius: 8px; padding: 12px; min-width: 0; }
.prayer-tools summary { cursor: pointer; min-height: 44px; padding: 8px 0; color: var(--pt-dark); }
.prayer-tools .pt-qibla-caption, .prayer-tools .pt-bearing { text-align: center; }
.prayer-tools .pt-bearing { direction: ltr; color: var(--pt-green); font-size: calc(2.7rem * var(--ui-text-scale,1)); font-weight: 700; margin: 22px 0; }
.prayer-tools .pt-compass { direction: ltr; position: relative; width: min(100%, 360px); aspect-ratio: 1; margin: 30px auto; border-radius: 50%; background: #fffdf6; box-shadow: 0 0 0 1px #e0dbc9, inset 0 0 0 16px #fffdf6, inset 0 0 0 18px #e1e6d5; }
.prayer-tools .pt-compass > span { position: absolute; font-size: calc(.85rem * var(--ui-text-scale,1)); color: var(--pt-green); font-weight: 650; }
.prayer-tools .pt-north { top: 22px; left: 50%; transform: translateX(-50%); }
.prayer-tools .pt-south { bottom: 22px; left: 50%; transform: translateX(-50%); }
.prayer-tools .pt-east { right: 25px; top: 50%; transform: translateY(-50%); }
.prayer-tools .pt-west { left: 25px; top: 50%; transform: translateY(-50%); }
.prayer-tools .pt-pointer { position: absolute; width: 34px; height: 74%; top: 13%; left: calc(50% - 17px); transform-origin: 50% 50%; }
.prayer-tools .pt-pointer::before { content: ''; position: absolute; width: 30px; height: 48%; top: 4%; left: 2px; background: var(--pt-gold); clip-path: polygon(50% 0%, 100% 100%, 50% 86%, 0% 100%); }
.prayer-tools .pt-pointer::after { content: ''; position: absolute; width: 24px; height: 30%; bottom: 20%; left: 5px; background: #bfcbb1; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); }
.prayer-tools .pt-pointer span { position: absolute; width: 100%; text-align: center; top: -14px; font-size: calc(22px * var(--ui-text-scale,1)); color: var(--pt-dark); }
.prayer-tools .pt-compass i { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--pt-dark); top: calc(50% - 7px); left: calc(50% - 7px); }
@media (max-width: 360px) { .prayer-tools .pt-two { grid-template-columns: 1fr; } .prayer-tools .pt-header { padding: 12px 8px; gap: 4px; } }
/* Qibla: an honest north-fixed bearing, with a separately labelled sensor aid. */
.prayer-tools .pt-compass { box-shadow: 0 0 0 3px #648066, 0 12px 28px #48351b0b; }
.prayer-tools .pt-dial-ticks { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: #8f8978; stroke-width: 1.2; }
.prayer-tools .pt-compass .pt-north { top: 15%; }
.prayer-tools .pt-compass .pt-south { bottom: 15%; }
.prayer-tools .pt-compass .pt-east { right: 15%; }
.prayer-tools .pt-compass .pt-west { left: 15%; }
.prayer-tools .pt-kaaba { position: absolute; width: 30%; height: 30%; top: 35%; left: 35%; background: #f9f4e9; border: 1px solid #dfd7c3; border-radius: 50%; display: grid; place-items: center; box-shadow: 0 5px 12px #4a402416; }
.prayer-tools .pt-kaaba svg { width: 62%; height: 62%; }
.prayer-tools .pt-pointer { height: 72%; top: 14%; }
.prayer-tools .pt-pointer::before { height: 32%; top: 0; }
.prayer-tools .pt-pointer::after, .prayer-tools .pt-pointer > span { display: none; }
.prayer-tools .pt-bearing { margin: 14px 0 4px; font-variant-numeric: tabular-nums; font-size: clamp(1.6rem, 7vw, 2.7rem); }
.prayer-tools .pt-position-quality { text-align: center; font-size: calc(.82rem * var(--ui-text-scale,1)); color: #72684f; }
.prayer-tools .pt-qibla-actions { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; }
.prayer-tools .pt-qibla-actions .pt-secondary { margin-top: 0; }
.prayer-tools .pt-heading-aid { margin-top: 22px; border: 1px solid #ded5c3; background: #fffaf2; padding: 16px; border-radius: 14px; }
.prayer-tools .pt-heading-aid h3 { font-size: calc(1rem * var(--ui-text-scale,1)); margin: 0; color: #526548; }
.prayer-tools .pt-heading-readout { display: flex; justify-content: center; gap: 15px; align-items: center; }
.prayer-tools .pt-heading-readout p { font-variant-numeric: tabular-nums; text-align: center; }
.prayer-tools .pt-magnetic-pointer { font-size: calc(2.1rem * var(--ui-text-scale,1)); line-height: 1; color: #776a50; display: inline-block; }
.prayer-tools .pt-cardinal-ring { position: absolute; inset: 0; transform-origin: center; }
.prayer-tools .pt-cardinal-ring > span { position: absolute; font-size: calc(.82rem * var(--ui-text-scale,1)); color: var(--pt-green); font-weight: 650; }
.prayer-tools .pt-compass .pt-phone-marker { position: absolute; top: -16px; left: calc(50% - 10px); width: 20px; height: 15px; background: var(--pt-green); clip-path: polygon(0 0,100% 0,50% 100%); }

/* Activation is always ahead of the dial; fallback forms cannot push it away. */
.prayer-tools .pt-heading-aid { margin: 0 0 14px; padding: 13px; }
.prayer-tools .pt-heading-aid .pt-status { margin: 8px 0; overflow-wrap: anywhere; }
.prayer-tools .pt-live-status { margin: 8px 0; font-size: calc(.88rem * var(--ui-text-scale,1)); font-weight: 600; overflow-wrap: anywhere; }
.prayer-tools .pt-activation-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.prayer-tools .pt-activation-actions button { flex: 1 1 125px; min-width: 0; padding: 9px 10px; overflow-wrap: anywhere; }
.prayer-tools .pt-activation-actions .pt-secondary { margin-top: 0; }
.prayer-tools .pt-heading-aid .pt-posture { margin: 9px 0 0; }
.prayer-tools .pt-heading-aid[data-guidance="live"] { border-color: #648066; background: #eef4e8; }
.prayer-tools .pt-compass { width: min(100%, 300px); margin: 24px auto; }
.prayer-tools .pt-fixed-bearing, .prayer-tools .pt-heading-details { border-top: 1px solid #ded5c3; margin-top: 14px; padding-top: 5px; }
.prayer-tools .pt-fixed-bearing summary { font-size: calc(.9rem * var(--ui-text-scale,1)); }
.prayer-tools .pt-qibla-actions { margin-block: 12px; }
@media (max-height: 500px) and (orientation: landscape) {
  .prayer-tools .pt-body { padding: 12px; }
  .prayer-tools .pt-header { padding-block: 8px; }
  .prayer-tools .pt-location { margin-bottom: 8px; }
  .prayer-tools .pt-compass { width: min(70vw, 240px); }
}

/* Keep a neutral, non-directional frame visible while awaiting usable sensors. */
.prayer-tools .pt-compass-placeholder { position:absolute; inset:28%; display:grid; place-items:center; text-align:center; padding:8px; color:var(--pt-ink); font-size:calc(1rem * var(--ui-text-scale,1)); font-weight:600; line-height:1.6; overflow-wrap:anywhere; }
.prayer-tools .pt-compass[data-guidance="inactive"] { box-shadow:0 0 0 2px #96978a; background:#f1eee5; }
.prayer-tools .pt-compass[data-guidance="inactive"] .pt-dial-ticks { opacity:.35; }

.prayer-tools .pt-sensor-check { margin:12px 0; border:1px solid #ded5c3; border-radius:10px; padding:4px 12px; }
.prayer-tools .pt-sensor-check dl { margin:10px 0; }
.prayer-tools .pt-sensor-check dl>div { display:flex; justify-content:space-between; gap:12px; padding:5px 0; }
.prayer-tools .pt-sensor-check dt { overflow-wrap:anywhere; }
.prayer-tools .pt-sensor-check dd { margin:0; font-variant-numeric:tabular-nums; white-space:nowrap; }

/* Interpolate only a live, fresh direction. The short 100ms blend damps small
   measurement wobble without changing the sensor/filter. Withholding remains
   immediate; never fade an old arrow as live. Angles are unwrapped in JS. */
.prayer-tools .pt-compass[data-guidance="live"] .pt-pointer,
.prayer-tools .pt-compass[data-guidance="live"] .pt-dial-ticks,
.prayer-tools .pt-compass[data-guidance="live"] .pt-cardinal-ring { transition: transform 100ms linear; }
@media (prefers-reduced-motion: reduce) {
  .prayer-tools .pt-compass[data-guidance="live"] .pt-pointer,
  .prayer-tools .pt-compass[data-guidance="live"] .pt-dial-ticks,
  .prayer-tools .pt-compass[data-guidance="live"] .pt-cardinal-ring { transition: none; }
}
.prayer-tools .pt-compass[data-validity="available"] { box-shadow:0 0 0 3px #37663e,0 12px 28px #48351b0b; }
.prayer-tools .pt-compass[data-validity="unavailable"] { box-shadow:0 0 0 3px #923e32; }
.prayer-tools .pt-compass .pt-validity-mark { z-index:2; inset:auto 9% 5% auto; width:32px; height:32px; display:grid; place-items:center; border-radius:50%; border:2px solid currentColor; background:#f7f1e3; color:#37663e; font:700 calc(23px * var(--ui-text-scale,1))/1 system-ui,sans-serif; }
.prayer-tools .pt-compass[data-validity="unavailable"] .pt-validity-mark { color:#923e32; }
.prayer-tools .pt-qibla-caption:empty,.prayer-tools .pt-live-status:empty { display:none; }
