:root {
  color-scheme: dark;
  --bg: #061612;
  --bg-2: #09221c;
  --card: rgba(18, 43, 35, 0.76);
  --card-strong: rgba(20, 54, 44, 0.88);
  --border: rgba(255, 255, 255, 0.10);
  --text: #f3fbf7;
  --muted: rgba(243, 251, 247, 0.62);
  --faint: rgba(243, 251, 247, 0.42);
  --accent: #58e79f;
  --accent-2: #bff7d5;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.30);
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --danger: #ff7777;
  --radius-xl: 30px;
  --radius-lg: 24px;
  --max: 1120px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f1e5;
  --bg-2: #edf7ec;
  --card: rgba(255, 255, 255, 0.76);
  --card-strong: rgba(255, 255, 255, 0.92);
  --border: rgba(22, 50, 40, 0.10);
  --text: #14241f;
  --muted: rgba(20, 36, 31, 0.62);
  --faint: rgba(20, 36, 31, 0.42);
  --accent: #188e5c;
  --accent-2: #0f6f49;
  --shadow: 0 24px 70px rgba(37, 77, 58, 0.14);
  --surface: rgba(20, 36, 31, 0.045);
  --surface-2: rgba(20, 36, 31, 0.075);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(88, 231, 159, 0.13), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
svg { display: block; }

.bg-orb {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.6;
}
.orb-a { top: -160px; right: -130px; width: 360px; height: 360px; background: rgba(88, 231, 159, 0.18); }
.orb-b { bottom: -190px; left: -150px; width: 420px; height: 420px; background: rgba(191, 247, 213, 0.10); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(var(--max), calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 10px;
  backdrop-filter: blur(16px);
}
.brand-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-2);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.brand-mark span {
  width: 12px;
  height: 22px;
  border-radius: 999px 999px 999px 999px;
  background: linear-gradient(180deg, var(--accent), #31d98a);
  transform: rotate(0deg);
}
.brand-name { font-size: 18px; line-height: 1.05; font-weight: 800; letter-spacing: -0.04em; }
.brand-sub { margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, background 0.16s ease;
}
.icon-button:active { transform: scale(0.96); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(var(--max), calc(100% - 28px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 4px 0 18px;
}

.next-card, .times-card, .panel {
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
}
.next-card {
  border-radius: var(--radius-xl);
  padding: 18px;
  overflow: hidden;
  position: relative;
}
.next-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -80px auto;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  background: rgba(88, 231, 159, 0.13);
  pointer-events: none;
}
.next-topline, .next-main, .location-line { position: relative; z-index: 1; }
.next-topline { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pill, .method-chip, .small-status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.method-chip { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-main {
  margin-top: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
}
.muted-label, .eyebrow, .field-label { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0.01em; }
h1, h2 { margin: 0; letter-spacing: -0.055em; }
h1 { margin-top: 4px; font-size: clamp(46px, 13vw, 76px); line-height: 0.92; }
h2 { font-size: 22px; line-height: 1.08; }
.time-block { text-align: right; flex: 0 0 auto; }
.next-time { font-size: clamp(38px, 11vw, 68px); line-height: 0.92; font-weight: 850; letter-spacing: -0.07em; font-variant-numeric: tabular-nums; }
.countdown { margin-top: 8px; color: var(--accent-2); font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.location-line {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.location-line svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.times-card {
  border-radius: var(--radius-xl);
  padding: 15px;
}
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.compact-head { margin-bottom: 10px; }
.prayer-list { display: grid; gap: 8px; }
.prayer-row {
  min-height: 56px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 13px;
}
.prayer-row.active {
  background: linear-gradient(135deg, rgba(88, 231, 159, 0.18), rgba(255, 255, 255, 0.045));
  border-color: rgba(88, 231, 159, 0.33);
}
.prayer-name { font-size: 16px; font-weight: 850; letter-spacing: -0.035em; }
.prayer-note { margin-top: 2px; font-size: 12px; color: var(--muted); font-weight: 650; }
.prayer-time { font-size: 22px; font-weight: 850; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }

.settings-grid { display: grid; gap: 12px; }
.panel {
  border-radius: var(--radius-lg);
  padding: 18px;
}
.small-button {
  min-height: 38px;
  border: 1px solid rgba(88, 231, 159, 0.34);
  border-radius: 999px;
  background: rgba(88, 231, 159, 0.14);
  color: var(--text);
  padding: 0 14px;
  font-weight: 850;
}
.field-label { display: block; margin: 13px 0 7px; }
.input {
  width: 100%;
  min-height: 48px;
  border-radius: 17px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
  outline: none;
  padding: 0 14px;
  font-weight: 650;
}
[data-theme="light"] .input { background: rgba(255, 255, 255, 0.65); }
.input:focus { border-color: rgba(88, 231, 159, 0.55); box-shadow: 0 0 0 4px rgba(88, 231, 159, 0.10); }
.input option { background: #10251f; color: #f3fbf7; }
[data-theme="light"] .input option { background: white; color: #14241f; }
.advanced-panel summary {
  list-style: none;
  cursor: pointer;
  color: var(--text);
  font-size: 16px;
  font-weight: 850;
  letter-spacing: -0.035em;
}
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary::before { content: "+"; display: inline-flex; justify-content: center; width: 22px; color: var(--accent); }
.advanced-panel[open] summary::before { content: "–"; }
.advanced-content { padding-top: 8px; }
.adjust-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.adjust-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.adjust-grid input {
  width: 100%;
  min-height: 42px;
  border-radius: 15px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.footer {
  width: min(var(--max), calc(100% - 28px));
  margin: 0 auto;
  padding: 14px 0 calc(18px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 750;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(18px);
  z-index: 50;
  max-width: min(92vw, 430px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--card-strong);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  font-size: 13px;
  font-weight: 750;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.clean-view .topbar,
.clean-view .times-card,
.clean-view .settings-grid,
.clean-view .footer { display: none; }
.clean-view .app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 18px 0;
}
.clean-view .next-card { width: 100%; max-width: 520px; }
.clean-view .next-card::before {
  content: "";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}

@media (min-width: 840px) {
  .app-shell {
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 0.72fr);
    align-items: start;
    gap: 16px;
    padding-top: 26px;
  }
  .next-card { grid-column: 1; grid-row: 1; min-height: 278px; padding: 26px; }
  .times-card { grid-column: 2; grid-row: 1 / span 2; padding: 20px; }
  .settings-grid { grid-column: 1; grid-row: 2; grid-template-columns: 1fr; gap: 16px; }
  .prayer-row { min-height: 66px; padding: 13px 16px; }
  .prayer-time { font-size: 24px; }
}

@media (max-width: 430px) {
  .topbar { width: calc(100% - 22px); padding-top: 11px; }
  .app-shell, .footer { width: calc(100% - 22px); }
  .brand-mark { width: 42px; height: 42px; border-radius: 16px; }
  .brand-name { font-size: 17px; }
  .brand-sub { max-width: 160px; }
  .icon-button { width: 39px; height: 39px; border-radius: 15px; }
  .next-card { padding: 15px; border-radius: 26px; }
  .times-card { padding: 12px; border-radius: 26px; }
  h1 { font-size: 44px; }
  .next-time { font-size: 39px; }
  .countdown { font-size: 13px; }
  .method-chip { max-width: 145px; }
  .prayer-row { min-height: 51px; border-radius: 18px; padding: 9px 11px; }
  .prayer-name { font-size: 15px; }
  .prayer-time { font-size: 21px; }
  .panel { padding: 15px; border-radius: 23px; }
  .footer { flex-direction: column; }
}


/* v7 clean view polish: true centered fullscreen card + visible Back control */
.clean-exit {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  right: 14px;
  z-index: 100;
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 14px 0 12px;
  background: color-mix(in srgb, var(--card-strong) 88%, transparent);
  color: var(--text);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  font-weight: 850;
  letter-spacing: -0.02em;
}
.clean-exit svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.clean-exit:active { transform: scale(0.97); }

body.clean-view {
  min-height: 100svh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 32%, rgba(88, 231, 159, 0.16), transparent 26rem),
    radial-gradient(circle at 50% 110%, rgba(191, 247, 213, 0.10), transparent 30rem),
    linear-gradient(135deg, var(--bg), var(--bg-2));
}
.clean-view .clean-exit { display: inline-flex; }
.clean-view .topbar,
.clean-view .times-card,
.clean-view .settings-grid,
.clean-view .footer { display: none !important; }
.clean-view .app-shell {
  width: 100% !important;
  max-width: none !important;
  min-height: 100svh !important;
  margin: 0 !important;
  padding: calc(70px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)) !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}
.clean-view .next-card {
  grid-column: auto !important;
  grid-row: auto !important;
  width: min(100%, 540px) !important;
  max-width: 540px !important;
  min-height: 0 !important;
  border-radius: clamp(28px, 6vw, 42px) !important;
  padding: clamp(20px, 5vw, 34px) !important;
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.34) !important;
}
.clean-view .next-card::before { display: none !important; }
.clean-view .next-card::after {
  width: clamp(150px, 32vw, 220px);
  height: clamp(150px, 32vw, 220px);
  right: -54px;
  bottom: -64px;
  opacity: 0.82;
}
.clean-view .next-topline { margin-bottom: clamp(18px, 4vw, 28px); }
.clean-view h1 { font-size: clamp(52px, 12vw, 88px); }
.clean-view .next-time { font-size: clamp(46px, 10vw, 78px); }
.clean-view .countdown { font-size: clamp(13px, 3vw, 16px); }
.clean-view .location-line { margin-top: clamp(18px, 4vw, 26px); }
.clean-view .bg-orb { opacity: 0.72; }

@media (max-width: 560px) {
  .clean-exit {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    min-height: 42px;
    padding: 0 12px 0 10px;
    font-size: 13px;
  }
  .clean-view .app-shell {
    padding-left: 13px !important;
    padding-right: 13px !important;
  }
  .clean-view .next-main {
    gap: 12px;
  }
  .clean-view .next-card {
    width: min(100%, 390px) !important;
  }
}
