:root {
	--bg: #f5f6f8;
	--card: #fff;
	--text: #16181d;
	--muted: #6b7280;
	--line: #e3e5ea;
	--accent: #2563eb;
	--red: #dc2626;
	--radius: 14px;
	color-scheme: light;
	font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	-webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
[hidden] { display: none !important; }
h1 { font-size: 28px; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 19px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 0 0 1px var(--line); }
#app, .narrow { max-width: 640px; margin: 0 auto; }
.narrow { max-width: 400px; margin-top: 8vh; padding: 28px 24px; }
.narrow > p { margin: 4px 0 20px; }

form { display: grid; gap: 14px; }
label, legend { font-size: 14px; font-weight: 600; display: grid; gap: 6px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 6px; }
input:not([type=radio], [type=checkbox]), select {
	font: inherit;
	font-weight: 400;
	color: inherit;
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid var(--line);
	border-radius: 10px;
	background: #fff;
	appearance: none;
}
select { padding-right: 28px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(37 99 235 / 0.18); }
input[aria-invalid=true] { border-color: var(--red); }
input::-webkit-date-and-time-value { text-align: left; }
.msg { margin: -8px 0 0; font-size: 13px; color: var(--muted); min-height: 1em; }
.msg.error { color: var(--red); }
#todo-msg { margin: 0; }
#todo-msg:empty { display: none; }

button { font: inherit; cursor: pointer; border: 0; -webkit-tap-highlight-color: transparent; }
.primary, .secondary, .danger { min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 600; }
.primary { background: var(--accent); color: #fff; }
.secondary { background: #eef0f3; color: var(--text); }
.danger { background: var(--red); color: #fff; }
.primary:hover { background: #1d4ed8; }
button:focus-visible { outline: 3px solid rgb(37 99 235 / 0.4); outline-offset: 2px; }

header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
header .muted { margin-left: auto; font-size: 14px; }
.icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: transparent; color: var(--muted); }
.icon:hover { background: #eceef2; color: var(--text); }
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.danger-icon:hover { background: #fdecec; color: var(--red); }

#todo-form { padding: 18px; margin-bottom: 20px; }
.row { display: grid; grid-template-columns: 1fr auto 120px; gap: 12px; align-items: end; }
.time-row { display: flex; align-items: center; gap: 4px; }
.time select { width: auto; }
.suffix { position: relative; display: block; }
.suffix span { position: absolute; right: 12px; top: 50%; translate: 0 -50%; color: var(--muted); font-weight: 400; pointer-events: none; }
.suffix input { padding-right: 44px; }

.segmented > label { display: inline-block; }
.segmented { display: flex; flex-wrap: wrap; gap: 0; }
.segmented legend { width: 100%; }
.segmented label {
	flex: 1;
	text-align: center;
	font-weight: 500;
	padding: 9px 0;
	border: 1px solid var(--line);
	margin-left: -1px;
	cursor: pointer;
}
.segmented label:first-of-type { border-radius: 10px 0 0 10px; margin-left: 0; }
.segmented label:last-of-type { border-radius: 0 10px 10px 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(:checked) { background: var(--accent); border-color: var(--accent); color: #fff; position: relative; }
.segmented label:has(:focus-visible) { box-shadow: 0 0 0 3px rgb(37 99 235 / 0.3); position: relative; }

#list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.todo { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; }
.todo .body { flex: 1; min-width: 0; }
.todo .title { font-weight: 600; overflow-wrap: anywhere; }
.todo .meta { font-size: 14px; }
.overdue { color: var(--red); }
.nowrap { white-space: nowrap; }
.prio { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; min-width: 60px; text-align: center; }
.prio.low { background: #eef0f3; color: #4b5563; }
.prio.normal { background: #e6eefe; color: #1d4ed8; }
.prio.high { background: #fdecec; color: #b91c1c; }
.empty { text-align: center; padding: 24px; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(380px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgb(0 0 0 / 0.2); color: var(--text); }
dialog form { padding: 22px; gap: 12px; }
dialog p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
dialog::backdrop { background: rgb(15 18 25 / 0.4); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 16px; cursor: pointer; padding: 8px 0; }
.switch small { display: block; font-size: 13px; font-weight: 400; }
.switch input { appearance: none; flex: none; width: 51px; height: 31px; border-radius: 99px; background: #d9dce2; position: relative; margin: 0; cursor: pointer; transition: background 0.2s; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25); transition: translate 0.2s; }
.switch input:checked { background: #34c759; }
.switch input:checked::after { translate: 20px; }
.switch input:focus-visible { outline: 3px solid rgb(37 99 235 / 0.4); outline-offset: 2px; }

#tip { position: fixed; z-index: 10; background: #16181d; color: #fff; font-size: 13px; padding: 5px 9px; border-radius: 7px; pointer-events: none; white-space: nowrap; }

@media (max-width: 560px) {
	h1 { font-size: 26px; }
	.row { grid-template-columns: 1fr; }
	.time select { flex: 1; }
	.narrow { margin-top: 2vh; }
}
