/* Lore — base: reset, tokens, typography, utilities. Mobile-first. */

:root {
	--ember: #E4572E;
	--ember-dark: #c34a26;
	--ember-light: #f8ddd2;
	--teal: #1B998B;
	--teal-dark: #157569;
	--ink: #1d1d1f;
	--ink-soft: #4a4a4d;
	--ink-faint: #7a7a7e;
	--paper: #fbfaf7;
	--paper-alt: #f2efe9;
	--line: #e6e2da;
	--white: #ffffff;
	--danger: #c62828;
	--success: #1B998B;

	--radius-sm: 6px;
	--radius-md: 10px;
	--radius-lg: 16px;
	--radius-pill: 999px;

	--space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
	--space-5: 20px; --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;

	--shadow-sm: 0 1px 2px rgba(29,29,31,.06), 0 1px 1px rgba(29,29,31,.04);
	--shadow-md: 0 4px 16px rgba(29,29,31,.10);
	--shadow-lg: 0 12px 32px rgba(29,29,31,.16);

	--header-h: 60px;
	--tabbar-h: 58px;
	--max-w: 1240px;

	color-scheme: light;
}

@media (prefers-color-scheme: dark) {
	:root:not([data-app-theme="light"]) {
		--paper: #16161a;
		--paper-alt: #1e1e23;
		--ink: #f2f1ee;
		--ink-soft: #c9c7c2;
		--ink-faint: #8f8d89;
		--line: #2c2c32;
		--white: #201f24;
		--ember-light: #3a251d;
		color-scheme: dark;
	}
}
:root[data-app-theme="dark"] {
	--paper: #16161a; --paper-alt: #1e1e23; --ink: #f2f1ee; --ink-soft: #c9c7c2;
	--ink-faint: #8f8d89; --line: #2c2c32; --white: #201f24; --ember-light: #3a251d;
	color-scheme: dark;
}

/* The `hidden` attribute must always win, even against a class that sets
   `display` (e.g. `.lore-btn[hidden]`) — same specificity as the UA
   stylesheet's own `[hidden]` rule means source order would otherwise let
   an author `.some-class { display: ... }` rule show it again. This bit
   several `[hidden]` toggles (publish/unpublish buttons, unread badge,
   install button) until caught in QA. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	*, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--lore-font-ui);
	font-size: 16px;
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}

img, svg { max-width: 100%; display: block; }
img { height: auto; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; } h4 { font-size: 1rem; }
p { margin: 0 0 1em; }

a { color: inherit; text-decoration: none; }
a.lore-link { color: var(--ember); text-decoration: underline; text-underline-offset: 2px; }

button { font: inherit; color: inherit; }

/* Focus visibility — never remove outlines, only restyle them. */
:focus-visible {
	outline: 2px solid var(--teal);
	outline-offset: 2px;
	border-radius: 4px;
}
a:focus-visible, button:focus-visible { outline-offset: 3px; }

.lore-skip-link {
	position: absolute; left: -999px; top: 0; z-index: 1000;
	background: var(--ember); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.lore-skip-link:focus { left: 0; }

.screen-reader-text {
	position: absolute !important; width: 1px; height: 1px; overflow: hidden;
	clip: rect(1px,1px,1px,1px); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

.lore-container { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--space-4); }

/* Buttons */
.lore-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
	min-height: 44px; padding: 0 var(--space-5);
	border-radius: var(--radius-pill); border: 1px solid transparent;
	font-weight: 600; font-size: .95rem; cursor: pointer;
	transition: transform .1s ease, background-color .15s ease, border-color .15s ease, opacity .15s;
	background: var(--paper-alt); color: var(--ink);
}
.lore-btn:active { transform: scale(.98); }
.lore-btn--primary { background: var(--ember); color: #fff; }
.lore-btn--primary:hover { background: var(--ember-dark); }
.lore-btn--teal { background: var(--teal); color: #fff; }
.lore-btn--teal:hover { background: var(--teal-dark); }
.lore-btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.lore-btn--ghost:hover { background: var(--paper-alt); }
.lore-btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.lore-btn--sm { min-height: 36px; padding: 0 var(--space-4); font-size: .85rem; }
.lore-btn--block { width: 100%; }
.lore-btn[disabled], .lore-btn.is-loading { opacity: .6; pointer-events: none; }
.lore-btn--icon { min-height: 40px; min-width: 40px; padding: 0; border-radius: 50%; }

.lore-icon-btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 44px; height: 44px; border-radius: 50%; position: relative;
	background: transparent; border: 0; cursor: pointer; color: var(--ink);
}
.lore-icon-btn:hover { background: var(--paper-alt); }
.lore-icon { width: 22px; height: 22px; }
.lore-icon--sm { width: 16px; height: 16px; }

/* Forms */
.lore-field { margin-bottom: var(--space-4); }
.lore-field label, .lore-label {
	display: block; font-weight: 600; font-size: .875rem; margin-bottom: var(--space-2);
}
.lore-input, .lore-textarea, .lore-select {
	width: 100%; min-height: 46px; padding: 10px 14px;
	border: 1px solid var(--line); border-radius: var(--radius-md);
	background: var(--white); color: var(--ink); font-size: 1rem; font-family: inherit;
}
.lore-textarea { min-height: 120px; resize: vertical; }
.lore-input:focus, .lore-textarea:focus, .lore-select:focus { border-color: var(--teal); }
.lore-field__hint { font-size: .8rem; color: var(--ink-faint); margin-top: var(--space-1); }
.lore-field__error { font-size: .8rem; color: var(--danger); margin-top: var(--space-1); }
.lore-field.has-error .lore-input, .lore-field.has-error .lore-textarea { border-color: var(--danger); }
.lore-checkbox { display: flex; align-items: flex-start; gap: var(--space-2); font-size: .9rem; }
.lore-checkbox input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

.lore-toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; }
.lore-toggle__switch { position: relative; width: 44px; height: 26px; flex: none; }
.lore-toggle__switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.lore-toggle__track { position: absolute; inset: 0; background: var(--line); border-radius: var(--radius-pill); transition: background .15s; }
.lore-toggle__track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: var(--shadow-sm); }
.lore-toggle__switch input:checked + .lore-toggle__track { background: var(--ember); }
.lore-toggle__switch input:checked + .lore-toggle__track::after { transform: translateX(18px); }

/* Chips */
.lore-chip {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 4px 12px; border-radius: var(--radius-pill);
	background: var(--paper-alt); font-size: .8rem; font-weight: 600; color: var(--ink-soft);
	border: 1px solid var(--line);
}
.lore-chip--ember { background: var(--ember-light); color: var(--ember-dark); border-color: transparent; }
.lore-chip--teal { background: rgba(27,153,139,.12); color: var(--teal-dark); border-color: transparent; }
.lore-chip button { background: none; border: 0; cursor: pointer; color: inherit; line-height: 0; }

.lore-badge {
	display: inline-flex; align-items: center; justify-content: center;
	min-width: 18px; height: 18px; padding: 0 4px; border-radius: 999px;
	background: var(--ember); color: #fff; font-size: .65rem; font-weight: 700;
	position: absolute; top: 4px; right: 4px;
}

.lore-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Utility */
.u-flex { display: flex; } .u-flex-col { display: flex; flex-direction: column; }
.u-items-center { align-items: center; } .u-justify-between { justify-content: space-between; }
.u-gap-2 { gap: var(--space-2); } .u-gap-3 { gap: var(--space-3); } .u-gap-4 { gap: var(--space-4); }
.u-mt-4 { margin-top: var(--space-4); } .u-mb-4 { margin-bottom: var(--space-4); }
.u-muted { color: var(--ink-faint); }
.u-center-text { text-align: center; }
.u-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* No horizontal scroll safety at small widths */
html, body { max-width: 100%; }
