/*
 * AI eBook Studio — front-end styles.
 * Everything is scoped under .aiebs-app (or .aiebs-fullscreen for the page
 * shell) so the theme is never affected, and a local reset shields the app
 * from theme button/input/heading styles.
 */

.aiebs-app {
	--aiebs-primary: #4f46e5;
	--aiebs-primary-600: #4338ca;
	--aiebs-primary-50: #eef2ff;
	--aiebs-primary-100: #e0e7ff;
	--aiebs-text: #111827;
	--aiebs-text-2: #4b5563;
	--aiebs-muted: #6b7280;
	--aiebs-border: #e5e7eb;
	--aiebs-border-2: #d1d5db;
	--aiebs-bg: #f6f7fb;
	--aiebs-surface: #ffffff;
	--aiebs-danger: #dc2626;
	--aiebs-success: #059669;
	--aiebs-amber: #d97706;
	--aiebs-radius: 12px;
	--aiebs-radius-sm: 8px;
	--aiebs-shadow-sm: 0 1px 2px rgba(17, 24, 39, .05);
	--aiebs-shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 6px 16px rgba(17, 24, 39, .06);
	--aiebs-shadow-lg: 0 20px 50px rgba(17, 24, 39, .18);
	--aiebs-font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--aiebs-sidebar: 240px;

	position: relative;
	display: flex;
	min-height: 720px;
	background: var(--aiebs-bg);
	color: var(--aiebs-text);
	font-family: var(--aiebs-font);
	font-size: 14px;
	font-weight: 400;
	line-height: 1.5;
	text-align: left;
	-webkit-font-smoothing: antialiased;
	border-radius: var(--aiebs-radius);
	border: 1px solid var(--aiebs-border);
}

/* ---------- Local reset ----------
 * Selectors are .aiebs-app :where(...) so they beat theme element styles
 * (0,0,1) while staying at (0,1,0): any component class declared later wins. */
.aiebs-app,
.aiebs-app :where(*),
.aiebs-app ::before,
.aiebs-app ::after { box-sizing: border-box; }
.aiebs-app :where(h1, h2, h3, p, dl, dd) { margin: 0; padding: 0; font-family: inherit; color: inherit; letter-spacing: normal; text-transform: none; line-height: inherit; }
.aiebs-app :where(button, input, select, textarea) { font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none; }
.aiebs-app :where(a) { color: inherit; text-decoration: none; box-shadow: none; }
.aiebs-app :where(img) { max-width: 100%; display: block; }
.aiebs-app [hidden] { display: none !important; }
.aiebs-app :focus-visible { outline: 2px solid var(--aiebs-primary); outline-offset: 2px; }
.aiebs-app .aiebs-icon { flex: none; }

/* ---------- Full-screen page shell ---------- */
body.aiebs-fullscreen { margin: 0; background: #f6f7fb; }
body.aiebs-fullscreen .aiebs-app { min-height: calc(100vh - var(--wp-admin--admin-bar--height, 0px)); border-radius: 0; border: 0; }
body.aiebs-fullscreen .aiebs-gate { min-height: 100vh; }

/* ---------- Boot / gate ---------- */
.aiebs-boot { margin: auto; display: flex; gap: 12px; align-items: center; color: var(--aiebs-muted); padding: 60px; }
.aiebs-spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--aiebs-primary-100); border-top-color: var(--aiebs-primary); animation: aiebs-spin .8s linear infinite; }
@keyframes aiebs-spin { to { transform: rotate(360deg); } }

.aiebs-app.aiebs-gate { border: 0; background: transparent; }
.aiebs-gate { align-items: center; justify-content: center; padding: 40px 16px; min-height: 520px; }
.aiebs-gate__card { width: 100%; max-width: 400px; background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: 16px; box-shadow: var(--aiebs-shadow); padding: 32px; text-align: center; }
.aiebs-gate__title { font-size: 22px; font-weight: 700; margin: 14px 0 6px; }
.aiebs-gate__lead { color: var(--aiebs-muted); margin-bottom: 20px; }
.aiebs-gate__links { margin-top: 16px; color: var(--aiebs-muted); font-size: 13px; }
.aiebs-gate__links a { color: var(--aiebs-primary); }
.aiebs-gate form { text-align: left; }
.aiebs-gate form p { margin: 0 0 14px; }
.aiebs-gate form label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.aiebs-gate form input[type="text"], .aiebs-gate form input[type="password"] { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--aiebs-border-2); border-radius: var(--aiebs-radius-sm); background: #fff; }
.aiebs-gate form .login-remember label { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.aiebs-gate form input[type="submit"] { width: 100%; height: 42px; border: 0; border-radius: var(--aiebs-radius-sm); background: var(--aiebs-primary); color: #fff; font-weight: 600; cursor: pointer; }
.aiebs-gate form input[type="submit"]:hover { background: var(--aiebs-primary-600); }
.aiebs-gate .aiebs-logo { display: flex; justify-content: center; }
.aiebs-gate .aiebs-logo__mark { width: 44px; height: 44px; }
.aiebs-notice { padding: 16px; }

/* ---------- Logo ---------- */
.aiebs-logo__mark { display: inline-block; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(140deg, #6366f1, #4f46e5 55%, #7c3aed); position: relative; flex: none; box-shadow: 0 4px 10px rgba(79, 70, 229, .35); }
.aiebs-logo__mark::before, .aiebs-logo__mark::after { content: ""; position: absolute; top: 28%; bottom: 28%; width: 30%; background: #fff; border-radius: 2px; }
.aiebs-logo__mark::before { left: 18%; transform: skewY(8deg); opacity: .95; }
.aiebs-logo__mark::after { right: 18%; transform: skewY(-8deg); opacity: .75; }

/* ---------- Shell ---------- */
.aiebs-sidebar { position: sticky; top: var(--wp-admin--admin-bar--height, 0px); align-self: flex-start; height: calc(100vh - var(--wp-admin--admin-bar--height, 0px)); max-height: 100%; overflow-y: auto; border-radius: var(--aiebs-radius) 0 0 var(--aiebs-radius); width: var(--aiebs-sidebar); flex: none; background: var(--aiebs-surface); border-right: 1px solid var(--aiebs-border); display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; z-index: 30; }
.aiebs-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.aiebs-brand__name { font-weight: 700; font-size: 15px; color: var(--aiebs-text); }
.aiebs-nav { display: flex; flex-direction: column; gap: 2px; }
.aiebs-nav__item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--aiebs-radius-sm); color: var(--aiebs-text-2); font-weight: 500; transition: background .15s, color .15s; }
.aiebs-nav__item:hover { background: #f3f4f6; color: var(--aiebs-text); }
.aiebs-nav__item.is-active { background: var(--aiebs-primary-50); color: var(--aiebs-primary); }
.aiebs-nav__soon { margin-left: auto; font-size: 10px; font-weight: 600; color: var(--aiebs-muted); background: #f3f4f6; padding: 1px 6px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.aiebs-sidebar__foot { margin-top: auto; border-top: 1px solid var(--aiebs-border); padding-top: 12px; }
.aiebs-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--aiebs-radius-sm); }
.aiebs-user:hover { background: #f3f4f6; }
.aiebs-user__text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.aiebs-user__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aiebs-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
.aiebs-avatar--lg { width: 64px; height: 64px; }

.aiebs-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.aiebs-topbar { display: none; }
.aiebs-main { flex: 1; padding: 28px 32px 48px; outline: none; max-width: 1400px; width: 100%; }
.aiebs-scrim { display: none; }

/* ---------- Page header / sections ---------- */
.aiebs-pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.aiebs-pagehead__title { font-size: 24px; font-weight: 700; line-height: 1.25; }
.aiebs-pagehead p { margin-top: 4px; }
.aiebs-section { margin-top: 28px; }
.aiebs-section__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.aiebs-section__title { font-size: 16px; font-weight: 600; }
.aiebs-link { color: var(--aiebs-primary); font-weight: 500; }
.aiebs-link:hover { text-decoration: underline; }
.aiebs-muted { color: var(--aiebs-muted); }

/* ---------- Buttons ---------- */
.aiebs-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: var(--aiebs-radius-sm); border: 1px solid transparent; background: transparent; font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none; }
.aiebs-btn:disabled { opacity: .5; cursor: not-allowed; }
.aiebs-btn--primary { background: var(--aiebs-primary); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3); }
.aiebs-btn--primary:hover:not(:disabled) { background: var(--aiebs-primary-600); }
.aiebs-btn--secondary { background: var(--aiebs-surface); border-color: var(--aiebs-border-2); color: var(--aiebs-text); }
.aiebs-btn--secondary:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; }
.aiebs-btn--ghost { color: var(--aiebs-text-2); }
.aiebs-btn--ghost:hover:not(:disabled) { background: #f3f4f6; color: var(--aiebs-text); }
.aiebs-btn--danger { background: var(--aiebs-danger); color: #fff; }
.aiebs-btn--danger:hover:not(:disabled) { background: #b91c1c; }
.aiebs-btn--link { height: auto; padding: 0; color: #c7d2fe; font-weight: 600; }
.aiebs-btn--sm { height: 32px; padding: 0 10px; font-size: 13px; }
.aiebs-btn--icon { width: 36px; padding: 0; }
.aiebs-btn--sm.aiebs-btn--icon, .aiebs-card__actions .aiebs-btn--icon { width: 32px; height: 32px; }
.aiebs-btn.is-busy { position: relative; color: transparent !important; }
.aiebs-btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: aiebs-spin .7s linear infinite; }

/* ---------- Stats ---------- */
.aiebs-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.aiebs-stat { background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: var(--aiebs-radius); padding: 16px 18px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; box-shadow: var(--aiebs-shadow-sm); }
.aiebs-stat__icon { grid-row: span 2; width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.aiebs-stat__value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.aiebs-stat__label { color: var(--aiebs-muted); font-size: 13px; }
.aiebs-stat--indigo .aiebs-stat__icon { background: var(--aiebs-primary-50); color: var(--aiebs-primary); }
.aiebs-stat--green .aiebs-stat__icon { background: #ecfdf5; color: var(--aiebs-success); }
.aiebs-stat--amber .aiebs-stat__icon { background: #fffbeb; color: var(--aiebs-amber); }
.aiebs-stat--sky .aiebs-stat__icon { background: #f0f9ff; color: #0284c7; }

/* ---------- Toolbar ---------- */
.aiebs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.aiebs-toolbar__right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.aiebs-search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 360px; }
.aiebs-search .aiebs-icon { position: absolute; left: 12px; color: var(--aiebs-muted); pointer-events: none; }
.aiebs-search .aiebs-input { padding-left: 36px; }
.aiebs-input, .aiebs-select { width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--aiebs-border-2); border-radius: var(--aiebs-radius-sm); background: var(--aiebs-surface); color: var(--aiebs-text); font-size: 14px; transition: border-color .15s, box-shadow .15s; box-shadow: none; }
textarea.aiebs-input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.aiebs-input:focus, .aiebs-select:focus { outline: none; border-color: var(--aiebs-primary); box-shadow: 0 0 0 3px var(--aiebs-primary-100); }
.aiebs-toolbar .aiebs-select { width: auto; min-width: 150px; }
.aiebs-segment { display: inline-flex; background: #eef0f4; border-radius: 10px; padding: 3px; gap: 2px; }
.aiebs-segment__btn { height: 32px; padding: 0 12px; border-radius: 8px; font-weight: 500; color: var(--aiebs-text-2); font-size: 13px; }
.aiebs-segment__btn.aiebs-btn--icon { width: 34px; padding: 0; }
.aiebs-segment__btn:hover { color: var(--aiebs-text); }
.aiebs-segment__btn[aria-pressed="true"] { background: var(--aiebs-surface); color: var(--aiebs-primary); box-shadow: var(--aiebs-shadow-sm); }
.aiebs-results__count { margin-bottom: 12px; font-size: 13px; }

/* ---------- Grid & cards ---------- */
.aiebs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.aiebs-card { background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: var(--aiebs-radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--aiebs-shadow-sm); transition: box-shadow .2s, transform .2s, border-color .2s; }
.aiebs-card:hover { box-shadow: var(--aiebs-shadow); transform: translateY(-2px); }
.aiebs-card__cover { display: block; padding: 14px 14px 0; border: 0; background: #f3f4f6; cursor: pointer; width: 100%; }
.aiebs-card__cover .aiebs-cover { margin: 0 auto; width: 72%; box-shadow: 0 10px 20px rgba(17, 24, 39, .2); transform: translateY(6px); }
.aiebs-card__body { padding: 16px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.aiebs-card__title { font-size: 15px; font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aiebs-card__meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--aiebs-text-2); min-height: 18px; }
.aiebs-card__meta.aiebs-muted { color: var(--aiebs-muted); }
.aiebs-card__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; }
.aiebs-card__actions { display: flex; gap: 4px; }

.aiebs-card--create { align-items: center; justify-content: center; gap: 12px; border: 2px dashed #c7d2fe; background: #fafaff; color: var(--aiebs-primary); font-weight: 600; min-height: 300px; cursor: pointer; box-shadow: none; }
.aiebs-card--create:hover { background: var(--aiebs-primary-50); border-color: var(--aiebs-primary); }
.aiebs-card--create__plus { width: 56px; height: 56px; border-radius: 50%; background: var(--aiebs-primary); color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 18px rgba(79, 70, 229, .35); }

/* Generated / image covers keep a 2:3 book ratio. */
.aiebs-cover { aspect-ratio: 2 / 3; border-radius: 4px 8px 8px 4px; overflow: hidden; position: relative; background: #e5e7eb; }
.aiebs-cover img { width: 100%; height: 100%; object-fit: cover; }
.aiebs-cover--generated { display: flex; flex-direction: column; justify-content: space-between; padding: 14% 12%; color: #fff; }
.aiebs-cover--generated::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6%; background: rgba(0, 0, 0, .18); }
.aiebs-cover--generated::after { content: ""; position: absolute; right: -20%; bottom: -15%; width: 80%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.aiebs-cover__title { font-weight: 800; font-size: 15px; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; position: relative; z-index: 1; }
.aiebs-cover__author { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; opacity: .85; position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aiebs-cover--xs { width: 36px; flex: none; padding: 5px 4px; border-radius: 2px 4px 4px 2px; }
.aiebs-cover--xs .aiebs-cover__title { font-size: 5px; -webkit-line-clamp: 4; }
.aiebs-cover--xs .aiebs-cover__author { display: none; }

/* Skeletons */
.aiebs-card--skeleton { pointer-events: none; }
.aiebs-skel { background: linear-gradient(90deg, #f3f4f6 25%, #e9eaee 37%, #f3f4f6 63%); background-size: 400% 100%; animation: aiebs-shimmer 1.4s ease infinite; border-radius: 6px; }
.aiebs-skel--cover { aspect-ratio: 4 / 5; border-radius: 0; }
.aiebs-skel--line { height: 12px; margin-top: 6px; }
.aiebs-skel--line.short { width: 55%; }
@keyframes aiebs-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Badges ---------- */
.aiebs-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.aiebs-badge--draft { background: #fff7ed; color: #c2410c; }
.aiebs-badge--published { background: #ecfdf5; color: #047857; }
.aiebs-badge--archived { background: #f3f4f6; color: #4b5563; }
.aiebs-badge--soon { background: var(--aiebs-primary-50); color: var(--aiebs-primary); font-size: 10.5px; height: 20px; }
.aiebs-badge--plan { background: var(--aiebs-primary-50); color: var(--aiebs-primary); margin-top: 6px; }

/* ---------- List view ---------- */
.aiebs-table { background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: var(--aiebs-radius); overflow: hidden; }
.aiebs-row { display: grid; grid-template-columns: minmax(0, 3fr) 110px 100px 140px 130px; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--aiebs-border); }
.aiebs-row:first-child { border-top: 0; }
.aiebs-row:hover:not(.aiebs-row--head) { background: #fafafa; }
.aiebs-row--head { background: #f9fafb; font-size: 12px; font-weight: 600; color: var(--aiebs-muted); text-transform: uppercase; letter-spacing: .04em; padding-top: 10px; padding-bottom: 10px; }
.aiebs-row__main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.aiebs-row__text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.aiebs-row__title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aiebs-row__cell { font-size: 13px; }
.aiebs-row__actions { display: flex; justify-content: flex-end; gap: 4px; }

/* ---------- Pager ---------- */
.aiebs-pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 24px; }
.aiebs-pager:empty { display: none; }

/* ---------- Empty states ---------- */
.aiebs-empty { background: var(--aiebs-surface); border: 1px dashed var(--aiebs-border-2); border-radius: var(--aiebs-radius); padding: 48px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.aiebs-empty h3 { font-size: 17px; font-weight: 600; }
.aiebs-empty p { max-width: 420px; }
.aiebs-empty .aiebs-btn { margin-top: 8px; }
.aiebs-empty__icon { width: 60px; height: 60px; border-radius: 16px; background: var(--aiebs-primary-50); color: var(--aiebs-primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.aiebs-empty__icon.is-error { background: #fef2f2; color: var(--aiebs-danger); }
.aiebs-empty--soon { border-style: solid; padding: 64px 24px; }

/* ---------- Panels (account) ---------- */
.aiebs-panel { background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: var(--aiebs-radius); padding: 20px 22px; margin-bottom: 16px; max-width: 760px; box-shadow: var(--aiebs-shadow-sm); }
.aiebs-panel--row { display: flex; gap: 10px; flex-wrap: wrap; }
.aiebs-panel__title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.aiebs-account { display: flex; align-items: center; gap: 16px; }
.aiebs-account__name { font-size: 18px; font-weight: 700; }
.aiebs-usage { margin-top: 18px; }
.aiebs-usage__label { display: flex; justify-content: space-between; font-size: 13px; color: var(--aiebs-text-2); margin-bottom: 6px; }
.aiebs-progress { height: 8px; border-radius: 999px; background: #eef0f4; overflow: hidden; }
.aiebs-progress span { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5); border-radius: inherit; }
.aiebs-deflist { display: grid; grid-template-columns: 1fr auto; gap: 10px 24px; font-size: 14px; }
.aiebs-deflist dt { color: var(--aiebs-text-2); }
.aiebs-deflist dd { font-weight: 600; text-align: right; }

/* ---------- Menu ---------- */
.aiebs-menu { position: absolute; z-index: 60; width: 220px; background: var(--aiebs-surface); border: 1px solid var(--aiebs-border); border-radius: 10px; box-shadow: var(--aiebs-shadow-lg); padding: 6px; animation: aiebs-pop .12s ease-out; }
.aiebs-menu__item { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 6px; font-size: 13.5px; text-align: left; cursor: pointer; color: var(--aiebs-text); }
.aiebs-menu__item:hover:not(:disabled), .aiebs-menu__item:focus-visible { background: #f3f4f6; outline: none; }
.aiebs-menu__item:disabled { color: var(--aiebs-muted); cursor: default; }
.aiebs-menu__item .aiebs-badge { margin-left: auto; }
.aiebs-menu__item.is-danger { color: var(--aiebs-danger); }
.aiebs-menu__item.is-danger:hover { background: #fef2f2; }
.aiebs-menu__sep { height: 1px; background: var(--aiebs-border); margin: 4px 2px; }
@keyframes aiebs-pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.aiebs-overlay { position: fixed; inset: 0; z-index: 100000; background: rgba(17, 24, 39, .45); display: flex; align-items: center; justify-content: center; padding: 16px; animation: aiebs-fade .15s ease-out; font-family: var(--aiebs-font); }
.aiebs-overlay.is-leaving { opacity: 0; transition: opacity .15s; }
.aiebs-modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--aiebs-surface); border-radius: 16px; box-shadow: var(--aiebs-shadow-lg); animation: aiebs-rise .18s ease-out; outline: none; }
.aiebs-modal--sm { max-width: 420px; }
.aiebs-modal--lg { max-width: 820px; }
.aiebs-modal__head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.aiebs-modal__title { font-size: 18px; font-weight: 700; }
.aiebs-modal__body { padding: 8px 20px 20px; overflow-y: auto; }
.aiebs-modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--aiebs-border); background: #fafafa; border-radius: 0 0 16px 16px; }
@keyframes aiebs-fade { from { opacity: 0; } }
@keyframes aiebs-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- Create chooser ---------- */
.aiebs-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.aiebs-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; padding: 18px; border: 1px solid var(--aiebs-border); border-radius: var(--aiebs-radius); background: var(--aiebs-surface); cursor: pointer; transition: border-color .15s, box-shadow .15s, background .15s; position: relative; }
.aiebs-choice:hover:not(:disabled) { border-color: var(--aiebs-primary); box-shadow: 0 0 0 3px var(--aiebs-primary-100); }
.aiebs-choice.is-disabled { cursor: default; background: #fafafa; }
.aiebs-choice.is-disabled .aiebs-choice__icon { background: #f3f4f6; color: var(--aiebs-muted); }
.aiebs-choice .aiebs-badge { position: absolute; top: 14px; right: 14px; }
.aiebs-choice__icon { width: 42px; height: 42px; border-radius: 10px; background: var(--aiebs-primary-50); color: var(--aiebs-primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.aiebs-choice__title { font-weight: 600; font-size: 15px; }
.aiebs-choice__text { color: var(--aiebs-muted); font-size: 13px; }

/* ---------- Forms ---------- */
.aiebs-form { display: flex; flex-direction: column; gap: 14px; }
.aiebs-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.aiebs-field__label { font-size: 13px; font-weight: 600; color: var(--aiebs-text); }
.aiebs-field__hint { font-size: 12px; color: var(--aiebs-muted); }
.aiebs-field-row { display: flex; gap: 12px; }
.aiebs-form-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; border-radius: var(--aiebs-radius-sm); padding: 10px 12px; font-size: 13px; }

/* ---------- Toasts ---------- */
.aiebs-toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100001; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; font-family: var(--aiebs-font); }
.aiebs-toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--aiebs-shadow-lg); font-size: 14px; max-width: min(520px, calc(100vw - 32px)); animation: aiebs-rise .18s ease-out; }
.aiebs-toast--success .aiebs-icon { color: #34d399; }
.aiebs-toast--error { background: #7f1d1d; }
.aiebs-toast--error .aiebs-icon { color: #fca5a5; }
.aiebs-toast.is-leaving { opacity: 0; transition: opacity .2s; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
	.aiebs-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.aiebs-row { grid-template-columns: minmax(0, 3fr) 100px 90px 120px 120px; }
}

@media (max-width: 860px) {
	.aiebs-app { min-height: 100vh; border-radius: 0; border: 0; }
	.aiebs-sidebar { border-radius: 0; }
	.aiebs-sidebar { position: fixed; top: 0; bottom: 0; left: 0; height: auto; max-height: none; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--aiebs-shadow-lg); z-index: 1000; }
	.aiebs-app.is-nav-open .aiebs-sidebar { transform: none; }
	.aiebs-app.is-nav-open .aiebs-scrim { display: block; position: fixed; inset: 0; background: rgba(17, 24, 39, .4); z-index: 999; }
	.aiebs-topbar { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 10px; background: var(--aiebs-surface); border-bottom: 1px solid var(--aiebs-border); position: sticky; top: 0; z-index: 20; }
	.aiebs-main { padding: 20px 16px 40px; }
	.aiebs-pagehead__title { font-size: 21px; }
	.aiebs-search { max-width: none; flex-basis: 100%; }
	.aiebs-toolbar__right { margin-left: 0; width: 100%; }
	.aiebs-toolbar__right .aiebs-select { flex: 1; }
	.aiebs-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
	.aiebs-card--create { min-height: 240px; }
	.aiebs-cover__title { font-size: 12.5px; }
	.aiebs-hide-sm { display: none !important; }
	.aiebs-row { grid-template-columns: minmax(0, 1fr) auto auto; }
}

@media (max-width: 520px) {
	.aiebs-stats { gap: 10px; }
	.aiebs-stat { padding: 12px; }
	.aiebs-stat__icon { width: 34px; height: 34px; }
	.aiebs-stat__value { font-size: 19px; }
	.aiebs-field-row { flex-direction: column; }
	.aiebs-card__actions .aiebs-btn--secondary span { display: none; }
	.aiebs-card__actions .aiebs-btn--secondary { width: 32px; padding: 0; }
	.aiebs-modal { max-height: calc(100vh - 16px); }
	.aiebs-overlay { padding: 8px; align-items: flex-end; }
	.aiebs-segment > .aiebs-segment__btn:not(.aiebs-btn--icon) { padding: 0 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.aiebs-app *, .aiebs-overlay, .aiebs-overlay * { animation: none !important; transition: none !important; }
}

/* Account: AI usage */
.aiebs-usage-list { display: flex; flex-direction: column; gap: 14px; }
.aiebs-usage-list .aiebs-usage { margin-top: 0; }
.aiebs-usage__note { font-size: 12.5px; }
.aiebs-usage.is-near .aiebs-progress span { background: linear-gradient(90deg, #f59e0b, #d97706); }
.aiebs-usage__extra { margin-top: 4px; font-size: 13.5px; }

/* Create New: featured "Create from Resources" card */
.aiebs-choice--feature { border-color: #c7d2fe; background: linear-gradient(160deg, #f5f6ff 0%, #fff 60%); }
.aiebs-choice__art { display: flex; align-items: center; margin-bottom: 4px; height: 42px; }
.aiebs-choice__art > span { width: 32px; height: 38px; border-radius: 7px; background: #fff; border: 1px solid #c7d2fe; color: var(--aiebs-primary); display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(79, 70, 229, .12); }
.aiebs-choice__art > span:nth-child(1) { transform: rotate(-8deg); }
.aiebs-choice__art > span:nth-child(2) { background: var(--aiebs-primary); color: #fff; border-color: var(--aiebs-primary); margin: 0 -6px; z-index: 1; height: 42px; }
.aiebs-choice__art > span:nth-child(3) { transform: rotate(8deg); }
.aiebs-choice.is-disabled .aiebs-choice__art > span { filter: grayscale(1); opacity: .6; }
.aiebs-choice__cta { margin-top: auto; padding-top: 4px; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 650; color: var(--aiebs-primary); }
