@font-face {
	font-family: "Still Sans";
	src: local("Avenir Next"), local("Avenir"), local("Helvetica Neue");
	font-display: swap;
}

:root {
	color-scheme: dark;
	font-family: "Still Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	font-synthesis: none;
	--black: #000;
	--ink: #1d1712;
	--ink-raised: #262017;
	--paper: #ede6d8;
	--soft: #cec4b2;
	--muted: #8d8371;
	--faint: #6a6255;
	--line: #2e2820;
	--line-strong: #453d31;
	--vermilion: #b8553a;
	--vermilion-deep: #9c4530;
	--success: #97a985;
	--warning: #cfa571;
	--danger: #c07f6d;
	--serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
	--progress: 0deg;
}

* {
	box-sizing: border-box;
}

html {
	background: var(--black);
	-webkit-text-size-adjust: 100%;
}

body {
	min-width: 320px;
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0;
	overflow-x: hidden;
	background: var(--black);
	color: var(--paper);
	-webkit-tap-highlight-color: transparent;
}

/* The warm room: ink wash with a faint lantern glow high in the frame.
   Lives on its own layer so blackout can fade it to true black. */
body::before {
	position: fixed;
	z-index: -1;
	inset: 0;
	background:
		radial-gradient(110% 75% at 50% -10%, rgb(112 88 58 / 18%), transparent 62%),
		radial-gradient(140% 110% at 50% 115%, rgb(58 46 30 / 35%), transparent 60%),
		var(--ink);
	content: "";
	transition: opacity 1.1s ease;
}

::selection {
	background: rgb(184 85 58 / 30%);
}

button,
input,
select {
	font: inherit;
}

button,
select {
	cursor: pointer;
}

button {
	-webkit-touch-callout: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
	outline: 2px solid var(--soft);
	outline-offset: 3px;
}

[hidden] {
	display: none !important;
}

.app {
	width: min(100%, 760px);
	min-height: 100vh;
	min-height: 100dvh;
	margin: 0 auto;
	padding: max(28px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(26px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
	display: flex;
	flex-direction: column;
	transition: opacity 1.1s ease;
}

.topbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 48px;
}

.wordmark {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	color: var(--soft);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.22em;
	text-decoration: none;
	text-transform: uppercase;
}

.wordmark svg {
	width: 26px;
	height: 26px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
}

.icon-button {
	width: 48px;
	height: 48px;
	padding: 12px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--muted);
	transition: background 160ms ease, color 160ms ease;
}

.icon-button:hover {
	background: var(--ink-raised);
	color: var(--paper);
}

.icon-button svg {
	width: 24px;
	height: 24px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.5;
}

.view {
	flex: 1;
}

.setup-view {
	width: min(100%, 620px);
	margin: 0 auto;
	padding: clamp(48px, 8vh, 88px) 0 24px;
}

.setup-heading {
	margin-bottom: 40px;
}

/* A single brushed rule under the heading, heavier at its start —
   the one flourish this page allows itself. */
.setup-heading::after {
	display: block;
	width: 64px;
	height: 2px;
	margin-top: 26px;
	border-radius: 2px;
	background: linear-gradient(90deg, var(--line-strong), transparent);
	content: "";
}

.eyebrow {
	margin: 0 0 12px;
	color: var(--muted);
	font-size: 11px;
	font-weight: 500;
	letter-spacing: 0.24em;
	text-transform: uppercase;
}

h1,
h2,
p {
	margin-top: 0;
}

h1 {
	margin-bottom: 0;
	font-family: var(--serif);
	font-size: clamp(46px, 7vw, 68px);
	font-weight: 400;
	letter-spacing: -0.03em;
	line-height: 1.04;
}

h2 {
	margin-bottom: 0;
	font-family: var(--serif);
	font-size: 34px;
	font-weight: 400;
	letter-spacing: -0.02em;
}

.mode-switch {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 5px;
	margin-bottom: 30px;
	padding: 4px;
	border: 1px solid var(--line);
	border-radius: 999px;
	background: rgb(0 0 0 / 18%);
}

.mode-button {
	min-height: 48px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--muted);
	font-size: 14px;
	transition: background 200ms ease, color 200ms ease;
}

.mode-button.active {
	background: var(--ink-raised);
	color: var(--paper);
	box-shadow: inset 0 0 0 1px var(--line-strong);
}

.duration-section {
	transition: opacity 180ms ease;
}

.duration-section.inactive {
	pointer-events: none;
	opacity: 0.2;
}

.preset-grid {
	display: grid;
	grid-template-columns: repeat(6, 1fr);
	gap: 9px;
}

.preset-button {
	min-width: 0;
	aspect-ratio: 0.84;
	padding: 11px 4px;
	border: 1px solid var(--line);
	border-radius: 12px;
	background: rgb(0 0 0 / 14%);
	color: var(--soft);
	transition: border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.preset-button span {
	display: block;
	font-family: var(--serif);
	font-size: clamp(24px, 4vw, 34px);
	font-variant-numeric: tabular-nums;
}

.preset-button small {
	display: block;
	margin-top: 4px;
	color: var(--faint);
	font-size: 9px;
	font-weight: 600;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}

.preset-button:hover {
	border-color: var(--line-strong);
	color: var(--paper);
}

.preset-button.active {
	border-color: var(--line-strong);
	background: var(--ink-raised);
	color: var(--paper);
	box-shadow: inset 0 1px 0 rgb(237 230 216 / 5%);
}

.preset-button.active small {
	color: var(--vermilion);
}

.custom-duration {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 66px;
	margin-top: 10px;
	border-bottom: 1px solid var(--line);
	color: var(--soft);
	font-size: 13px;
}

.number-field {
	display: flex;
	align-items: center;
	gap: 8px;
	color: var(--muted);
	font-size: 12px;
}

.number-field input {
	width: 64px;
	padding: 8px 4px;
	border: 0;
	border-bottom: 1px solid var(--line-strong);
	border-radius: 0;
	background: transparent;
	color: var(--paper);
	font-family: var(--serif);
	font-size: 20px;
	font-variant-numeric: tabular-nums;
	text-align: right;
}

.number-field input:focus {
	border-color: var(--soft);
	outline: none;
}

.preferences {
	margin-top: 30px;
	border-top: 1px solid var(--line);
}

.preference-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	min-height: 62px;
	border-bottom: 1px solid var(--line);
}

.preference-row > label {
	color: var(--soft);
	font-size: 13px;
}

.sound-control {
	display: flex;
	align-items: center;
}

.sound-control select {
	max-width: 180px;
	padding: 9px 30px 9px 10px;
	border: 0;
	background: transparent;
	color: var(--muted);
	font-size: 13px;
	text-align: right;
	transition: color 160ms ease;
}

.sound-control select:hover {
	color: var(--soft);
}

.preview-button {
	width: 44px;
	height: 44px;
	padding: 11px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--soft);
	transition: background 160ms ease;
}

.preview-button:hover {
	background: var(--ink-raised);
}

.preview-button svg {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-width: 1.5;
}

.health-option {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	min-height: 82px;
	margin-top: 17px;
	padding: 14px 0;
	color: var(--paper);
}

.health-option strong,
.health-option small {
	display: block;
}

.health-option strong {
	font-size: 13px;
	font-weight: 520;
}

.health-option small {
	margin-top: 5px;
	color: var(--muted);
	font-size: 11px;
}

.switch {
	position: relative;
	width: 49px;
	height: 29px;
	flex: 0 0 auto;
}

.switch input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
}

.switch span {
	position: absolute;
	inset: 0;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: rgb(0 0 0 / 25%);
	transition: background 180ms ease, border-color 180ms ease;
}

.switch span::after {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 21px;
	height: 21px;
	border-radius: 50%;
	background: var(--muted);
	content: "";
	transition: transform 180ms ease, background 180ms ease;
}

.switch input:checked + span {
	border-color: var(--vermilion);
	background: var(--vermilion);
}

.switch input:checked + span::after {
	background: var(--paper);
	transform: translateX(20px);
}

.switch input:focus-visible + span {
	outline: 2px solid var(--soft);
	outline-offset: 3px;
}

.primary-button,
.secondary-button,
.quiet-button,
.text-button {
	min-height: 54px;
	border-radius: 999px;
}

/* Begin: the seal stamp. The only saturated element on the page. */
.primary-button {
	width: 100%;
	padding: 14px 24px;
	border: 1px solid rgb(237 230 216 / 12%);
	background: linear-gradient(180deg, #c25c40, var(--vermilion-deep));
	color: #f6ede1;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	box-shadow: inset 0 1px 0 rgb(246 237 225 / 18%), 0 10px 28px rgb(156 69 48 / 18%);
	transition: filter 180ms ease, box-shadow 180ms ease;
}

.primary-button:hover {
	filter: brightness(1.08);
	box-shadow: inset 0 1px 0 rgb(246 237 225 / 22%), 0 12px 34px rgb(156 69 48 / 26%);
}

.primary-button:active {
	filter: brightness(0.94);
}

.primary-button.compact {
	width: auto;
	min-width: 150px;
}

.secondary-button {
	padding: 13px 22px;
	border: 1px solid var(--line-strong);
	background: transparent;
	color: var(--soft);
	font-size: 13px;
	transition: border-color 160ms ease, color 160ms ease;
}

.secondary-button:hover {
	border-color: var(--muted);
	color: var(--paper);
}

.support-note {
	min-height: 18px;
	margin: 14px 0 0;
	color: var(--faint);
	font-size: 10px;
	text-align: center;
}

.timer-view {
	position: relative;
	min-height: calc(100vh - 76px - max(26px, env(safe-area-inset-bottom)));
	min-height: calc(100dvh - 76px - max(26px, env(safe-area-inset-bottom)));
	cursor: pointer;
}

.timer-center {
	position: absolute;
	top: 47%;
	left: 50%;
	width: 100%;
	text-align: center;
	transform: translate(-50%, -50%);
}

.progress-ring {
	display: grid;
	width: min(64vw, 410px);
	aspect-ratio: 1;
	margin: 28px auto 25px;
	padding: 2px;
	border-radius: 50%;
	background: conic-gradient(from -90deg, var(--soft) var(--progress), var(--line) 0deg);
	animation: breathe 9s ease-in-out infinite;
}

/* An unclosed enso ring for open-ended sits — no arc to fill, so the
   circle simply rests, a small opening left at the top right. */
.progress-ring.open-ended {
	background: conic-gradient(from 24deg, var(--line-strong) 320deg, transparent 0deg);
	animation: breathe 9s ease-in-out infinite;
}

.progress-ring-inner {
	display: grid;
	place-items: center;
	border-radius: 50%;
	background:
		radial-gradient(70% 70% at 50% 42%, rgb(96 74 48 / 10%), transparent 70%),
		var(--ink);
}

@keyframes breathe {
	0%, 100% {
		box-shadow: 0 0 60px rgb(206 196 178 / 3%);
	}
	50% {
		box-shadow: 0 0 90px rgb(206 196 178 / 8%);
	}
}

#timerValue {
	color: var(--paper);
	font-family: var(--serif);
	font-size: clamp(66px, 12vw, 112px);
	font-variant-numeric: tabular-nums;
	font-weight: 400;
	letter-spacing: -0.05em;
	line-height: 1;
}

.awake-status {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	color: var(--faint);
	font-size: 10px;
	letter-spacing: 0.05em;
}

.awake-status > span:first-child {
	width: 5px;
	height: 5px;
	border-radius: 50%;
	background: var(--success);
	box-shadow: 0 0 0 4px rgb(151 169 133 / 9%);
}

.awake-status.warning > span:first-child {
	background: var(--warning);
	box-shadow: 0 0 0 4px rgb(207 165 113 / 9%);
}

.timer-actions {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	text-align: center;
}

.timer-actions p {
	margin-bottom: 14px;
	color: var(--faint);
	font-size: 10px;
}

.quiet-button {
	min-width: 170px;
	padding: 13px 24px;
	border: 1px solid var(--line);
	background: transparent;
	color: var(--muted);
	font-size: 12px;
	transition: border-color 160ms ease, color 160ms ease;
}

.quiet-button:hover {
	border-color: var(--muted);
	color: var(--paper);
}

.blackout-surface {
	position: fixed;
	z-index: 100;
	inset: 0;
	width: 100%;
	height: 100%;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: default;
}

body.blacked-out .app,
body.blacked-out::before {
	opacity: 0;
}

.complete-view {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	width: min(100%, 540px);
	margin: 0 auto;
	padding: clamp(86px, 16vh, 160px) 0 24px;
	text-align: center;
}

.session-total {
	margin: 23px 0 0;
	color: var(--soft);
	font-family: var(--serif);
	font-size: 24px;
}

.queue-result {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-top: 24px;
	color: var(--muted);
	font-size: 11px;
}

.queue-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: var(--success);
}

.queue-result.warning .queue-dot {
	background: var(--warning);
}

.queue-result.error .queue-dot {
	background: var(--danger);
}

.complete-actions {
	display: grid;
	gap: 9px;
}

.text-button {
	border: 0;
	background: transparent;
	color: var(--muted);
	font-size: 12px;
}

.text-button:hover {
	color: var(--paper);
}

.modal {
	width: min(calc(100% - 32px), 560px);
	max-height: min(760px, calc(100dvh - 32px));
	padding: 30px;
	border: 1px solid var(--line);
	border-radius: 18px;
	background: linear-gradient(180deg, var(--ink-raised), var(--ink));
	color: var(--paper);
	box-shadow: 0 30px 100px rgb(0 0 0 / 70%);
}

.modal::backdrop {
	background: rgb(6 4 2 / 76%);
	backdrop-filter: blur(6px);
}

.modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 20px;
}

.modal-header .icon-button {
	margin: -10px -10px 0 0;
}

.modal-copy {
	margin: 17px 0 27px;
	color: var(--muted);
	font-size: 12px;
	line-height: 1.65;
}

.field {
	display: block;
	margin-top: 18px;
}

.field > span {
	display: block;
	margin-bottom: 8px;
	color: var(--soft);
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.field input {
	width: 100%;
	min-height: 50px;
	padding: 12px 14px;
	border: 1px solid var(--line-strong);
	border-radius: 9px;
	background: rgb(0 0 0 / 30%);
	color: var(--paper);
	font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
	font-size: 12px;
}

.field input:focus {
	border-color: var(--soft);
	outline: none;
}

.form-message {
	min-height: 20px;
	margin: 17px 0 0;
	color: var(--muted);
	font-size: 11px;
}

.form-message.success {
	color: var(--success);
}

.form-message.error {
	color: var(--danger);
}

.modal-actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 24px;
}

.confirm-modal {
	width: min(calc(100% - 32px), 460px);
	text-align: center;
}

.confirm-modal .modal-actions {
	justify-content: center;
}

.toast {
	position: fixed;
	z-index: 200;
	right: 24px;
	bottom: max(24px, env(safe-area-inset-bottom));
	left: 24px;
	width: fit-content;
	max-width: min(420px, calc(100% - 48px));
	margin: 0 auto;
	padding: 12px 17px;
	border: 1px solid var(--line-strong);
	border-radius: 999px;
	background: var(--ink-raised);
	color: var(--soft);
	font-size: 11px;
	text-align: center;
	box-shadow: 0 12px 40px rgb(0 0 0 / 50%);
}

@media (max-width: 600px) {
	.app {
		padding-right: max(18px, env(safe-area-inset-right));
		padding-left: max(18px, env(safe-area-inset-left));
	}

	.setup-view {
		padding-top: 38px;
	}

	.setup-heading {
		margin-bottom: 30px;
	}

	.setup-heading::after {
		margin-top: 20px;
	}

	.preset-grid {
		grid-template-columns: repeat(3, 1fr);
	}

	.preset-button {
		aspect-ratio: 1.4;
	}

	.progress-ring {
		width: min(82vw, 360px);
	}

	.modal {
		padding: 25px 20px;
	}

	.modal-actions.stacked-mobile {
		flex-direction: column-reverse;
	}

	.modal-actions.stacked-mobile > button {
		width: 100%;
	}
}

@media (orientation: landscape) and (max-height: 820px) {
	.app {
		width: min(100%, 980px);
	}

	.setup-view {
		width: min(100%, 820px);
		padding-top: 20px;
	}

	.setup-heading {
		margin-bottom: 20px;
	}

	.setup-heading::after {
		margin-top: 14px;
	}

	.setup-heading h1 {
		font-size: 42px;
	}

	.mode-switch {
		margin-bottom: 18px;
	}

	.preset-button {
		min-height: 74px;
		aspect-ratio: auto;
	}

	.custom-duration {
		min-height: 52px;
	}

	.preferences {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 24px;
		margin-top: 18px;
		border-top: 0;
	}

	.preference-row {
		min-height: 56px;
		border-top: 1px solid var(--line);
	}

	.health-option {
		min-height: 66px;
		margin-top: 5px;
		padding: 8px 0;
	}

	.support-note {
		margin-top: 8px;
	}

	.progress-ring {
		width: min(48vh, 300px);
		margin: 14px auto;
	}

	.timer-center {
		top: 46%;
	}

	.timer-actions p {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation: none !important;
		scroll-behavior: auto !important;
		transition-duration: 0.01ms !important;
	}

	.app,
	body::before {
		transition-duration: 1.1s !important;
	}
}
