/* ============================================================
   Postlecture — light theme design system
   Warm paper background, ink text, one confident accent (indigo),
   muted semantics. Crafted hierarchy, hairlines, generous space.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #f8f7f4;          /* warm paper */
  --surface: #ffffff;     /* cards */
  --surface-2: #f1efea;   /* insets, tracks */
  --surface-3: #e9e6df;

  /* Ink */
  --ink: #1b1b1f;
  --ink-2: #5f5b53;       /* secondary, warm grey */
  --ink-3: #97928a;       /* tertiary / labels */

  /* Lines */
  --line: #e9e5dd;
  --line-2: #ded9cf;

  /* Accent + semantics (muted, sit well on paper) */
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eceafe;
  --ok: #15803d;
  --ok-soft: #e6f4ea;
  --warn: #b45309;
  --warn-soft: #fbf0df;
  --danger: #c2362f;
  --danger-soft: #fae9e7;

  /* Radii + shadow */
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(28,28,30,.05), 0 1px 3px rgba(28,28,30,.04);
  --shadow-lg: 0 4px 16px rgba(28,28,30,.08);

  --tab-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  max-width: 100%;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }
button { font-family: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- Layout ---------- */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0) + 18px) 18px
           calc(var(--tab-h) + env(safe-area-inset-bottom, 0) + 24px);
}

/* ---------- Typography ---------- */
h1 { font-size: 26px; line-height: 1.15; font-weight: 760; letter-spacing: -0.02em; margin: 2px 0 4px; }
h2 { font-size: 13px; font-weight: 680; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); margin: 0 0 12px; }
h3 { font-size: 16px; font-weight: 650; margin: 0 0 6px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 13px; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.eyebrow { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.card.flush { padding: 6px 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-h h2 { margin: 0; }
.card.error { border-color: var(--danger); background: var(--danger-soft); color: #7a221d; }
.card-link { display: block; text-decoration: none; color: inherit; transition: border-color .15s, transform .05s; }
.card-link:active { transform: scale(.995); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  padding: 13px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 640;
  font-size: 15px;
  cursor: pointer;
  margin-top: 14px;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn.ghost { background: transparent; color: var(--accent); border-color: transparent; margin-top: 0; width: auto; padding: 6px 8px; }
.btn.sm { width: auto; padding: 9px 14px; font-size: 14px; margin-top: 0; }
.link { color: var(--accent); text-decoration: none; font-weight: 600; }
.link-btn { background: none; border: none; color: var(--ink-2); cursor: pointer; font: inherit; padding: 0; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--ink-3); padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Forms ---------- */
label.fld { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 14px 0 6px; }
input, textarea, select {
  width: 100%;
  padding: 12px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;       /* inputs don't inherit the body font by default */
  font-size: 16px;            /* avoids iOS zoom on focus */
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
select { -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2397928a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }

/* ---------- Pills / tags ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.tag-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }

/* ---------- Rows / list items ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-item:last-child { border-bottom: none; }
.list-item > div { min-width: 0; }
.list-item .lead { font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.list-item .trail { margin-left: auto; text-align: right; color: var(--ink-2); font-size: 13px; white-space: nowrap; flex: 0 0 auto; }
.chev { color: var(--ink-3); flex: 0 0 auto; }

/* ---------- Banners ---------- */
.banner { display: flex; gap: 10px; padding: 13px 14px; border-radius: var(--r-sm);
  background: var(--accent-soft); color: #2a2580; font-size: 14px; margin-bottom: 14px; align-items: flex-start; }
.banner.warn { background: var(--warn-soft); color: #6b3e08; }
.banner .b-ico { flex: 0 0 auto; margin-top: 1px; }

/* ---------- Hero (now / next) ---------- */
.hero { position: relative; overflow: hidden; }
.hero .eyebrow { margin-bottom: 6px; }
.hero .big { font-size: 30px; font-weight: 780; letter-spacing: -.02em; }
.hero .count { font-weight: 720; }
.hero.live { border-color: var(--accent); }
.hero.live::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }

/* ---------- Timeline (today) ---------- */
.tl { position: relative; padding-left: 26px; }
.tl-item { position: relative; padding: 11px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-item::before { content: ""; position: absolute; left: -22px; top: 17px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--line-2); }
.tl::after { content: ""; position: absolute; left: -17px; top: 6px; bottom: 6px; width: 2px; background: var(--line); z-index: -0; }
.tl-item.done::before { background: var(--ink-3); border-color: var(--ink-3); }
.tl-item.now::before { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-item.next::before { border-color: var(--accent); }
.tl-time { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl-title { font-weight: 620; }
.tl-item.done .tl-title { color: var(--ink-2); }

/* ---------- Attendance ring ---------- */
.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring-wrap > div { min-width: 0; }
.ring { position: relative; width: 92px; height: 92px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring .ring-val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .ring-num { font-size: 21px; font-weight: 760; letter-spacing: -.02em; }
.ring .ring-cap { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Stat grid ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: var(--r-sm); padding: 12px; text-align: center; }
.stat .n { font-size: 20px; font-weight: 740; letter-spacing: -.02em; }
.stat .l { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-top: 2px; }

/* ---------- Segmented control (attendance mark) ---------- */
.seg { display: flex; gap: 8px; }
.seg-btn { flex: 1; padding: 11px 8px; border: 1.5px solid var(--line-2); background: var(--surface);
  color: var(--ink-2); border-radius: var(--r-sm); font-size: 14px; font-weight: 620; cursor: pointer; transition: .12s; }
.seg-btn:hover { border-color: var(--ink-3); }
.seg-btn.on { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.seg-btn.on.ok { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.seg-btn.on.bad { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

/* ---------- Progress bar ---------- */
.bar { height: 7px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 9px 0; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }

/* ---------- Checklist ---------- */
.check { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: none; }
.check.done .c-body { text-decoration: line-through; color: var(--ink-3); }
.check input[type=checkbox] { -webkit-appearance: none; appearance: none; width: 21px; height: 21px; flex: 0 0 auto;
  border: 2px solid var(--line-2); border-radius: 7px; margin-top: 1px; cursor: pointer; position: relative; background: var(--surface); }
.check input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.check input[type=checkbox]:checked::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.check .c-body { flex: 1; }

/* ---------- Colors for states ---------- */
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-danger { color: var(--danger); } .t-accent { color: var(--accent); }
.spin { opacity: .5; }
.empty { text-align: center; color: var(--ink-3); padding: 22px 8px; }
.empty .e-ico { color: var(--line-2); margin-bottom: 8px; }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--tab-h); text-decoration: none; color: var(--ink-3); font-size: 11px; font-weight: 600;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.active { color: var(--accent); }

/* ---------- Header (slim, contextual) ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between;
  max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top,0) + 12px) 18px 0; }
.brand { font-weight: 760; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }

/* icon sizing helper */
.ico { display: inline-flex; vertical-align: middle; }
.ico svg { display: block; }
