/* ── TOKENS ───────────────────────────────────────────── */
:root {
	--bg: #f5f2eb;
	--surface: #fffef9;
	--border: #d6cfc0;
	--text: #1c1810;
	--muted: #7a6f5e;
	--accent: #c0392b;
	--accent-dim: #e8ccc9;
	--green: #27ae60;
	--green-dim: #c3e6cb;
	--tag-bg: #ede9df;
	--shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	--radius: 10px;
	--transition: 0.22s ease;
}
[data-theme="dark"] {
	--bg: #0f0e0b;
	--surface: #1a1914;
	--border: #2e2c26;
	--text: #e8e3d8;
	--muted: #7a7260;
	--accent: #e05c4b;
	--accent-dim: #3d1e1a;
	--green: #2ecc71;
	--green-dim: #1a3d2b;
	--tag-bg: #232119;
	--shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* ── RESET ────────────────────────────────────────────── */
*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}
body {
	font-family: "DM Mono", monospace;
	background: var(--bg);
	color: var(--text);
	min-height: 100vh;
	transition:
		background var(--transition),
		color var(--transition);
}

/* ── LAYOUT ───────────────────────────────────────────── */
.app {
	max-width: 820px;
	margin: 0 auto;
	padding: 48px 24px 80px;
}

/* ── HEADER ───────────────────────────────────────────── */
header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	margin-bottom: 48px;
}
.brand h1 {
	font-family: "DM Serif Display", serif;
	font-size: clamp(2.2rem, 5vw, 3.4rem);
	line-height: 1;
	letter-spacing: -0.02em;
	color: var(--text);
}
.brand p {
	font-size: 0.72rem;
	color: var(--muted);
	margin-top: 6px;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.header-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-top: 6px;
}

/* Theme toggle */
.theme-btn {
	width: 44px;
	height: 44px;
	border: 1.5px solid var(--border);
	border-radius: 50%;
	background: var(--surface);
	cursor: pointer;
	display: grid;
	place-items: center;
	font-size: 1.1rem;
	transition:
		border-color var(--transition),
		background var(--transition),
		transform 0.15s;
}
.theme-btn:hover {
	border-color: var(--accent);
	transform: rotate(20deg);
}

/* ── ADD / EDIT FORM ──────────────────────────────────── */
.form-card {
	background: var(--surface);
	border: 1.5px solid var(--border);
	border-radius: var(--radius);
	padding: 28px;
	margin-bottom: 36px;
	box-shadow: var(--shadow);
	transition:
		background var(--transition),
		border-color var(--transition);
}
.form-card h2 {
	font-family: "DM Serif Display", serif;
	font-size: 1.35rem;
	margin-bottom: 20px;
}
.form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}
.form-grid .full {
	grid-column: 1 / -1;
}
label {
	display: flex;
	flex-direction: column;
	gap: 6px;
	font-size: 0.78rem;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.06em;
}
input,
textarea,
select {
	font-family: "DM Mono", monospace;
	font-size: 0.95rem;
	background: var(--bg);
	border: 1.5px solid var(--border);
	border-radius: 6px;
	color: var(--text);
	padding: 10px 13px;
	outline: none;
	transition: border-color 0.18s;
	width: 100%;
}
input:focus,
textarea:focus,
select:focus {
	border-color: var(--accent);
}
textarea {
	resize: vertical;
	min-height: 72px;
}

/* checkbox row */
.checkbox-row {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 0.92rem;
	color: var(--text);
}
.checkbox-row input[type="checkbox"] {
	width: 17px;
	height: 17px;
	accent-color: var(--accent);
	cursor: pointer;
}

.form-footer {
	display: flex;
	gap: 10px;
	margin-top: 18px;
	justify-content: flex-end;
}
.btn {
	font-family: "DM Mono", monospace;
	font-size: 0.85rem;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	padding: 10px 22px;
	border-radius: 6px;
	border: 1.5px solid transparent;
	cursor: pointer;
	transition:
		opacity 0.15s,
		transform 0.12s;
}
.btn:active {
	transform: scale(0.97);
}
.btn-primary {
	background: var(--accent);
	color: #fff;
}
.btn-primary:hover {
	opacity: 0.88;
}
.btn-ghost {
	background: transparent;
	border-color: var(--border);
	color: var(--muted);
}
.btn-ghost:hover {
	border-color: var(--accent);
	color: var(--accent);
}

/* ── FILTER BAR ───────────────────────────────────────── */
.filter-bar {
	display: flex;
	gap: 8px;
	align-items: center;
	margin-bottom: 20px;
	flex-wrap: wrap;
}
.filter-bar input[type="text"] {
	flex: 1;
	min-width: 160px;
}
.chip {
	font-family: "DM Mono", monospace;
	font-size: 0.76rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	padding: 7px 14px;
	border-radius: 20px;
	border: 1.5px solid var(--border);
	background: var(--surface);
	color: var(--muted);
	cursor: pointer;
	transition:
		background 0.15s,
		border-color 0.15s,
		color 0.15s;
}
.chip.active,
.chip:hover {
	background: var(--accent-dim);
	border-color: var(--accent);
	color: var(--accent);
}

/* ── TASK LIST ────────────────────────────────────────── */
#task-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.task-item {
	background: var(--surface);
	border: 1.5px solid var(--border);
	border-radius: var(--radius);
	padding: 18px 20px;
	display: flex;
	align-items: flex-start;
	gap: 14px;
	box-shadow: var(--shadow);
	transition:
		background var(--transition),
		border-color var(--transition),
		transform 0.15s;
	animation: slideIn 0.25s ease both;
}
@keyframes slideIn {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}
.task-item:hover {
	border-color: var(--accent);
	transform: translateY(-1px);
}
.task-item.done {
	opacity: 0.65;
}

/* big checkbox */
.task-check {
	width: 20px;
	height: 20px;
	flex-shrink: 0;
	accent-color: var(--green);
	cursor: pointer;
	margin-top: 2px;
}

.task-body {
	flex: 1;
	min-width: 0;
}
.task-title {
	font-family: "DM Serif Display", serif;
	font-size: 1.15rem;
	line-height: 1.3;
	word-break: break-word;
}
.task-item.done .task-title {
	text-decoration: line-through;
	color: var(--muted);
}
.task-desc {
	font-size: 0.86rem;
	color: var(--muted);
	margin-top: 5px;
	line-height: 1.5;
}
.task-meta {
	display: flex;
	gap: 8px;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 10px;
}
.tag {
	font-size: 0.7rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	padding: 3px 9px;
	border-radius: 20px;
	background: var(--tag-bg);
	color: var(--muted);
	border: 1px solid var(--border);
}
.tag.done-tag {
	background: var(--green-dim);
	color: var(--green);
	border-color: var(--green);
}
.tag.overdue-tag {
	background: var(--accent-dim);
	color: var(--accent);
	border-color: var(--accent);
}
.tag.pending-tag {
	background: var(--tag-bg);
}

.task-actions {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}
.icon-btn {
	width: 34px;
	height: 34px;
	border: 1.5px solid var(--border);
	border-radius: 6px;
	background: transparent;
	cursor: pointer;
	display: grid;
	place-items: center;
	font-size: 0.9rem;
	color: var(--muted);
	transition:
		border-color 0.15s,
		color 0.15s,
		background 0.15s;
}
.icon-btn:hover {
	border-color: var(--accent);
	color: var(--accent);
	background: var(--accent-dim);
}
.icon-btn.del:hover {
	border-color: var(--accent);
	background: var(--accent-dim);
	color: var(--accent);
}

/* ── EMPTY / LOADING ──────────────────────────────────── */
.empty {
	text-align: center;
	padding: 64px 24px;
	color: var(--muted);
}
.empty .icon {
	font-size: 2.8rem;
	margin-bottom: 12px;
}
.empty p {
	font-size: 0.92rem;
}
.loading {
	text-align: center;
	padding: 48px;
	color: var(--muted);
	font-size: 0.92rem;
}
.spinner {
	display: inline-block;
	width: 22px;
	height: 22px;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: spin 0.7s linear infinite;
	vertical-align: middle;
	margin-right: 8px;
}
@keyframes spin {
	to {
		transform: rotate(360deg);
	}
}

/* ── TOAST ────────────────────────────────────────────── */
#toast-container {
	position: fixed;
	bottom: 28px;
	right: 28px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	z-index: 999;
}
.toast {
	font-family: "DM Mono", monospace;
	font-size: 0.84rem;
	padding: 12px 18px;
	border-radius: 8px;
	border: 1.5px solid var(--border);
	background: var(--surface);
	color: var(--text);
	box-shadow: var(--shadow);
	animation: toastIn 0.22s ease;
	max-width: 280px;
}
.toast.success {
	border-color: var(--green);
	color: var(--green);
}
.toast.error {
	border-color: var(--accent);
	color: var(--accent);
}
@keyframes toastIn {
	from {
		opacity: 0;
		transform: translateX(12px);
	}
}

/* ── MODAL (delete confirm) ───────────────────────────── */
.modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.45);
	display: grid;
	place-items: center;
	z-index: 99;
	animation: fadeIn 0.18s ease;
}
@keyframes fadeIn {
	from {
		opacity: 0;
	}
}
.modal {
	background: var(--surface);
	border: 1.5px solid var(--border);
	border-radius: var(--radius);
	padding: 32px;
	max-width: 340px;
	width: 90%;
	text-align: center;
}
.modal h3 {
	font-family: "DM Serif Display", serif;
	font-size: 1.4rem;
	margin-bottom: 10px;
}
.modal p {
	font-size: 0.8rem;
	color: var(--muted);
	margin-bottom: 24px;
}
.modal-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 540px) {
	.form-grid {
		grid-template-columns: 1fr;
	}
	.form-grid .full {
		grid-column: 1;
	}
	header {
		flex-direction: column;
		gap: 16px;
	}
}
