/* Colores desde el tema de Telegram (variables --tg-theme-*); los valores son respaldo fuera de Telegram. */
:root {
  color-scheme: light dark;
  --bg: var(--tg-theme-bg-color, #ffffff);
  --fg: var(--tg-theme-text-color, #111111);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --accent: var(--tg-theme-button-color, #2563eb);
  --accent-fg: var(--tg-theme-button-text-color, #ffffff);
  --bg2: var(--tg-theme-secondary-bg-color, #f3f4f6);
  --danger: var(--tg-theme-destructive-text-color, #dc2626);
  --line: rgba(128, 128, 128, .35);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

#app {
  max-width: 760px; margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
}
.view { display: flex; flex-direction: column; gap: 12px; }
h1 { font-size: 1.25rem; margin: 0; overflow-wrap: anywhere; }
h2 { font-size: 1.05rem; margin: 8px 0 0; overflow-wrap: anywhere; }
p { margin: 0; }
.meta { color: var(--hint); font-size: .875rem; overflow-wrap: anywhere; }
.empty { color: var(--hint); padding: 16px 0; }
.head { display: flex; flex-direction: column; gap: 2px; }

.notice { padding: 8px 10px; border-radius: 8px; background: var(--bg2); font-size: .9rem; }
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 736px; margin: 0 auto; border: 1px solid var(--line); z-index: 5; }

button, input[type="text"], textarea { font: inherit; color: var(--fg); }
button { min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.back { align-self: flex-start; min-height: 36px; padding: 4px 10px; }
button.link { min-height: 32px; padding: 2px 6px; border: 0; background: none; color: var(--accent); font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
textarea, input[type="text"] { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); }
textarea { min-height: 200px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; }

.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.card-title { font-weight: 600; overflow-wrap: anywhere; }

.prog { display: grid; grid-template-columns: minmax(48px, 22%) 1fr auto; gap: 8px; align-items: center; font-size: .85rem; }
.prog-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-n { color: var(--hint); font-variant-numeric: tabular-nums; }
.progs { display: flex; flex-direction: column; gap: 4px; }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); }

.week { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.week > summary { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 0; cursor: pointer; list-style: none; font-weight: 600; }
.week > summary::-webkit-details-marker { display: none; }
.week[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.week > * + * { margin-top: 8px; }
.week.current { border-color: var(--accent); }
.week.past { opacity: .92; }
.badge { flex: none; font-size: .75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; background: var(--bg2); color: var(--hint); }
.badge.current { background: var(--accent); color: var(--accent-fg); }
.range { line-height: 1.5; }
.pending { color: var(--danger); font-size: .875rem; }

.chapters { list-style: none; margin: 0; padding: 0 0 8px; display: flex; flex-direction: column; }
.chapter { padding: 6px 0; border-top: 1px solid var(--line); }
.chapter:first-child { border-top: 0; }
.chapter-main { display: flex; align-items: center; gap: 10px; }
.chapter-main label { flex: 1; overflow-wrap: anywhere; }
.chapter.mine label { color: var(--hint); }
.chapter input[type="checkbox"] { width: 24px; height: 24px; flex: none; accent-color: var(--accent); }
.dots { display: flex; gap: 4px; flex: none; }
.dot { min-height: 0; width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: .8rem; line-height: 1; }
.dot.done { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.dot.todo { background: transparent; color: var(--hint); border-style: dashed; }
.dot.overdue { border-color: var(--danger); color: var(--danger); }
.who { padding: 4px 0 0 34px; font-size: .85rem; color: var(--hint); }

.errors, .warnings { margin: 0; padding-left: 20px; font-size: .9rem; }
.errors { color: var(--danger); }
.plan-weeks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.plan-weeks li { padding: 8px 10px; border-radius: 10px; background: var(--bg2); }
fieldset.mode { border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; gap: 6px; }
.people { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; gap: 8px; align-items: center; }
.people input { flex: 1; }
#invite-out { display: flex; flex-direction: column; gap: 8px; }
