:root {
	color-scheme: light dark;
	--bg: #fbf7f4;
	--fg: #2a1f2d;
	--muted: #e9d5f0;
	--accent: #e4533d;
	--border: #e9dfe6;
	--danger: #b42318;
	--radius: 10px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0e0c0c;
		--fg: #f5eef6;
		--muted: #b3a6b8;
		--accent: #f07a66;
		--border: #f8f2fb;
		--danger: #ff9a8f;
	}
}

* {
	box-sizing: border-box;
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.shell {
	max-width: 42rem;
	margin: 0 auto;
	padding: calc(var(--space) * 3) var(--space);
}

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

.lede {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}

.hint {
	margin: 0;
	color: var(--muted);
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.55rem 0.9rem;
	border: 1px solid transparent;
	border-radius: var(--radius);
	background: var(--accent);
	color: var(--on-accent, #fff);
	font: inherit;
	font-weight: 500;
	cursor: pointer;
}

.btn:hover {
	filter: brightness(1.05);
}

.btn-secondary {
	background: transparent;
	color: var(--fg);
	border-color: var(--border);
}

.card {
	padding: var(--space);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--card, var(--bg));
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--input, var(--bg));
	color: var(--fg);
	font: inherit;
}

.field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.35rem;
	margin-bottom: var(--space);
}

.field > label {
	font-size: 0.875rem;
	color: var(--muted);
}

/*
 * 390px-safe, like .grid below. A grid with no column list gets one implicit
 * auto column, and an auto column is never narrower than its widest item's
 * min-content width. One nowrap scrolling strip (days, time slots) anywhere
 * inside an item therefore widened the whole column past the screen: the page
 * scrolled sideways instead of the strip scrolling on its own. minmax(0, 1fr)
 * caps the column at the container; the min-width rule keeps a child from
 * bringing the same floor back if an app redefines the columns. :where() adds
 * no specificity, so a min-width the app sets on a child still wins.
 */
.stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--space);
}

:where(.field, .stack, .list) > * {
	min-width: 0;
}

.row {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

/*
 * 390px-safe. An unclamped minmax track overflows a 390px viewport once the
 * shell padding is subtracted; min() clamps the track to the container.
 */
.grid {
	display: grid;
	gap: var(--space);
	grid-template-columns: repeat(auto-fit, minmax(min(15rem, 100%), 1fr));
}

.list {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.list-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
}

.table {
	width: 100%;
	border-collapse: collapse;
}

.table th,
.table td {
	padding: 0.6rem 0.5rem;
	text-align: left;
	border-bottom: 1px solid var(--border);
}

.table th {
	font-size: 0.8125rem;
	color: var(--muted);
	font-weight: 600;
}

.empty {
	padding: calc(var(--space) * 2);
	text-align: center;
	color: var(--muted);
}

.empty-title {
	margin: 0 0 0.25rem;
	color: var(--fg);
	font-weight: 600;
}

/* Loading. Every fetch has one; without a primitive each app invented its own. */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

@keyframes fab-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Placeholder for content whose shape is known before its data arrives. */
.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to {
		background-position: -200% 0;
	}
}

/* Error strip: a failure the user can see and retry, never a silent no-op. */
.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--danger);
	color: var(--danger);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}

/* Mobile-first is the default; these breakpoints only widen the shell. */
@media (min-width: 48rem) {
	.shell {
		max-width: 52rem;
		padding: calc(var(--space) * 3) calc(var(--space) * 1.5);
	}
}

@media (min-width: 64rem) {
	.shell {
		max-width: 64rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.spinner,
	.skeleton {
		animation: none;
	}
}

:root { --pos: #2f7a5a; --neg: #c0563a; }
textarea.notes { width: 100%; resize: vertical; min-height: 6rem; font: inherit; }
.notes-cell { min-width: 10rem; max-width: 18rem; white-space: pre-wrap; }
.conc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.conc-chip { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0.25rem 0.25rem 0.75rem; border: 1px solid var(--border, #ddd); border-radius: 999px; }
.conc-input { flex: 1; min-width: 0; }
.btn-del { padding: 0.35rem 0.75rem; font-size: 0.85rem; }
.report-stats { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.report-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.report-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.report-table th, .report-table td { border: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; }
.report-table th { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.report-table th.sub { font-weight: 400; font-size: 0.72rem; color: var(--muted); }
.report-table .nowrap, .report-table .ex-cell { white-space: nowrap; }
@media print {
	.no-print { display: none !important; }
	body { background: #fff; color: #000; }
	.report { max-width: none; padding: 0; }
	.report-scroll { overflow: visible; border: 0; }
	.report-table { font-size: 9pt; }
	.report-table th, .report-table td { border-color: #999; color: #000; }
	.report-table tr { break-inside: avoid; }
	@page { size: landscape; margin: 12mm; }
}
body { background: var(--page, color-mix(in srgb, var(--accent) 5%, var(--bg))); }
h2 { margin: 0; font-size: 1.15rem; }
h3 { margin: 0; font-size: 1rem; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.75rem; font-weight: 700; color: var(--accent); }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.topbar h1 { margin: 0; }
.spread { justify-content: space-between; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.date-input { width: auto; }
.card .field { margin-bottom: 0; }
.vitals, .ex-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); }
.ex-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 40rem) { .ex-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.bp { display: flex; align-items: center; gap: 0.4rem; }
.bp .input { min-width: 0; }
.exchange { display: grid; gap: 0.75rem; border-left: 4px solid var(--accent); }
.pill { padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }
.pos { background: color-mix(in srgb, var(--pos) 15%, transparent); color: var(--pos); }
.neg { background: color-mix(in srgb, var(--neg) 15%, transparent); color: var(--neg); }
.pos-t { color: var(--pos); font-weight: 600; } .neg-t { color: var(--neg); font-weight: 600; }
.savebar { position: sticky; bottom: 0; display: flex; justify-content: flex-end; align-items: center; gap: 1rem;
	padding: 0.75rem 0; background: linear-gradient(transparent, var(--bg) 35%); }
.save-btn { justify-content: center; padding: 0.75rem 1.4rem; font-size: 1.05rem; }
.btn:disabled { opacity: 0.6; cursor: default; }
.hist { width: 100%; background: var(--card, var(--bg)); color: var(--fg); font: inherit; cursor: pointer; text-align: left; }
.hist:hover { border-color: var(--accent); }
.hist-vals { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; color: var(--muted); font-size: 0.9rem; }
.small { font-size: 0.85rem; }
.auth { max-width: 28rem; }

:where(a, button, input, select, textarea):focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
}

/* Reminder */
.default-pill { margin-left: 0.5rem; font-weight: 500; font-size: 0.75rem; vertical-align: middle;
	background: color-mix(in srgb, var(--fg) 8%, transparent); color: color-mix(in srgb, var(--fg) 70%, transparent); }

/* Several blood-pressure readings per day */
.bp-row { display: grid; gap: 0.75rem; align-items: end;
	grid-template-columns: minmax(6.5rem, 0.8fr) minmax(5rem, 0.6fr) minmax(10rem, 1.4fr) 44px;
	grid-template-areas: "time pulse bp del"; }
.bp-f-time { grid-area: time; } .bp-f-bp { grid-area: bp; } .bp-f-pulse { grid-area: pulse; }
/* Red round X to delete a reading */
.bp-del { grid-area: del; justify-self: end; width: 44px; height: 44px; padding: 0; display: grid; place-items: center;
	border: 1px solid color-mix(in srgb, #d92d20 35%, transparent); border-radius: 50%;
	background: color-mix(in srgb, #d92d20 10%, transparent); color: #d92d20; cursor: pointer; }
@media (prefers-color-scheme: dark) { .bp-del { color: #ff8a80; border-color: color-mix(in srgb, #ff8a80 40%, transparent); background: color-mix(in srgb, #ff8a80 12%, transparent); } }
.bp-del:hover { background: #d92d20; color: #fff; }
.bp-row + .bp-row { padding-top: 0.75rem; border-top: 1px solid var(--border); }
/* Phone: time + pulse (+ X) / blood pressure full width */
@media (max-width: 560px) {
	.bp-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; grid-template-areas: "time pulse del" "bp bp bp"; }
}
.bp-time { opacity: 0.7; font-size: 0.85em; }

/* =====================================================================
 * "Mein Design": <html data-theme="mix"> (set in index.html). Overview
 * block in src/Dashboards.tsx; theme variables further below.
 * ===================================================================== */

/* Shared bits of the overview blocks */
.dash-hint { margin: 0; font-size: 0.9rem; color: var(--muted); }
.dash h2 { font-size: 0.95rem; }

/* Section reached via a tile / quick button lights up briefly */
@keyframes jump-flash { 0%, 35% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 3px transparent; } }
.jump-flash { animation: jump-flash 1.6s ease-out; border-radius: var(--radius); scroll-margin-top: 0.75rem; }
@media (prefers-reduced-motion: reduce) { .jump-flash { animation: none; outline: 3px solid var(--accent); } }

/* ---- Mein Design (mix) ---------------------------------------------- */
html[data-theme="mix"] {
	color-scheme: light dark;
	--bg: #f6f3f1; --page: #f6f3f1; --card: #ffffff; --input: #faf8f7;
	--fg: #231a20; --muted: #64585f; --accent: #e4533d; --on-accent: #ffffff;
	--border: #e8e0dc; --danger: #b42318; --pos: #1f6b4f; --neg: #b23a1f;
	--tile-soft: #fbeae6; --seg-off: #eadfdb;
	--radius: 16px;
	--font: Outfit, ui-sans-serif, system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
	html[data-theme="mix"] {
		--bg: #0e0c0c; --page: #0e0c0c; --card: #292323; --input: #120f0f;
		--fg: #f5eef6; --muted: #b9adb6; --accent: #f07a66; --on-accent: #1a1312;
		--border: #2c2526; --danger: #ff9a8f; --pos: #7fd8a8; --neg: #ff9a8f;
		--tile-soft: #2a1d1b; --seg-off: #2f2728;
	}
}
html[data-theme="mix"] h1 { font-weight: 800; }
html[data-theme="mix"] .eyebrow { color: var(--accent); }
html[data-theme="mix"] .card { border-color: transparent; border-radius: 24px; }
html[data-theme="mix"] .btn { min-height: 44px; font-weight: 600; }
html[data-theme="mix"] .btn-del { min-height: 0; }
html[data-theme="mix"] .btn-secondary { background: var(--card); border-color: var(--border); }
html[data-theme="mix"] .exchange { border-left: 0; }
html[data-theme="mix"] .list-item { border-color: transparent; }
html[data-theme="mix"] .save-btn { border-radius: 18px; font-weight: 700; }

.dash-mix { display: grid; gap: 0.75rem; }
.dash-mix .m-alarm { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.15rem; border-radius: 24px; background: var(--accent); color: var(--on-accent); }
.dash-mix .m-alarm-icon { flex: none; width: 3.4rem; height: 3.4rem; border-radius: 50%; display: grid; place-items: center;
	background: color-mix(in srgb, var(--on-accent) 16%, transparent); }
.dash-mix .m-alarm-txt { display: grid; gap: 0.15rem; flex: 1; min-width: 0; }
.dash-mix .m-alarm-txt span { font-size: 0.875rem; opacity: 0.92; }
.dash-mix .m-alarm-txt strong { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.dash-mix .m-due .m-alarm-icon { animation: m-ring 1.2s ease-in-out infinite; }
@keyframes m-ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(0); } }
@media (prefers-reduced-motion: reduce) { .dash-mix .m-due .m-alarm-icon { animation: none; } }
.dash-mix .m-done, .dash-mix .m-none { background: var(--card); color: var(--fg); }
.dash-mix .m-done .m-alarm-icon, .dash-mix .m-none .m-alarm-icon { background: var(--tile-soft); color: var(--accent); }
.dash-mix .m-alarm-btn { flex: none; min-height: 48px; padding: 0 1rem; border: 0; border-radius: 16px; background: var(--card); color: var(--fg); font: inherit; font-weight: 700; cursor: pointer; }
.dash-mix .m-done .m-alarm-btn, .dash-mix .m-none .m-alarm-btn { background: var(--accent); color: var(--on-accent); }

.dash-mix .m-grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash-mix .m-tile { display: grid; gap: 0.35rem; align-content: start; min-width: 0; min-height: 7rem; padding: 0.95rem 1.05rem; text-align: left;
	border: 1px solid transparent; border-radius: 22px; background: var(--card); color: var(--fg); font: inherit; cursor: pointer;
	transition: transform 0.12s ease, border-color 0.12s ease; }
.dash-mix .m-tile:hover { border-color: var(--accent); }
.dash-mix .m-tile:active { transform: scale(0.98); }
.dash-mix .m-wide { grid-column: 1 / -1; min-height: 0; }
.dash-mix .m-head { display: flex; justify-content: space-between; align-items: center; }
.dash-mix .m-label { font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.dash-mix .m-go { width: 1.75rem; height: 1.75rem; border-radius: 50%; display: grid; place-items: center; background: var(--tile-soft); color: var(--accent); font-size: 1.2rem; font-weight: 700; line-height: 1; }
.dash-mix .m-big { font-size: 1.85rem; font-weight: 800; line-height: 1.05; }
.dash-mix .m-big small { font-size: 1rem; font-weight: 600; }
.dash-mix .m-sub { font-size: 0.85rem; color: var(--muted); }
.dash-mix .m-sub.pos-t, .dash-mix .m-sub.neg-t { font-weight: 600; }
.dash-mix .m-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.dash-mix .m-uf { font-size: 1.15rem; font-weight: 700; }
.dash-mix .m-seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.dash-mix .m-seg i { height: 8px; border-radius: 4px; background: var(--seg-off); }
.dash-mix .m-seg i.on { background: var(--accent); }
.dash-mix .m-bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 0.25rem; }
/* Each bar is a button that opens its day; the whole column is the tap target. */
.dash-mix .m-bar { display: grid; grid-template-rows: 2.4rem auto; gap: 3px; min-width: 0; padding: 0 0 2px; border: 0; border-radius: 8px;
	background: none; color: var(--muted); font: inherit; cursor: pointer; }
.dash-mix .m-bar i { align-self: end; border-radius: 5px; background: color-mix(in srgb, var(--accent) 30%, var(--card)); transition: background 0.12s ease; }
.dash-mix .m-bar small { font-size: 0.7rem; line-height: 1; text-align: center; }
.dash-mix .m-bar:hover i { background: color-mix(in srgb, var(--accent) 60%, var(--card)); }
.dash-mix .m-bar:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dash-mix .m-bar.now { cursor: default; color: var(--accent); }
.dash-mix .m-bar.now small { font-weight: 700; }
.dash-mix .m-bar.now i { background: var(--accent); }
.dash-mix .m-bar.neg i { background: color-mix(in srgb, var(--neg) 45%, var(--card)); }
/* Tiles with several click areas: the tile itself is not a button. */
.dash-mix .m-split { cursor: default; }
.dash-mix .m-split:active { transform: none; }
.dash-mix .m-main { display: grid; gap: 0.35rem; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.dash-mix .m-main:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 12px; }
.dash-mix .m-drink:hover { border-color: transparent; }
.dash-mix .m-drink-btns { display: flex; gap: 0.5rem; }
.dash-mix .m-add { min-width: 4.2rem; min-height: 48px; padding: 0 0.9rem; border: 0; border-radius: 16px; background: var(--accent); color: var(--on-accent);
	font: inherit; font-size: 1.05rem; font-weight: 800; cursor: pointer; transition: transform 0.1s ease; }
.dash-mix .m-add:active { transform: scale(0.94); }
.dash-mix .m-add:disabled { opacity: 0.6; }
.dash-mix .m-undo { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.dash-mix .m-note { font-size: 0.95rem; line-height: 1.4; color: var(--muted); white-space: pre-line; }

/* Readings imported from the smartwatch */
.watch-pill { margin-left: 0.4rem; padding: 0.05rem 0.45rem; font-size: 0.7rem; font-weight: 600; vertical-align: middle;
	background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--fg); }
.import-status { display: grid; gap: 0.25rem; }
.import-pick { border: 1px solid var(--line, rgba(127,127,127,0.3)); border-radius: 12px; padding: 0.75rem 1rem; display: grid; gap: 0.6rem; }
.import-pick legend { padding: 0 0.3rem; font-weight: 600; }
.import-opt { display: flex; align-items: center; gap: 0.6rem; cursor: pointer; }
.import-opt input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent); }
.import-opt .hint { margin-left: auto; }
.import-opt.is-empty { opacity: 0.55; cursor: default; }
label.btn { cursor: pointer; }
label.btn.is-busy { opacity: 0.6; cursor: default; }
label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
