/* Тема Telegram: переменные ставит telegram-web-app.js; fallback — светлая. */
:root {
  color-scheme: light;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #000000);
  --hint: var(--tg-theme-hint-color, #707579);
  --secondary: var(--tg-theme-secondary-bg-color, #f1f1f1);
  --button: var(--tg-theme-button-color, #2481cc);
  --link: var(--tg-theme-link-color, #2481cc);
  --divider: rgba(112, 117, 121, 0.2);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #17212b);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #708499);
  --secondary: var(--tg-theme-secondary-bg-color, #232e3c);
  --button: var(--tg-theme-button-color, #5288c1);
  --link: var(--tg-theme-link-color, #6ab2f2);
  --divider: rgba(112, 132, 153, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

main {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.status,
.empty {
  margin: 0;
  padding: 16px 0;
  color: var(--hint);
}

/* ── Задачи ─────────────────────────────────────────────────────────────── */

.tasks-section + .tasks-section {
  margin-top: 28px;
}

.tasks-section h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
}

.tasks-list {
  display: block;
}

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 0;
  border-bottom: 1px solid var(--divider);
  cursor: default;
}

.task:last-child {
  border-bottom: none;
}

.task input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--button);
}

.task-title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.task.done .task-title {
  color: var(--hint);
}

/* ── Markdown-страница ──────────────────────────────────────────────────── */

.markdown {
  overflow-wrap: anywhere;
}

.markdown h1,
.markdown h2,
.markdown h3 {
  margin: 1.2em 0 0.5em;
  line-height: 1.25;
}

.markdown h1:first-child,
.markdown h2:first-child,
.markdown h3:first-child {
  margin-top: 0;
}

.markdown h1 {
  font-size: 1.5em;
}

.markdown h2 {
  font-size: 1.2em;
}

.markdown h3 {
  font-size: 1.05em;
}

.markdown p {
  margin: 0.7em 0;
}

.markdown ul,
.markdown ol {
  margin: 0.7em 0;
  padding-left: 1.4em;
}

.markdown li {
  margin: 0.2em 0;
}

.markdown blockquote {
  margin: 0.8em 0;
  padding-left: 12px;
  border-left: 3px solid var(--hint);
  color: var(--hint);
}

.markdown code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.markdown pre {
  margin: 0.8em 0;
  padding: 12px;
  border-radius: 8px;
  background: var(--secondary);
  overflow-x: auto;
}

.markdown pre code {
  padding: 0;
  background: none;
}

.markdown table {
  display: block;
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  overflow-x: auto;
  font-size: 0.95em;
}

.markdown th,
.markdown td {
  padding: 6px 8px;
  border: 1px solid var(--divider);
  text-align: left;
  vertical-align: top;
}

.markdown th {
  background: var(--secondary);
  font-weight: 600;
}

.markdown hr {
  margin: 1.2em 0;
  border: none;
  border-top: 1px solid var(--divider);
}

.markdown a {
  color: var(--link);
  overflow-wrap: anywhere;
}
