:root {
	--bg: #f6f4ef;
	--surface: #ffffff;
	--surface-2: #f0ede6;
	--line: #e3dfd5;
	--text: #1d1d1b;
	--muted: #6f6c64;
	--accent: #2f6b4f;
	--accent-soft: #e2efe7;
	--warn: #a85a12;
	--warn-soft: #fbeedd;
	--danger: #b3362f;
	--danger-soft: #fae3e1;
	--info-soft: #e5ecf7;
	--radius: 14px;
	--shadow: 0 1px 2px rgba(30, 25, 10, 0.05), 0 4px 16px rgba(30, 25, 10, 0.04);
	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-theme="light"]) {
		--bg: #16171a;
		--surface: #1f2024;
		--surface-2: #27292e;
		--line: #33353b;
		--text: #ecebe7;
		--muted: #9b9a94;
		--accent: #6fc39a;
		--accent-soft: #1f3a2d;
		--warn: #f0a85a;
		--warn-soft: #3b2c1a;
		--danger: #f08079;
		--danger-soft: #3d2221;
		--info-soft: #232c3b;
		--shadow: none;
		color-scheme: dark;
	}
}
:root[data-theme="dark"] {
	--bg: #16171a;
	--surface: #1f2024;
	--surface-2: #27292e;
	--line: #33353b;
	--text: #ecebe7;
	--muted: #9b9a94;
	--accent: #6fc39a;
	--accent-soft: #1f3a2d;
	--warn: #f0a85a;
	--warn-soft: #3b2c1a;
	--danger: #f08079;
	--danger-soft: #3d2221;
	--info-soft: #232c3b;
	--shadow: none;
	color-scheme: dark;
}

* {
	box-sizing: border-box;
}
html {
	-webkit-text-size-adjust: 100%;
}
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
	padding-bottom: env(safe-area-inset-bottom);
}
a {
	color: var(--accent);
}

.top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	max-width: 980px;
	margin: 0 auto;
	padding: 14px 16px 8px;
}
.brand {
	display: flex;
	align-items: center;
	gap: 10px;
}
.brand-mark {
	font-size: 28px;
}
.brand-title {
	font-weight: 700;
	font-size: 18px;
	letter-spacing: -0.01em;
}
.brand-sub {
	color: var(--muted);
	font-size: 13px;
}

.tabs {
	position: sticky;
	top: 0;
	z-index: 5;
	display: flex;
	gap: 4px;
	overflow-x: auto;
	scrollbar-width: none;
	max-width: 980px;
	margin: 0 auto;
	padding: 6px 16px 10px;
	background: var(--bg);
}
.tabs::-webkit-scrollbar {
	display: none;
}
.tab {
	flex: none;
	border: 0;
	background: transparent;
	color: var(--muted);
	font: inherit;
	font-weight: 600;
	padding: 8px 12px;
	border-radius: 999px;
	cursor: pointer;
	white-space: nowrap;
}
.tab[aria-selected="true"] {
	background: var(--text);
	color: var(--bg);
}
.tab .dot {
	display: inline-block;
	min-width: 18px;
	padding: 0 5px;
	margin-left: 4px;
	border-radius: 99px;
	background: var(--danger);
	color: #fff;
	font-size: 11px;
	line-height: 18px;
	text-align: center;
}

main {
	max-width: 980px;
	margin: 0 auto;
	padding: 4px 16px 48px;
}
.pad {
	padding: 16px 0;
}

.grid {
	display: grid;
	gap: 12px;
}
@media (min-width: 760px) {
	.grid.two {
		grid-template-columns: 1fr 1fr;
	}
	.grid.three {
		grid-template-columns: repeat(3, 1fr);
	}
}

.card {
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: var(--radius);
	padding: 16px;
	box-shadow: var(--shadow);
	min-width: 0;
}
.card h2,
.section-title {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: -0.005em;
}
.section-title {
	margin: 22px 2px 10px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
}
.card + .card {
	margin-top: 0;
}
.stack > * + *,
.feed > .card + .card {
	margin-top: 12px;
}
.feed .date-head:first-child {
	margin-top: 0;
}

.stats {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
}
@media (min-width: 760px) {
	.stats {
		grid-template-columns: repeat(4, 1fr);
	}
}
.stat .label {
	color: var(--muted);
	font-size: 13px;
}
.stat .value {
	font-size: 26px;
	font-weight: 700;
	letter-spacing: -0.02em;
	font-variant-numeric: tabular-nums;
}
.stat .hint {
	color: var(--muted);
	font-size: 12px;
}

.bars {
	display: grid;
	grid-template-columns: repeat(7, 1fr);
	gap: 6px;
	align-items: end;
	height: 70px;
	margin-top: 8px;
}
.bar {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: flex-end;
	height: 100%;
	gap: 4px;
	font-size: 11px;
	color: var(--muted);
}
.bar i {
	display: block;
	width: 100%;
	max-width: 26px;
	border-radius: 5px 5px 2px 2px;
	background: var(--accent);
	min-height: 2px;
}
.bar i.over {
	background: var(--warn);
}

.pill {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 2px 9px;
	border-radius: 99px;
	font-size: 12px;
	font-weight: 600;
	background: var(--surface-2);
	color: var(--muted);
	white-space: nowrap;
}
.pill.ok {
	background: var(--accent-soft);
	color: var(--accent);
}
.pill.warn {
	background: var(--warn-soft);
	color: var(--warn);
}
.pill.danger {
	background: var(--danger-soft);
	color: var(--danger);
}
.pill.info {
	background: var(--info-soft);
	color: var(--text);
}

.muted {
	color: var(--muted);
}
.small {
	font-size: 13px;
}
.pre {
	white-space: pre-wrap;
	overflow-wrap: anywhere;
}
.row {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}
.row.between {
	justify-content: space-between;
}
.grow {
	flex: 1;
	min-width: 0;
}

.item {
	display: flex;
	gap: 10px;
	align-items: flex-start;
	padding: 10px 0;
	border-top: 1px solid var(--line);
}
.item:first-child {
	border-top: 0;
	padding-top: 0;
}
.item:last-child {
	padding-bottom: 0;
}
.item .title {
	overflow-wrap: anywhere;
}
.item.done .title {
	text-decoration: line-through;
	color: var(--muted);
}

.metric {
	margin-top: 8px;
	padding: 10px 12px;
	border-radius: 10px;
	background: var(--accent-soft);
	font-weight: 600;
}
.metric small {
	display: block;
	font-weight: 500;
	color: var(--muted);
	font-size: 12px;
	margin-bottom: 2px;
}

.checkin-block {
	display: grid;
	gap: 8px;
}
.k {
	font-size: 12px;
	font-weight: 700;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.reply {
	margin-top: 10px;
	padding: 10px 12px;
	background: var(--info-soft);
	border-radius: 10px;
}

button,
.btn {
	font: inherit;
	font-weight: 600;
	border: 1px solid transparent;
	border-radius: 10px;
	padding: 9px 14px;
	cursor: pointer;
	background: var(--accent);
	color: #fff;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	min-height: 40px;
}
button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}
button.secondary {
	background: var(--surface-2);
	color: var(--text);
	border-color: var(--line);
}
button.ghost,
.ghost {
	background: transparent;
	color: var(--muted);
	border-color: transparent;
	padding: 6px 10px;
	min-height: 32px;
	text-decoration: none;
	font-weight: 600;
}
button.danger {
	background: var(--danger-soft);
	color: var(--danger);
}
button.small {
	padding: 5px 10px;
	min-height: 32px;
	font-size: 13px;
}
.check {
	appearance: none;
	flex: none;
	width: 22px;
	height: 22px;
	margin: 0;
	border: 2px solid var(--line);
	border-radius: 7px;
	background: var(--surface);
	cursor: pointer;
	display: grid;
	place-items: center;
}
.check:checked {
	background: var(--accent);
	border-color: var(--accent);
}
.check:checked::after {
	content: "";
	width: 6px;
	height: 11px;
	border: solid #fff;
	border-width: 0 2.5px 2.5px 0;
	transform: rotate(45deg) translate(-1px, -1px);
}

label.field {
	display: grid;
	gap: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--muted);
}
input,
textarea,
select {
	font: inherit;
	font-weight: 400;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--line);
	border-radius: 10px;
	padding: 9px 11px;
	width: 100%;
	min-width: 0;
}
textarea {
	resize: vertical;
	min-height: 64px;
}
input:focus,
textarea:focus,
select:focus,
button:focus-visible,
.tab:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 1px;
}
.form {
	display: grid;
	gap: 10px;
}
.form .cols {
	display: grid;
	gap: 10px;
	grid-template-columns: 1fr 1fr;
}
@media (max-width: 520px) {
	.form .cols {
		grid-template-columns: 1fr;
	}
}

.empty {
	color: var(--muted);
	text-align: center;
	padding: 18px 8px;
	font-size: 14px;
}
.banner {
	border-radius: var(--radius);
	padding: 12px 14px;
	background: var(--warn-soft);
	color: var(--text);
}
.banner.ok {
	background: var(--accent-soft);
}

details summary {
	cursor: pointer;
	color: var(--muted);
	font-weight: 600;
	padding: 6px 0;
}
.date-head {
	font-size: 13px;
	font-weight: 700;
	color: var(--muted);
	margin: 18px 2px 8px;
}

.toast {
	position: fixed;
	left: 50%;
	bottom: calc(20px + env(safe-area-inset-bottom));
	transform: translateX(-50%) translateY(20px);
	opacity: 0;
	pointer-events: none;
	background: var(--text);
	color: var(--bg);
	padding: 10px 16px;
	border-radius: 12px;
	font-weight: 600;
	transition: 0.2s;
	max-width: calc(100% - 32px);
	z-index: 20;
}
.toast.show {
	opacity: 1;
	transform: translateX(-50%) translateY(0);
}

dialog {
	border: 1px solid var(--line);
	border-radius: 18px;
	padding: 18px;
	width: min(520px, calc(100% - 32px));
	background: var(--surface);
	color: var(--text);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
dialog::backdrop {
	background: rgba(20, 18, 12, 0.45);
}
dialog h3 {
	margin: 0 0 12px;
}
audio {
	width: 100%;
	height: 36px;
}

/* ---- план: зоны, быстрое добавление, иконки ---- */
.plan-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
	.plan-grid {
		grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
		align-items: start;
	}
}
.quick {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 8px;
}
.quick-opts {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.quick-opts select,
.quick-opts input[type="date"] {
	width: auto;
	flex: 1 1 130px;
	min-width: 0;
	min-height: 40px;
}
.quick-opts button {
	flex: 0 0 auto;
}
.zone-head {
	display: flex;
	align-items: flex-start;
	gap: 8px;
}
@media (max-width: 599px) {
	/* На телефоне опции быстрого добавления появляются, когда начинаешь вводить */
	.quick:not(:focus-within) .quick-opts {
		display: none;
	}
}
.zone-title {
	font-weight: 700;
	overflow-wrap: anywhere;
}
.zone-sub {
	color: var(--muted);
	font-size: 13px;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.zone-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	margin: 3px 0;
}
.zone-body {
	margin-top: 10px;
	padding-top: 6px;
	border-top: 1px solid var(--line);
}
.zone-body form {
	margin-top: 6px;
}
.zone-body form input,
.card form[data-form="idea-new"] input {
	background: var(--surface-2);
	border-style: dashed;
}
button.icon {
	flex: none;
	width: 36px;
	height: 36px;
	min-height: 36px;
	padding: 0;
	justify-content: center;
	background: transparent;
	color: var(--muted);
	border-radius: 10px;
	font-size: 16px;
}
button.icon:hover {
	background: var(--surface-2);
	color: var(--text);
}
.check-wrap {
	flex: none;
	display: grid;
	place-items: center;
	width: 36px;
	height: 36px;
	margin: -7px -6px -7px -7px;
	cursor: pointer;
}
.item.task {
	align-items: center;
}
.toast.action {
	pointer-events: auto;
	display: flex;
	align-items: center;
	gap: 12px;
}
.toast-btn {
	background: transparent;
	color: inherit;
	text-decoration: underline;
	min-height: 0;
	padding: 2px 4px;
}

.tab-ico {
	display: none;
}

/* ---- Telegram Mini App: чёрно-жёлтая тема, без рамок и подложек, нижнее меню ---- */
:root[data-tg][data-tg] {
	--bg: #000;
	--surface: #000;
	--surface-2: #141414;
	--line: transparent;
	--text: #f5f5f5;
	--muted: #8c8c8c;
	--accent: #ffd60a;
	--accent-soft: rgba(255, 214, 10, 0.14);
	--warn: #ffd60a;
	--warn-soft: transparent;
	--danger: #ff6b5b;
	--danger-soft: transparent;
	--info-soft: transparent;
	--shadow: none;
	--nav-h: 64px;
	color-scheme: dark;
}
:root[data-tg] body {
	background: #000;
	-webkit-tap-highlight-color: transparent;
}
:root[data-tg] .top {
	display: none;
}
:root[data-tg] main {
	padding: calc(20px + var(--app-top, 0px)) 18px calc(var(--nav-h) + 28px + var(--app-bottom, 0px));
}

/* Без карточек: секции разделяет воздух, а не рамки и фоны */
:root[data-tg] .card {
	background: none;
	border: 0;
	box-shadow: none;
	border-radius: 0;
	padding: 0;
}
:root[data-tg] .stack > * + *,
:root[data-tg] .feed > .card + .card,
:root[data-tg] .plan-grid,
:root[data-tg] .grid {
	gap: 28px;
}
:root[data-tg] .stack > * + * {
	margin-top: 28px;
}
:root[data-tg] .card h2,
:root[data-tg] .zone-title {
	font-size: 18px;
	font-weight: 800;
	letter-spacing: -0.01em;
}
:root[data-tg] .card h2 {
	margin-bottom: 12px;
}
:root[data-tg] .item {
	border-top: 0;
	padding: 10px 0;
}
:root[data-tg] .zone-body {
	border-top: 0;
	margin-top: 6px;
	padding-top: 0;
}
:root[data-tg] .zone-sub,
:root[data-tg] .metric {
	color: var(--accent);
}
:root[data-tg] .metric {
	background: none;
	padding: 0;
	margin-top: 6px;
	font-weight: 600;
}
:root[data-tg] .metric small {
	color: var(--muted);
}
:root[data-tg] .reply {
	background: none;
	padding: 6px 0 0 14px;
	border-radius: 0;
}
:root[data-tg] .reply .muted:first-child {
	color: var(--accent);
}
:root[data-tg] .k {
	color: var(--muted);
}
:root[data-tg] .date-head {
	color: var(--accent);
	margin-top: 28px;
}
:root[data-tg] .empty {
	text-align: left;
	padding: 4px 0;
}

/* Плашки — просто цветной текст */
:root[data-tg] .pill {
	background: none;
	padding: 0;
	color: var(--muted);
	font-weight: 600;
}
:root[data-tg] .pill + .pill::before {
	content: "·";
	margin-right: 6px;
	color: var(--muted);
}
:root[data-tg] .pill.ok,
:root[data-tg] .pill.warn,
:root[data-tg] .pill.info {
	color: var(--accent);
}
:root[data-tg] .pill.danger {
	color: var(--danger);
}

/* Поля: без рамок, мягкая заливка */
:root[data-tg] input:not(.check),
:root[data-tg] textarea,
:root[data-tg] select {
	background: var(--surface-2);
	border: 0;
	border-radius: 14px;
	padding: 12px 14px;
	color: var(--text);
}
:root[data-tg] .zone-body form input,
:root[data-tg] .card form[data-form="idea-new"] input {
	background: none;
	border: 0;
	padding: 8px 0;
	color: var(--accent);
}
:root[data-tg] .zone-body form input::placeholder,
:root[data-tg] .card form[data-form="idea-new"] input::placeholder {
	color: var(--accent);
	opacity: 0.75;
}
:root[data-tg] input:focus,
:root[data-tg] textarea:focus,
:root[data-tg] select:focus {
	outline: 1.5px solid var(--accent);
	outline-offset: 0;
}

/* Кнопки */
:root[data-tg] button {
	border: 0;
	border-radius: 14px;
	font-weight: 700;
}
:root[data-tg] button:not(.secondary):not(.ghost):not(.icon):not(.tab):not(.toast-btn):not(.danger) {
	background: var(--accent);
	color: #000;
}
:root[data-tg] button.secondary,
:root[data-tg] button.ghost,
:root[data-tg] .ghost {
	background: none;
	color: var(--accent);
}
:root[data-tg] button.icon {
	color: var(--muted);
}
:root[data-tg] button.icon:hover {
	background: none;
	color: var(--accent);
}
:root[data-tg] a {
	color: var(--accent);
}

/* Чекбоксы */
:root[data-tg] .check {
	background: none;
	border: 2px solid #4a4a4a;
	border-radius: 8px;
}
:root[data-tg] .check:checked {
	background: var(--accent);
	border-color: var(--accent);
}
:root[data-tg] .check:checked::after {
	border-color: #000;
}
:root[data-tg] .item.done .title {
	color: #5c5c5c;
}

/* Нижнее меню: три равные кнопки, иконка + подпись, активная — жёлтая */
:root[data-tg] .tabs {
	position: fixed;
	top: auto;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 10;
	max-width: none;
	margin: 0;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 0;
	height: calc(var(--nav-h) + var(--app-bottom, 0px));
	padding: 0 8px var(--app-bottom, 0px);
	background: #000;
	overflow: visible;
}
:root[data-tg] .tab {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	min-height: 0;
	height: var(--nav-h);
	padding: 0;
	border-radius: 0;
	background: none;
	color: #6f6f6f;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.01em;
}
:root[data-tg] .tab[aria-selected="true"] {
	background: none;
	color: var(--accent);
}
:root[data-tg] .tab-ico {
	display: block;
	width: 24px;
	height: 24px;
}
:root[data-tg] .tab-ico svg {
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

/* Диалог — шторка снизу */
:root[data-tg] dialog {
	margin: auto 0 0;
	width: 100%;
	max-width: none;
	max-height: 88vh;
	border: 0;
	border-radius: 22px 22px 0 0;
	background: #0d0d0d;
	padding: 22px 18px calc(22px + var(--app-bottom, 0px));
	box-shadow: none;
}
:root[data-tg] dialog::backdrop {
	background: rgba(0, 0, 0, 0.7);
}
:root[data-tg] dialog label.field {
	color: var(--muted);
}

:root[data-tg] .toast {
	background: var(--accent);
	color: #000;
	bottom: calc(var(--nav-h) + 16px + var(--app-bottom, 0px));
}

/* ---- Мини-апп: тонкие рамки вместо подложек ---- */
:root[data-tg][data-tg] {
	--border: #262626;
	--hair: #1a1a1a;
}
:root[data-tg] .card {
	border: 1px solid var(--border);
	border-radius: 18px;
	padding: 16px;
	background: none;
}
:root[data-tg] .stack > * + * {
	margin-top: 14px;
}
:root[data-tg] .plan-grid,
:root[data-tg] .grid {
	gap: 14px;
}
:root[data-tg] .feed > .card + .card {
	margin-top: 10px;
}
:root[data-tg] .date-head {
	margin: 22px 4px 10px;
}
:root[data-tg] .item {
	border-top: 1px solid var(--hair);
	padding: 12px 0;
}
:root[data-tg] .item:first-child {
	border-top: 0;
	padding-top: 2px;
}
:root[data-tg] .zone-body {
	border-top: 1px solid var(--hair);
	margin-top: 12px;
	padding-top: 4px;
}
:root[data-tg] .zone-body form,
:root[data-tg] .card form[data-form="idea-new"] {
	border-top: 1px solid var(--hair);
}
:root[data-tg] input:not(.check),
:root[data-tg] textarea,
:root[data-tg] select {
	background: none;
	border: 1px solid var(--border);
}
:root[data-tg] .zone-body form input,
:root[data-tg] .card form[data-form="idea-new"] input {
	border: 0;
	padding: 12px 0 2px;
}
:root[data-tg] input:focus,
:root[data-tg] textarea:focus,
:root[data-tg] select:focus {
	outline: 0;
	border-color: var(--accent);
}
:root[data-tg] .tabs {
	border-top: 1px solid var(--hair);
}
:root[data-tg] dialog {
	border: 1px solid var(--border);
	border-bottom: 0;
	background: #000;
}
:root[data-tg] .card.quick {
	border: 0;
	padding: 0;
	border-radius: 0;
}
