:root {
    --bg: #f6f3f8;
    --panel: #ffffff;
    --panel-soft: #fbf8ff;
    --text: #24212b;
    --muted: #746d7d;
    --line: #e8e0ee;
    --accent: #cb11ab;
    --accent-2: #7f2cff;
    --accent-dark: #8d137a;
    --accent-soft: #fff0fb;
    --focus: #cb11ab;
    --success: #2aa66a;
    --shadow: 0 16px 38px rgba(70, 38, 83, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 0%, rgba(203, 17, 171, 0.10), transparent 28%),
        radial-gradient(circle at 88% 8%, rgba(127, 44, 255, 0.12), transparent 30%),
        var(--bg);
    font-family: "Trebuchet MS", Verdana, sans-serif;
}

button,
input,
textarea,
a {
    font: inherit;
}

.market-header {
    background: linear-gradient(90deg, #cb11ab 0%, #8b2cff 58%, #4b1ca8 100%);
    color: #fff;
    box-shadow: 0 12px 28px rgba(101, 35, 124, 0.24);
}

.market-header-inner {
    width: min(1180px, calc(100% - 32px));
    min-height: 82px;
    display: grid;
    grid-template-columns: auto minmax(260px, 1fr) auto;
    gap: 18px;
    align-items: center;
    margin: 0 auto;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
}

.brand-logo {
    width: 44px;
    height: 44px;
    display: block;
    flex: 0 0 auto;
    filter: drop-shadow(0 8px 12px rgba(63, 16, 85, 0.26));
}

.brand-text {
    font-size: clamp(1.35rem, 3vw, 2.15rem);
    font-weight: 900;
    letter-spacing: 0;
}

.market-search-shell {
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 18px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    color: #756c80;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38);
}

.market-search-dot {
    width: 16px;
    height: 16px;
    border: 3px solid var(--accent);
    border-radius: 999px;
    position: relative;
    flex: 0 0 auto;
}

.market-search-dot::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 3px;
    right: -7px;
    bottom: -4px;
    border-radius: 999px;
    background: var(--accent);
    transform: rotate(45deg);
}

.market-search-text {
    font-size: 0.95rem;
    font-weight: 700;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 44px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.08;
    letter-spacing: 0;
}

h2 {
    font-size: clamp(1.55rem, 3vw, 2.35rem);
    font-weight: 900;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: #fff;
    font-size: 0.76rem;
    font-weight: 900;
    white-space: nowrap;
}

.header-pill {
    border-color: rgba(255, 255, 255, 0.38);
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
}

.tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
}

.tab {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    color: #5f5668;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 900;
    text-align: center;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tab:hover {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.tab-active {
    color: #fff;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 10px 22px rgba(203, 17, 171, 0.24);
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(320px, 0.88fr);
    gap: 18px;
    margin-top: 18px;
}

.competitors-workspace {
    display: grid;
    gap: 18px;
    margin-top: 18px;
}

.form-panel,
.result-panel {
    padding: clamp(20px, 4vw, 32px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow);
}

.section-heading {
    margin-bottom: 22px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field-wide {
    grid-column: 1 / -1;
}

.field-group label {
    display: block;
    margin-bottom: 8px;
    color: #3a3344;
    font-size: 0.9rem;
    font-weight: 900;
}

.field-group input,
.field-group textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 15px;
    color: var(--text);
    background: #fff;
    outline: 0;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field-group input[type="file"] {
    padding: 11px 14px;
    background: var(--panel-soft);
}

.field-group textarea {
    min-height: 118px;
    resize: vertical;
}

.field-group input:focus,
.field-group textarea:focus {
    border-color: var(--focus);
    box-shadow: 0 0 0 4px rgba(203, 17, 171, 0.12);
}

.field-error,
.form-alert {
    margin-top: 8px;
    color: var(--accent-dark);
    font-size: 0.84rem;
    font-weight: 900;
}

.form-alert {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    background: var(--accent-soft);
}

.form-alert p {
    margin: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 22px;
}

.primary-button,
.secondary-button {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 12px 20px;
    font-weight: 900;
    cursor: pointer;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.primary-button {
    color: #fff;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    box-shadow: 0 12px 22px rgba(203, 17, 171, 0.22);
}

.primary-button:disabled {
    cursor: wait;
    opacity: 0.86;
}

.button-loading {
    position: relative;
    gap: 10px;
}

.button-loading::before {
    content: "";
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    border: 3px solid rgba(255, 255, 255, 0.42);
    border-top-color: #fff;
    border-radius: 999px;
    animation: loading-spin 760ms linear infinite;
}

.secondary-button {
    width: 100%;
    margin-top: 18px;
    color: #fff;
    background: #3a2248;
}

.primary-button:hover,
.secondary-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(93, 42, 126, 0.22);
}

.primary-button:disabled:hover {
    transform: none;
    box-shadow: 0 12px 22px rgba(203, 17, 171, 0.22);
}

.generated-result,
.empty-result,
.image-preview {
    min-height: 280px;
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.generated-result p,
.empty-result p {
    margin: 0;
    font-size: 1.03rem;
    line-height: 1.65;
}

.empty-result {
    display: flex;
    align-items: center;
    color: var(--muted);
    border-style: dashed;
    background: var(--panel-soft);
}

.loading-result {
    min-height: 280px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border: 1px solid rgba(203, 17, 171, 0.22);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(255, 240, 251, 0.92), rgba(255, 255, 255, 0.96)),
        #fff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.loading-result[hidden] {
    display: none;
}

.loading-spinner {
    width: 46px;
    height: 46px;
    border: 5px solid rgba(203, 17, 171, 0.16);
    border-top-color: var(--accent);
    border-right-color: var(--accent-2);
    border-radius: 999px;
    animation: loading-spin 860ms linear infinite;
}

.loading-title {
    margin: 0 0 8px;
    color: #3a2248;
    font-size: 1.08rem;
    font-weight: 900;
}

.loading-text {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.45;
    font-weight: 800;
}

.loading-bar {
    grid-column: 1 / -1;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(203, 17, 171, 0.12);
}

.loading-bar span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    animation: loading-bar 1.25s ease-in-out infinite;
}

.image-preview {
    display: grid;
    place-items: center;
    min-height: 360px;
    padding: 14px;
}

.image-preview img {
    width: min(100%, 520px);
    aspect-ratio: 3 / 4;
    display: block;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--bg);
}

.image-empty {
    min-height: 360px;
}

.download-link {
    width: 100%;
}

.query-hints {
    margin: -8px 0 22px;
    padding: 14px;
    border: 1px solid #f2c6ea;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff7fd, #ffffff);
}

.query-hints p {
    margin: 0 0 10px;
    color: #675b70;
    font-size: 0.92rem;
    font-weight: 800;
}

.query-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.query-category-list {
    display: grid;
    gap: 14px;
}

.query-category {
    display: grid;
    gap: 9px;
}

.query-category h3 {
    color: #3a2248;
    font-size: 0.92rem;
    font-weight: 900;
}

.query-chip-list a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid rgba(203, 17, 171, 0.24);
    border-radius: 999px;
    color: var(--accent-dark);
    background: #fff;
    font-size: 0.84rem;
    font-weight: 900;
    text-decoration: none;
}

.query-chip-list a:hover {
    color: #fff;
    background: var(--accent);
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
}

.search-actions {
    margin-top: 0;
}

.competitors-panel {
    min-height: 420px;
}

.competitors-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.competitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 14px;
}

.competitor-results-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    gap: 18px;
    align-items: start;
}

.competitor-card {
    position: relative;
    display: grid;
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(70, 38, 83, 0.08);
}

.competitor-position {
    position: absolute;
    left: 14px;
    top: 14px;
    z-index: 2;
    min-width: 42px;
    padding: 6px 8px;
    color: #fff;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    font-size: 0.78rem;
    font-weight: 900;
    text-align: center;
}

.competitor-image {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.competitor-content h3 {
    margin: 0 0 10px;
    min-height: 42px;
    font-size: 1.05rem;
    line-height: 1.25;
    font-weight: 900;
}

.competitor-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.competitor-stats span {
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 0.78rem;
    font-weight: 900;
}

.competitor-stats span:first-child {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.product-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    width: 100%;
    border-radius: 8px;
    color: #fff;
    background: #3a2248;
    font-size: 0.86rem;
    font-weight: 900;
    text-decoration: none;
}

.competitor-analytics {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(70, 38, 83, 0.08);
}

.analytics-heading h3 {
    color: #3a2248;
    font-size: 1.2rem;
    font-weight: 900;
}

.analytics-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.analytics-kpi,
.top-reviewed {
    display: grid;
    gap: 5px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
}

.analytics-kpi span,
.top-reviewed span,
.top-reviewed small {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
}

.analytics-kpi strong,
.top-reviewed strong {
    color: #3a2248;
    font-size: 1rem;
    line-height: 1.2;
    font-weight: 900;
}

.top-reviewed strong {
    font-size: 0.92rem;
}

.analytics-chart {
    display: grid;
    gap: 9px;
}

.analytics-chart h4 {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
}

.chart-row {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 62px;
    gap: 8px;
    align-items: center;
}

.chart-label,
.chart-value {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
}

.chart-value {
    text-align: right;
}

.chart-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #f1eaf6;
}

.chart-bar {
    display: block;
    height: 100%;
    min-width: 8px;
    border-radius: inherit;
}

.price-bar {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.review-bar {
    background: linear-gradient(90deg, #2aa66a, #72d38f);
}

.rating-bar {
    background: linear-gradient(90deg, #f4a62a, #ffd166);
}

.competitors-empty {
    min-height: 240px;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.result-meta span {
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    background: var(--panel-soft);
    font-size: 0.78rem;
    font-weight: 900;
}

.copy-status {
    min-height: 20px;
    margin: 10px 0 0;
    color: var(--success);
    font-size: 0.86rem;
    font-weight: 900;
}

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

@keyframes loading-bar {
    0% {
        transform: translateX(-115%);
    }

    50% {
        transform: translateX(70%);
    }

    100% {
        transform: translateX(245%);
    }
}

@media (max-width: 820px) {
    .market-header-inner,
    .workspace,
    .field-grid,
    .tabs,
    .search-row,
    .competitor-results-layout {
        grid-template-columns: 1fr;
    }

    .market-header-inner {
        padding: 16px 0;
    }

    .header-pill {
        justify-self: start;
    }

    .search-actions,
    .search-actions .primary-button {
        width: 100%;
    }

    .competitor-analytics {
        position: static;
    }

    .loading-result {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .app-shell,
    .market-header-inner {
        width: min(100% - 20px, 1180px);
    }

    .app-shell {
        padding-top: 14px;
    }

    .form-panel,
    .result-panel {
        padding: 18px;
    }

    .generated-result,
    .empty-result,
    .image-preview {
        min-height: 210px;
        padding: 16px;
    }

    .image-empty {
        min-height: 210px;
    }

    .competitor-grid {
        grid-template-columns: 1fr;
    }

    .brand-text {
        font-size: 1.35rem;
    }
}
