:root {
	--bg: #140d14;
	--card: #1f161f;
	--card2: #2a1e29;
	--line: #3a2a36;
	--text: #f6eaf1;
	--muted: #b49aaa;
	--accent: #ff6f91;
	--accent2: #e0457b;
	--good: #5fd38d;
	--bad: #ff6b6b;
	--radius: 16px;
	color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

h1 { font-size: 1.5rem; margin: 0.4rem 0; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; letter-spacing: 0.01em; }
a { color: var(--accent); }
code { background: var(--card2); padding: 2px 6px; border-radius: 6px; word-break: break-all; font-size: 0.85rem; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--bad); min-height: 1.2em; margin: 0.5rem 0 0; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.logo { width: 72px; height: 72px; }
.login-card input { margin: 1rem 0 0.8rem; }

/* Layout */
.topbar {
	position: sticky; top: 0; z-index: 5;
	display: flex; align-items: center; justify-content: space-between;
	padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
	background: rgba(20, 13, 20, 0.92); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.brand img { width: 30px; height: 30px; }
.alive { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.alive .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.alive.ok .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
.alive.bad .dot { background: var(--bad); }

.tabs {
	position: sticky; top: calc(50px + env(safe-area-inset-top)); z-index: 4;
	display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px 12px;
	background: var(--bg); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
	flex: none; border: 1px solid var(--line); background: var(--card); color: var(--muted);
	padding: 8px 14px; border-radius: 999px; font: inherit; font-size: 0.9rem; cursor: pointer;
}
.tabs button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.tab { padding: 0 16px calc(28px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

/* Form controls */
input[type="text"], input[type="password"], input[type="time"], input:not([type]), textarea, select {
	width: 100%; background: var(--card2); color: var(--text); border: 1px solid var(--line);
	border-radius: 12px; padding: 11px 12px; font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 96px; }
label { display: block; font-size: 0.9rem; color: var(--muted); }
label > input, label > select { margin-top: 4px; color: var(--text); }
.field { margin: 0.6rem 0; }
.field label { margin: 0.35rem 0; color: var(--text); }
.field label select { width: auto; display: inline-block; padding: 6px 8px; margin: 0 0 0 4px; }
.row { display: flex; gap: 10px; align-items: flex-end; margin: 0.6rem 0; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 10px; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); margin: 0.8rem 0; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); margin-top: 8px; }
input[type="radio"] { accent-color: var(--accent); }

.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	border: 1px solid var(--line); background: var(--card2); color: var(--text);
	border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer;
	text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); border-color: transparent; color: #fff; }
.btn.danger { color: var(--bad); }
.btn.wide { width: 100%; }
.btn.tiny { padding: 4px 10px; font-size: 0.8rem; border-radius: 8px; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }
.upload { margin-top: 0.6rem; }

/* Switch rows */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; color: var(--text); font-size: 1rem; border-top: 1px solid var(--line); }
.card h2 + .switch-row { border-top: 0; }
.switch { appearance: none; -webkit-appearance: none; width: 50px; height: 30px; border-radius: 999px; background: var(--line); position: relative; flex: none; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* Segmented control & chips */
.seg { display: flex; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 9px 4px; border-radius: 9px; font: inherit; font-size: 0.9rem; cursor: pointer; }
.seg button.active { background: var(--accent); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0.4rem 0; }
.chips button, .chips span { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 999px; padding: 7px 13px; font: inherit; font-size: 0.9rem; cursor: pointer; }
.chips.removable span { display: inline-flex; align-items: center; gap: 6px; cursor: default; }
.chips.removable span button { border: 0; padding: 0 2px; background: none; color: var(--muted); font-size: 1.1rem; line-height: 1; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-top: 1px solid var(--line); padding: 12px 0; }
.list li:first-child { border-top: 0; }
.list .meta { color: var(--muted); font-size: 0.8rem; margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.list .actions { display: flex; gap: 8px; margin-top: 8px; }
.badge { background: var(--card2); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 0.75rem; }
.badge.today { background: var(--accent); border-color: var(--accent); color: #fff; }
.note-preview { font-family: "Snell Roundhand", "Segoe Script", cursive; font-size: 1.3rem; margin: 0 0 0.8rem; color: var(--text); }
.note-preview.muted { font-family: inherit; font-size: 1rem; color: var(--muted); }
.note-text { white-space: pre-wrap; word-wrap: break-word; }

/* Photos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--card2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo.current { outline: 3px solid var(--accent); outline-offset: -3px; }
.photo button { position: absolute; top: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 1rem; cursor: pointer; }
.photo .del { right: 6px; }
.photo .pin { left: 6px; }
.photo .pin.on { color: #ffd166; }

/* Status */
.status { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.status dt { color: var(--muted); }
.status dd { margin: 0; }

/* Spotify */
.spotify-status { display: flex; gap: 12px; align-items: center; margin: 0.4rem 0 1rem; }
.spotify-status img { width: 56px; height: 56px; border-radius: 8px; }
.steps { padding-left: 1.2rem; margin: 0; }
.steps li { margin: 0 0 0.9rem; }

/* Toast */
.toast {
	position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
	background: #2e2230; border: 1px solid var(--line); color: var(--text); padding: 11px 18px; border-radius: 999px;
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); z-index: 10; max-width: calc(100vw - 32px); text-align: center;
}
.toast.err { border-color: var(--bad); }
