:root {
	--bg: #f4f5fb;
	--panel: #ffffff;
	--ink: #1b1f3b;
	--muted: #6b7088;
	--line: #e3e5f0;
	--shadow: 0 10px 30px rgba(27, 31, 59, 0.08);
	--radius: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	padding: 24px 16px calc(40px + env(safe-area-inset-bottom));
	background: var(--bg);
	color: var(--ink);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	line-height: 1.4;
}

.wrap { max-width: 720px; margin: 0 auto; }

header { text-align: center; margin-bottom: 20px; }

header h1 {
	margin: 0;
	font-size: clamp(1.6rem, 5vw, 2.25rem);
	letter-spacing: -0.02em;
}

header p { margin: 6px 0 0; color: var(--muted); font-size: 0.95rem; }

.clock {
	display: inline-flex;
	align-items: baseline;
	gap: 10px;
	margin-top: 14px;
	padding: 8px 18px;
	background: var(--ink);
	color: #fff;
	border-radius: 999px;
	box-shadow: var(--shadow);
}

.clock #time { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.1rem; }
.clock #date { font-size: 0.8rem; color: rgba(255, 255, 255, 0.7); }

.settings {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
	font-size: 0.85rem;
	color: var(--muted);
}

.settings label { font-weight: 500; }

.settings input[type="time"],
.datebar input[type="date"] {
	font: inherit;
	padding: 5px 8px;
	border: 1px solid var(--line);
	border-radius: 8px;
	background: #fff;
	color: var(--ink);
}

.settings #now-label { color: var(--ink); font-weight: 600; }

/* account row */
.account {
	margin-top: 10px;
	font-size: 0.82rem;
	color: var(--muted);
	display: flex;
	gap: 10px;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
}

.account button, .linkish {
	font: inherit;
	border: none;
	background: none;
	color: #3aa0ff;
	cursor: pointer;
	padding: 0;
	text-decoration: underline;
}

.account .who { color: var(--ink); font-weight: 600; }

.panel {
	background: var(--panel);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 16px;
	margin-bottom: 18px;
}

.panel-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}

.panel-head h2 {
	margin: 0;
	font-size: 0.95rem;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--muted);
}

.pill-btn {
	border: 1px solid var(--line);
	background: #fff;
	color: var(--muted);
	padding: 7px 14px;
	border-radius: 999px;
	font-size: 0.85rem;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pill-btn:hover { background: #f0f4ff; color: var(--ink); }
.pill-btn.danger:hover { background: #fff0f0; color: #d23b3b; border-color: #f2c2c2; }

/* date navigation */
.datebar {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
}

.datebar .nav {
	width: 36px; height: 36px;
	border-radius: 50%;
	border: 1px solid var(--line);
	background: #fff;
	cursor: pointer;
	font-size: 1rem;
	color: var(--ink);
}
.datebar .nav:hover { background: #f0f4ff; }
.datebar .today-tag { font-size: 0.8rem; color: var(--muted); }
.datebar .today-tag.is-today { color: #2bb673; font-weight: 600; }

.palette { display: flex; flex-wrap: wrap; gap: 8px; }

.swatch {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 12px;
	border: 2px solid transparent;
	border-radius: 999px;
	background: var(--bg);
	cursor: pointer;
	font-size: 0.85rem;
	font-weight: 500;
	user-select: none;
	transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}

.swatch:hover { transform: translateY(-1px); }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: var(--shadow); }

.swatch .dot {
	width: 16px; height: 16px;
	border-radius: 50%;
	border: 1px solid rgba(0, 0, 0, 0.12);
}

.swatch.erase .dot {
	background:
		linear-gradient(45deg, transparent 45%, #d23b3b 45%, #d23b3b 55%, transparent 55%),
		#fff;
}

#all-blocks {
	display: grid;
	grid-template-columns: repeat(10, 1fr);
	gap: clamp(3px, 1.2vw, 7px);
	touch-action: none; /* let us paint by dragging instead of scrolling */
}

.block {
	aspect-ratio: 1 / 1;
	border-radius: 6px;
	background: #fff;
	border: 1px solid var(--line);
	cursor: pointer;
	position: relative;
	transition: transform 0.08s, box-shadow 0.12s;
}

.block:hover { box-shadow: 0 0 0 2px rgba(27, 31, 59, 0.2); }
.block.filled { border-color: transparent; }

.block.now {
	box-shadow: 0 0 0 3px var(--ink);
	z-index: 1;
	animation: nowPulse 2s ease-in-out infinite;
}

@keyframes nowPulse {
	0%, 100% { box-shadow: 0 0 0 3px var(--ink); }
	50% { box-shadow: 0 0 0 3px rgba(27, 31, 59, 0.35); }
}

.summary { display: flex; flex-wrap: wrap; gap: 10px; }

.stat { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--muted); }
.stat .dot { width: 12px; height: 12px; border-radius: 50%; }
.stat.total { margin-left: auto; font-weight: 600; color: var(--ink); }

/* history */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 8px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	cursor: pointer;
	font-size: 0.88rem;
	background: #fff;
}
.history-row:hover { background: #f0f4ff; }
.history-row.active { border-color: var(--ink); }
.history-row .count { color: var(--muted); font-size: 0.8rem; }
.history-empty { color: var(--muted); font-size: 0.85rem; }

/* auth overlay */
.overlay {
	position: fixed;
	inset: 0;
	background: rgba(27, 31, 59, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	z-index: 10;
}

.overlay[hidden] { display: none; }

.auth-card {
	background: #fff;
	border-radius: var(--radius);
	box-shadow: var(--shadow);
	padding: 24px;
	width: 100%;
	max-width: 360px;
}

.auth-card h2 { margin: 0 0 4px; }
.auth-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 0.9rem; }

.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.auth-tabs button {
	flex: 1;
	padding: 8px;
	border: 1px solid var(--line);
	background: var(--bg);
	border-radius: 10px;
	cursor: pointer;
	font: inherit;
	color: var(--muted);
}
.auth-tabs button[aria-selected="true"] {
	background: var(--ink);
	color: #fff;
	border-color: var(--ink);
}

.auth-card label { display: block; font-size: 0.8rem; color: var(--muted); margin: 10px 0 4px; }
.auth-card input {
	width: 100%;
	font: inherit;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
}

.auth-card .submit {
	width: 100%;
	margin-top: 16px;
	padding: 11px;
	border: none;
	border-radius: 10px;
	background: var(--ink);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.auth-card .error { color: #d23b3b; font-size: 0.85rem; margin-top: 10px; min-height: 1em; }
.auth-card .local-link { text-align: center; margin-top: 16px; }

footer { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
footer a { color: var(--muted); }

[hidden] { display: none !important; }
