/* AIG Free Tools — app UI. Uses theme tokens when present, with fallbacks. */
.aig-app, .aig-land, .aig-contact, .aig-try {
	--a-ink: var(--ink-900, #0b1324);
	--a-text: var(--ink-700, #2b3550);
	--a-muted: var(--ink-500, #5b6683);
	--a-line: var(--line, #e4e7f0);
	--a-line2: var(--line-strong, #cfd4e3);
	--a-bg: var(--surface, #fff);
	--a-bg2: var(--surface-2, #f6f7fb);
	--a-bg3: var(--surface-3, #eef0f8);
	--a-brand: var(--brand, #4f46e5);
	--a-brand2: var(--brand-ink, #3730a3);
	--a-brand-soft: var(--brand-soft, #eef0ff);
	--a-r: var(--r-lg, 18px);
	--a-ring: var(--ring, 0 0 0 3px rgba(79, 70, 229, .28));
	--a-head: var(--font-head, inherit);
	--a-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);
}
.aig-wrap { max-width: 1200px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 720px) { .aig-wrap { padding-inline: 24px; } }
.aig-app-wrap { padding: 24px 0 8px; background: linear-gradient(var(--surface-2, #f6f7fb) 0 120px, transparent 120px); }

/* App shell */
.aig-app { background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 22px; box-shadow: 0 24px 48px -20px rgba(43, 36, 140, .22), 0 4px 12px rgba(11, 19, 36, .05); padding: 16px; color: var(--a-text); }
@media (min-width: 720px) { .aig-app { padding: 22px; } }
.aig-split { display: grid; gap: 16px; }
@media (min-width: 900px) { .aig-split { grid-template-columns: 1fr 1fr; } }
.aig-studio { display: grid; gap: 16px; }
@media (min-width: 900px) { .aig-studio { grid-template-columns: 360px 1fr; } }
.aig-pane { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.aig-pane-out { background: var(--a-bg2); border: 1px solid var(--a-line); border-radius: 16px; padding: 14px; }
.aig-pane-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: var(--a-head); font-weight: 700; color: var(--a-ink); font-size: .95rem; }
.aig-count { font-family: inherit; font-weight: 500; font-size: .8rem; color: var(--a-muted); }
.aig-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.aig-pane .aig-toolbar { margin: 0; }
.aig-options { display: flex; flex-wrap: wrap; gap: 14px; }
.aig-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Fields */
.aig-textarea, .aig-field input, .aig-field select, .aig-field textarea { width: 100%; border: 1px solid var(--a-line2); border-radius: 12px; background: var(--a-bg); padding: .7rem .85rem; font: inherit; font-size: .97rem; color: var(--a-ink); transition: border-color .15s, box-shadow .15s; }
.aig-textarea { min-height: 240px; resize: vertical; line-height: 1.6; }
.aig-textarea:focus, .aig-field input:focus, .aig-field select:focus, .aig-field textarea:focus { outline: 0; border-color: var(--a-brand); box-shadow: var(--a-ring); }
.aig-field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 600; color: var(--a-ink); }
.aig-field em { font-style: normal; font-weight: 500; color: var(--a-muted); margin-left: 6px; }
.aig-field em.is-over { color: #c0262d; }
.aig-field em.is-good { color: #15803d; }
.aig-form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; align-content: start; }
@media (min-width: 560px) { .aig-form-grid { grid-template-columns: 1fr 1fr; } .aig-span-2 { grid-column: span 2; } }
.aig-checks, .aig-seg { border: 0; padding: 0; margin: 0; min-width: 0; }
.aig-checks legend, .aig-seg legend { font-size: .78rem; font-weight: 700; color: var(--a-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; padding: 0; }
.aig-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .9rem; }
.aig-checks legend { width: 100%; }
.aig-check { display: inline-flex; gap: 6px; align-items: center; font-size: .9rem; }
.aig-seg { display: inline-flex; flex-wrap: wrap; background: var(--a-bg3); border-radius: 999px; padding: 3px; position: relative; }
.aig-seg legend { position: absolute; top: -22px; left: 4px; }
.aig-options .aig-seg, .aig-toolbar .aig-seg { margin-top: 22px; }
.aig-seg input { position: absolute; opacity: 0; pointer-events: none; }
.aig-seg label { padding: .42rem .85rem; border-radius: 999px; font-size: .87rem; font-weight: 600; color: var(--a-muted); cursor: pointer; transition: background .15s, color .15s; }
.aig-seg input:checked + label { background: var(--a-bg); color: var(--a-ink); box-shadow: 0 1px 2px rgba(11, 19, 36, .1); }
.aig-seg input:focus-visible + label { box-shadow: var(--a-ring); }

/* Buttons */
.aig-btn { display: inline-flex; align-items: center; justify-content: center; gap: .45em; min-height: 44px; padding: 0 1.1rem; border-radius: 999px; border: 1px solid transparent; font-family: var(--a-head); font-weight: 650; font-size: .9rem; cursor: pointer; background: var(--a-bg); color: var(--a-ink); transition: background .15s, border-color .15s, color .15s, transform .1s; text-decoration: none; }
.aig-btn:active { transform: translateY(1px); }
.aig-btn-sm { min-height: 34px; padding: 0 .8rem; font-size: .8rem; }
.aig-btn-block { width: 100%; }
.aig-btn-primary { background: var(--a-brand); color: #fff; box-shadow: 0 4px 14px -4px rgba(79, 70, 229, .55); }
.aig-btn-primary:hover { background: var(--a-brand2); color: #fff; }
.aig-btn-ghost { border-color: var(--a-line2); }
.aig-btn-ghost:hover { border-color: var(--a-brand); color: var(--a-brand); }
.aig-btn:disabled, .aig-btn.is-busy { opacity: .55; cursor: not-allowed; }
.aig-btn.is-busy::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: aig-spin .7s linear infinite; }
@keyframes aig-spin { to { transform: rotate(360deg); } }
.aig-chip { border: 1px solid var(--a-line); background: var(--a-bg); color: var(--a-text); border-radius: 999px; padding: .32rem .7rem; font-size: .82rem; font-weight: 550; cursor: pointer; }
.aig-chip:hover { border-color: var(--a-brand); color: var(--a-brand); }
.aig-file input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.aig-file { position: relative; }
.aig-file:focus-within { box-shadow: var(--a-ring); }

/* Output */
.aig-output { flex: 1; min-height: 240px; background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 12px; padding: .9rem 1rem; line-height: 1.65; overflow: auto; color: var(--a-ink); white-space: pre-wrap; word-wrap: break-word; margin: 0; }
.aig-output p { margin: 0 0 .8em; }
.aig-mono { font-family: var(--a-mono); font-size: .85rem; line-height: 1.6; }
.aig-code { min-height: 200px; max-height: 360px; background: #0b1324; color: #dfe3f2; border-color: #0b1324; }
.aig-empty { color: var(--a-muted); margin: 0; white-space: normal; }
.aig-skeleton { display: grid; gap: 10px; }
.aig-skeleton i { display: block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--a-bg3), #f8f9fd, var(--a-bg3)); background-size: 200% 100%; animation: aig-shimmer 1.2s infinite; }
.aig-skeleton i:nth-child(2) { width: 92%; } .aig-skeleton i:nth-child(3) { width: 80%; } .aig-skeleton i:nth-child(4) { width: 64%; }
@keyframes aig-shimmer { to { background-position: -200% 0; } }

.aig-error { margin: 12px 0 0; padding: .7rem .9rem; border-radius: 12px; background: #fdeeee; color: #9f1c22; font-size: .9rem; }
.aig-alert { padding: .8rem 1rem; border-radius: 12px; font-size: .92rem; margin: 0 0 14px; }
.aig-alert-warn { background: #fff6e5; color: #8a4b08; border: 1px solid #f6dfb5; }
.aig-alert-ok { background: #eaf7ee; color: #14632f; border: 1px solid #c4e8d0; }
.aig-note { margin: 12px 0 0; font-size: .82rem; color: var(--a-muted); }
.aig-label { margin: 0; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--a-muted); }

/* Prompt generator */
.aig-examples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; font-size: .85rem; color: var(--a-muted); }

/* Image generator */
.aig-controls { background: var(--a-bg2); border: 1px solid var(--a-line); border-radius: 16px; padding: 14px; }
.aig-controls .aig-seg { margin-top: 22px; align-self: flex-start; }
.aig-suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.aig-canvas { gap: 12px; }
.aig-preview { position: relative; flex: 1; min-height: 340px; display: grid; place-items: center; border-radius: 16px; background: repeating-conic-gradient(var(--a-bg3) 0 25%, var(--a-bg) 0 50%) 0 0 / 22px 22px; border: 1px solid var(--a-line); overflow: hidden; text-align: center; padding: 16px; }
.aig-preview img { max-width: 100%; max-height: 640px; border-radius: 12px; box-shadow: 0 12px 30px -12px rgba(11, 19, 36, .35); }
.aig-preview .aig-empty { max-width: 32ch; background: rgba(255, 255, 255, .85); padding: 10px 14px; border-radius: 10px; }
.aig-loading { display: grid; gap: 12px; justify-items: center; color: var(--a-muted); font-size: .9rem; }
.aig-loading::before { content: ""; width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--a-brand-soft); border-top-color: var(--a-brand); animation: aig-spin .8s linear infinite; }

/* Meta tag previews */
.aig-serp { background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 12px; padding: 14px 16px; font-family: Arial, sans-serif; }
.aig-serp-site { font-size: 12px; color: #4d5156; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-serp-title { font-size: 19px; line-height: 1.3; color: #1a0dab; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-serp-desc { font-size: 14px; color: #4d5156; line-height: 1.55; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.aig-og { border: 1px solid var(--a-line); border-radius: 12px; overflow: hidden; background: var(--a-bg); }
.aig-og-img { aspect-ratio: 1.91 / 1; background: var(--a-bg3) center / cover no-repeat; display: grid; place-items: center; color: var(--a-muted); font-size: .8rem; }
.aig-og-img.has-img span { display: none; }
.aig-og-body { padding: 10px 12px; background: #f2f3f5; font-family: Arial, sans-serif; }
.aig-og-site { font-size: 11px; color: #65676b; text-transform: uppercase; }
.aig-og-title { font-size: 15px; font-weight: 700; color: #050505; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-og-desc { font-size: 13px; color: #65676b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-tabs { display: flex; gap: 4px; background: var(--a-bg3); border-radius: 999px; padding: 3px; align-self: flex-start; flex-wrap: wrap; }
.aig-tabs button { border: 0; background: none; padding: .38rem .8rem; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--a-muted); cursor: pointer; }
.aig-tabs button.is-on { background: var(--a-bg); color: var(--a-ink); box-shadow: 0 1px 2px rgba(11, 19, 36, .1); }

/* Spam table */
.aig-table-wrap { overflow-x: auto; border: 1px solid var(--a-line); border-radius: 12px; }
.aig-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.aig-table th, .aig-table td { padding: .7rem .8rem; text-align: left; border-bottom: 1px solid var(--a-line); white-space: nowrap; }
.aig-table th { background: var(--a-bg2); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--a-muted); }
.aig-table td:nth-child(2) { white-space: normal; word-break: break-all; min-width: 220px; }
.aig-table tr:last-child td { border-bottom: 0; }
.aig-pill { display: inline-block; min-width: 46px; text-align: center; padding: .15rem .5rem; border-radius: 999px; font-weight: 700; font-size: .82rem; }
.aig-pill-low { background: #eaf7ee; color: #15803d; }
.aig-pill-mid { background: #fff6e5; color: #b45309; }
.aig-pill-high { background: #fdeeee; color: #c0262d; }
.aig-pill-na { background: var(--a-bg3); color: var(--a-muted); }

/* Read time */
.aig-big { text-align: center; padding: 18px 8px 8px; }
.aig-big span { display: block; font-family: var(--a-head); font-size: clamp(2.4rem, 2rem + 2vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; color: var(--a-brand); line-height: 1; }
.aig-big small { color: var(--a-muted); font-size: .85rem; }
.aig-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.aig-stats div { background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 12px; padding: 10px 12px; }
.aig-stats dt { font-size: .74rem; color: var(--a-muted); text-transform: uppercase; letter-spacing: .05em; }
.aig-stats dd { margin: 2px 0 0; font-family: var(--a-head); font-weight: 750; color: var(--a-ink); font-size: 1.1rem; }

/* History */
.aig-history { margin-top: 14px; font-size: .88rem; }
.aig-history summary { cursor: pointer; font-weight: 600; color: var(--a-muted); }
.aig-history ol { padding-left: 1.2rem; margin: 8px 0 0; display: grid; gap: 6px; }
.aig-history button { border: 0; background: none; color: var(--a-brand); cursor: pointer; text-align: left; padding: 0; font: inherit; }

/* Landing content */
.aig-land { padding-top: 40px; padding-bottom: 64px; display: grid; gap: 40px; max-width: 840px; }
.aig-land h2 { font-size: clamp(1.35rem, 1.2rem + .7vw, 1.75rem); margin: 0 0 12px; color: var(--a-ink); }
.aig-land p { font-size: 1.04rem; line-height: 1.75; color: var(--a-text); }
.aig-steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; gap: 10px; }
.aig-steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--a-line); border-radius: 14px; background: var(--a-bg); }
.aig-steps li::before { content: counter(s); flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--a-brand-soft); color: var(--a-brand); font-family: var(--a-head); font-weight: 800; font-size: .85rem; }
.aig-faq { display: grid; gap: 10px; }
.aig-faq details { border: 1px solid var(--a-line); border-radius: 14px; background: var(--a-bg); padding: 0 16px; }
.aig-faq summary { cursor: pointer; list-style: none; padding: 14px 0; font-family: var(--a-head); font-weight: 700; color: var(--a-ink); display: flex; justify-content: space-between; gap: 12px; }
.aig-faq summary::-webkit-details-marker { display: none; }
.aig-faq summary::after { content: "+"; color: var(--a-brand); font-size: 1.25rem; line-height: 1; transition: transform .2s; }
.aig-faq details[open] summary::after { transform: rotate(45deg); }
.aig-faq details p { margin: 0 0 14px; color: var(--a-muted); font-size: .98rem; }
.aig-related, .aig-try ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
@media (min-width: 720px) { .aig-related { grid-template-columns: repeat(3, 1fr); } .aig-try ul { grid-template-columns: 1fr 1fr; } }
.aig-related a, .aig-try a { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 14px 16px; border: 1px solid var(--a-line); border-radius: 14px; background: var(--a-bg); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.aig-related a:hover, .aig-try a:hover { border-color: var(--a-brand); box-shadow: 0 6px 18px -8px rgba(79, 70, 229, .35); }
.aig-related strong, .aig-try strong { font-family: var(--a-head); color: var(--a-ink); }
.aig-related span, .aig-try span { color: var(--a-muted); font-size: .88rem; }
.aig-guides-h { font-size: 1.05rem; margin: 20px 0 8px; color: var(--a-ink); }
.aig-guides { margin: 0; padding-left: 1.2rem; display: grid; gap: 6px; }
.aig-try { padding: 18px; border-radius: 18px; background: linear-gradient(135deg, var(--a-brand-soft), #f5f0ff); border: 1px solid #e2defd; }
.aig-try-h { font-family: var(--a-head); font-weight: 800; color: var(--a-ink); margin: 0 0 10px; }

/* Contact form */
.aig-contact { display: grid; gap: 14px; margin-top: 8px; }
.aig-hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

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

/* Spam checker layout */
.aig-app[data-aig-tool="spam"] .aig-textarea { min-height: 140px; }
.aig-app[data-aig-tool="spam"] .aig-toolbar { justify-content: flex-start; align-items: center; gap: 10px 20px; }
.aig-app[data-aig-tool="spam"] .aig-toolbar .js-run { margin-left: auto; }
.aig-app[data-aig-tool="spam"] .js-results { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--a-line); }
@media (max-width: 560px) { .aig-app[data-aig-tool="spam"] .aig-toolbar .js-run { margin-left: 0; width: 100%; } }
