/* memo.haizulali.com — dark, compact, phone-first. */

:root {
  --bg: #0d1117;
  --card: #161b22;
  --card-2: #1c2230;
  --line: #262d3a;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #e3b341;
  --green: #3fb950;
  --red: #f85149;
  --blue: #58a6ff;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--red); font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── Gate ─────────────────────────────────────────────────────────────── */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
  display: grid;
  gap: 12px;
}
.gate-card h1 { font-size: 28px; letter-spacing: -0.5px; }
.gate-card input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  width: 100%;
}
.gate-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.gate-card button[type="submit"] {
  background: var(--accent);
  color: #17202a;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  font-weight: 650;
  cursor: pointer;
}

/* ── Chrome ───────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: rgba(13, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: -0.3px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--muted);
  cursor: pointer;
  min-height: 40px;
}
.tabs button.active { background: var(--card-2); color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.link {
  background: none;
  border: 0;
  color: var(--blue);
  cursor: pointer;
  padding: 6px 4px;
  font-size: 13px;
}

main { padding: 16px; display: grid; gap: 14px; max-width: 900px; margin: 0 auto; }
.view { display: grid; gap: 14px; }
/* A class with `display` outranks the [hidden] attribute, so without this the
   hidden tabs render underneath the visible one. */
[hidden] { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.card-head.tight { margin-top: 18px; }
.empty { text-align: center; padding: 32px 16px; }

/* ── Hero ─────────────────────────────────────────────────────────────── */

.hero-main { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pct { font-size: 44px; font-weight: 750; letter-spacing: -1.5px; color: var(--accent); }
.bar { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin: 12px 0; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }
.track { font-size: 14px; font-weight: 600; }
.track.ahead { color: var(--green); }
.track.behind { color: var(--red); }
.track.neutral { color: var(--muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 26px; font-weight: 700; margin: 2px 0; }
.stat-sub { font-size: 12px; }

.pace-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.pace-row:last-child { border-bottom: 0; }

/* ── Surah list ───────────────────────────────────────────────────────── */

.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.surah-list { display: grid; gap: 2px; }
.surah { border-radius: 8px; }
.surah.open { background: var(--card-2); }
.surah-head { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }

.check {
  flex: none;
  width: 22px; height: 22px;
  border: 2px solid var(--line);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.check.checked { background: var(--accent); border-color: var(--accent); }
.check.checked::after {
  content: '✓'; position: absolute; inset: 0;
  display: grid; place-items: center; color: #17202a; font-size: 14px; font-weight: 800;
}
.check.partial::after {
  content: ''; position: absolute; inset: 4px;
  background: var(--accent); border-radius: 2px;
}

.surah-name {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; cursor: pointer;
  text-align: left; padding: 8px 2px; min-height: 40px;
}
.num {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 20px; padding: 0 5px;
  background: var(--card-2); border-radius: 5px;
  font-size: 11px; color: var(--muted);
}
.surah.open .num { background: var(--bg); }
.chev { color: var(--muted); font-size: 11px; }
/* Marks a surah in the full 1–114 list that is also in the target, so the
   link between the two lists is visible rather than implied. */
.in-target { color: var(--accent); font-size: 9px; }
.surah-right { display: flex; align-items: center; gap: 8px; flex: none; }
.count { font-size: 12px; min-width: 52px; text-align: right; }
.mini-bar { display: block; width: 54px; height: 6px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.surah.open .mini-bar { background: var(--bg); }
.mini-bar.wide { width: 100%; min-width: 60px; }
.mini-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.pct-small { font-size: 12px; min-width: 34px; text-align: right; color: var(--muted); }

.ayah-grid {
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 4px 8px 12px 34px;
}
.ayah {
  min-width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--muted);
  font-size: 12px; cursor: pointer;
}
.ayah.on { background: var(--accent); border-color: var(--accent); color: #17202a; font-weight: 700; }
.ayah-actions { width: 100%; padding-top: 4px; }

/* ── Compare ──────────────────────────────────────────────────────────── */

.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.standings li {
  display: grid;
  grid-template-columns: 22px minmax(64px, 1fr) minmax(60px, 1.4fr) auto auto auto;
  align-items: center; gap: 10px;
  padding: 8px; border-radius: 8px;
}
.standings li.me { background: var(--card-2); }
.rank { color: var(--muted); font-size: 13px; }
.who-name { font-weight: 600; }
.who-num { font-size: 13px; }
.who-pct { font-size: 13px; min-width: 38px; text-align: right; color: var(--accent); }
.tag {
  font-size: 11px; padding: 3px 7px; border-radius: 99px;
  background: var(--card-2); color: var(--muted); white-space: nowrap;
}
.standings li.me .tag { background: var(--bg); }
.tag.lead { background: rgba(63, 185, 80, .15); color: var(--green); }

.table-scroll { overflow-x: auto; }
table.compare { width: 100%; border-collapse: collapse; font-size: 13px; }
table.compare th, table.compare td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); }
table.compare thead th { position: sticky; top: 0; background: var(--card); color: var(--muted); font-size: 12px; }
table.compare th.left { text-align: left; white-space: nowrap; font-weight: 500; }
.cell-pct { display: block; font-weight: 650; }
.cell-sub { display: block; font-size: 11px; color: var(--muted); }
td.full .cell-pct { color: var(--green); }
td.part .cell-pct { color: var(--accent); }
td.none .cell-pct { color: var(--muted); }
td.mine { background: rgba(88, 166, 255, .07); }

/* ── Settings ─────────────────────────────────────────────────────────── */

.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field-row input, .field-row select {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; min-height: 42px;
}
.preset-row { display: flex; flex-wrap: wrap; gap: 4px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 5px; }
.pick {
  display: flex; align-items: center; gap: 7px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; min-height: 42px;
  cursor: pointer; text-align: left;
}
.pick.on { background: rgba(227, 179, 65, .14); border-color: var(--accent); }
.pick-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
#save-settings {
  background: var(--accent); color: #17202a; border: 0;
  border-radius: 8px; padding: 11px 18px; font-weight: 650; cursor: pointer;
}

@media (max-width: 520px) {
  .standings li { grid-template-columns: 20px 1fr auto auto; }
  .standings .mini-bar { display: none; }
  .pct { font-size: 36px; }
}
