/* FLW App Bar + Application Header. Canon: docs/app-standards.md */

:root {
	--flw-app-bar-height: 32px;
}

.flw-app-bar {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	height: var(--flw-app-bar-height);
	padding: 0;
	width: 100%;
	background: #fff;
	color: #111;
	border-bottom: 1px solid #e5e5e5;
	font-family: "Source Sans 3", system-ui, sans-serif;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	line-height: 1;
	position: sticky;
	top: 0;
	z-index: 40;
	overflow: visible;
}

.flw-app-switcher {
	position: relative;
	display: flex;
	align-items: stretch;
	margin: 0;
}

.flw-app-bar-toggle {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	height: var(--flw-app-bar-height);
	padding: 0 0.85rem;
	margin: 0;
	cursor: pointer;
	list-style: none;
	user-select: none;
	color: inherit;
	background: transparent;
	border: 0;
	font: inherit;
	font-weight: 600;
}

.flw-app-bar-toggle::-webkit-details-marker {
	display: none;
}

.flw-app-bar-toggle::marker {
	content: "";
	display: none;
}

.flw-app-bar-toggle:hover,
.flw-app-bar-toggle:focus-visible {
	text-decoration: none;
	color: inherit;
}

.flw-app-bar-toggle:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: -2px;
}

.flw-app-bar-label {
	white-space: nowrap;
}

.flw-app-bar-caret {
	width: 10px;
	height: 10px;
	flex-shrink: 0;
	display: block;
	transition: transform 0.12s ease;
}

.flw-app-switcher[open] .flw-app-bar-caret {
	transform: rotate(180deg);
}

.flw-app-switcher-panel {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 50;
	box-sizing: border-box;
	min-width: 220px;
	max-width: min(320px, calc(100vw - 0.5rem));
	max-height: min(70vh, 420px);
	overflow-y: auto;
	padding: 0.35rem 0;
	background: #fff;
	color: #111;
	border: 1px solid #e5e5e5;
	border-top: 0;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.flw-app-switcher-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 44px;
	padding: 0.45rem 0.85rem;
	color: inherit;
	text-decoration: none;
	font: inherit;
	font-weight: 600;
}

.flw-app-switcher-item:hover,
.flw-app-switcher-item:focus-visible {
	text-decoration: none;
	color: inherit;
	background: #f5f5f5;
}

.flw-app-switcher-item[aria-current="page"] {
	background: #f5f5f5;
}

.flw-app-switcher-tag {
	font-size: 11px;
	font-weight: 600;
	color: #737373;
	letter-spacing: 0.02em;
}

.flw-app-switcher-sep {
	height: 1px;
	margin: 0.25rem 0;
	background: #e5e5e5;
}

.flw-app-bar-mark {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	display: block;
	fill: currentColor;
}

.dark .flw-app-bar,
html.dark .flw-app-bar {
	background: #000;
	color: #fff;
	border-bottom-color: #222;
}

.dark .flw-app-switcher-panel,
html.dark .flw-app-switcher-panel {
	background: #000;
	color: #fff;
	border-color: #222;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.dark .flw-app-switcher-item:hover,
.dark .flw-app-switcher-item:focus-visible,
.dark .flw-app-switcher-item[aria-current="page"],
html.dark .flw-app-switcher-item:hover,
html.dark .flw-app-switcher-item:focus-visible,
html.dark .flw-app-switcher-item[aria-current="page"] {
	background: #1a1a1a;
}

.dark .flw-app-switcher-tag,
html.dark .flw-app-switcher-tag {
	color: #a3a3a3;
}

.dark .flw-app-switcher-sep,
html.dark .flw-app-switcher-sep {
	background: #222;
}

@media (prefers-color-scheme: dark) {
	html:not(.light) .flw-app-bar {
		background: #000;
		color: #fff;
		border-bottom-color: #222;
	}

	html:not(.light) .flw-app-switcher-panel {
		background: #000;
		color: #fff;
		border-color: #222;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
	}

	html:not(.light) .flw-app-switcher-item:hover,
	html:not(.light) .flw-app-switcher-item:focus-visible,
	html:not(.light) .flw-app-switcher-item[aria-current="page"] {
		background: #1a1a1a;
	}

	html:not(.light) .flw-app-switcher-tag {
		color: #a3a3a3;
	}

	html:not(.light) .flw-app-switcher-sep {
		background: #222;
	}
}

.flw-app-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.85rem 1.1rem;
	border-bottom: 1px solid var(--line, #e7e5e4);
	background: color-mix(in srgb, #fff 88%, transparent);
	backdrop-filter: blur(8px);
	position: sticky;
	top: 0;
	z-index: 30;
}

.flw-chrome--with-app-bar.shell {
	grid-template-rows: auto auto 1fr auto;
}

.flw-chrome--with-app-bar .flw-app-header,
.flw-chrome--with-app-bar .topbar {
	top: var(--flw-app-bar-height);
}

.flw-app-header-brand {
	font-family: "Fraunces", Georgia, serif;
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--ink, #1c1917);
	text-decoration: none;
	line-height: 1.1;
}

.flw-app-header-brand:hover {
	text-decoration: none;
	color: var(--ink, #1c1917);
}

.flw-app-header-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 0.35rem 0.85rem;
	flex: 1;
}

.flw-app-header-nav a {
	color: var(--muted, #57534e);
	font-weight: 600;
	text-decoration: none;
	padding: 0.5rem 0.75rem;
	min-height: 44px;
	display: inline-flex;
	align-items: center;
	font-family: "Source Sans 3", system-ui, sans-serif;
	font-size: 0.95rem;
}

.flw-app-header-nav a[aria-current="page"],
.flw-app-header-nav a:hover {
	color: var(--ink, #1c1917);
	text-decoration: none;
}

.flw-app-header-actions {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: wrap;
}

.flw-app-header-actions form {
	margin: 0;
}

.flw-app-header .flw-app-header-btn,
.flw-app-header-actions button,
.flw-app-header-actions .btn {
	appearance: none;
	border: 1px solid var(--line, #e7e5e4);
	background: var(--panel, #fff);
	color: var(--ink, #1c1917);
	border-radius: 999px;
	padding: 0.55rem 1rem;
	font: inherit;
	font-family: "Source Sans 3", system-ui, sans-serif;
	font-weight: 600;
	font-size: 0.9rem;
	cursor: pointer;
	min-height: 44px;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.flw-app-header .flw-app-header-btn:hover,
.flw-app-header-actions button:hover {
	text-decoration: none;
	color: var(--ink, #1c1917);
}

.dark .flw-app-header,
html.dark .flw-app-header {
	background: color-mix(in srgb, var(--background, #1c1917) 88%, transparent);
	border-bottom-color: var(--border, #333);
}

.dark .flw-app-header-brand,
.dark .flw-app-header-brand:hover,
html.dark .flw-app-header-brand,
html.dark .flw-app-header-brand:hover {
	color: var(--foreground, #fafaf9);
}

.dark .flw-app-header-nav a,
html.dark .flw-app-header-nav a {
	color: var(--muted-foreground, #a8a29e);
}

.dark .flw-app-header-nav a[aria-current="page"],
.dark .flw-app-header-nav a:hover,
html.dark .flw-app-header-nav a[aria-current="page"],
html.dark .flw-app-header-nav a:hover {
	color: var(--foreground, #fafaf9);
}

.dark .flw-app-header .flw-app-header-btn,
.dark .flw-app-header-actions button,
html.dark .flw-app-header .flw-app-header-btn,
html.dark .flw-app-header-actions button {
	background: var(--card, #292524);
	border-color: var(--border, #444);
	color: var(--foreground, #fafaf9);
}

@media (max-width: 720px) {
	.flw-app-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.flw-app-header-nav {
		width: 100%;
	}
}
