/* ── Claude-style Design System ── */
:root {
  --bg:        #f7f4ee;
  --bg-subtle: #f0ece4;
  --bg-input:  #eeebe3;
  --border:    #e2ddd5;
  --border-med:#d4cfc7;
  --text:      #1a1915;
  --text-2:    #6b6760;
  --text-3:    #9c9890;
  --accent:    #cf6523;
  --accent-bg: #fef3ec;
  --accent-hov:#b85720;
  --surface:   #ffffff;
  --green:     #1e7e5a;
  --green-bg:  #edf7f2;
  --red-bg:    #fef0f0;
  --red:       #c53030;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --r:         10px;
  --r-sm:      7px;
  --font:      'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w: 240px;
  --topbar-h:  52px;
  --safe-top:  env(safe-area-inset-top, 0px);
  --safe-bot:  env(safe-area-inset-bottom, 0px);
  --transition:.15s ease;
}

[data-theme="dark"] {
  --bg:        #1a1915;
  --bg-subtle: #222118;
  --bg-input:  #2a2820;
  --border:    #2e2c26;
  --border-med:#3a3830;
  --text:      #e8e4da;
  --text-2:    #8a8780;
  --text-3:    #5a5852;
  --accent:    #e07535;
  --accent-bg: #2a1e12;
  --accent-hov:#f08040;
  --surface:   #222118;
  --green:     #3aaa78;
  --green-bg:  #0f2218;
  --red-bg:    #2a1010;
  --red:       #e05555;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.25);
  --shadow:    0 4px 12px rgba(0,0,0,.35);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.app { display: flex; height: 100dvh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  transition: transform var(--transition);
  z-index: 200;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + var(--safe-top)) 16px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.logo-mark { font-size: 20px; color: var(--accent); line-height: 1; }

.sidebar-close {
  display: none;
  width: 28px; height: 28px;
  background: none; border: none;
  color: var(--text-2); cursor: pointer;
  border-radius: 6px;
  align-items: center; justify-content: center;
  transition: background var(--transition);
}
.sidebar-close:hover { background: var(--border); }

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: none;
  background: none;
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 400;
  border-radius: var(--r-sm);
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--border); color: var(--text); }
.nav-item.active { background: var(--bg-input); color: var(--text); font-weight: 500; }
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 16px calc(14px + var(--safe-bot));
  border-top: 1px solid var(--border);
}
.sf-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 4px; }
.sf-val { font-size: 13px; color: var(--text); font-weight: 500; margin-bottom: 8px; line-height: 1.3; }
.sf-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: none;
  color: var(--accent); font-family: var(--font);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer; padding: 0;
}
.sf-btn:hover { color: var(--accent-hov); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 150;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  padding-top: var(--safe-top);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 14px;
  padding-right: 14px;
  background: var(--bg);
  flex-shrink: 0;
}
.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.topbar-btn {
  width: 32px; height: 32px;
  background: none; border: none;
  color: var(--text-2); cursor: pointer;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  position: relative; z-index: 1;
}
.topbar-btn:hover { background: var(--bg-subtle); color: var(--text); }

/* Theme toggle icons */
.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* ── Views ── */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.view::-webkit-scrollbar { width: 5px; }
.view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.view.active { display: block; }

.content-pad { padding: 20px 20px calc(32px + var(--safe-bot)); max-width: 560px; }

/* ── Date row ── */
.date-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}
.date-main { font-size: 15px; font-weight: 500; color: var(--text); }
.date-hijri { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.location-chip {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 12px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color var(--transition), color var(--transition);
  font-family: var(--font);
}
.location-chip:hover { border-color: var(--border-med); color: var(--text); }
#location-chip-text { overflow: hidden; text-overflow: ellipsis; }

/* ── Next prayer card ── */
.next-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 18px 0;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.next-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}
.next-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  font-weight: 500;
}
.next-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.next-time {
  font-size: 36px;
  font-weight: 300;
  color: var(--text);
  letter-spacing: -1px;
  line-height: 1.1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.next-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.next-countdown { font-size: 13px; color: var(--accent); font-weight: 500; }
.next-iqama-text { font-size: 12px; color: var(--text-3); }
.next-iqama-text:not(:empty)::before { content: '·'; margin-right: 6px; color: var(--text-3); }

.next-track {
  height: 2px;
  background: var(--border);
  margin: 0 -18px;
}
.next-fill {
  height: 100%;
  background: var(--accent);
  transition: width 1s linear;
  min-width: 2px;
  border-radius: 0 1px 1px 0;
}

/* ── Section head ── */
.section-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: 10px;
}

/* ── Prayer list ── */
.prayer-list { display: flex; flex-direction: column; gap: 1px; }

.prayer-row {
  display: flex;
  align-items: center;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  gap: 12px;
  transition: background var(--transition);
  animation: rowIn .3s ease both;
}
.prayer-row:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.prayer-row:last-child  { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.prayer-row:only-child  { border-radius: var(--r-sm); }
.prayer-row + .prayer-row { border-top: none; }

@keyframes rowIn {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0); }
}
.prayer-row:nth-child(1){animation-delay:.04s}
.prayer-row:nth-child(2){animation-delay:.08s}
.prayer-row:nth-child(3){animation-delay:.12s}
.prayer-row:nth-child(4){animation-delay:.16s}
.prayer-row:nth-child(5){animation-delay:.20s}
.prayer-row:nth-child(6){animation-delay:.24s}

.prayer-row.active { background: var(--accent-bg); }
.prayer-row.passed { opacity: .5; }

.pr-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pr-info { flex: 1; min-width: 0; }
.pr-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}
.prayer-row.active .pr-name { color: var(--accent); }
.pr-iqama-tag { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.pr-times { text-align: right; flex-shrink: 0; }
.pr-adhan {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.prayer-row.active .pr-adhan { color: var(--accent); }
.pr-iqama-time { font-size: 11px; color: var(--text-3); margin-top: 1px; font-variant-numeric: tabular-nums; }
.pr-check { font-size: 12px; color: var(--green); margin-left: 6px; }

/* ── Footnote ── */
.footnote {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--text-3);
}
.fn-btn {
  background: none; border: none;
  color: var(--accent); font-family: var(--font);
  font-size: 11.5px; font-weight: 500;
  cursor: pointer; padding: 0;
}
.fn-btn:hover { color: var(--accent-hov); }

/* ── Settings view ── */
.view-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.view-sub {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 20px;
}

.iqama-list { display: flex; flex-direction: column; gap: 1px; margin-bottom: 20px; }

.iqama-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  gap: 12px;
}
.iqama-row:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.iqama-row:last-child  { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.iqama-row + .iqama-row { border-top: none; }

.ir-left { display: flex; align-items: center; gap: 10px; }
.ir-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ir-name { font-size: 14px; font-weight: 500; color: var(--text); }

.stepper { display: flex; align-items: center; gap: 8px; }
.step-btn {
  width: 28px; height: 28px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  font-family: var(--font);
}
.step-btn:hover { background: var(--border); border-color: var(--border-med); }
.step-btn:active { transform: scale(.93); }
.step-val {
  min-width: 36px; text-align: center;
  font-size: 14px; font-weight: 500; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.step-unit { font-size: 11px; color: var(--text-3); }

.divider { height: 1px; background: var(--border); margin: 4px 0 16px; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.sr-title { font-size: 14px; font-weight: 500; color: var(--text); }
.sr-sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.notif-hint { font-size: 12px; color: var(--text-3); margin-top: 8px; }
.notif-hint.ok  { color: var(--green); }
.notif-hint.err { color: var(--red);   }

/* Toggle */
.toggle {
  width: 44px; height: 24px;
  border-radius: 99px;
  background: var(--border-med);
  border: none; cursor: pointer;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.toggle.on .knob { transform: translateX(20px); }

.save-btn {
  margin-top: 20px;
  width: 100%;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-family: var(--font);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), transform .1s;
}
.save-btn:hover  { background: var(--accent-hov); }
.save-btn:active { transform: scale(.99); }

/* ── Method list ── */
.method-list { display: flex; flex-direction: column; gap: 1px; }
.method-item {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.method-item:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.method-item:last-child  { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.method-item + .method-item { border-top: none; }
.method-item:hover { background: var(--bg-subtle); }
.method-item.selected { background: var(--accent-bg); }
.mi-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.method-item.selected .mi-name { color: var(--accent); }
.mi-org { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn .15s ease;
}
.modal-backdrop.hidden { display: none; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.modal {
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bot));
  animation: slideUp .25s cubic-bezier(.4,0,.2,1);
  scrollbar-width: none;
}
.modal::-webkit-scrollbar { display: none; }
@keyframes slideUp { from{transform:translateY(40px);opacity:0} to{transform:translateY(0);opacity:1} }

.modal-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-x {
  width: 28px; height: 28px;
  background: var(--bg-subtle); border: none;
  border-radius: 50%; cursor: pointer;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition);
}
.modal-x:hover { background: var(--border); }

.modal-search-box {
  display: flex; align-items: center; gap: 9px;
  margin: 14px 18px 0;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--transition);
}
.modal-search-box:focus-within { border-color: var(--accent); }
.modal-search-box svg { color: var(--text-3); flex-shrink: 0; }
.modal-search-box input {
  flex: 1; background: none; border: none; outline: none;
  font-family: var(--font); font-size: 14px; color: var(--text);
}
.modal-search-box input::placeholder { color: var(--text-3); }

.modal-actions {
  display: flex; gap: 8px;
  padding: 10px 18px 0;
}
.modal-search-btn {
  flex: 1; padding: 9px 14px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: background var(--transition);
}
.modal-search-btn:hover { background: var(--accent-hov); }
.modal-gps-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-family: var(--font); font-size: 13.5px; font-weight: 500;
  color: var(--text-2); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-gps-btn:hover { background: var(--border); color: var(--text); }

.search-results {
  padding: 8px 18px 0;
  display: flex; flex-direction: column; gap: 1px;
}
.result-item {
  padding: 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.result-item:first-child { border-radius: var(--r-sm) var(--r-sm) 0 0; }
.result-item:last-child  { border-radius: 0 0 var(--r-sm) var(--r-sm); }
.result-item + .result-item { border-top: none; }
.result-item:hover { background: var(--accent-bg); }
.ri-name { font-size: 13.5px; font-weight: 500; color: var(--text); }
.ri-country { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

.search-err {
  margin: 10px 18px 0;
  padding: 10px 12px;
  background: var(--red-bg);
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--red);
}
.search-err.hidden { display: none; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(20px + var(--safe-bot));
  left: 50%; transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  z-index: 999;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
}
.toast.hidden { display: none; }
@keyframes toastIn { from{opacity:0;transform:translateX(-50%) translateY(8px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }

/* Skeleton */
.skel {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-subtle) 50%, var(--bg-input) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0%{background-position:300% 0} 100%{background-position:-300% 0} }

/* ── Mobile: sidebar becomes drawer ── */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .sidebar-overlay.open { display: block; }
  .topbar-title { position: static; transform: none; }
}

/* ── Desktop: sidebar always visible ── */
@media (min-width: 641px) {
  .sidebar-close { display: none; }
  #menu-btn { display: none; }
}
