/* Hamstr design system: shared by the Hamstr shell and AppCrumb.
   A calm, modern look: neutral greys, one indigo accent, a soft gradient
   wallpaper, glass bars and home-screen style app icons. Light and dark
   follow the OS. Apps copy this file to /ui.css (see sync.ts) and add
   their own styles on top. */
:root {
	color-scheme: light dark;
	--bg: #f4f4f6;
	--wall-1: rgba(99, 102, 241, 0.16);
	--wall-2: rgba(14, 165, 233, 0.12);
	--wall-3: rgba(236, 72, 153, 0.08);
	--surface: #ffffff;
	--surface-2: #f1f1f4;
	--glass: rgba(255, 255, 255, 0.72);
	--glass-line: rgba(255, 255, 255, 0.7);
	--ink: #18181b;
	--dim: #6b6b76;
	--line: rgba(24, 24, 27, 0.09);
	--accent: #5452e8;
	--accent-strong: #4340d4;
	--accent-ink: #ffffff;
	--accent-soft: rgba(84, 82, 232, 0.12);
	--danger: #dc2f45;
	--ok: #16a34a;
	--shadow: 0 1px 2px rgba(15, 15, 30, 0.05), 0 4px 14px rgba(15, 15, 30, 0.05);
	--shadow-lift: 0 2px 6px rgba(15, 15, 30, 0.06), 0 18px 48px rgba(15, 15, 30, 0.14);
	--icon-shadow: 0 1px 1px rgba(0, 0, 0, 0.06), 0 6px 16px rgba(15, 15, 40, 0.16);
	--radius: 16px;
	--radius-sm: 10px;
	--page: 1080px;
	--font: "Inter", "InterVariable", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0c0c10;
		--wall-1: rgba(99, 102, 241, 0.22);
		--wall-2: rgba(14, 165, 233, 0.1);
		--wall-3: rgba(236, 72, 153, 0.08);
		--surface: #17171c;
		--surface-2: #222229;
		--glass: rgba(24, 24, 30, 0.66);
		--glass-line: rgba(255, 255, 255, 0.07);
		--ink: #f4f4f6;
		--dim: #9b9ba8;
		--line: rgba(255, 255, 255, 0.08);
		--accent: #7c7bff;
		--accent-strong: #9796ff;
		--accent-ink: #ffffff;
		--accent-soft: rgba(124, 123, 255, 0.16);
		--danger: #ff6b7d;
		--ok: #4ade80;
		--shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.25);
		--shadow-lift: 0 2px 6px rgba(0, 0, 0, 0.4), 0 18px 48px rgba(0, 0, 0, 0.5);
		--icon-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 6px 16px rgba(0, 0, 0, 0.45);
	}
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
	background:
		radial-gradient(60vw 50vh at 12% -5%, var(--wall-1), transparent 70%),
		radial-gradient(50vw 45vh at 95% 0%, var(--wall-2), transparent 70%),
		radial-gradient(60vw 50vh at 70% 110%, var(--wall-3), transparent 70%),
		var(--bg);
	background-attachment: fixed;
	color: var(--ink);
	font: 15px/1.5 var(--font);
	font-feature-settings: "cv11", "ss01";
	-webkit-font-smoothing: antialiased;
	min-height: 100vh;
}
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { letter-spacing: -0.025em; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); font-weight: 650; }
h2 { font-size: 1.15rem; font-weight: 620; }
h3 { font-size: 0.98rem; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 8px; }
.dim { color: var(--dim); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.76rem; }
.error { color: var(--danger); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- buttons and fields --- */
.button {
	display: inline-flex; align-items: center; justify-content: center; gap: 7px;
	border: 1px solid transparent; border-radius: var(--radius-sm); padding: 8px 15px;
	background: var(--accent); color: var(--accent-ink); font-weight: 560; font-size: 0.92rem;
	text-decoration: none; cursor: pointer; white-space: nowrap;
	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 1px 2px rgba(20, 20, 60, 0.2);
	transition: background 0.15s, transform 0.12s, box-shadow 0.15s;
}
.button:hover { background: var(--accent-strong); }
.button:active { transform: scale(0.97); }
.button:disabled { opacity: 0.55; cursor: progress; }
.button.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); }
.button.ghost:hover { background: var(--surface-2); }
.button.quiet { background: transparent; color: var(--dim); padding: 6px 10px; box-shadow: none; }
.button.quiet:hover { background: var(--surface-2); color: var(--ink); }
.button.danger { background: transparent; color: var(--danger); border-color: var(--line); box-shadow: none; }
.button.danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.button.small { padding: 5px 11px; font-size: 0.84rem; border-radius: 8px; }
.icon-button {
	display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
	border: 0; background: transparent; color: var(--dim); cursor: pointer; text-decoration: none;
}
.icon-button:hover { background: var(--surface-2); color: var(--ink); }
.icon-button svg { width: 18px; height: 18px; }
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field label { font-weight: 560; font-size: 0.86rem; }
.input {
	width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
	background: var(--surface); padding: 9px 12px;
	transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* --- top bar: a floating glass strip --- */
.bar {
	position: sticky; top: 12px; z-index: 10;
	display: flex; align-items: center; gap: 14px;
	width: min(var(--page), calc(100% - 24px)); margin: 12px auto 0; padding: 7px 8px 7px 14px;
	background: var(--glass); border: 1px solid var(--glass-line); border-radius: 16px;
	backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
	box-shadow: var(--shadow);
}
.bar.scrolled { box-shadow: var(--shadow-lift); }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); font-weight: 650; font-size: 1.02rem; letter-spacing: -0.02em; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; gap: 2px; margin: 0 auto; padding: 3px; overflow-x: auto; background: var(--surface-2); border-radius: 11px; }
.nav a { padding: 5px 14px; border-radius: 8px; color: var(--dim); text-decoration: none; font-weight: 540; font-size: 0.88rem; white-space: nowrap; transition: color 0.15s, background 0.15s; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--line); }
.me { position: relative; }
.avatar {
	width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
	background: linear-gradient(135deg, #818cf8, #6366f1 55%, #8b5cf6); color: #fff; font-weight: 600; font-size: 0.78rem;
	box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.menu {
	position: absolute; right: 0; top: 42px; min-width: 220px; z-index: 20;
	background: var(--glass); border: 1px solid var(--glass-line); border-radius: 12px;
	backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px);
	box-shadow: var(--shadow-lift); padding: 5px; animation: pop 0.14s ease;
}
.menu-head { display: grid; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.menu-item { width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 0.9rem; }
.menu-item:hover { background: var(--accent); color: var(--accent-ink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger); color: #fff; }
/* The account menu sits inside the top bar, which already blurs what is behind
   it, and a nested backdrop-filter blurs nothing: give it a solid surface. */
.me .menu { background: var(--surface); border-color: var(--line); }
a.menu-item { color: var(--ink); text-decoration: none; }

/* --- pages --- */
.page { width: min(var(--page), calc(100% - 24px)); margin: 0 auto; padding: 40px 14px 72px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 8px 0 30px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; }
.section { margin-top: 44px; }
.section > h2 { margin-bottom: 14px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; margin-left: -4px; }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 16px; height: 16px; }
.app-head { display: flex; align-items: center; gap: 18px; }
.app-head h1 { margin: 0; }
.tile-icon.big { width: 76px; height: 76px; border-radius: 21px; font-size: 2.2rem; flex: none; }

/* --- app icons --- */
.tile-icon {
	width: 56px; height: 56px; border-radius: 15px; display: grid; place-items: center; font-size: 1.7rem;
	color: #fff; box-shadow: var(--icon-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -1px 0 rgba(0, 0, 0, 0.08);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}
.c-sun { background: linear-gradient(160deg, #fdba74, #f97316 60%, #ea580c); }
.c-leaf { background: linear-gradient(160deg, #86efac, #22c55e 60%, #15803d); }
.c-sky { background: linear-gradient(160deg, #7dd3fc, #3b82f6 60%, #2563eb); }
.c-rose { background: linear-gradient(160deg, #f9a8d4, #ec4899 60%, #be185d); }
.c-sand { background: linear-gradient(160deg, #5eead4, #14b8a6 60%, #0f766e); }
.c-lilac { background: linear-gradient(160deg, #c4b5fd, #8b5cf6 60%, #6d28d9); }

/* --- lists and cards --- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card {
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
	padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.card-head { display: flex; gap: 14px; align-items: center; }
.card-head .tile-icon { width: 48px; height: 48px; font-size: 1.45rem; border-radius: 13px; flex: none; }
.card-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 6px; flex-wrap: wrap; align-items: center; }
.rows { display: grid; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row .tile-icon { width: 38px; height: 38px; font-size: 1.15rem; border-radius: 10px; flex: none; }
.row .grow { flex: 1; min-width: 0; }
.row .grow > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--dim); font-size: 0.75rem; font-weight: 560; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.search { max-width: 320px; }
.empty { text-align: center; padding: 64px 20px; color: var(--dim); }
.empty img { width: 56px; height: 56px; margin-bottom: 14px; }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* --- app page: breadcrumb, hero, toolbar --- */
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 0.86rem; color: var(--dim); margin-bottom: 18px; }
.crumbs a { color: var(--dim); text-decoration: none; padding: 2px 6px; margin-left: -6px; border-radius: 6px; }
.crumbs a:hover { color: var(--ink); background: var(--surface-2); }
.crumbs svg { width: 14px; height: 14px; opacity: 0.6; }
.crumbs [aria-current] { color: var(--ink); font-weight: 560; }
.hero {
	display: flex; align-items: center; gap: 22px; padding: 22px; margin-bottom: 26px;
	background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px; box-shadow: var(--shadow);
	backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.hero-text { flex: 1; min-width: 0; }
.hero-text p { margin: 4px 0 10px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; align-self: center; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.warn { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #b45309; }
@media (prefers-color-scheme: dark) { .chip.warn { color: #fbbf24; } }
.chip svg { width: 12px; height: 12px; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 11px; }
.segmented > * {
	display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 0; border-radius: 8px; background: transparent;
	color: var(--dim); text-decoration: none; font-weight: 540; font-size: 0.86rem; cursor: pointer; white-space: nowrap;
}
.segmented > *:hover { color: var(--ink); }
.segmented > [aria-selected="true"], .segmented > [aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--line); }
.segmented.icons > * { padding: 5px 8px; }
.segmented svg { width: 16px; height: 16px; }
.count { font-size: 0.72rem; font-weight: 600; padding: 0 6px; border-radius: 6px; background: color-mix(in srgb, var(--dim) 14%, transparent); }
.search-box {
	display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 8px 0 11px; width: min(260px, 100%);
	background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--dim);
	transition: border-color 0.15s, box-shadow 0.15s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box svg { width: 16px; height: 16px; flex: none; }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--ink); font-size: 0.9rem; }
kbd { font: 600 0.7rem/1 var(--font); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--dim); }
.select { width: auto; height: 36px; padding: 0 30px 0 11px; font-size: 0.88rem; cursor: pointer; }
.more .menu { top: calc(100% + 4px); min-width: 200px; background: var(--surface); border-color: var(--line); }
.more .menu.flip { right: auto; left: 0; max-width: calc(100vw - 16px); }
.menu-item { display: flex; align-items: center; gap: 9px; }
.menu-icon { display: inline-grid; width: 16px; height: 16px; opacity: 0.8; }
.menu-icon svg { width: 16px; height: 16px; }
.menu-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.rows.list { overflow: visible; }
.rows.list .row.head { padding-top: 8px; padding-bottom: 8px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.rows.list .row:not(.head):hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.rows.list .row:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.rows .col { width: 120px; flex: none; }
.rows .icon-col { width: 38px; flex: none; }
.rows .actions-col { display: flex; align-items: center; justify-content: flex-end; gap: 2px; width: 76px; flex: none; }
.row-link { color: var(--ink); font-weight: 600; text-decoration: none; display: block; }
.row-link:hover { color: var(--accent); }
.row .chip { margin-right: 6px; }
.show-sm { display: none; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 0; }
.facts dt { color: var(--dim); }
.facts dd { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.button.danger-solid { background: var(--danger); }
.button.danger-solid:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }

/* --- store details --- */
.card-link { text-decoration: none; color: inherit; border-radius: 10px; }
.card-link:hover h3 { color: var(--accent); }
.card-actions .push { margin-left: auto; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; }
.panel > h2 { margin-bottom: 12px; }
.prose { max-width: 68ch; line-height: 1.65; }
.panel .button { display: flex; width: 100%; }
.chip.tag { text-decoration: none; }
.chip.tag:hover { color: var(--accent); }
.chip.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.callout.warn { border-color: color-mix(in srgb, #f59e0b 55%, var(--line)); background: color-mix(in srgb, #f59e0b 10%, var(--surface-2)); }
.callout.error { color: var(--danger); }
.caps { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cap { display: flex; gap: 14px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.cap p { margin: 4px 0 0; }
.cap-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.cap-icon svg { width: 18px; height: 18px; }
.cap.warn .cap-icon { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #d97706; }
.role-list { margin: 8px 0 0; padding-left: 18px; font-size: 0.86rem; }
.role-list li { margin: 3px 0; }
.rows .actions-col.wide { width: 130px; }
.mono { font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace; }
.row .grow .chip { margin: 0 0 0 6px; }


/* --- full-screen app view (a crumb in Hamstr, a demo in the store): the app
   fills the screen under a slim title bar --- */
body.crumb-mode { overflow: hidden; }
.crumb-view { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr; background: var(--bg); }
.crumb-bar {
	display: flex; align-items: center; gap: 8px; padding: 6px 10px; min-height: 50px;
	border-bottom: 1px solid var(--line); background: var(--glass);
	backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.crumb-bar .tile-icon { width: 28px; height: 28px; font-size: 0.95rem; border-radius: 8px; flex: none; box-shadow: none; }
.crumb-title { font-weight: 600; font-size: 0.95rem; border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 4px 8px; min-width: 0; width: min(420px, 40vw); text-overflow: ellipsis; }
.crumb-title:not([readonly]):hover { background: var(--surface-2); }
.crumb-title:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.crumb-bar .spacer { flex: 1; }
.crumb-app { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; border-radius: 8px; color: var(--dim); text-decoration: none; font-size: 0.88rem; font-weight: 540; white-space: nowrap; }
.crumb-app:hover { background: var(--surface-2); color: var(--ink); }
.crumb-sep { display: inline-grid; color: var(--dim); opacity: 0.6; margin: 0 -4px; }
.crumb-sep svg { width: 14px; height: 14px; }
.crumb-warn { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5; margin: 0; box-shadow: var(--shadow); display: grid; gap: 4px; background: var(--surface); }
.crumb-frame { width: 100%; height: 100%; border: 0; background: var(--surface); }
.crumb-loading { display: grid; place-items: center; color: var(--dim); }

/* --- dialogs --- */
.scrim {
	position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
	background: rgba(8, 8, 14, 0.32); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
	animation: fade 0.15s ease;
}
.sheet {
	width: min(540px, 100%); max-height: min(86vh, 760px); overflow: auto;
	background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lift); padding: 22px;
	animation: pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.sheet-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.choices { display: grid; gap: 6px; }
.choice {
	font-weight: 400;
	display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px;
	border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: left; width: 100%;
	transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.choice:hover { background: var(--surface-2); }
.choice[aria-pressed="true"], .choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent); }
.choice input { accent-color: var(--accent); }
.choice .tile-icon { width: 40px; height: 40px; font-size: 1.2rem; border-radius: 11px; flex: none; }
.linkbox { display: flex; gap: 8px; }
.linkbox .input { font-family: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace; font-size: 0.82rem; }
.callout { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 12px 0; font-size: 0.9rem; }
.perm-list { margin: 8px 0 0; padding-left: 18px; }

/* --- toast and misc --- */
.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
	background: color-mix(in srgb, var(--ink) 92%, transparent); color: var(--bg); padding: 9px 16px; border-radius: 12px;
	backdrop-filter: blur(12px); box-shadow: var(--shadow-lift); font-weight: 540; font-size: 0.9rem; animation: rise 0.18s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.97) translateY(4px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* --- sign-in and plain server pages --- */
body.plain, .plain-page, .welcome { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.center-card, .welcome-card {
	width: min(400px, 100%); text-align: center; background: var(--glass); border: 1px solid var(--glass-line); border-radius: 24px;
	backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px);
	box-shadow: var(--shadow-lift); padding: 40px 30px 32px;
}
.center-card h1, .welcome-card h1 { margin: 16px 0 8px; font-size: 1.6rem; }
.center-card .stack, .welcome-card .stack { display: grid; gap: 8px; margin-top: 26px; }
.center-card .button, .welcome-card .button { padding: 10px 16px; }
.center-card form { margin: 0; }
.center-card form .button { width: 100%; }
.logo-lg img, .welcome-card img { width: 64px; height: 64px; filter: drop-shadow(0 8px 18px rgba(84, 82, 232, 0.35)); }
.app-icon { font-size: 0.9em; }
.tagline { font-size: 1rem; }

@media (max-width: 640px) {
	.bar { gap: 8px; padding: 6px 6px 6px 10px; }
	.brand span { display: none; }
	.nav a { padding: 5px 10px; }
	.page { padding: 26px 16px 64px; }
	.hide-sm { display: none !important; }
	.show-sm { display: inline; }
	.hero { flex-wrap: wrap; padding: 18px; gap: 16px; }
	.hero-actions { width: 100%; }
	.toolbar .spacer { display: none; }
	.search-box { flex: 1; width: auto; }
	.segmented { max-width: 100%; overflow-x: auto; }
	.detail-grid { grid-template-columns: 1fr; }
}

/* spacing helpers (inline styles are blocked by the CSP) */
.sheet-sub { margin-top: 4px; }
.hint { margin-top: 28px; }
.gap-top { margin-top: 16px; }
.gap-top-sm { margin-top: 8px; }
.gap-bottom { margin-bottom: 12px; }
.span-all { grid-column: 1 / -1; }
.page-head.compact { margin: 0 0 14px; }
.flush { margin: 0; }
.eyebrow { margin: 0 0 6px; font-weight: 540; text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.74rem; }

/* SvelteKit's route announcer styles itself inline, which the CSP blocks. */
#svelte-announcer { position: absolute; left: 0; top: 0; width: 1px; height: 1px; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; }

/* --- context menu (right click, long press, Menu key) --- */
.menu.context-menu { position: fixed; right: auto; z-index: 60; min-width: 210px; max-width: min(300px, calc(100vw - 16px)); background: var(--surface); border-color: var(--line); -webkit-touch-callout: none; }
.confirm-check { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; font-weight: 500; cursor: pointer; }
.confirm-check input { width: 18px; height: 18px; accent-color: var(--danger); }
.no-callout { -webkit-touch-callout: none; }
.button.danger-text { color: var(--danger); }
.sheet-foot .push-left { margin-right: auto; }
.menu.context-menu:focus { outline: none; }

/* --- file picker (restore a backup) --- */
.file-pick { position: relative; display: grid; justify-items: center; gap: 4px; padding: 22px 16px; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface-2); cursor: pointer; text-align: center; transition: border-color 0.15s, background 0.15s; }
.file-pick:hover, .file-pick.dragging, .file-pick:focus-within { border-color: var(--accent); }
.file-pick.dragging { background: var(--surface); }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-pick strong { overflow-wrap: anywhere; }
.file-pick-icon { display: inline-grid; width: 26px; height: 26px; color: var(--accent); }
.file-pick-icon svg { width: 26px; height: 26px; }

/* --- settings lists: what an item is, then its chips and actions. On a narrow
   screen the actions drop below the text instead of squeezing it --- */
/* One column that may shrink below its content, so a long name truncates instead of widening the page. */
.rows { grid-template-columns: minmax(0, 1fr); }
.item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 14px; }
.item + .item { border-top: 1px solid var(--line); }
.item > .avatar { flex: none; display: inline-grid; place-items: center; cursor: default; }
.item-main { flex: 1 1 200px; min-width: 0; }
.item-main > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-side { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.item.dim { justify-content: center; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); font-weight: 600; text-align: left; cursor: pointer; }
.link-button:hover { color: var(--accent); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section.first { margin-top: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* A button with a caret that opens a menu of variants (MoreMenu with button="button split-caret"). */
.split { display: inline-flex; }
.split > .more { display: flex; }
.split > .button { flex: 1; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.split-caret { padding: 8px 9px; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-color: rgba(255, 255, 255, 0.22); }
.split-caret svg { width: 15px; height: 15px; transform: rotate(90deg); }
.subnav { margin: -8px 0 26px; }
.segmented > [aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--line); }
.input.narrow { width: 180px; }
@media (max-width: 640px) {
	.item-side { margin-left: 0; width: 100%; }
	.item-side .button { flex: 1; }
	.item-side .chip { flex: none; }
	.head-actions { width: 100%; }
	.head-actions > * { flex: 1; min-width: 0; }
	.section-head .search { max-width: none; flex: 1; }
	.input.narrow { width: 100%; }
	.subnav { display: flex; width: 100%; }
	.sheet-foot { flex-wrap: wrap; }
}
