/* Панель: цвета — только темы Telegram, шрифт системный, три размера: 17/22, 15/20, 13/18.
   Сигналы цветом два: акцент — «ждёт / просрочено» и нажимаемый текст, hint — «давно / второстепенное». */

:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #8e8e93);
  --accent: var(--tg-theme-link-color, #2481cc);
  --bg2: var(--tg-theme-secondary-bg-color, #efeff4);
  --line: var(--tg-theme-section-separator-color, #d9d9de);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* иначе display:flex у .screen перебивает hidden */

html {
  font: 17px/22px system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) calc(env(safe-area-inset-bottom) + 32px) env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: anywhere;
}

h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  text-align: left;
  touch-action: manipulation;
}
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* размеры */
.s { font-size: 15px; line-height: 20px; }
.c { font-size: 13px; line-height: 18px; }
.b { font-weight: 600; }
.hint { color: var(--hint); }
.acc { color: var(--accent); }

.status { padding: 24px 16px; color: var(--hint); }

.screen { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; flex-direction: column; gap: 2px; }
.head h1 { font-size: 17px; line-height: 22px; font-weight: 600; text-wrap: balance; }

section { display: flex; flex-direction: column; gap: 6px; }
section h2 { font-size: 15px; line-height: 20px; font-weight: 600; }
section h3 { font-size: 13px; line-height: 18px; font-weight: 400; color: var(--hint); padding-top: 6px; }

/* сегмент «Сегодня · Неделя · Месяц» */
.seg { display: flex; background: var(--bg2); border-radius: 9px; padding: 2px; }
.seg button {
  flex: 1;
  text-align: center;
  padding: 5px 0;
  border-radius: 7px;
  color: var(--hint);
  font-size: 15px;
  line-height: 20px;
}
.seg button[aria-pressed="true"] { background: var(--bg); color: var(--fg); font-weight: 600; }

/* полоса недели */
.week { display: grid; grid-template-columns: repeat(7, 1fr); }
.cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; }
.cell .day { width: 32px; height: 32px; line-height: 32px; text-align: center; border-radius: 8px; }
.cell.today .day { background: var(--bg2); font-weight: 600; }

/* строки списков */
.list { display: flex; flex-direction: column; }
.row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: baseline; }
.row:first-child { border-top: 0; }
.row .time { flex: 0 0 44px; font-variant-numeric: tabular-nums; }
.row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.list > h3 { border-top: 1px solid var(--line); padding: 8px 0 2px; }
.list > h3.acc { color: var(--accent); }
.li { padding: 6px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.dash { color: var(--hint); }

/* карточка сферы: две строки, нажимается целиком */
.sphere {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.sphere:first-child { border-top: 0; }
.sphere .top { display: flex; gap: 6px; align-items: baseline; }
.sphere .top::after { content: "›"; margin-left: auto; color: var(--hint); }

/* кнопки словами: «ещё N», «Все записи», якоря месяцев */
.more { color: var(--accent); font-size: 15px; line-height: 20px; padding: 6px 0; }
.anchors { display: flex; flex-wrap: wrap; gap: 6px 14px; }

/* цифры */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; white-space: nowrap; }
th, td { text-align: left; padding: 4px 16px 4px 0; font-weight: 400; font-size: 15px; line-height: 20px; }
th { color: var(--hint); font-size: 13px; line-height: 18px; }
td { border-top: 1px solid var(--line); }
td:not(:first-child), th:not(:first-child) { text-align: right; padding-right: 0; padding-left: 16px; }

.spark { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.spark .label { flex: 1; }
.spark svg { flex: 0 0 auto; display: block; overflow: visible; }
.spark polyline { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: currentColor; stroke: var(--bg); stroke-width: 2; }
.spark .last { flex: 0 0 auto; min-width: 52px; text-align: right; font-weight: 600; }

/* свёртки */
details > summary { cursor: pointer; color: var(--hint); font-size: 15px; line-height: 20px; }
details > ul, details > div { padding-top: 6px; }

/* дневник */
.search {
  width: 100%;
  background: var(--bg2);
  border-radius: 10px;
  padding: 8px 12px;
  -webkit-appearance: none;
  appearance: none;
}
.search::placeholder { color: var(--hint); }
.entry { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); }
.entry:first-of-type { border-top: 0; }
.entry details > div { display: flex; flex-direction: column; gap: 6px; }
