/* =========================================================================
   PostYard Frontend — full takeover CSS
   ========================================================================= */

:root {
	--py-primary:        #1a56db;
	--py-primary-hover:  #1341a8;
	--py-primary-soft:   #eff4fe;
	--py-success:        #0e7c59;
	--py-success-soft:   #ecfdf5;
	--py-warning:        #b45309;
	--py-warning-soft:   #fef3c7;
	--py-danger:         #c81e1e;
	--py-danger-soft:    #fef2f2;

	--py-ink:            #0f172a;
	--py-ink-muted:      #475569;
	--py-ink-subtle:     #64748b;
	--py-border:         #e2e8f0;
	--py-border-strong:  #cbd5e1;
	--py-surface:        #ffffff;
	--py-surface-alt:    #f8fafc;
	--py-bg:             #f1f5f9;

	--py-radius:         12px;
	--py-radius-sm:      8px;
	--py-radius-lg:      18px;
	--py-shadow-sm:      0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
	--py-shadow:         0 4px 12px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
	--py-shadow-lg:      0 12px 32px rgba(15,23,42,.10), 0 4px 12px rgba(15,23,42,.06);

	--py-sidebar-w:      260px;
	--py-topbar-h:       72px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.py-body {
	margin: 0;
	padding: 0;
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: var(--py-ink);
	background: var(--py-bg);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

a { color: var(--py-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }

/* =========================================================================
   Logo
   ========================================================================= */

.py-logo-mark {
	display: inline-block;
	width: 32px;
	height: 32px;
	background: linear-gradient(135deg, var(--py-primary) 0%, #4f46e5 100%);
	border-radius: 8px;
	position: relative;
	flex-shrink: 0;
}
.py-logo-mark::before,
.py-logo-mark::after {
	content: '';
	position: absolute;
	background: #fff;
	border-radius: 1px;
}
.py-logo-mark::before { left: 7px;  top: 9px;  width: 18px; height: 3px; }
.py-logo-mark::after  { left: 7px;  top: 15px; width: 12px; height: 3px; box-shadow: 0 6px 0 #fff; }

.py-logo-mark--lg { width: 48px; height: 48px; border-radius: 12px; }
.py-logo-mark--lg::before { left: 10px; top: 14px; width: 28px; height: 4px; }
.py-logo-mark--lg::after  { left: 10px; top: 23px; width: 18px; height: 4px; box-shadow: 0 9px 0 #fff; }

.py-logo-text {
	font-size: 18px;
	font-weight: 600;
	letter-spacing: -0.4px;
	color: var(--py-ink);
}
.py-logo-text strong {
	color: var(--py-primary);
	font-weight: 800;
}

.py-logo-text--lg { font-size: 28px; }

/* =========================================================================
   App layout
   ========================================================================= */

.py-app {
	display: grid;
	grid-template-columns: var(--py-sidebar-w) 1fr;
	min-height: 100vh;
}

.py-sidebar {
	background: var(--py-surface);
	border-right: 1px solid var(--py-border);
	padding: 24px 16px;
	display: flex;
	flex-direction: column;
	position: sticky;
	top: 0;
	height: 100vh;
}

.py-sidebar__brand a {
	display: flex;
	align-items: center;
	gap: 10px;
	color: var(--py-ink);
	padding: 4px 8px;
	margin-bottom: 32px;
}
.py-sidebar__brand a:hover { text-decoration: none; }

.py-nav {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1;
}

.py-nav__item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 12px;
	border-radius: var(--py-radius-sm);
	color: var(--py-ink-muted);
	font-weight: 500;
	font-size: 14px;
	transition: all .15s ease;
}

.py-nav__item svg {
	width: 18px; height: 18px;
	stroke: currentColor;
	stroke-linejoin: round;
	stroke-linecap: round;
}

.py-nav__item:hover {
	background: var(--py-surface-alt);
	color: var(--py-ink);
	text-decoration: none;
}

.py-nav__item.is-active {
	background: var(--py-primary-soft);
	color: var(--py-primary);
	font-weight: 600;
}

.py-nav__badge {
	margin-left: auto;
	background: var(--py-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	padding: 2px 7px;
	border-radius: 999px;
	min-width: 20px;
	text-align: center;
}

.py-sidebar__user {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px;
	margin-top: 16px;
	border-top: 1px solid var(--py-border);
	padding-top: 16px;
}
.py-user-avatar {
	width: 36px; height: 36px;
	background: linear-gradient(135deg, #6366f1, #8b5cf6);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	font-weight: 600;
	font-size: 14px;
}
.py-user-name { font-weight: 600; font-size: 13px; }
.py-user-logout { font-size: 12px; color: var(--py-ink-subtle); }

/* Main column */

.py-main {
	min-width: 0;
}

.py-topbar {
	height: var(--py-topbar-h);
	background: var(--py-surface);
	border-bottom: 1px solid var(--py-border);
	padding: 0 32px;
	display: flex;
	align-items: center;
	position: sticky;
	top: 0;
	z-index: 10;
}

.py-topbar__title {
	margin: 0;
	font-size: 20px;
	font-weight: 700;
	letter-spacing: -0.3px;
}

.py-content {
	padding: 32px;
	max-width: 1400px;
}

/* =========================================================================
   Stats
   ========================================================================= */

.py-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 32px;
}

.py-stat {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 20px 22px;
	box-shadow: var(--py-shadow-sm);
}

.py-stat__number {
	display: block;
	font-size: 32px;
	font-weight: 700;
	line-height: 1;
	color: var(--py-primary);
	letter-spacing: -1px;
}

.py-stat--warning .py-stat__number { color: var(--py-warning); }
.py-stat--success .py-stat__number { color: var(--py-success); }
.py-stat--neutral .py-stat__number { color: var(--py-ink-muted); }

.py-stat__label {
	display: block;
	margin-top: 6px;
	font-size: 12px;
	font-weight: 600;
	color: var(--py-ink-subtle);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* =========================================================================
   Section
   ========================================================================= */

.py-section {
	background: transparent;
	margin-bottom: 32px;
}

.py-section__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.py-section__header h2 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: -0.3px;
}

.py-section__header small {
	color: var(--py-ink-subtle);
	font-size: 13px;
}

.py-section--muted {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 24px;
	color: var(--py-ink-muted);
}

.py-link {
	color: var(--py-primary);
	font-weight: 500;
	font-size: 13px;
}

/* =========================================================================
   Post cards
   ========================================================================= */

.py-post-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
	gap: 20px;
}

/* List view — one post per row, full-size square image at 1/3 width */
.py-post-list {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
.py-post-list .py-card {
	flex-direction: row;
	align-items: stretch;
}
.py-post-list .py-card__media {
	flex: 0 0 33%;
	width: 33%;
	max-width: 360px;
	min-width: 240px;
	aspect-ratio: 1 / 1;
}
.py-post-list .py-card__body {
	flex: 1;
	padding: 22px 26px;
}
.py-post-list .py-card__caption {
	-webkit-line-clamp: 7;
}
@media (max-width: 720px) {
	.py-post-list .py-card { flex-direction: column; }
	.py-post-list .py-card__media { width: 100%; max-width: none; flex: 0 0 auto; }
}

.py-card {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	box-shadow: var(--py-shadow-sm);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: all .2s ease;
}
.py-card:hover {
	box-shadow: var(--py-shadow);
	transform: translateY(-1px);
}

.py-card__media {
	position: relative;
	aspect-ratio: 1200 / 628;
	background: var(--py-surface-alt);
	overflow: hidden;
}
.py-card__media img {
	width: 100%; height: 100%;
	object-fit: cover;
	display: block;
}

.py-card__placeholder {
	width: 100%; height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
	color: var(--py-primary);
	font-weight: 600;
	font-size: 14px;
	text-align: center;
	padding: 24px;
}

.py-card__platform {
	position: absolute;
	top: 12px;
	right: 12px;
	font-size: 11px;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	gap: 5px;
	backdrop-filter: blur(8px);
}

.py-card__body {
	padding: 18px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	flex: 1;
}

.py-card__brand {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.5px;
	color: var(--py-primary);
	text-transform: uppercase;
}

.py-card__caption {
	margin: 0;
	font-size: 13px;
	line-height: 1.55;
	color: var(--py-ink);
	display: -webkit-box;
	-webkit-line-clamp: 5;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.py-card__tags {
	margin: 0;
	font-size: 12px;
	color: var(--py-primary);
}

.py-card__meta {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-top: auto;
}

.py-card__time,
.py-card__rev {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 500;
	color: var(--py-ink-subtle);
	background: var(--py-surface-alt);
	padding: 4px 9px;
	border-radius: 999px;
	border: 1px solid var(--py-border);
}

.py-card__rejection {
	background: var(--py-warning-soft);
	border: 1px solid #fcd34d;
	border-radius: var(--py-radius-sm);
	padding: 10px 12px;
	font-size: 12px;
	color: #78350f;
	line-height: 1.5;
}

.py-card__actions {
	display: flex;
	gap: 8px;
	margin-top: 4px;
}

.py-card__reject-form {
	border-top: 1px solid var(--py-border);
	margin-top: 8px;
	padding-top: 12px;
}

.py-card__reject-note {
	width: 100%;
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	padding: 10px;
	font-family: inherit;
	font-size: 13px;
	resize: vertical;
}
.py-card__reject-note:focus {
	outline: none;
	border-color: var(--py-primary);
	box-shadow: 0 0 0 3px var(--py-primary-soft);
}
.py-card__reject-note--error {
	border-color: var(--py-danger) !important;
	box-shadow: 0 0 0 3px var(--py-danger-soft) !important;
}
.py-card__reject-note--error::placeholder {
	color: var(--py-danger);
}

.py-card__reject-actions {
	margin-top: 8px;
	display: flex;
	gap: 8px;
}

.py-card--loading { opacity: .5; pointer-events: none; }
.py-card--approved {
	background: var(--py-success-soft);
	border-color: var(--py-success);
}
.py-card--rejected {
	background: var(--py-danger-soft);
	border-color: var(--py-danger);
}

/* Status banner shown instead of approve/reject buttons for non-pending posts */
.py-card__status {
	padding: 12px 14px;
	border-radius: var(--py-radius-sm);
	font-size: 13px;
	font-weight: 600;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.py-card__status small {
	font-size: 11px;
	font-weight: 500;
	opacity: .8;
}
.py-card__status--approved {
	background: var(--py-success-soft);
	color: var(--py-success);
	border: 1px solid #6ee7b7;
}
.py-card__status--scheduled {
	background: var(--py-primary-soft);
	color: var(--py-primary);
	border: 1px solid #93c5fd;
}
.py-card__status--rejected {
	background: var(--py-warning-soft);
	color: var(--py-warning);
	border: 1px solid #fcd34d;
}

/* =========================================================================
   Platform badges
   ========================================================================= */

.py-platform {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 8px;
	border-radius: 999px;
	color: #fff;
}
.py-platform--linkedin  { background: #0077b5; }
.py-platform--instagram { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); }
.py-platform--facebook  { background: #1877f2; }
.py-platform--twitter,
.py-platform--x         { background: #000; }

/* =========================================================================
   Buttons
   ========================================================================= */

.py-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 16px;
	border-radius: var(--py-radius-sm);
	border: 1px solid transparent;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: all .12s ease;
	font-family: inherit;
	white-space: nowrap;
}
.py-btn:disabled { opacity: .5; cursor: not-allowed; }

.py-btn--primary {
	background: var(--py-primary);
	color: #fff;
	border-color: var(--py-primary);
	flex: 1;
}
.py-btn--primary:hover {
	background: var(--py-primary-hover);
	border-color: var(--py-primary-hover);
	text-decoration: none;
	color: #fff;
}

.py-btn--ghost {
	background: var(--py-surface);
	color: var(--py-ink-muted);
	border-color: var(--py-border);
}
.py-btn--ghost:hover {
	background: var(--py-surface-alt);
	color: var(--py-ink);
	border-color: var(--py-border-strong);
}

.py-btn--danger {
	background: var(--py-danger);
	color: #fff;
	border-color: var(--py-danger);
}
.py-btn--danger:hover { background: #a01515; border-color: #a01515; color: #fff; }

.py-btn--block { width: 100%; }
.py-btn--sm    { padding: 6px 12px; font-size: 12px; }

/* =========================================================================
   Team table
   ========================================================================= */

.py-team-table {
	width: 100%;
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	overflow: hidden;
	border-collapse: collapse;
	margin-bottom: 16px;
}
.py-team-table thead {
	background: var(--py-surface-alt);
}
.py-team-table th,
.py-team-table td {
	padding: 14px 18px;
	text-align: left;
	font-size: 14px;
	vertical-align: middle;
	border-bottom: 1px solid var(--py-border);
}
.py-team-table th {
	font-size: 11px;
	font-weight: 700;
	color: var(--py-ink-subtle);
	text-transform: uppercase;
	letter-spacing: 0.5px;
}
.py-team-table tr:last-child td { border-bottom: none; }
.py-team-table__actions { text-align: right; }
.py-team-table select {
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	padding: 5px 10px;
	font-size: 13px;
	background: var(--py-surface);
}
.py-inline-form { display: inline-block; margin: 0; }

.py-diag-log {
	list-style: none;
	padding: 0;
	margin: 0;
	max-height: 360px;
	overflow-y: auto;
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	background: var(--py-surface);
	font-family: 'SF Mono', Monaco, monospace;
	font-size: 12px;
}
.py-diag-log li {
	padding: 8px 12px;
	border-bottom: 1px solid var(--py-border);
	display: flex;
	gap: 8px;
	align-items: baseline;
	flex-wrap: wrap;
}
.py-diag-log li:last-child { border-bottom: none; }

/* =========================================================================
   Queue status tabs
   ========================================================================= */

.py-queue-tabs {
	display: flex;
	gap: 4px;
	margin-bottom: 20px;
	border-bottom: 1px solid var(--py-border);
	overflow-x: auto;
}

.py-queue-tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	font-size: 14px;
	font-weight: 600;
	color: var(--py-ink-subtle);
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	transition: all .15s;
	white-space: nowrap;
}
.py-queue-tab:hover {
	color: var(--py-ink);
	text-decoration: none;
}
.py-queue-tab.is-active {
	color: var(--py-primary);
	border-bottom-color: var(--py-primary);
}
.py-queue-tab__count {
	background: var(--py-surface-alt);
	color: var(--py-ink-muted);
	font-size: 11px;
	font-weight: 700;
	padding: 2px 8px;
	border-radius: 999px;
	min-width: 22px;
	text-align: center;
}
.py-queue-tab.is-active .py-queue-tab__count {
	background: var(--py-primary);
	color: #fff;
}

/* =========================================================================
   Filters
   ========================================================================= */

.py-filters {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 24px;
}

.py-filters__label {
	font-size: 13px;
	color: var(--py-ink-subtle);
	font-weight: 500;
	margin-right: 4px;
}

.py-chip {
	padding: 5px 14px;
	font-size: 13px;
	border-radius: 999px;
	border: 1px solid var(--py-border);
	color: var(--py-ink-muted);
	background: var(--py-surface);
	font-weight: 500;
	transition: all .15s ease;
}
.py-chip:hover {
	border-color: var(--py-primary);
	color: var(--py-primary);
	text-decoration: none;
}
.py-chip.is-active {
	background: var(--py-primary);
	border-color: var(--py-primary);
	color: #fff;
}
.py-chip.is-active:hover { color: #fff; }

/* =========================================================================
   Pills
   ========================================================================= */

.py-pill {
	display: inline-flex;
	align-items: center;
	font-size: 11px;
	font-weight: 600;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--py-primary-soft);
	color: var(--py-primary);
}
.py-pill--warning { background: var(--py-warning-soft); color: var(--py-warning); }
.py-pill--neutral { background: var(--py-surface-alt); color: var(--py-ink-muted); border: 1px solid var(--py-border); }

/* =========================================================================
   Rejected list
   ========================================================================= */

.py-rejected {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.py-rejected__item {
	background: var(--py-surface);
	border: 1px solid var(--py-warning-soft);
	border-left: 3px solid var(--py-warning);
	border-radius: var(--py-radius-sm);
	padding: 12px 16px;
	display: grid;
	grid-template-columns: 100px 80px 1fr 200px 60px;
	gap: 12px;
	align-items: center;
	font-size: 13px;
}
.py-rejected__brand   { font-weight: 600; color: var(--py-primary); }
.py-rejected__excerpt { color: var(--py-ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.py-rejected__note    { color: var(--py-warning); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.py-rejected__rev     { font-size: 11px; color: var(--py-ink-subtle); text-align: right; }

/* =========================================================================
   Empty state
   ========================================================================= */

.py-empty {
	text-align: center;
	padding: 64px 32px;
	background: var(--py-surface);
	border: 2px dashed var(--py-border);
	border-radius: var(--py-radius);
	color: var(--py-ink-muted);
}
.py-empty h2 {
	margin: 0 0 8px;
	font-size: 22px;
	font-weight: 700;
	color: var(--py-ink);
	letter-spacing: -0.3px;
}
.py-empty p {
	margin: 0 0 16px;
	font-size: 14px;
	line-height: 1.6;
	max-width: 500px;
	margin-left: auto;
	margin-right: auto;
}

/* =========================================================================
   Brand grid
   ========================================================================= */

.py-brand-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
	gap: 16px;
}

.py-brand-card {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-top: 4px solid var(--brand-accent, var(--py-primary));
	border-radius: var(--py-radius);
	padding: 20px;
	box-shadow: var(--py-shadow-sm);
}

.py-brand-card__head {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 16px;
}
.py-brand-card__logo {
	width: 44px; height: 44px;
	border-radius: 8px;
	object-fit: cover;
}
.py-brand-card__initial {
	width: 44px; height: 44px;
	border-radius: 8px;
	background: var(--brand-accent, var(--py-primary));
	color: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	font-size: 18px;
}
.py-brand-card__name { margin: 0; font-size: 16px; font-weight: 700; }
.py-brand-card__id   { font-size: 11px; color: var(--py-ink-subtle); }

.py-brand-card__meta {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 8px;
	margin-bottom: 16px;
	font-size: 12px;
}
.py-brand-card__meta dt { color: var(--py-ink-subtle); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.py-brand-card__meta dd { margin: 0; font-weight: 600; }

/* =========================================================================
   Settings form
   ========================================================================= */

.py-settings-form .py-section {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 24px;
	margin-bottom: 16px;
}

.py-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.py-field__label {
	font-size: 13px;
	font-weight: 600;
	color: var(--py-ink);
}

.py-field input,
.py-field textarea,
.py-field select {
	padding: 10px 14px;
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	font-family: inherit;
	font-size: 14px;
	color: var(--py-ink);
	background: var(--py-surface);
	transition: all .15s;
}
.py-field input:focus,
.py-field textarea:focus,
.py-field select:focus {
	outline: none;
	border-color: var(--py-primary);
	box-shadow: 0 0 0 3px var(--py-primary-soft);
}

.py-field__row {
	display: flex;
	gap: 8px;
	align-items: center;
}
.py-field__row input { flex: 1; }

.py-field__hint {
	font-size: 12px;
	color: var(--py-ink-subtle);
	line-height: 1.5;
}
.py-field__hint code {
	background: var(--py-surface-alt);
	padding: 2px 6px;
	border-radius: 4px;
	font-size: 11px;
}

.py-field--checkbox {
	flex-direction: row;
	align-items: center;
	gap: 8px;
}
.py-field--checkbox input { width: auto; }

.py-form-actions {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-top: 16px;
}

/* =========================================================================
   Toast
   ========================================================================= */

.py-toast {
	padding: 12px 16px;
	border-radius: var(--py-radius-sm);
	margin-bottom: 16px;
	font-size: 13px;
	font-weight: 500;
}
.py-toast--success {
	background: var(--py-success-soft);
	color: var(--py-success);
	border: 1px solid #6ee7b7;
}
.py-toast--error {
	background: var(--py-danger-soft);
	color: var(--py-danger);
	border: 1px solid #fca5a5;
}
.py-toast--info {
	background: var(--py-primary-soft);
	color: var(--py-primary);
	border: 1px solid #93c5fd;
}

/* =========================================================================
   Form grid
   ========================================================================= */

.py-form-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 16px;
	margin-bottom: 16px;
}

.py-checkgroup {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
}

.py-check {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	background: var(--py-surface);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all .15s;
}
.py-check:has(input:checked) {
	background: var(--py-primary-soft);
	border-color: var(--py-primary);
	color: var(--py-primary);
}
.py-check input { width: auto; }

/* File uploader (logo) */

.py-bg-uploader {
	display: grid;
	grid-template-columns: 160px 1fr;
	gap: 20px;
	align-items: start;
}

.py-logo-preview {
	aspect-ratio: 1 / 1;
	border: 2px dashed var(--py-border-strong);
	border-radius: var(--py-radius-sm);
	background: var(--py-surface-alt);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.py-logo-preview img {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
}
.py-bg-uploader__placeholder {
	text-align: center;
	color: var(--py-ink-subtle);
}
.py-bg-uploader__placeholder svg { color: var(--py-border-strong); margin-bottom: 8px; }
.py-bg-uploader__placeholder p { margin: 0; font-size: 11px; }

.py-bg-uploader__controls {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding-top: 4px;
}

/* Colour picker row */

.py-colour-row {
	display: flex;
	gap: 8px;
	align-items: center;
}
.py-colour-row input[type="color"] {
	width: 56px;
	height: 44px;
	padding: 2px;
	cursor: pointer;
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	background: var(--py-surface);
}
.py-colour-row input[type="text"] {
	flex: 1;
	font-family: 'SF Mono', Monaco, monospace;
	font-size: 13px;
	text-transform: uppercase;
}

/* =========================================================================
   Canonical preview canvas — ONE source of truth.
   Used at three sizes (brand listing card, template designer card, large
   form preview). Container query units (cqw) keep all sizes consistent.
   ========================================================================= */

.py-canvas {
	container-type: inline-size;
	aspect-ratio: 1 / 1;
	position: relative;
	overflow: hidden;
	/* font-family is set via inline style by py_canvas_preview / pyCanvasPreviewHTML
	   so each brand uses its chosen font in the preview. UI font (Inter) is the
	   fallback. */
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	color: #fff;
	user-select: none;
	transition: background .15s ease, font-family .15s ease;
}

.py-font-select {
	font-size: 14px;
}
.py-font-select option { font-size: 14px; padding: 4px; }

.py-canvas__el {
	position: absolute;
}

/* Element width/height/font-size now come from inline style attributes
   so each template can be sized independently. The CSS only provides
   weight/line-height/etc. that aren't part of the editable layout. */

.py-canvas__title {
	line-height: 1.25;
	font-weight: 800;
	letter-spacing: -0.02em;
	z-index: 2;
}

.py-canvas__icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.py-canvas__logo {
	object-fit: contain;
	height: auto;
	z-index: 2;
}

.py-canvas__logo--placeholder {
	height: 8cqw;
	background: rgba(255,255,255,.12);
	border: 1px dashed rgba(255,255,255,.3);
	color: rgba(255,255,255,.7);
	font-size: 2cqw;
	font-weight: 700;
	letter-spacing: 0.15em;
	display: flex;
	align-items: center;
	justify-content: center;
}

.py-canvas__hint {
	position: absolute;
	bottom: 3cqw;
	left: 50%;
	transform: translateX(-50%);
	font-size: 1.8cqw;
	color: rgba(255,255,255,.55);
	font-weight: 500;
	letter-spacing: 0.05em;
	pointer-events: none;
	opacity: 0;
	transition: opacity .2s;
	white-space: nowrap;
	z-index: 1;
}
.py-canvas--interactive:hover .py-canvas__hint { opacity: 1; }

/* Interactive mode — drag affordances */
.py-canvas--interactive .py-canvas__el {
	cursor: grab;
	touch-action: none;
	outline: 0.2cqw dashed transparent;
	outline-offset: 0.5cqw;
	border-radius: 3px;
	transition: outline-color .12s ease, box-shadow .12s ease;
}
.py-canvas--interactive .py-canvas__el:hover {
	outline-color: rgba(255,255,255,.5);
}
.py-canvas--interactive .py-canvas__el.is-dragging {
	cursor: grabbing;
	outline-color: rgba(255,255,255,.95);
	box-shadow: 0 4px 16px rgba(0,0,0,.35);
	z-index: 10;
}
.py-canvas--interactive.is-active {
	background-image:
		linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px),
		linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px);
	background-size: 10% 10%, 10% 10%;
}

.py-preview-large-wrap {
	max-width: 520px;
	margin: 0 auto;
	text-align: center;
}
.py-preview-large-wrap .py-canvas {
	border-radius: var(--py-radius);
	box-shadow: var(--py-shadow);
}

/* =========================================================================
   Template tabs
   ========================================================================= */

.py-tpl-tabs {
	display: flex;
	gap: 4px;
	overflow-x: auto;
	border-bottom: 1px solid var(--py-border);
	margin-bottom: 16px;
	padding-bottom: 0;
}

.py-tpl-tab {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 600;
	color: var(--py-ink-subtle);
	background: transparent;
	border: none;
	border-bottom: 2px solid transparent;
	margin-bottom: -1px;
	cursor: pointer;
	transition: all .15s;
	white-space: nowrap;
}
.py-tpl-tab:hover {
	color: var(--py-ink);
}
.py-tpl-tab.is-active {
	color: var(--py-primary);
	border-bottom-color: var(--py-primary);
}
.py-tpl-tab__swatch {
	width: 14px;
	height: 14px;
	border-radius: 4px;
	border: 2px solid;
	display: inline-block;
}
.py-tpl-tab--add {
	color: var(--py-primary);
	font-weight: 600;
	border-left: 1px solid var(--py-border);
	margin-left: 8px;
	padding-left: 16px;
}

/* =========================================================================
   Editor: big canvas + controls panel
   ========================================================================= */

.py-tpl-editor {
	display: grid;
	grid-template-columns: 1fr 320px;
	gap: 24px;
	margin-bottom: 16px;
}

.py-tpl-editor__canvas {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 0;
	overflow: hidden;
}

.py-tpl-editor__controls {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 20px;
}

.py-canvas--interactive .py-canvas__el.is-selected {
	outline: 2px solid var(--py-primary);
	box-shadow: 0 0 0 4px rgba(26, 86, 219, .25);
}

.py-align-buttons {
	display: flex;
	gap: 4px;
	margin-top: 6px;
}
.py-align-buttons button {
	flex: 1;
	padding: 8px 10px;
	font-size: 12px;
	font-weight: 500;
	background: var(--py-surface-alt);
	color: var(--py-ink-muted);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius-sm);
	cursor: pointer;
}
.py-align-buttons button.is-active {
	background: var(--py-primary);
	color: #fff;
	border-color: var(--py-primary);
}

input[type="range"] {
	width: 100%;
	accent-color: var(--py-primary);
}

@media (max-width: 820px) {
	.py-tpl-editor { grid-template-columns: 1fr; }
}

/* =========================================================================
   Legacy template-card rules (kept for graceful fallback during deploy)
   ========================================================================= */

.py-templates {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 16px;
	margin-bottom: 16px;
}

.py-template-card {
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	overflow: hidden;
	box-shadow: var(--py-shadow-sm);
}

.py-template-card__preview-wrap {
	/* Wrapper around .py-canvas inside the template card */
}

.py-template-card__controls {
	padding: 14px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	border-top: 1px solid var(--py-border);
}

.py-field--compact .py-field__label { font-size: 11px; }
.py-field--compact input,
.py-field--compact select {
	padding: 6px 10px;
	font-size: 13px;
}
.py-field--compact .py-colour-row input[type="color"] {
	width: 44px; height: 34px;
}

.py-tpl-remove {
	margin-top: 4px;
	color: var(--py-danger) !important;
	border-color: transparent !important;
}
.py-tpl-remove:hover {
	background: var(--py-danger-soft) !important;
	border-color: var(--py-danger) !important;
}
.py-tpl-remove:disabled {
	opacity: .35;
	cursor: not-allowed;
}

/* =========================================================================
   Brand card — uses py-preview-tile inside
   ========================================================================= */

.py-brand-card__preview-link {
	display: block;
	color: inherit;
	margin: -20px -20px 16px;
	position: relative;
	overflow: hidden;
}
.py-brand-card__preview-link:hover { text-decoration: none; }
.py-brand-card__preview-link .py-canvas {
	transition: transform .25s ease;
}
.py-brand-card__preview-link:hover .py-canvas {
	transform: scale(1.02);
}

.py-brand-card__variants {
	position: absolute;
	bottom: 10px;
	left: 10px;
	display: flex;
	gap: 4px;
	background: rgba(0,0,0,.4);
	backdrop-filter: blur(6px);
	border-radius: 999px;
	padding: 4px 8px;
	z-index: 3;
}
.py-variant-dot {
	width: 14px; height: 14px;
	border-radius: 50%;
	border: 2px solid;
	display: inline-block;
}
.py-variant-more {
	font-size: 10px;
	color: #fff;
	font-weight: 700;
	padding-left: 2px;
}

.py-brand-card__body { padding: 0 4px; }


@media (max-width: 700px) {
	.py-bg-uploader { grid-template-columns: 1fr; }
}

/* =========================================================================
   Login
   ========================================================================= */

.py-auth-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background:
		radial-gradient(circle at 15% 25%, #dbeafe 0%, transparent 50%),
		radial-gradient(circle at 85% 75%, #e0e7ff 0%, transparent 50%),
		var(--py-bg);
	padding: 24px;
}

.py-login__card {
	background: var(--py-surface);
	border-radius: var(--py-radius-lg);
	box-shadow: var(--py-shadow-lg);
	padding: 48px;
	width: 100%;
	max-width: 420px;
}

.py-login__brand {
	text-align: center;
	margin-bottom: 32px;
}
.py-login__brand h1 { margin: 16px 0 4px; }
.py-login__tagline {
	margin: 0;
	color: var(--py-ink-subtle);
	font-size: 13px;
}

.py-login__error {
	background: var(--py-danger-soft);
	border: 1px solid #fca5a5;
	color: var(--py-danger);
	padding: 12px 14px;
	border-radius: var(--py-radius-sm);
	font-size: 13px;
	margin-bottom: 16px;
}

.py-login__form {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.py-login__footer {
	text-align: center;
	margin-top: 24px;
	font-size: 12px;
	color: var(--py-ink-subtle);
}

/* =========================================================================
   Post detail
   ========================================================================= */

.py-back-link {
	display: inline-block;
	color: var(--py-ink-subtle);
	margin-bottom: 20px;
	font-size: 13px;
}

.py-detail {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 32px;
	background: var(--py-surface);
	border: 1px solid var(--py-border);
	border-radius: var(--py-radius);
	padding: 32px;
}

.py-detail__media img { width: 100%; border-radius: var(--py-radius-sm); }

.py-detail__meta {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 16px;
}
.py-detail__title {
	margin: 0 0 12px;
	font-size: 24px;
	font-weight: 800;
	letter-spacing: -0.5px;
}
.py-detail__caption {
	font-size: 14px;
	line-height: 1.7;
	color: var(--py-ink);
	white-space: pre-line;
}
.py-detail__tags { color: var(--py-primary); font-weight: 500; }
.py-detail__time { font-size: 13px; color: var(--py-ink-muted); }
.py-detail__revisions {
	margin-top: 24px;
	padding-top: 24px;
	border-top: 1px solid var(--py-border);
}
.py-detail__revisions blockquote {
	margin: 4px 0 0 0;
	padding: 8px 12px;
	background: var(--py-warning-soft);
	border-left: 3px solid var(--py-warning);
	border-radius: 0 var(--py-radius-sm) var(--py-radius-sm) 0;
	font-size: 13px;
	color: #78350f;
}

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1024px) {
	.py-detail { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
	:root { --py-sidebar-w: 0; }
	.py-app { grid-template-columns: 1fr; }
	.py-sidebar {
		position: fixed;
		left: -260px;
		width: 260px;
		z-index: 100;
		transition: left .25s;
	}
	.py-sidebar.is-open { left: 0; }
	.py-content { padding: 20px; }
	.py-topbar { padding: 0 20px; }
	.py-rejected__item { grid-template-columns: 1fr; }
}
