@font-face {
	font-family: "Quicksand";
	font-style: normal;
	font-weight: 500;
	font-display: swap;
	src: url(Quicksand.woff2) format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
	--bg: #f4f6f5;
	--surface: #ffffff;
	--surface-2: #f0f3f1;
	--text: #1c2522;
	--muted: #66736d;
	--border: #e3e8e5;
	--primary: #0b7a47;
	--primary-strong: #096239;
	--primary-soft: #e3f3ea;
	--on-primary: #ffffff;
	--friday: #fbf7ea;
	--shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 6px 20px rgba(16, 32, 24, .07);
	--radius: 18px;
	--font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--font-display: "Quicksand", var(--font);
	--safe-top: env(safe-area-inset-top, 0px);
	--safe-bottom: env(safe-area-inset-bottom, 0px);
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1513;
		--surface: #18201d;
		--surface-2: #1f2925;
		--text: #e7eeea;
		--muted: #93a29b;
		--border: #2a3531;
		--primary: #34c47f;
		--primary-strong: #5fd89c;
		--primary-soft: rgba(52, 196, 127, .14);
		--on-primary: #062516;
		--friday: rgba(240, 200, 90, .06);
		--shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
		color-scheme: dark;
	}
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	font-family: var(--font);
	font-size: 15px;
	line-height: 1.5;
	color: var(--text);
	background: var(--bg);
	-webkit-font-smoothing: antialiased;
	-webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, p { margin: 0; }

button {
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	padding: 0;
	cursor: pointer;
}

button:focus-visible, input:focus-visible, .table-wrap:focus-visible, a:focus-visible {
	outline: 2px solid var(--primary);
	outline-offset: 2px;
}

.ic {
	width: 20px;
	height: 20px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.ic-sm { width: 16px; height: 16px; }

/* ---------- Hero ---------- */

.hero {
	position: relative;
	isolation: isolate;
	overflow: hidden;
	min-height: 340px;
	padding: calc(12px + var(--safe-top)) 16px 72px;
	color: #fff;
	background: #4b3f9e;
}

.hero-bg, .hero-bg img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.hero-bg { z-index: -1; }

.hero-bg img {
	object-fit: cover;
	object-position: center 72%;
	opacity: 0;
	transition: opacity .8s ease;
}

.hero[data-period="dawn"] img[data-scene="dawn"],
.hero[data-period="day"] img[data-scene="day"],
.hero[data-period="night"] img[data-scene="night"] { opacity: 1; }

/* legibility scrim */
.hero-bg::after {
	content: "";
	position: absolute;
	inset: 0;
	background:
		linear-gradient(180deg, rgba(0, 0, 0, .28) 0%, rgba(0, 0, 0, 0) 38%),
		linear-gradient(0deg, var(--bg) 0%, rgba(0, 0, 0, 0) 22%);
}

.hero[data-period="day"] { color: #0f2a3a; background: #7fd3f6; }
.hero[data-period="day"] .hero-bg::after {
	background:
		linear-gradient(180deg, rgba(255, 255, 255, .25) 0%, rgba(255, 255, 255, 0) 40%),
		linear-gradient(0deg, var(--bg) 0%, rgba(255, 255, 255, 0) 22%);
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	max-width: 720px;
	margin: 0 auto;
}

.brand {
	display: flex;
	align-items: center;
	gap: 10px;
	min-width: 0;
	font-family: var(--font-display);
	font-size: 16px;
	letter-spacing: .01em;
}

.brand img {
	width: 32px;
	height: 32px;
	border-radius: 9px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

.location-chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 40px;
	max-width: 60%;
	padding: 0 12px 0 10px;
	border-radius: 999px;
	background: rgba(255, 255, 255, .2);
	border: 1px solid rgba(255, 255, 255, .35);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	font-size: 14px;
	font-weight: 600;
	transition: background .2s;
}

.location-chip:hover { background: rgba(255, 255, 255, .3); }
.hero[data-period="day"] .location-chip { background: rgba(255, 255, 255, .55); border-color: rgba(255, 255, 255, .8); }

.location-chip span {
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.hero-body {
	max-width: 720px;
	margin: 36px auto 0;
	text-align: center;
	text-shadow: 0 1px 12px rgba(0, 0, 0, .18);
}

.hero[data-period="day"] .hero-body { text-shadow: 0 1px 12px rgba(255, 255, 255, .5); }

.hero-date {
	font-size: 13px;
	opacity: .92;
}

.hero-date .dot { margin: 0 8px; opacity: .6; }

.hero-status {
	margin-top: 18px;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: .02em;
}

.hero-countdown {
	font-family: var(--font-display);
	font-size: clamp(48px, 16vw, 72px);
	line-height: 1.1;
	font-variant-numeric: tabular-nums;
	letter-spacing: .02em;
}

.hero-next {
	margin-top: 4px;
	font-size: 14px;
	opacity: .92;
}

/* ---------- Layout ---------- */

.container {
	position: relative;
	max-width: 720px;
	margin: -48px auto 0;
	padding: 0 16px calc(24px + var(--safe-bottom));
	display: grid;
	gap: 16px;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	overflow: hidden;
}

.card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px 12px;
}

.card-head h2 {
	font-size: 16px;
	font-weight: 650;
}

.badge {
	padding: 2px 10px;
	border-radius: 999px;
	background: var(--primary-soft);
	color: var(--primary);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: .04em;
}

/* ---------- Today list ---------- */

.times {
	list-style: none;
	margin: 0;
	padding: 0 8px 8px;
}

.time-row {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 12px 10px;
	border-radius: 12px;
	color: var(--muted);
	transition: background .3s, color .3s;
}

.time-row + .time-row { margin-top: 2px; }

.time-row.is-prayer { color: var(--text); }
.time-row.is-past { opacity: .55; }

.time-icon {
	display: grid;
	place-items: center;
	width: 38px;
	height: 38px;
	border-radius: 11px;
	background: var(--surface-2);
	color: var(--muted);
}

.is-prayer .time-icon { color: var(--primary); background: var(--primary-soft); }

.time-label { flex: 1; font-weight: 550; }
.is-prayer .time-label { font-weight: 650; }

.time-value {
	font-family: var(--font-display);
	font-size: 20px;
	font-variant-numeric: tabular-nums;
	color: var(--text);
}

.time-row:not(.is-prayer) .time-value { font-size: 17px; color: var(--muted); }

.sec { font-size: .68em; opacity: .55; margin-left: 1px; }

.time-row.is-active {
	background: var(--primary);
	color: var(--on-primary);
	opacity: 1;
}

.time-row.is-active .time-icon { background: rgba(255, 255, 255, .18); color: inherit; }
.time-row.is-active .time-value { color: inherit; }

/* ---------- Rules ---------- */

.rules {
	display: grid;
	gap: 10px;
	padding: 0 16px 16px;
}

.rule {
	padding: 14px 16px;
	border-radius: 14px;
	background: var(--surface-2);
	border: 1px solid transparent;
	transition: border-color .3s, background .3s;
}

.rule h3 {
	font-size: 14px;
	font-weight: 700;
	margin-bottom: 4px;
}

.rule p { color: var(--muted); font-size: 14px; }
.rule strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }

.rule.is-active {
	background: var(--primary-soft);
	border-color: var(--primary);
}

.rule.is-active h3 { color: var(--primary); }

/* ---------- Monthly table ---------- */

.month-head { padding-bottom: 8px; }

.month-title {
	flex: 1;
	text-align: center;
	min-width: 0;
}

.link-btn {
	font-size: 13px;
	color: var(--primary);
	font-weight: 600;
}

.link-btn:hover { text-decoration: underline; }

.icon-btn {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--surface-2);
	color: var(--text);
	transition: background .2s;
}

.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }

.table-wrap {
	max-height: 70vh;
	overflow: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	border-top: 1px solid var(--border);
}

.month-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	font-size: 14px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.month-table th, .month-table td {
	padding: 10px 9px;
	text-align: center;
	border-bottom: 1px solid var(--border);
}

.month-table thead th {
	position: sticky;
	top: 0;
	z-index: 2;
	background: var(--surface);
	color: var(--primary);
	font-size: 12px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .04em;
	box-shadow: inset 0 -1px 0 var(--border);
}

.month-table th:first-child {
	position: sticky;
	left: 0;
	z-index: 1;
	background: var(--surface);
	text-align: left;
	box-shadow: inset -1px 0 0 var(--border);
}

.month-table thead th:first-child { z-index: 3; }

.month-table tbody th { font-weight: 600; }
.d-num { display: inline-block; min-width: 1.6em; font-size: 15px; }
.d-name { color: var(--muted); font-size: 12px; font-weight: 500; }

.month-table tbody tr.is-friday th,
.month-table tbody tr.is-friday td { background: var(--friday); }
.month-table tbody tr.is-friday .d-name { color: var(--primary); font-weight: 700; }

.month-table tbody tr.is-today th,
.month-table tbody tr.is-today td {
	background: var(--primary);
	color: var(--on-primary);
	font-weight: 700;
	border-bottom-color: var(--primary);
}

.month-table tbody tr.is-today .d-name { color: inherit; }

.month-table tbody tr:hover:not(.is-today) td,
.month-table tbody tr:hover:not(.is-today) th { background: var(--surface-2); }

.meta {
	padding: 12px 18px 16px;
	color: var(--muted);
	font-size: 12px;
	border-top: 1px solid var(--border);
}

/* ---------- Footer ---------- */

.footer {
	padding: 24px 0 8px;
	text-align: center;
}

.footer a {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	color: var(--muted);
	font-size: 12px;
	text-decoration: none;
}

.footer img { width: 56px; height: auto; }

/* ---------- City dialog (bottom sheet) ---------- */

.sheet {
	width: 100%;
	max-width: 560px;
	max-height: none;
	height: 100%;
	margin: 0 auto;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--text);
}

.sheet[open] { display: flex; align-items: flex-end; }

.sheet::backdrop {
	background: rgba(10, 16, 13, .5);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.sheet-inner {
	display: flex;
	flex-direction: column;
	width: 100%;
	height: min(86vh, 720px);
	height: min(86dvh, 720px);
	padding: 8px 16px calc(12px + var(--safe-bottom));
	background: var(--surface);
	border-radius: 22px 22px 0 0;
	box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
	animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1);
}

.sheet-inner::before {
	content: "";
	align-self: center;
	width: 40px;
	height: 4px;
	margin-bottom: 4px;
	border-radius: 2px;
	background: var(--border);
}

@keyframes sheet-up {
	from { transform: translateY(40px); opacity: 0; }
	to { transform: none; opacity: 1; }
}

.sheet-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 8px 0 12px;
}

.sheet-head h2 { font-size: 18px; font-weight: 700; }

.search {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 0 14px;
	min-height: 48px;
	border-radius: 14px;
	background: var(--surface-2);
	border: 1px solid var(--border);
	color: var(--muted);
}

.search:focus-within { border-color: var(--primary); }

.search input {
	flex: 1;
	min-width: 0;
	height: 46px;
	border: 0;
	outline: 0;
	background: transparent;
	color: var(--text);
	font: inherit;
	font-size: 16px; /* cegah auto-zoom iOS */
}

.locate-btn {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-top: 10px;
	padding: 12px 14px;
	border-radius: 14px;
	color: var(--primary);
	font-weight: 600;
	background: var(--primary-soft);
}

.locate-btn:disabled { opacity: .6; cursor: progress; }

.sheet-msg {
	margin-top: 10px;
	color: var(--muted);
	font-size: 13px;
	text-align: center;
}

.city-list {
	flex: 1;
	margin: 10px -16px 0;
	padding: 0 8px;
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.city-list button {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	min-height: 48px;
	padding: 10px 12px;
	border-radius: 12px;
	text-align: left;
}

.city-list button:hover { background: var(--surface-2); }

.c-tz {
	flex: none;
	font-size: 11px;
	font-weight: 700;
	color: var(--muted);
	letter-spacing: .04em;
}

.city-list [aria-selected="true"] button {
	background: var(--primary-soft);
	color: var(--primary);
	font-weight: 650;
}

.city-list [aria-selected="true"] .c-tz { color: var(--primary); }

/* ---------- Larger screens ---------- */

@media (min-width: 640px) {
	.hero { min-height: 380px; padding-left: 24px; padding-right: 24px; }
	.hero-body { margin-top: 48px; }
	.container { padding-left: 24px; padding-right: 24px; }
	.rules { grid-template-columns: repeat(3, 1fr); }
	.sheet[open] { align-items: center; }
	.sheet-inner { border-radius: 22px; height: min(80vh, 680px); }
	.sheet-inner::before { display: none; }
}

@media (min-width: 640px) {
	.month-table th, .month-table td { padding: 10px 12px; }
}

@media (min-width: 1040px) {
	.container, .topbar, .hero-body { max-width: 1120px; }
	.container { grid-template-columns: 340px 1fr; align-items: start; }
	.container > .today { grid-row: span 1; }
	.container > .card:nth-child(2) { grid-column: 1; }
	.container > .monthly { grid-column: 2; grid-row: 1 / span 2; }
	.container > .footer { grid-column: 1 / -1; }
	.rules { grid-template-columns: 1fr; }
	.table-wrap { max-height: 640px; }
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
