:root {
  --bg: var(--tg-theme-bg-color, #17212b);
  --fg: var(--tg-theme-text-color, #f5f5f5);
  --hint: var(--tg-theme-hint-color, #8a9aa9);
  --card: var(--tg-theme-secondary-bg-color, #232e3c);
  --accent: var(--tg-theme-button-color, #5288c1);
  --accent-fg: var(--tg-theme-button-text-color, #fff);
  --danger: var(--tg-theme-destructive-text-color, #e06c6c);
  --line: color-mix(in srgb, var(--hint) 22%, transparent);
  --nav-h: 58px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
#hdr { padding: 16px 16px 8px; }
#hdr h1 { margin: 0; font-size: 22px; font-weight: 650; }
#sub { color: var(--hint); font-size: 14px; margin-top: 2px; }
#banner {
  margin: 0 16px 8px; padding: 10px 12px; border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger); font-size: 14px;
}
main { padding: 0 16px; }
.hint { color: var(--hint); padding: 12px 0; font-size: 15px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em;
     color: var(--hint); margin: 20px 0 8px; font-weight: 600; }
.card { background: var(--card); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-top: 1px solid var(--line); min-height: 50px;
}
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .t { display: block; overflow-wrap: anywhere; }
.row a { color: var(--accent); text-decoration: none; }
.row .m { display: block; color: var(--hint); font-size: 13px; margin-top: 2px; }
.row.tap { cursor: pointer; }
.row.tap:active { background: color-mix(in srgb, var(--fg) 7%, var(--card)); }
.time { color: var(--accent); font-variant-numeric: tabular-nums; min-width: 46px; }
.done .t { text-decoration: line-through; color: var(--hint); }
.m.late { color: var(--danger); }
.box {
  width: 24px; height: 24px; flex: 0 0 24px; border-radius: 7px;
  border: 2px solid var(--hint); display: grid; place-items: center;
  font-size: 14px; color: var(--accent-fg);
}
.box.on { background: var(--accent); border-color: var(--accent); }
.week { display: flex; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--accent); }
.dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.streak { color: var(--hint); font-size: 13px; font-variant-numeric: tabular-nums; }
.add { display: flex; gap: 8px; margin: 12px 0 4px; }
.add input {
  flex: 1; min-width: 0; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
  font-size: 16px;
}
.add input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.add input[type=date] { color-scheme: dark light; padding: 12px 10px; max-width: 46%; }
#tabs button { font-size: 10.5px; }
.add button, .ghost {
  padding: 12px 16px; border-radius: 10px; border: 0; font-size: 16px;
  background: var(--accent); color: var(--accent-fg); font-weight: 600;
}
.ghost { background: transparent; color: var(--accent); padding: 8px 0; font-weight: 500; }
.chips { display: flex; gap: 8px; margin: 4px 0 0; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--hint); font-size: 14px;
}
.chip.on { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.del { background: transparent; border: 0; color: var(--hint); font-size: 18px; padding: 4px 6px; }
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; border: 0; background: transparent; color: var(--hint);
  font-size: 11px; padding: 8px 0 10px; display: grid; gap: 2px; justify-items: center;
}
#tabs button span { font-size: 19px; line-height: 1; }
#tabs button.on { color: var(--accent); }
.triage { padding: 14px; display: grid; gap: 10px; margin-top: 10px; }
.triage .t { font-size: 17px; overflow-wrap: anywhere; }
.triage .m { color: var(--hint); font-size: 13px; }
.acts { display: flex; gap: 8px; }
.acts button {
  flex: 1; padding: 10px 0; border-radius: 10px; font-size: 14px;
  border: 1px solid var(--line); background: transparent; color: var(--fg);
}
.acts button:active { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.acts button.bad { color: var(--danger); }
.note { padding: 14px; display: grid; gap: 10px; }
.faces { display: flex; gap: 8px; }
.face {
  flex: 1; font-size: 22px; padding: 6px 0; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; line-height: 1.3;
}
.face.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, transparent); }
#nn {
  width: 100%; padding: 10px 12px; border-radius: 10px; resize: vertical;
  border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  font: inherit; font-size: 16px;
}
#nn:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.bar {
  flex: 0 0 56px; height: 6px; border-radius: 99px; overflow: hidden;
  background: var(--line);
}
.bar span { display: block; height: 100%; background: var(--accent); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal b { font-size: 11px; font-weight: 600; color: var(--hint); text-align: center; padding-bottom: 2px; }
.cal button {
  min-height: 46px; border: 0; border-radius: 10px; background: var(--card);
  color: var(--fg); display: grid; justify-items: center; align-content: center;
  gap: 1px; padding: 2px 0; position: relative;
}
.cal u { font-size: 10px; color: var(--hint); text-decoration: none; font-variant-numeric: tabular-nums; }
.cal em { font-size: 17px; font-style: normal; line-height: 1.1; }
.cal button.nil em { color: var(--hint); opacity: .5; }
.cal button.now { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal button.sel { background: color-mix(in srgb, var(--accent) 30%, var(--card)); }
.cal button:active { opacity: .6; }
/* A day with something written on it, without spending a line on the text. */
.cal i {
  position: absolute; bottom: 4px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}
.wk { display: flex; align-items: flex-end; justify-content: space-between; gap: 6px; }
.wkb { flex: 1; display: grid; justify-items: center; gap: 4px; }
.wkb b { font-size: 12px; font-weight: 600; color: var(--hint); }
.wkb i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); }

/* ------------------------------------------------- touch targets and iOS */
/* Apple's minimum is 44pt and these controls are 24px. The pseudo-element
   grows the hit area without moving a single pixel on screen. */
.box, .del { position: relative; }
.box::after, .del::after { content: ''; position: absolute; inset: -12px; }
.face { min-height: 44px; }
.acts button { min-height: 44px; }
.chip { min-height: 34px; }
/* No hover on a phone: every control has to answer the finger. */
.add button:active, .ghost:active, .chip:active, .del:active, .box:active { opacity: .6; }
button, #tabs, .chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Keeps the rubber-band inside the app instead of handing it to Telegram. */
body { overscroll-behavior-y: contain; }
/* Four tabs instead of five — room for a readable label. */
#tabs button { font-size: 12px; }
#tabs button svg { width: 25px; height: 25px; }

details#up { margin: 22px 0 0; }
details#up summary {
  padding: 12px 0; color: var(--accent); font-size: 15px;
  list-style: none; cursor: pointer;
}
details#up summary::-webkit-details-marker { display: none; }
details#up summary::after { content: ' ▾'; }
details#up[open] summary::after { content: ' ▴'; }

.wkb u { font-size: 10px; color: var(--hint); text-decoration: none; font-variant-numeric: tabular-nums; }
details#up { margin-bottom: 10px; }

/* Partly done: the accent outline says "started", the count says how far. */
.box.part { border-color: var(--accent); color: var(--accent); font-size: 13px; font-weight: 600; }
.dot.part { background: color-mix(in srgb, var(--accent) 45%, transparent); }

#undo {
  display: flex; align-items: center; gap: 10px;
  margin: 0 16px 8px; padding: 6px 12px; border-radius: 10px;
  background: var(--card); font-size: 14px;
}
#undo span { flex: 1; color: var(--hint); }
#undo button { padding: 6px 0; }
.edit {
  width: 100%; padding: 6px 8px; border-radius: 8px; font: inherit; font-size: 16px;
  border: 1px solid var(--accent); background: var(--bg); color: var(--fg);
}
.edit:focus { outline: none; }
