/* =============================================================================
 * CyphCard — iOS design layer
 * -----------------------------------------------------------------------------
 * Loaded LAST on every page, after the page's own stylesheets.
 *
 *   1. System tokens      --ios-*  Apple-style semantic colours and glass
 *                                   materials for light and dark.
 *   2. Legacy tokens      --cc-*   Only defined in light mode. The legacy CSS
 *                                   was rewritten to var(--cc-..., original),
 *                                   so dark mode renders the original colours.
 *   3. Foundations        typography, tap feedback, focus, safe areas.
 *   4. Materials          Liquid-glass surfaces for the app's panels.
 *   5. Controls           buttons, fields, tables, badges.
 *   6. Appearance UI      floating theme button and segmented control.
 *   7. Responsive         phone / tablet / desktop adjustments.
 *
 * Specificity: rules are prefixed with `html` (or :root) so they win over the
 * page stylesheets without !important. `:where()` keeps a rule at zero
 * specificity where a page must still be able to override it.
 * ========================================================================== */

/* ------------------------------------------------------------ 1. System tokens */

:root {
	--ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--ios-font-rounded: ui-rounded, "SF Pro Rounded", var(--ios-font);
	--ios-font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

	/* iOS sheet / spring curve and a quick ease for small state changes. */
	--ios-ease: cubic-bezier(0.32, 0.72, 0, 1);
	--ios-ease-out: cubic-bezier(0.22, 1, 0.36, 1);

	--ios-r-xs: 8px;
	--ios-r-sm: 12px;
	--ios-r-md: 16px;
	--ios-r-lg: 22px;
	--ios-r-xl: 28px;

	--ios-blur: 28px;
	--ios-safe-top: env(safe-area-inset-top, 0px);
	--ios-safe-bottom: env(safe-area-inset-bottom, 0px);
	--ios-safe-left: env(safe-area-inset-left, 0px);
	--ios-safe-right: env(safe-area-inset-right, 0px);
}

/* Dark is the brand's native look and the default before the theme script
   runs, so it applies to :root as well as the explicit attribute. */
:root,
:root[data-theme="dark"] {
	color-scheme: dark;

	--ios-bg: #05071a;
	--ios-bg-2: #0b0f2a;
	--ios-bg-3: #141a3d;
	--ios-bg-elevated: #121737;

	--ios-label: #ffffff;
	--ios-label-2: rgba(235, 235, 245, 0.64);
	--ios-label-3: rgba(235, 235, 245, 0.34);
	--ios-separator: rgba(255, 255, 255, 0.12);
	--ios-fill: rgba(120, 120, 128, 0.32);
	--ios-fill-2: rgba(120, 120, 128, 0.22);
	--ios-fill-3: rgba(118, 118, 128, 0.14);

	--ios-accent: #6d8bff;
	--ios-accent-2: #8aa2ff;
	/* Deeper than the text accent so white labels on filled buttons pass
	   WCAG AA (about 4.9:1). */
	--ios-accent-fill: #3d5cf0;
	--ios-accent-tint: rgba(109, 139, 255, 0.18);
	--ios-on-accent: #ffffff;
	--ios-teal: #5eead4;
	--ios-green: #30d158;
	--ios-red: #ff453a;
	--ios-orange: #ff9f0a;
	--ios-yellow: #ffd60a;

	/* Liquid glass */
	--ios-glass: rgba(24, 30, 66, 0.52);
	--ios-glass-strong: rgba(18, 23, 55, 0.78);
	--ios-glass-thin: rgba(255, 255, 255, 0.07);
	--ios-glass-edge: rgba(255, 255, 255, 0.14);
	--ios-glass-highlight: rgba(255, 255, 255, 0.2);
	--ios-glass-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 16px 44px rgba(0, 0, 0, 0.42);
	--ios-glass-saturate: 170%;

	--ios-ambient-1: rgba(79, 110, 255, 0.28);
	--ios-ambient-2: rgba(94, 234, 212, 0.12);
	--ios-ambient-3: rgba(140, 90, 255, 0.14);
}

:root[data-theme="light"] {
	color-scheme: light;

	--ios-bg: #f2f2f7;
	--ios-bg-2: #ffffff;
	--ios-bg-3: #e8ebf4;
	--ios-bg-elevated: #ffffff;

	--ios-label: #0b0d17;
	--ios-label-2: rgba(60, 60, 67, 0.72);
	--ios-label-3: rgba(60, 60, 67, 0.36);
	--ios-separator: rgba(60, 60, 67, 0.16);
	--ios-fill: rgba(120, 120, 128, 0.2);
	--ios-fill-2: rgba(120, 120, 128, 0.14);
	--ios-fill-3: rgba(118, 118, 128, 0.1);

	--ios-accent: #2f55f5;
	--ios-accent-2: #1f44de;
	--ios-accent-fill: #2f55f5;
	--ios-accent-tint: rgba(47, 85, 245, 0.12);
	--ios-on-accent: #ffffff;
	--ios-teal: #0e8a7c;
	--ios-green: #248a3d;
	--ios-red: #d70015;
	--ios-orange: #c93400;
	--ios-yellow: #a05a00;

	--ios-glass: rgba(255, 255, 255, 0.62);
	--ios-glass-strong: rgba(255, 255, 255, 0.84);
	--ios-glass-thin: rgba(255, 255, 255, 0.46);
	--ios-glass-edge: rgba(255, 255, 255, 0.8);
	--ios-glass-highlight: rgba(255, 255, 255, 0.95);
	--ios-glass-shadow: 0 1px 2px rgba(20, 28, 70, 0.06), 0 14px 40px rgba(20, 28, 70, 0.1);
	--ios-glass-saturate: 190%;

	--ios-ambient-1: rgba(79, 110, 255, 0.16);
	--ios-ambient-2: rgba(20, 184, 166, 0.1);
	--ios-ambient-3: rgba(168, 85, 247, 0.08);

	/* ---------------------------------------------------- 2. Legacy tokens
	   Consumed by the rewritten legacy stylesheets. Never define these for
	   dark mode: the var() fallbacks already hold the original colours. */
	--cc-label: #0b0d17;
	--cc-fg-rgb: 17, 20, 38;
	--cc-glass-rgb: 255, 255, 255;
	--cc-glass-k: 7;
	--cc-line-rgb: 60, 60, 67;
	--cc-line-k: 1.5;
	--cc-shadow-rgb: 23, 31, 72;
	--cc-shadow-k: 0.32;
	--cc-shade-rgb: 60, 60, 67;
	--cc-shade-k: 0.35;

	/* Legacy variables that the pages read directly. */
	--cc-nav-bg: rgba(255, 255, 255, 0.72);
	--cc-nav-border: rgba(255, 255, 255, 0.85);
	--cc-nav-icon: rgba(60, 60, 67, 0.64);
	--cc-nav-active: #2f55f5;
	--cc-nav-active-bg: rgba(47, 85, 245, 0.12);
}

/* Button variants that swap an accent background for glass (.admin-btn
   .secondary, .v4-btn.secondary, ...) inherit the base button's white label
   from a different rule, which a per-rule colour rewrite cannot see. */
:root[data-theme="light"] :is(a, button, input)[class*="btn"]:is(.secondary, .ghost, .outline, .subtle, .soft, .plain, .light) {
	color: var(--ios-label);
}

/* Dark islands: content that stays dark in both themes (the payment card
   artwork, the splash). Resets the legacy tokens to their dark values; the
   generated per-colour tokens are reset in cc-tokens.css. */
:root[data-theme="light"] :is(.cc-dark-island, .bank-card, #ccSplash) {
	color-scheme: dark;
	--cc-label: #ffffff;
	--cc-fg-rgb: 255, 255, 255;
	--cc-glass-rgb: 255, 255, 255;
	--cc-glass-k: 1;
	--cc-line-rgb: 255, 255, 255;
	--cc-line-k: 1;
	--cc-shadow-rgb: 0, 0, 0;
	--cc-shadow-k: 1;
	--cc-shade-rgb: 0, 0, 0;
	--cc-shade-k: 1;
	--ios-label: #ffffff;
	--ios-label-2: rgba(235, 235, 245, 0.64);
	/* Resetting the variables is not enough: text that sets no colour of its
	   own inherits the parent's already-resolved (dark) colour. */
	color: #ffffff;
}

/* ------------------------------------------------------------ 3. Foundations */

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	-webkit-tap-highlight-color: transparent;
}

html body {
	font-family: var(--ios-font);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	font-feature-settings: "kern", "ss01";
	/* Clip rather than hide, so position: sticky keeps working. */
	overflow-x: clip;
}

html :is(button, input, select, textarea, optgroup) {
	font-family: inherit;
}

html :is(h1, h2, h3) {
	letter-spacing: -0.022em;
}

/* Numbers in balances and tables line up like a banking app. */
html :is(td, .amount, [class*="balance"], [class*="amount"], [class*="metric"] strong) {
	font-variant-numeric: tabular-nums;
}

html :is(img, video, canvas, svg) {
	max-width: 100%;
}

html :is(button, [role="button"], a, summary, label, select) {
	touch-action: manipulation;
}

/* Tap feedback. The standalone `scale` property composes with any transform a
   page already uses (translateY(-50%) on an icon button, for example), so the
   press never moves an element out of position. */
html :is(button, [role="button"], input[type="button"], input[type="submit"], a[class*="btn"], a[class*="button"]) {
	transition-property: scale, background-color, border-color, color, opacity, box-shadow, transform;
	transition-duration: 0.18s;
	transition-timing-function: var(--ios-ease-out);
}

html :is(button, [role="button"], input[type="button"], input[type="submit"], a[class*="btn"], a[class*="button"]):not(:disabled):active {
	scale: 0.965;
	transition-duration: 0.06s;
}

html :focus-visible {
	outline: 3px solid color-mix(in srgb, var(--ios-accent) 55%, transparent);
	outline-offset: 2px;
}

/* Text fields always match :focus-visible while focused, so the ring above
   drew a hard rectangle inside every field (and inside grouped fields with
   their own glow). Fields show focus as a soft glow instead; :where() keeps
   it at zero specificity so a page's own field focus style wins. */
html :is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="button"], [type="submit"], [type="reset"], [type="file"]), textarea, select):focus-visible {
	outline: none;
}

:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="button"], [type="submit"], [type="reset"], [type="file"]), textarea, select):focus-visible {
	box-shadow: 0 0 0 3px var(--ios-accent-tint);
}

/* Browser autofill paints a tinted block behind the value. Clipping the
   background to the text hides that block under the glyphs, so a filled
   field keeps the app's own background. The long transition is a fallback
   for engines that ignore the clip. */
html :is(input, textarea, select):is(:-webkit-autofill, :autofill) {
	-webkit-background-clip: text;
	background-clip: text;
	transition: background-color 600000s 0s, color 600000s 0s;
}

html ::selection {
	background: color-mix(in srgb, var(--ios-accent) 30%, transparent);
}

/* Touch devices: iOS zooms the page into any field under 16px. */
@media (pointer: coarse) {
	html :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
		font-size: max(16px, 1em);
	}
}

/* Thin, theme-aware scrollbars on desktop. */
@media (pointer: fine) {
	html {
		scrollbar-width: thin;
		scrollbar-color: var(--ios-fill) transparent;
	}
}

/* Theme switch cross-fade (see cc-theme.js). */
::view-transition-old(root),
::view-transition-new(root) {
	animation-duration: 0.32s;
	animation-timing-function: var(--ios-ease-out);
}

/* ------------------------------------------------------------- 4. Materials */

/* The ambient light behind the glass. Glass needs something to refract: a
   flat background makes every translucent surface look like a grey box. */
html body::before {
	content: "";
	position: fixed;
	inset: -10vmax;
	z-index: -1;
	pointer-events: none;
	background:
		radial-gradient(40vmax 34vmax at 12% 6%, var(--ios-ambient-1), transparent 70%),
		radial-gradient(36vmax 30vmax at 92% 18%, var(--ios-ambient-3), transparent 70%),
		radial-gradient(44vmax 36vmax at 70% 100%, var(--ios-ambient-2), transparent 70%);
}

/* Liquid glass. Top-level panels across every page family: translucent fill,
   heavy blur with saturation boost, a bright hairline on the top edge (the
   specular highlight) and a soft ambient shadow. */
html :is(
	.cc-panel, .cc-card, .cc-stat,
	.hero-card, .activity-panel, .metric-card, .stat-card, .panel,
	.balance-card, .portal-profile-card,
	.admin-card, .admin-panel, .table-card, .data-card,
	.wallet-card, .wallet-panel, .asset-card, .assets-card,
	.mk-panel, .mk-card,
	.profile-card, .profile-panel, .settings-card,
	.comm-card, .comm-panel, .v4-card,
	.tx-card, .tx-panel,
	.notice-card, .notification-card,
	.cc-glass
) {
	-webkit-backdrop-filter: blur(var(--ios-blur)) saturate(var(--ios-glass-saturate));
	backdrop-filter: blur(var(--ios-blur)) saturate(var(--ios-glass-saturate));
	box-shadow: inset 0 1px 0 var(--ios-glass-highlight), var(--ios-glass-shadow);
}

/* A panel inside a panel would blur the blur. Only the outermost surface gets
   the backdrop filter, which is also what keeps scrolling smooth on phones. */
html :is(.cc-panel, .cc-card, .hero-card, .panel, .mk-panel, .wallet-card, .admin-card, .table-card) :is(.cc-panel, .cc-card, .cc-stat, .panel, .metric-card, .stat-card, .mk-card, .asset-card) {
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
	box-shadow: none;
}

@media (prefers-reduced-transparency: reduce) {
	html * {
		-webkit-backdrop-filter: none !important;
		backdrop-filter: none !important;
	}
}

/* -------------------------------------------------------------- 5. Controls */

/* Activity indicator: the iOS eight-spoke spinner, drawn as an SVG mask so it
   takes the colour of whatever it sits on. */
:root {
	--ios-spinner: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg stroke='%23000' stroke-width='2.4' stroke-linecap='round'%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='1'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.88' transform='rotate(-45 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.76' transform='rotate(-90 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.64' transform='rotate(-135 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.52' transform='rotate(-180 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.4' transform='rotate(-225 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.3' transform='rotate(-270 12 12)'/%3E%3Cline x1='12' y1='2.8' x2='12' y2='7' opacity='.22' transform='rotate(-315 12 12)'/%3E%3C/g%3E%3C/svg%3E");
}

@keyframes iosSpin {
	to {
		rotate: 360deg;
	}
}

.ios-activity {
	display: inline-block;
	width: 1.15em;
	height: 1.15em;
	flex: 0 0 auto;
	vertical-align: -0.2em;
	background: currentColor;
	-webkit-mask: var(--ios-spinner) center / contain no-repeat;
	mask: var(--ios-spinner) center / contain no-repeat;
	animation: iosSpin 0.8s steps(8) infinite;
}

/* Component display rules (inline-flex, inline-block) would otherwise beat
   the [hidden] attribute, so hidden controls stayed visible. */
:is(.ios-activity, .ios-btn, .ios-switch, .cc-push-prompt, .cc-push-control)[hidden] {
	display: none !important;
}

/* Pages that draw their own Font Awesome spinner get the same indicator, so
   every loading state in the app looks alike. */
html :is(.fa-spinner, .fa-circle-notch, .fa-rotate).fa-spin {
	display: inline-block;
	width: 1.1em;
	height: 1.1em;
	vertical-align: -0.18em;
	background: currentColor;
	-webkit-mask: var(--ios-spinner) center / contain no-repeat;
	mask: var(--ios-spinner) center / contain no-repeat;
	animation: iosSpin 0.8s steps(8) infinite;
}

html :is(.fa-spinner, .fa-circle-notch, .fa-rotate).fa-spin::before {
	content: none;
}

@media (prefers-reduced-motion: reduce) {
	.ios-activity,
	html :is(.fa-spinner, .fa-circle-notch, .fa-rotate).fa-spin {
		animation-duration: 1.6s;
	}
}

/* Buttons. Capsule shapes with iOS fill styles:
     filled  primary action          tinted  secondary, accent-coloured
     gray    neutral                 plain   text-only
   .is-busy keeps the button's exact size: the label turns transparent and
   the activity indicator sits centred on top, so nothing shifts on tap. */
.ios-btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 44px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	font: 600 16px/1.2 var(--ios-font);
	letter-spacing: -0.01em;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	user-select: none;
	-webkit-user-select: none;
}

.ios-btn--large {
	width: 100%;
	min-height: 52px;
	font-size: 17px;
}

.ios-btn--filled {
	color: var(--ios-on-accent);
	background: var(--ios-accent-fill, var(--ios-accent));
	box-shadow:
		inset 0 1px 0 rgba(255, 255, 255, 0.24),
		0 8px 22px -6px color-mix(in srgb, var(--ios-accent) 60%, transparent);
}

.ios-btn--filled:hover:not(:disabled) {
	background: color-mix(in srgb, var(--ios-accent-fill, var(--ios-accent)) 88%, #000);
}

.ios-btn--tinted {
	color: var(--ios-accent);
	background: var(--ios-accent-tint);
}

.ios-btn--tinted:hover:not(:disabled) {
	background: color-mix(in srgb, var(--ios-accent) 22%, transparent);
}

.ios-btn--gray {
	color: var(--ios-label);
	background: var(--ios-fill-2);
}

.ios-btn--gray:hover:not(:disabled) {
	background: var(--ios-fill);
}

.ios-btn--plain {
	color: var(--ios-accent);
	background: transparent;
}

.ios-btn--plain:hover:not(:disabled) {
	background: var(--ios-fill-3);
}

.ios-btn:disabled {
	cursor: default;
	opacity: 0.5;
}

.ios-btn.is-busy:disabled {
	opacity: 1;
	cursor: progress;
}

.ios-btn__label {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: opacity 0.15s var(--ios-ease-out);
}

.ios-btn__icon {
	width: 20px;
	height: 20px;
	flex: 0 0 auto;
}

.ios-btn.is-busy .ios-btn__label {
	opacity: 0;
}

.ios-btn.is-busy > .ios-activity {
	position: absolute;
	inset: 0;
	margin: auto;
	width: 22px;
	height: 22px;
}

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

/* Inset grouped lists, as in iOS Settings. Used by rebuilt pages. */
html body:has(> .ios-page) {
	margin: 0;
}

.ios-page,
.ios-page * {
	box-sizing: border-box;
}

.ios-page {
	width: min(720px, 100%);
	margin: 0 auto;
	padding:
		max(20px, calc(var(--ios-safe-top) + 12px))
		max(16px, calc(var(--ios-safe-right) + 16px))
		max(96px, calc(var(--ios-safe-bottom) + 88px))
		max(16px, calc(var(--ios-safe-left) + 16px));
	color: var(--ios-label);
}

.ios-nav {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: 44px;
	margin-bottom: 4px;
}

.ios-nav a,
.ios-nav button {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 8px 0;
	border: 0;
	background: none;
	color: var(--ios-accent);
	font: 400 17px/1 var(--ios-font);
	text-decoration: none;
	cursor: pointer;
}

.ios-large-title {
	margin: 4px 4px 22px;
	font-size: 34px;
	font-weight: 700;
	line-height: 1.12;
	letter-spacing: -0.03em;
}

.ios-section {
	margin: 0 0 28px;
}

.ios-section__header,
.ios-section__footer {
	margin: 0 16px 7px;
	font-size: 13px;
	line-height: 1.4;
	color: var(--ios-label-2);
}

.ios-section__header {
	text-transform: uppercase;
	letter-spacing: 0.02em;
}

.ios-section__footer {
	margin: 7px 16px 0;
}

.ios-list {
	overflow: hidden;
	border: 0.5px solid var(--ios-glass-edge);
	border-radius: 20px;
	background: var(--ios-glass);
	-webkit-backdrop-filter: blur(var(--ios-blur)) saturate(var(--ios-glass-saturate));
	backdrop-filter: blur(var(--ios-blur)) saturate(var(--ios-glass-saturate));
	box-shadow: inset 0 1px 0 var(--ios-glass-highlight), var(--ios-glass-shadow);
}

.ios-cell {
	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 52px;
	padding: 8px 16px;
	font-size: 17px;
}

.ios-cell + .ios-cell::before {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	left: 16px;
	height: 0.5px;
	background: var(--ios-separator);
}

.ios-cell__label {
	flex: 1 1 auto;
	min-width: 0;
}

.ios-cell :is(input, select) {
	flex: 0 1 55%;
	min-width: 0;
	height: 36px;
	padding: 0;
	border: 0;
	outline: none;
	background: transparent;
	color: var(--ios-label-2);
	font: 400 17px/1.2 var(--ios-font);
	text-align: right;
}

.ios-cell :is(input, select):focus {
	color: var(--ios-label);
}

/* Inline fields in a list row: the row highlights, the field stays flat. */
.ios-cell :is(input, select):focus-visible {
	box-shadow: none;
}

.ios-cell:focus-within {
	background: var(--ios-fill-3);
}

.ios-cell select {
	text-align-last: right;
	cursor: pointer;
}

.ios-cell--stack {
	display: grid;
	gap: 10px;
	padding-block: 14px;
}

.ios-cell--button {
	width: 100%;
	border: 0;
	background: transparent;
	color: var(--ios-accent);
	font: 400 17px/1.2 var(--ios-font);
	text-align: left;
	cursor: pointer;
}

.ios-cell--button:hover {
	background: var(--ios-fill-3);
}

.ios-cell--destructive {
	color: var(--ios-red);
}

/* Tables scroll sideways inside their panel instead of stretching the page. */
html :is(.table-wrap, .table-wrapper, .table-container, .table-scroll, .cc-table-wrap, [class*="table-card"]) {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior-x: contain;
}

html :where(table) {
	border-collapse: separate;
	border-spacing: 0;
}

html :where(th) {
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--ios-label-2);
}

/* Native form controls follow the theme and the accent. */
html :is(input[type="checkbox"], input[type="radio"], input[type="range"], progress) {
	accent-color: var(--ios-accent);
}

html :where(select) {
	color-scheme: inherit;
}

/* ------------------------------------------------------- 6. Appearance UI */

.cc-theme-fab {
	position: fixed;
	right: max(16px, calc(var(--ios-safe-right) + 12px));
	bottom: max(18px, calc(var(--ios-safe-bottom) + 14px));
	z-index: 1450;
	font-family: var(--ios-font);
}

/* Lift above the floating tab bar on user pages. */
body[data-cc-icon-nav] .cc-theme-fab {
	bottom: calc(max(10px, var(--ios-safe-bottom)) + 66px + 14px);
}

.cc-theme-fab__button {
	width: 46px;
	height: 46px;
	display: grid;
	place-items: center;
	padding: 0;
	border: 0.5px solid var(--ios-glass-edge);
	border-radius: 999px;
	color: var(--ios-label);
	background: var(--ios-glass);
	-webkit-backdrop-filter: blur(22px) saturate(var(--ios-glass-saturate));
	backdrop-filter: blur(22px) saturate(var(--ios-glass-saturate));
	box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 10px 30px rgba(0, 0, 0, 0.22);
	cursor: pointer;
}

.cc-theme-fab__button:hover {
	background: var(--ios-glass-strong);
}

.cc-theme-fab__icon,
.cc-theme-menu__icon {
	display: grid;
	place-items: center;
	line-height: 0;
}

.cc-theme-fab svg,
.cc-segmented svg {
	width: 21px;
	height: 21px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cc-theme-fab svg .cc-fill,
.cc-segmented svg .cc-fill {
	fill: currentColor;
	stroke: none;
}

.cc-theme-menu {
	position: absolute;
	right: 0;
	bottom: calc(100% + 10px);
	width: 220px;
	padding: 6px;
	border: 0.5px solid var(--ios-glass-edge);
	border-radius: 18px;
	color: var(--ios-label);
	background: var(--ios-glass-strong);
	-webkit-backdrop-filter: blur(30px) saturate(var(--ios-glass-saturate));
	backdrop-filter: blur(30px) saturate(var(--ios-glass-saturate));
	box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 22px 60px rgba(0, 0, 0, 0.3);
	transform-origin: bottom right;
	opacity: 0;
	scale: 0.86;
	transition: opacity 0.18s var(--ios-ease-out), scale 0.26s var(--ios-ease);
}

.cc-theme-fab.is-open .cc-theme-menu {
	opacity: 1;
	scale: 1;
}

.cc-theme-menu__title {
	padding: 8px 12px 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--ios-label-2);
}

.cc-theme-menu button {
	width: 100%;
	min-height: 44px;
	display: grid;
	grid-template-columns: 24px 1fr 20px;
	align-items: center;
	gap: 10px;
	padding: 0 12px;
	border: 0;
	border-radius: 12px;
	color: inherit;
	background: transparent;
	font: 500 16px/1.2 var(--ios-font);
	text-align: left;
	cursor: pointer;
}

.cc-theme-menu button:hover,
.cc-theme-menu button:focus-visible {
	background: var(--ios-fill-2);
	outline: none;
}

.cc-theme-menu__check {
	color: var(--ios-accent);
	opacity: 0;
	line-height: 0;
}

.cc-theme-menu__check svg {
	width: 18px;
	height: 18px;
	stroke-width: 2.4;
}

.cc-theme-menu button[aria-checked="true"] .cc-theme-menu__check {
	opacity: 1;
}

/* Segmented control, iOS style: a sliding thumb under three equal segments. */
.cc-segmented {
	--cc-seg-count: 3;
	position: relative;
	display: grid;
	grid-template-columns: repeat(var(--cc-seg-count), minmax(0, 1fr));
	width: 100%;
	max-width: 420px;
	padding: 3px;
	border-radius: 12px;
	background: var(--ios-fill-2);
	isolation: isolate;
}

.cc-segmented__thumb {
	position: absolute;
	z-index: -1;
	top: 3px;
	bottom: 3px;
	left: 3px;
	width: calc((100% - 6px) / var(--cc-seg-count));
	border-radius: 9px;
	background: var(--ios-bg-elevated);
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
	translate: calc(var(--cc-seg-index, 0) * 100%) 0;
	transition: translate 0.32s var(--ios-ease);
}

:root[data-theme="dark"] .cc-segmented__thumb {
	background: #636366;
}

.cc-segmented button {
	min-height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 6px 8px;
	border: 0;
	border-radius: 9px;
	color: var(--ios-label);
	background: transparent;
	font: 600 14px/1 var(--ios-font);
	cursor: pointer;
}

.cc-segmented button svg {
	width: 17px;
	height: 17px;
}

.cc-segmented button[aria-checked="false"] {
	color: var(--ios-label-2);
}

/* The inline control on Profile / Settings sits in its own labelled row. */
.cc-appearance-row {
	display: grid;
	gap: 10px;
	margin: 18px 0;
}

.cc-appearance-row > span {
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	color: var(--ios-label-2);
}

/* ---------------------------------------------------- Push notifications */

/* iOS switch: 51 x 31 track, knob slides, green when on. */
.ios-switch {
	position: relative;
	flex: 0 0 auto;
	width: 51px;
	height: 31px;
	padding: 0;
	border: 0;
	border-radius: 999px;
	background: var(--ios-fill);
	cursor: pointer;
	transition: background-color 0.25s var(--ios-ease-out);
}

.ios-switch[aria-checked="true"] {
	background: #34c759;
}

.ios-switch:disabled {
	cursor: default;
	opacity: 0.5;
}

.ios-switch[aria-busy="true"] {
	cursor: progress;
	opacity: 0.75;
}

.ios-switch__knob {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 27px;
	height: 27px;
	border-radius: 999px;
	background: #fff;
	box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 3px 1px rgba(0, 0, 0, 0.06);
	transition: translate 0.3s var(--ios-ease);
}

.ios-switch[aria-checked="true"] .ios-switch__knob {
	translate: 20px 0;
}

.cc-push-control {
	display: grid;
	gap: 12px;
	width: 100%;
}

.cc-push-row {
	display: flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
}

.cc-push-row__icon {
	width: 30px;
	height: 30px;
	flex: 0 0 auto;
	display: grid;
	place-items: center;
	border-radius: 8px;
	color: #fff;
	background: #ff3b30;
}

.cc-push-row__icon svg,
.cc-push-prompt__icon svg {
	width: 18px;
	height: 18px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.9;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.cc-push-row__text {
	display: grid;
	flex: 1 1 auto;
	gap: 2px;
	min-width: 0;
}

.cc-push-row__title {
	font-size: 17px;
	color: var(--ios-label);
}

.cc-push-row__detail {
	font-size: 13px;
	line-height: 1.35;
	color: var(--ios-label-2);
}

.cc-push-control[data-state="denied"] .cc-push-row__detail {
	color: var(--ios-orange);
}

/* One-time prompt: a floating card above the tab bar, like an iOS banner. */
.cc-push-prompt {
	position: fixed;
	left: 50%;
	bottom: max(16px, calc(var(--ios-safe-bottom) + 12px));
	z-index: 1460;
	display: grid;
	grid-template-columns: 44px 1fr;
	gap: 12px 14px;
	width: min(calc(100% - 24px), 440px);
	padding: 16px;
	border: 0.5px solid var(--ios-glass-edge);
	border-radius: 26px;
	color: var(--ios-label);
	background: var(--ios-glass-strong);
	-webkit-backdrop-filter: blur(30px) saturate(var(--ios-glass-saturate));
	backdrop-filter: blur(30px) saturate(var(--ios-glass-saturate));
	box-shadow: inset 0 1px 0 var(--ios-glass-highlight), 0 22px 60px rgba(0, 0, 0, 0.3);
	font-family: var(--ios-font);
	opacity: 0;
	translate: -50% 24px;
	transition: opacity 0.25s var(--ios-ease-out), translate 0.45s var(--ios-ease);
}

body[data-cc-icon-nav] .cc-push-prompt {
	bottom: calc(max(10px, var(--ios-safe-bottom)) + 66px + 12px);
}

.cc-push-prompt.is-visible {
	opacity: 1;
	translate: -50% 0;
}

.cc-push-prompt__icon {
	width: 44px;
	height: 44px;
	display: grid;
	place-items: center;
	border-radius: 12px;
	color: #fff;
	background: #ff3b30;
}

.cc-push-prompt__icon svg {
	width: 24px;
	height: 24px;
}

.cc-push-prompt__copy strong {
	display: block;
	margin-bottom: 3px;
	font-size: 16px;
	font-weight: 600;
}

.cc-push-prompt__copy p {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--ios-label-2);
}

.cc-push-prompt__actions {
	grid-column: 1 / -1;
	display: flex;
	gap: 10px;
}

.cc-push-prompt__actions .ios-btn {
	flex: 1;
}

@media (prefers-reduced-motion: reduce) {
	.ios-switch,
	.ios-switch__knob,
	.cc-push-prompt {
		transition: none;
	}
}

/* ------------------------------------------------------------ 7. Responsive */

@media (max-width: 640px) {
	.cc-theme-fab__button {
		width: 42px;
		height: 42px;
	}
}

@media print {
	.cc-theme-fab,
	html body::before {
		display: none !important;
	}
}
