:root {
	color-scheme: light;
	--bg: #f6f3ee;
	--surface: #fffdf9;
	--fg: #23302c;
	--muted: #66736e;
	--accent: #4f8a74;
	--accent-soft: #dcebe3;
	--lav: #b9b3dc;
	--border: #e6e0d6;
	--danger: #b4533e;
	--radius: 18px;
	--space: 1rem;
	--font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}



* {
	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: #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(--bg);
}

.input,
.select,
.textarea {
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: 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, and nothing in the pipeline ever looked at a
 * phone-width layout, so every generated app inherited the horizontal scroll.
 * min() clamps the track to the container instead.
 */
.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);
}

/*
 * The scaffold had exactly one @media rule (prefers-color-scheme) and no width
 * breakpoint at all, so the shell was a 42rem column at every size.
 * Mobile-first stays the default; these only widen it.
 */
@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;
	}
}

/* ---- Calm Compass ---- */
body {
	background: radial-gradient(circle at 10% 0%, #e7f0ea 0, transparent 40%),
		radial-gradient(circle at 100% 20%, #ece9f6 0, transparent 40%), var(--bg);
	min-height: 100vh;
}
h1, h2, h3 { font-family: Georgia, "Iowan Old Style", serif; font-weight: 500; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 0.6rem; }
.card { background: var(--surface); box-shadow: 0 6px 24px -14px rgba(35, 48, 44, 0.25); padding: 1.2rem; }
.btn { border-radius: 999px; padding: 0.65rem 1.2rem; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn:disabled { opacity: 0.6; cursor: default; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { justify-content: center; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.field > span { font-size: 0.875rem; color: var(--muted); }
.input { background: #fff; border-radius: 12px; }

.auth { max-width: 26rem; margin: 0 auto; padding: 3rem 1rem 6rem; text-align: center; }
.auth form { text-align: left; margin-top: 1.5rem; }
.brand-mark {
	display: inline-grid; place-items: center; width: 3.5rem; height: 3.5rem; border-radius: 50%;
	background: linear-gradient(135deg, var(--accent-soft), var(--lav)); color: var(--accent); font-size: 1.8rem;
}
.brand-mark.sm { width: 2rem; height: 2rem; font-size: 1rem; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; font-family: Georgia, serif; font-size: 1.2rem; }
.shell { padding-top: 1.5rem; padding-bottom: 6rem; display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }

.tabs { display: flex; gap: 0.3rem; padding: 0.3rem; background: #ebe6dd; border-radius: 999px; }
.tab {
	flex: 1; border: 0; background: transparent; padding: 0.55rem 0.4rem; border-radius: 999px;
	font: inherit; font-size: 0.92rem; color: var(--muted); cursor: pointer; transition: background 0.2s;
}
@media (max-width: 420px) { .tab { font-size: 0.82rem; padding: 0.55rem 0.2rem; } }
.worry { display: grid; gap: 0.5rem; }
.worry-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.worry-body { font-size: 1.02rem; overflow-wrap: anywhere; }
.worry .chips { align-items: center; }
.worry-pair { display: grid; gap: 0.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .worry-pair { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); } }
.pair-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.2rem; }
.balanced { background: #e6f2ec; border-left: 3px solid #6fa58a; border-radius: 10px; padding: 0.55rem 0.7rem; overflow-wrap: anywhere; }
.edit-balanced { align-self: flex-start; font-size: 0.85rem; }
.due-card { background: #fbf3e4; border: 1px solid #ecd9b4; }
.due-item { display: grid; gap: 0.35rem; }
.tab.on { background: var(--surface); color: var(--fg); box-shadow: 0 2px 8px -4px rgba(0, 0, 0, 0.25); font-weight: 600; }

.advice {
	padding: 1.2rem; border-radius: var(--radius); scroll-margin-top: 1rem;
	background: linear-gradient(135deg, var(--accent-soft), #ece9f6); border: 1px solid #d3e3da;
}
.advice.urgent { background: linear-gradient(135deg, #f8e3dc, #f3e9f1); border-color: #ecc9bd; }
.advice ul { margin: 0.6rem 0 0.8rem; padding-left: 1.2rem; }
.advice li { margin-bottom: 0.3rem; }

.level-display { display: flex; align-items: baseline; gap: 0.4rem; font-weight: 500; transition: color 0.3s; }
.level-num { font-family: Georgia, serif; font-size: 3.2rem; line-height: 1; }
.range { width: 100%; accent-color: var(--accent); height: 1.6rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
	border: 1px solid var(--border); background: #fff; color: var(--fg); border-radius: 999px;
	padding: 0.4rem 0.85rem; font: inherit; font-size: 0.88rem; cursor: pointer; transition: all 0.15s;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.save-entry { justify-self: start; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 0.8rem; text-align: center; }
.stat b { display: block; font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; color: var(--accent); }
.stat span { font-size: 0.75rem; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.grid-line { stroke: var(--border); stroke-dasharray: 4 4; }
.axis { fill: var(--muted); font-size: 12px; }
.line { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.area { fill: rgba(79, 138, 116, 0.12); }
.bar-row { display: grid; grid-template-columns: minmax(0, 7.5rem) minmax(0, 1fr) 1.5rem; align-items: center; gap: 0.6rem; margin: 0.45rem 0; }
.bar-label { font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 0.6rem; background: #efeae2; border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--lav)); border-radius: 999px; }
.bar-val { font-size: 0.85rem; color: var(--muted); text-align: right; }
.hist { flex-wrap: nowrap; align-items: flex-start; background: #fff; }
.hist-lvl { flex: none; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; color: #fff; font-weight: 600; }
.hist-body { flex: 1; min-width: 0; font-size: 0.92rem; }
.note { margin-top: 0.3rem; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.footer { text-align: center; }

.breath-wrap { display: grid; place-items: center; height: 15rem; }
.breath-orb {
	width: 13rem; height: 13rem; border-radius: 50%; display: grid; place-items: center; align-content: center;
	background: radial-gradient(circle at 35% 30%, #fff, var(--accent-soft) 45%, var(--lav));
	box-shadow: 0 0 0 14px rgba(79, 138, 116, 0.08), 0 0 50px rgba(185, 179, 220, 0.6);
}
.breath-label { font-family: Georgia, serif; font-size: 1.2rem; }
.breath-count { font-size: 2rem; color: var(--accent); min-height: 2.4rem; }
.ground-big { font-family: Georgia, serif; font-size: 1.4rem; text-align: center; margin: 1rem 0; }
.ground-big strong { color: var(--accent); font-size: 2rem; }
.dots { display: flex; justify-content: center; gap: 0.5rem; margin-bottom: 1rem; }
.dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--border); transition: background 0.3s; }
.dot.on { background: var(--accent); }

/* Panic flow */
.panic-btn {
	position: fixed; right: 1rem; bottom: 1rem; z-index: 50; display: flex; align-items: center; gap: 0.4rem;
	border: 0; border-radius: 999px; padding: 0.85rem 1.2rem; background: #c8553d; color: #fff;
	font: inherit; font-weight: 600; cursor: pointer; box-shadow: 0 10px 28px -8px rgba(200, 85, 61, 0.7);
}
.panic-overlay {
	position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; color: #fff;
	background: linear-gradient(160deg, #2f5a4c, #4b4876); animation: panic-in 0.4s ease;
}
@keyframes panic-in { from { opacity: 0; } }
.panic-top { display: flex; justify-content: space-between; align-items: center; padding: 1rem; }
.panic-progress { opacity: 0.8; font-size: 0.9rem; }
.panic-body { flex: 1; overflow-y: auto; display: grid; place-items: center; padding: 1rem 1.5rem 3rem; outline: none; }
.panic-step { max-width: 30rem; text-align: center; display: grid; justify-items: center; gap: 1rem; }
.panic-big { font-size: clamp(1.6rem, 6vw, 2.3rem); color: #fff; margin: 0; }
.panic-sub { font-size: 1.1rem; line-height: 1.6; opacity: 0.9; margin: 0; }
.panic-num { font-family: Georgia, serif; font-size: 5rem; line-height: 1; }
.panic-next, .panic-close {
	border-radius: 999px; padding: 0.8rem 1.5rem; font: inherit; font-weight: 600; cursor: pointer;
}
.panic-next { border: 0; background: #fff; color: #2f5a4c; }
.panic-close { border: 1px solid rgba(255, 255, 255, 0.5); background: transparent; color: #fff; padding: 0.5rem 1rem; }
.panic-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.panic-orb {
	width: 14rem; height: 14rem; border-radius: 50%; display: grid; place-items: center; margin: 1rem 0;
	background: radial-gradient(circle at 35% 30%, rgba(255,255,255,0.9), rgba(220,235,227,0.6) 45%, rgba(185,179,220,0.5));
	box-shadow: 0 0 60px rgba(255, 255, 255, 0.35); transition-property: transform; transition-timing-function: ease-in-out;
	transform: scale(0.6);
}
.panic-orb-0, .panic-orb-1 { transform: scale(1); }
.panic-orb-2 { transform: scale(0.6); }
.panic-count { font-size: 2.6rem; color: #2f5a4c; font-weight: 600; }
@media (max-width: 30rem) {
	.breath-orb { width: 11rem; height: 11rem; }
	.panic-orb { width: 12rem; height: 12rem; }
}
@media (prefers-reduced-motion: reduce) {
	.breath-orb, .panic-orb { transition: none !important; }
}

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