:root {
  --bg: #f3efe7; --card: #fffdf9; --ink: #1d2a38; --muted: #6b7682; --line: #e5dfd3;
  --brand: #1f4e74; --brand-2: #2b6a9b; --ok: #2e7d4f; --warn: #a15c00; --danger: #b3261e;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--brand-2); }
h1 { font-size: 1.35rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: .75rem 1rem; background: var(--brand); color: #fff;
}
.top .brand { color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.top form { margin: 0; }
.link { background: none; border: 0; color: #dbe8f3; font: inherit; cursor: pointer; }
main { max-width: 640px; margin: 0 auto; padding: .75rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: .75rem; }
.card.narrow { max-width: 380px; margin: 2rem auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 700; }
.warn { color: var(--warn); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .75rem; text-decoration: none; color: inherit; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

label { display: block; font-size: .9rem; color: var(--muted); margin: .5rem 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .7rem .75rem; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 46px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 1px; }
.field.check label, label.check { display: flex; gap: .5rem; align-items: center; color: var(--ink); }
.field.check input { width: 22px; height: 22px; }
.help { margin: -.25rem 0 .5rem; font-size: .8rem; color: var(--muted); }
.errorlist { color: var(--danger); margin: .25rem 0; padding-left: 1rem; font-size: .85rem; }
form.inline { display: inline; }

.btn {
  display: inline-block; padding: .55rem .9rem; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--danger); border-color: #efc9c6; }
.btn.small { padding: .3rem .6rem; font-size: .85rem; }
.btn.block { display: block; width: 100%; margin-top: .75rem; padding: .85rem; font-size: 1rem; }

.msg { padding: .7rem .9rem; border-radius: 10px; margin-bottom: .75rem; background: #e8f1f8; }
.msg.success { background: #e3f3e8; color: var(--ok); }
.msg.error { background: #fbe9e7; color: var(--danger); }

table.times { width: 100%; border-collapse: collapse; margin-top: .75rem; }
table.times th, table.times td { padding: .5rem .25rem; text-align: left; border-bottom: 1px solid var(--line); }
table.times thead th { color: var(--muted); font-weight: 500; font-size: .8rem; text-transform: uppercase; }
table.times td.warn { font-size: .8rem; border-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: #eef3f7; border-radius: 999px; padding: .3rem .7rem; font-size: .85rem; }
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.tag { font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #eee; color: var(--muted); }
.tag.on { background: #e3f3e8; color: var(--ok); }
pre.code { background: #f4f1ea; padding: .6rem; border-radius: 8px; font-size: .78rem; overflow-x: auto; }

/* iqamah editor */
.seg { display: flex; background: #eef1f4; border-radius: 10px; padding: 3px; margin: .5rem 0; }
.seg label { flex: 1; margin: 0; text-align: center; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: .5rem; border-radius: 8px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg input:checked + span { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.prayer[data-mode=fixed] .offset-only, .prayer[data-mode=offset] .fixed-only { display: none; }
.prayer h2 { margin: 0; }
details summary { cursor: pointer; margin-top: .25rem; }
.sticky-save { position: sticky; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 3; margin-bottom: .75rem; }
.sticky-save .btn { box-shadow: 0 6px 18px rgba(31,78,116,.3); }

nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a { flex: 1; text-align: center; padding: .45rem 0 .55rem; font-size: .72rem; color: var(--muted); text-decoration: none; }
nav.tabs a span { display: block; font-size: 1.25rem; line-height: 1.3; }
nav.tabs a.on { color: var(--brand); font-weight: 700; }

/* ---- 7-day editor ---- */
.week-nav { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; }
.week-nav input[type=date] { width: auto; max-width: 9rem; padding-left: .4rem; padding-right: .4rem; }
table.week-times { width: 100%; border-collapse: collapse; margin-top: .5rem; table-layout: fixed; }
table.week-times th, table.week-times td { padding: .3rem .15rem; text-align: left; border-bottom: 1px solid var(--line); }
table.week-times thead th { color: var(--muted); font-weight: 500; font-size: .75rem; text-transform: uppercase; }
table.week-times thead th:first-child, table.week-times tbody th { width: 4.6rem; }
table.week-times tbody th { font-weight: 600; font-size: .9rem; }
table.week-times input[type=time] { width: 100%; min-width: 0; padding: .35rem .3rem; font-size: .95rem; box-sizing: border-box; }
table.week-times td { position: relative; }
table.week-times .tag { position: absolute; top: -.15rem; right: .1rem; font-size: .62rem; padding: 0 .35rem; }
table.week-times td.warn { border-bottom: 0; }
.week-day h2 { margin: 0; font-size: 1.05rem; }
