:root {
    --bg: #f4f7fb;
    --card-bg: rgba(255, 255, 255, 0.82);
    --border: rgba(255, 255, 255, 0.4);
    --shadow: 0 25px 60px rgba(15, 34, 64, 0.12);
    --accent: #5a67ff;
    --accent-dark: #4140ff;
    --text: #1b2540;
    --text-muted: #54607a;
    --warning: #f2994a;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: clamp(1.5rem, 3vw, 3rem);
    padding-bottom: calc(clamp(1.5rem, 3vw, 3rem) + env(safe-area-inset-bottom, 0px));
    position: relative;
    overflow-x: hidden;
}

.gradient-backdrop {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(90, 103, 255, 0.35), transparent 50%),
                radial-gradient(circle at 80% 0%, rgba(255, 140, 251, 0.3), transparent 45%),
                linear-gradient(135deg, rgba(211, 226, 255, 0.6), rgba(245, 248, 255, 0.6));
    z-index: -2;
    animation: gradientShift 16s ease-in-out infinite alternate;
}

@keyframes gradientShift {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-20px);
    }
}

.app-shell {
    width: min(980px, 100%);
    display: grid;
    gap: 1rem;
    position: relative;
    flex: 0 0 auto;
}

.app-header {
    text-align: center;
    padding: 1rem 0 0.2rem;
    animation: headerFloat 12s ease-in-out infinite;
}

.app-header h1 {
    font-size: clamp(2.4rem, 5vw, 3.2rem);
    margin: 0 0 0.2rem;
}

.app-header h2 {
    margin: 0 0 2.2em;
}

.app-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: clamp(1rem, 2vw, 1.2rem);
}

@keyframes headerFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

.alert {
    border-radius: 16px;
    padding: 1rem 1.5rem;
    background: rgba(242, 153, 74, 0.18);
    border: 1px solid rgba(242, 153, 74, 0.4);
    color: var(--text);
    backdrop-filter: blur(8px);
}

.app-main {
    display: grid;
    gap: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 22px;
    padding: clamp(1.5rem, 3vw, 2rem);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 30px 70px rgba(26, 38, 96, 0.16);
}

.hero-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    align-items: center;
}

.hero-form input[type="text"] {
    height: 54px;
    border-radius: 999px;
    font-size: 1.05rem;
}

input[type="text"],
textarea {
    border-radius: 16px;
    border: 1px solid rgba(107, 121, 173, 0.25);
    padding: 0.85rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    transition: border 0.2s ease, box-shadow 0.2s ease;
    background: rgba(255, 255, 255, 0.9);
    resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: rgba(90, 103, 255, 0.6);
    box-shadow: 0 0 0 4px rgba(90, 103, 255, 0.12);
}

.cta-button {
    border: none;
    border-radius: 999px;
    padding: 0 1.9rem;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: linear-gradient(135deg, rgba(90, 103, 255, 1), rgba(111, 139, 255, 1));
    color: #fff;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cta-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cta-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 25px rgba(90, 103, 255, 0.25);
}

.cta-button:hover::before {
    opacity: 1;
}

.helper-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.card--result {
    min-height: 260px;
    display: grid;
    align-content: start;
    gap: 1.5rem;
}

.card--result.is-empty {
    display: none;
}

.card--result.is-empty .result-body {
    display: none;
}

.card--result.is-empty .placeholder {
    display: block;
    color: var(--text-muted);
    text-align: center;
    font-size: 1.05rem;
}

.result-body {
    display: grid;
    gap: 1.5rem;
    animation: fadeInUp 0.4s ease forwards;
}

.market-hint {
    margin: 0;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.16em;
}

.placeholder {
    display: none;
}

.card--reviews {
    display: grid;
    gap: 1.5rem;
}

.card--reviews[hidden] {
    display: none !important;
}

.card--reviews h3 {
    margin: 0;
    font-size: 1.25rem;
}

.reviews-subtitle {
    margin: 0.2rem 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.card--reviews ul {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 1rem;
}

.card--reviews li {
    position: relative;
    padding: 1rem 1.2rem 1rem 1.4rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(90, 103, 255, 0.22);
    box-shadow: 0 12px 28px rgba(26, 38, 96, 0.12);
    font-size: 1rem;
    color: var(--text);
    line-height: 1.55;
    display: grid;
    gap: 0.5rem;
}

.card--reviews li::before {
    content: '“';
    position: absolute;
    left: 0.6rem;
    top: 0.4rem;
    font-size: 2rem;
    color: rgba(90, 103, 255, 0.35);
}

.card--reviews li p {
    margin: 0;
}

.review-source {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.review-source a {
    color: var(--accent-dark);
    font-weight: 600;
    text-decoration: none;
}

.review-source a:hover {
    text-decoration: underline;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.brand-meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    align-items: center;
}

.logo-wrap {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.9);
    display: grid;
    place-items: center;
    box-shadow: inset 0 0 0 1px rgba(90, 103, 255, 0.18);
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% {
        box-shadow: inset 0 0 0 1px rgba(90, 103, 255, 0.18), 0 0 0 rgba(90, 103, 255, 0.0);
    }
    50% {
        box-shadow: inset 0 0 0 1px rgba(90, 103, 255, 0.32), 0 12px 25px rgba(90, 103, 255, 0.18);
    }
}

.logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#brand-name {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
}

#brand-domain {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

#brand-domain::after {
    content: '↗';
    font-size: 0.85rem;
}

#brand-domain:hover {
    text-decoration: underline;
}

#ad-output {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text);
    display: grid;
    gap: 0.85rem;
}

#ad-output p {
    margin: 0;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    backdrop-filter: blur(12px);
    background: rgba(238, 241, 255, 0.55);
    gap: 0.85rem;
    color: var(--text);
    font-weight: 600;
    z-index: 10;
}

.loading-spinner {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: 4px solid rgba(90, 103, 255, 0.18);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay[hidden] {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

body.is-loading {
    cursor: progress;
}

.loading-progress {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    width: min(260px, 72vw);
    color: inherit;
}

.loading-progress__track {
    position: relative;
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(90, 103, 255, 0.18);
}

.loading-progress__bar {
    position: absolute;
    inset: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, #4c6fff 60%, #7f9dff 100%);
    transition: width 0.28s ease;
}

.loading-progress__label {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
}

.app-footer {
    margin: auto auto calc(1.5rem + env(safe-area-inset-bottom, 0px));
    width: min(720px, 94vw);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    font-size: 0.88rem;
    color: var(--muted-text);
    padding: 2em 0 0 0;
}

.footer-disclaimer {
    flex-basis: 100%;
    margin: 0.35rem 0 0;
    text-align: center;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--text-muted);
    opacity: 0.92;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem 0.9rem;
    border-radius: 999px;
    background: rgba(90, 103, 255, 0.08);
    color: inherit;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.footer-link:hover,
.footer-link:focus-visible {
    background: rgba(90, 103, 255, 0.15);
    border-color: rgba(90, 103, 255, 0.24);
    color: var(--text);
    outline: none;
}

.footer-link--linkedin::before {
    content: 'in';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    margin-right: 0.4rem;
    border-radius: 0.2rem;
    font-weight: 700;
    background: rgba(90, 103, 255, 0.35);
    color: var(--text);
    font-size: 0.75rem;
}

.inline-toast {
    position: fixed;
    right: clamp(1rem, 4vw, 2.25rem);
    bottom: clamp(1rem, 4vw, 2.25rem);
    padding: 0.9rem 1.2rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 40px rgba(26, 38, 96, 0.18);
    color: var(--text);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 20;
    font-weight: 600;
}

.inline-toast--error {
    border: 1px solid rgba(255, 99, 132, 0.4);
}

.inline-toast--success {
    border: 1px solid rgba(90, 197, 140, 0.45);
}

.inline-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

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

@media (max-width: 720px) {
    body {
        padding: 1.25rem;
    }

    .card {
        padding: 1.25rem;
    }

    .hero-form {
        grid-template-columns: 1fr;
    }

    .cta-button {
        width: 100%;
        padding: 0.85rem 1.2rem;
        height: 52px;
    }

    .brand-meta {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
}
