/**
 * T-Shirt Generator Frontend Styles
 * assets/css/frontend.css
 */

/* CSS Variables — Pet Band Tee vintage tour-poster theme.
   The generator is ALWAYS the dark "merch table" card, regardless of the
   visitor's OS color scheme — it's brand, and the B&W engraving previews
   pop hardest on warm black. Values mirror the site's --pbt-* palette
   (see landing-page/SETUP-NOTES.md); keep the two in sync. */
:root {
    --tsg-primary: #C13828;            /* tour-poster red */
    --tsg-primary-hover: #AD3120;      /* darker on hover — lighter red fails contrast */
    --tsg-secondary: #4A443B;          /* muted warm gray */
    --tsg-secondary-hover: #5A5347;
    --tsg-success: #4F7A4F;
    --tsg-success-hover: #446A44;
    --tsg-warning: #C98A2B;
    --tsg-warning-hover: #B37A24;
    --tsg-error: #E4523D;
    --tsg-error-hover: #C13828;
    --tsg-background: #0F0D0B;         /* warm faded black */
    --tsg-surface: #1B1815;            /* card surface */
    --tsg-border: #2E2A23;
    --tsg-text: #EDE5D0;               /* bone / cracked-white plastisol */
    --tsg-text-muted: #B8AE95;
    --tsg-on-primary: #FBF6EA;         /* text on red (bone ink fails AA there) */
    --tsg-accent-hi: #E4523D;          /* brighter red for icons/highlights */
    --tsg-paper: #E8E0CF;              /* "paper" wells behind artwork previews */
    --tsg-font-display: 'Oswald', 'Arial Narrow', Impact, sans-serif;
    --tsg-font-body: 'Inter', system-ui, 'Segoe UI', sans-serif;
    --tsg-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.16'/%3E%3C/svg%3E");
    --tsg-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.4);
    --tsg-shadow-lg: 0 14px 34px -8px rgb(0 0 0 / 0.55);
    --tsg-radius: 10px;   /* mockup geometry: softly rounded, not pill */
    --tsg-radius-lg: 14px;
}

/* Reset and base styles */
.tsg-wrapper {
    font-family: var(--tsg-font-body);
    line-height: 1.6;
    color: var(--tsg-text);
    /* Invisible chrome: the CARDS are the containers (mockup style) —
       no box-around-a-box. */
    background: transparent;
    border: 0;
    border-radius: 0;
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0;
    scroll-margin-top: 90px; /* sticky mobile CTA scrolls here */
    /* Layout decisions inside the card key off the CARD's width, not the
       viewport — it lives in a half-width summary column on product pages
       but can span full width via the [tshirt_generator] shortcode. */
    container-type: inline-size;
    container-name: tsg;
}

.tsg-wrapper * {
    box-sizing: border-box;
}

/* Header — hidden for customers: the card title, "Welcome, admin" and the
   notification bell are internal chrome, not shopper UI. (Kept in the DOM
   so frontend.js references stay valid.) */
.tsg-header {
    display: none;
}

.tsg-title {
    font-family: var(--tsg-font-display);
    font-size: 1.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
    color: var(--tsg-text);
}

.tsg-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tsg-login-notice {
    font-size: 0.875rem;
    color: var(--tsg-text-muted);
}

.tsg-login-notice a {
    color: var(--tsg-primary);
    text-decoration: none;
}

.tsg-login-notice a:hover {
    text-decoration: underline;
}

/* Grid Layout — single column by default; two columns only when the card
   itself is wide enough (container query, viewport-independent). */
.tsg-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@container tsg (min-width: 820px) {
    .tsg-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
}

/* Cards */
.tsg-card {
    background: var(--tsg-surface);
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius-lg);
    box-shadow: var(--tsg-shadow);
    overflow: hidden;
}

.tsg-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--tsg-border);
}

.tsg-card-header h3 {
    font-family: var(--tsg-font-display);
    margin: 0 0 0.5rem 0;
    font-size: 1.3rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tsg-card-description {
    margin: 0;
    color: var(--tsg-text-muted);
    font-size: 0.875rem;
}

.tsg-card-content {
    padding: 1.5rem;
}

.tsg-card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--tsg-border);
    background: var(--tsg-background);
}

/* Form Styles */
.tsg-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
    .tsg-form-row {
        grid-template-columns: 1fr;
    }
}

.tsg-form-group {
    margin-bottom: 1.5rem;
}

/* Inside a two-column row the row itself carries the bottom margin —
   per-field margins would double the gap. */
.tsg-form-row .tsg-form-group {
    margin-bottom: 0;
}

.tsg-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--tsg-text);
}

.tsg-input,
.tsg-select,
.tsg-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius);
    background: var(--tsg-background);
    color: var(--tsg-text);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tsg-input:focus,
.tsg-select:focus,
.tsg-textarea:focus {
    outline: none;
    border-color: var(--tsg-accent-hi);
    box-shadow: 0 0 0 3px rgb(193 56 40 / 0.18);
}

.tsg-textarea {
    min-height: 120px;
    resize: vertical;
}

.tsg-prompt-textarea {
    min-height: 300px;
    font-family: monospace;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Prompt preview — hidden from customers for now (the textarea stays in the
   DOM because frontend.js writes the generation payload into it). */
.tsg-prompt-section {
    display: none;
}

/* Divider */
.tsg-divider {
    border: none;
    height: 1px;
    background: var(--tsg-border);
    margin: 1.5rem 0;
}

/* Checklist Styles — Include and Exclude groups STACK (two clear questions),
   with the motif chips in a 2-column grid under each title. */
.tsg-checklist-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

.tsg-checklist-group {
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius);
    overflow: hidden;
}

.tsg-checklist-header {
    padding: 1rem;
    background: var(--tsg-background);
    border-bottom: 1px solid var(--tsg-border);
}

.tsg-checklist-header h4 {
    margin: 0 0 0.25rem 0;
    font-weight: 600;
}

.tsg-checklist-header p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--tsg-text-muted);
}

.tsg-checklist-scroll {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.9rem;
}

/* Very narrow cards (small phones): fall back to one column of chips */
@container tsg (max-width: 420px) {
    .tsg-checklist-scroll {
        grid-template-columns: 1fr;
    }
}

.tsg-checklist-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 0.5em 0.85em;
    border: 1px solid var(--tsg-text-muted);
    border-radius: var(--tsg-radius);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--tsg-text-muted);
    background: transparent;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.tsg-checklist-item:hover {
    border-color: var(--tsg-text);
    color: var(--tsg-text);
    background: rgb(237 229 208 / 0.05);
}

/* The real checkbox stays functional (label click + keyboard) but invisible */
.tsg-checklist-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.tsg-checklist-item span {
    font-size: inherit;
    flex: none;
}

/* Selected as INCLUDE — solid red chip */
#tsg-include-checklist .tsg-checklist-item:has(input:checked) {
    background: var(--tsg-primary);
    border-color: var(--tsg-primary);
    color: var(--tsg-on-primary);
}

/* Selected as EXCLUDE — struck-through outline chip */
#tsg-exclude-checklist .tsg-checklist-item:has(input:checked) {
    border-color: var(--tsg-accent-hi);
    color: var(--tsg-text);
    background: rgb(193 56 40 / 0.10);
    text-decoration: line-through;
    text-decoration-color: var(--tsg-accent-hi);
    text-decoration-thickness: 2px;
}

/* Keyboard focus ring on the chip */
.tsg-checklist-item:has(input:focus-visible) {
    outline: 2px solid var(--tsg-accent-hi);
    outline-offset: 2px;
}

/* Buttons */
.tsg-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: var(--tsg-radius);
    font-family: var(--tsg-font-display);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tsg-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tsg-btn-primary {
    background: var(--tsg-primary);
    color: var(--tsg-on-primary);
}

.tsg-btn-primary:hover:not(:disabled) {
    background: var(--tsg-primary-hover);
}

.tsg-btn-secondary {
    background: var(--tsg-secondary);
    color: white;
}

.tsg-btn-secondary:hover:not(:disabled) {
    background: var(--tsg-secondary-hover);
}

.tsg-btn-success {
    background: var(--tsg-success);
    color: white;
}

.tsg-btn-success:hover:not(:disabled) {
    background: var(--tsg-success-hover);
}

.tsg-form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

@media (max-width: 640px) {
    .tsg-form-actions {
        flex-direction: column;
    }
}

/* Loader */
.tsg-loader {
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: tsg-spin 1s linear infinite;
}

@keyframes tsg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Badges */
.tsg-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.tsg-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--tsg-primary);
    color: white;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Image Container */
.tsg-image-container {
    margin-bottom: 2rem;
    text-align: center;
}

.tsg-generated-image {
    max-width: 100%;
    height: auto;
    border-radius: var(--tsg-radius);
    box-shadow: var(--tsg-shadow-lg);
    margin-bottom: 1rem;
}

.tsg-image-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Upload Area */
.tsg-upload-section {
    margin: 2rem 0;
}

.tsg-upload-section h4 {
    font-family: var(--tsg-font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 600;
}

.tsg-upload-area {
    border: 2px dashed var(--tsg-border);
    border-radius: var(--tsg-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tsg-upload-area:hover,
.tsg-upload-area.tsg-dragover {
    border-color: var(--tsg-accent-hi);
    background: rgb(193 56 40 / 0.08);
}

.tsg-upload-content .dashicons {
    font-size: 3rem;
    color: var(--tsg-text-muted);
    margin-bottom: 1rem;
}

.tsg-upload-content p {
    margin: 0.5rem 0;
    font-weight: 500;
}

.tsg-upload-content small {
    color: var(--tsg-text-muted);
}

.tsg-upload-progress {
    padding: 1rem;
    text-align: center;
}

.tsg-progress-bar {
    width: 100%;
    height: 0.5rem;
    background: var(--tsg-border);
    border-radius: 9999px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.tsg-progress-fill {
    height: 100%;
    background: var(--tsg-primary);
    width: 0%;
    transition: width 0.3s;
    animation: tsg-progress 2s ease-in-out infinite;
}

@keyframes tsg-progress {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

/* Notifications */
.tsg-notifications {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    max-width: 400px;
}

.tsg-notification {
    background: var(--tsg-surface);
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius);
    box-shadow: var(--tsg-shadow-lg);
    margin-bottom: 0.5rem;
    animation: tsg-slide-in 0.3s ease-out;
}

.tsg-notification-success {
    border-left: 4px solid var(--tsg-success);
}

.tsg-notification-error {
    border-left: 4px solid var(--tsg-error);
}

.tsg-notification-warning {
    border-left: 4px solid var(--tsg-warning);
}

.tsg-notification-info {
    border-left: 4px solid var(--tsg-primary);
}

.tsg-notification-content {
    display: flex;
    align-items: flex-start;
    padding: 1rem;
}

.tsg-notification-message {
    flex: 1;
    font-size: 0.875rem;
}

.tsg-notification-close {
    background: none;
    border: none;
    color: var(--tsg-text-muted);
    cursor: pointer;
    padding: 0;
    margin-left: 0.5rem;
}

.tsg-notification-close:hover {
    color: var(--tsg-text);
}

@keyframes tsg-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.tsg-notification-badge {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--tsg-error);
    color: white;
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Modal */
.tsg-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tsg-modal-content {
    background: var(--tsg-surface);
    border-radius: var(--tsg-radius-lg);
    box-shadow: var(--tsg-shadow-lg);
    max-width: 600px;
    width: 90vw;
    max-height: 80vh;
    overflow: hidden;
}

.tsg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--tsg-border);
}

.tsg-modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.tsg-modal-close {
    background: none;
    border: none;
    color: var(--tsg-text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--tsg-radius);
    transition: background-color 0.2s;
}

.tsg-modal-close:hover {
    background: var(--tsg-border);
}

.tsg-modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

/* Generation History */
.tsg-history-section {
    margin-top: 2rem;
}

.tsg-history-section h4 {
    font-family: var(--tsg-font-display);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 600;
}

.tsg-generation-history {
    max-height: 300px;
    overflow-y: auto;
}

.tsg-history-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tsg-history-item:hover {
    background: var(--tsg-background);
    border-color: var(--tsg-primary);
}

.tsg-history-thumbnail {
    width: 3rem;
    height: 3rem;
    border-radius: var(--tsg-radius);
    overflow: hidden;
    flex-shrink: 0;
}

.tsg-history-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tsg-history-info {
    flex: 1;
    min-width: 0;
}

.tsg-history-info strong {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tsg-history-info small {
    color: var(--tsg-text-muted);
    font-size: 0.75rem;
}

/* Notification List */
.tsg-notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.tsg-notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--tsg-border);
}

.tsg-notification-item:last-child {
    border-bottom: none;
}

.tsg-notification-item.tsg-unread {
    background: rgb(193 56 40 / 0.08);
    border-left: 3px solid var(--tsg-primary);
}

.tsg-notification-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.tsg-notification-header strong {
    font-size: 0.875rem;
}

.tsg-notification-header small {
    color: var(--tsg-text-muted);
    font-size: 0.75rem;
}

.tsg-notification-body {
    font-size: 0.875rem;
    color: var(--tsg-text-muted);
    line-height: 1.5;
}

/* Loading states */
.tsg-loading {
    text-align: center;
    color: var(--tsg-text-muted);
    font-style: italic;
}

/* Footer Info */
.tsg-footer-info {
    text-align: center;
    color: var(--tsg-text-muted);
    font-size: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .tsg-wrapper {
        padding: 0.5rem;
    }
    
    .tsg-title {
        font-size: 1.5rem;
    }
    
    .tsg-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .tsg-card-content {
        padding: 1rem;
    }
    
    .tsg-image-actions {
        flex-direction: column;
    }
    
    .tsg-modal-content {
        width: 95vw;
    }
}

/* Print styles */
@media print {
    .tsg-wrapper {
        box-shadow: none;
    }
    
    .tsg-btn,
    .tsg-upload-section,
    .tsg-notifications {
        display: none;
    }
}

/* Image Gallery Styles */
.tsg-image-gallery {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding: 10px 0;
}

.tsg-image-variant {
    flex: 0 0 auto;
    position: relative;
    cursor: pointer;
    border: 3px solid transparent;
    border-radius: 8px;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.tsg-image-variant.active {
    border-color: var(--tsg-accent-hi);
    opacity: 1;
    transform: scale(1.02);
}

.tsg-image-variant:hover {
    opacity: 1;
    transform: scale(1.01);
}

.tsg-image-wrapper {
    position: relative;
    width: 200px;
    height: 280px;
    overflow: hidden;
    border-radius: 5px;
    background: var(--tsg-paper);
}

.tsg-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.tsg-recommended-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--tsg-primary);
    color: var(--tsg-on-primary);
    font-family: var(--tsg-font-display);
    padding: 4px 9px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    box-shadow: 0 2px 4px rgba(0,0,0,0.35);
    z-index: 10;
}

.tsg-gallery-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
    background: var(--tsg-surface);
    border: 1px solid var(--tsg-border);
    border-radius: var(--tsg-radius-lg);
}

.tsg-nav-btn {
    background: var(--tsg-primary);
    color: var(--tsg-on-primary);
    font-family: var(--tsg-font-display);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: none;
    padding: 8px 16px;
    border-radius: var(--tsg-radius);
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.3s ease;
}

.tsg-nav-btn:hover:not(:disabled) {
    background: var(--tsg-primary-hover);
}

.tsg-nav-btn:disabled {
    background: var(--tsg-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.tsg-image-counter {
    font-weight: bold;
    color: var(--tsg-text-muted);
    font-size: 14px;
    min-width: 80px;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .tsg-image-gallery {
        gap: 10px;
    }
    
    .tsg-image-wrapper {
        width: 150px;
        height: 210px;
    }
    
    .tsg-gallery-nav {
        gap: 10px;
        padding: 8px;
    }
    
    .tsg-nav-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .tsg-image-wrapper {
        width: 120px;
        height: 168px;
    }
    
    .tsg-recommended-badge {
        font-size: 10px;
        padding: 3px 6px;
    }
}
/* ============================================================
   Build-flow reskin (mockup): numbered steps, option pills,
   single tri-state motif list, generate row, "skip the robot".
============================================================ */

/* Legacy pieces stay in the DOM for the generator JS, never shown */
.tsg-header,
.tsg-legacy-controls,
.tsg-checklist-container,
.tsg-prompt-section {
    display: none !important;
}

.tsg-build-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 12px;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid var(--tsg-border);
    background: rgba(0, 0, 0, 0.25);
}
.tsg-build-head h3 {
    font-family: var(--tsg-font-display);
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
}
.tsg-build-head span {
    color: var(--tsg-text-muted);
    font-size: 0.9rem;
}

.tsg-step {
    padding: 1.4rem 0;
    border-bottom: 1px solid var(--tsg-border);
}
.tsg-step:first-of-type {
    padding-top: 0.3rem;
}
.tsg-step-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 1rem;
}
.tsg-step-num {
    background: var(--tsg-primary);
    color: var(--tsg-on-primary);
    font-family: var(--tsg-font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    padding: 0.25em 0.55em;
    border-radius: 6px;
}
.tsg-step-title {
    font-family: var(--tsg-font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.95rem;
    margin: 0;
}
.tsg-counts {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.tsg-count {
    background: var(--tsg-surface);
    border: 1px solid var(--tsg-border);
    color: var(--tsg-text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.3em 0.85em;
    border-radius: 999px;
}
.tsg-count-in.tsg-count-hot {
    background: rgba(193, 56, 40, 0.25);
    border-color: var(--tsg-primary);
    color: var(--tsg-accent-hi);
}
.tsg-tap-hint {
    color: var(--tsg-text-muted);
    font-size: 0.85rem;
    margin: -0.35rem 0 0.9rem;
}
.tsg-tap-hint .tsg-hint-in {
    color: var(--tsg-accent-hi);
    font-style: normal;
    font-weight: 600;
}
.tsg-tap-hint .tsg-hint-ban {
    font-style: normal;
    text-decoration: line-through;
}

/* Small-caps field labels */
.tsg-form-group label,
.tsg-pill-label {
    display: block;
    font-family: var(--tsg-font-display);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--tsg-text-muted);
    margin-bottom: 0.5rem;
}

/* Option pills (expression / text placement) */
.tsg-pillrow {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.tsg-pill {
    /* Resting state: muted border + muted text, same tone as the
       field headings (mockup) */
    border: 1px solid var(--tsg-text-muted);
    background: transparent;
    color: var(--tsg-text-muted);
    border-radius: 999px;
    padding: 0.8em 1.2em;
    font-family: var(--tsg-font-body);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.tsg-pill:hover {
    border-color: var(--tsg-text);
    color: var(--tsg-text);
}
.tsg-pill:focus:not(:focus-visible) {
    outline: none;
}
.tsg-pill:focus-visible {
    outline: 2px solid var(--tsg-accent-hi);
    outline-offset: 2px;
}
.tsg-pill.is-active {
    background: var(--tsg-paper);
    border-color: var(--tsg-paper);
    color: #1C1916;
    font-weight: 500;
}

/* Tri-state motif chips */
.tsg-motifs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.tsg-chip {
    /* Resting state: muted border + muted text, same tone as the
       field headings (mockup) */
    border: 1px solid var(--tsg-text-muted);
    background: transparent;
    color: var(--tsg-text-muted);
    border-radius: 999px;
    padding: 0.8em 1.2em;
    font-family: var(--tsg-font-body);
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.tsg-chip:hover {
    border-color: var(--tsg-text);
    color: var(--tsg-text);
}
.tsg-chip:focus:not(:focus-visible) {
    outline: none;
}
.tsg-chip:focus-visible {
    outline: 2px solid var(--tsg-accent-hi);
    outline-offset: 2px;
}
.tsg-chip.is-in {
    background: var(--tsg-primary);
    border-color: var(--tsg-primary);
    color: var(--tsg-on-primary);
    font-weight: 500;
}
.tsg-chip.is-in::before {
    content: '+ ';
}
.tsg-chip.is-ban {
    border-style: dashed;
    color: var(--tsg-text-muted);
    text-decoration: line-through;
}
.tsg-chip.is-ban::before {
    content: '\00d7  ';
}

/* Generate row */
.tsg-generate-row {
    display: flex;
    gap: 12px;
    margin-top: 1.4rem;
}
.tsg-btn-generate {
    flex: 1;
    justify-content: center;
    font-size: 1rem;
    padding: 1.05em 1.5em;
}
.tsg-generate-note {
    text-align: center;
    color: var(--tsg-text-muted);
    font-size: 0.85rem;
    margin: 0.7rem 0 0;
}

/* "Or skip the robot" divider */
.tsg-or-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 1.5rem 0 1rem;
    color: var(--tsg-text-muted);
    font-family: var(--tsg-font-display);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    font-size: 0.72rem;
    white-space: nowrap;
}
.tsg-or-divider::before,
.tsg-or-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--tsg-border);
}

/* ============================================================
   Narrow-card adaptations (container queries on the tsg card):
   the card can be narrow on wide screens (summary column) — size
   everything to the CARD, not the viewport.
============================================================ */
@container tsg (max-width: 520px) {
    .tsg-form-row {
        grid-template-columns: 1fr; /* name/breed stack */
    }
    .tsg-pill,
    .tsg-chip {
        font-size: 0.84rem;
        padding: 0.5em 0.9em;
    }
    .tsg-step-head {
        gap: 9px;
    }
}
@container tsg (max-width: 430px) {
    .tsg-generate-row {
        flex-direction: column;
        align-items: stretch;
    }
    .tsg-generate-row .tsg-btn-secondary {
        width: 100%;
        justify-content: center;
    }
    .tsg-btn-generate {
        width: 100%;
        font-size: 0.92rem;
        padding: 1em 0.75em;
    }
    .tsg-counts {
        margin-left: 0;
        width: 100%;
    }
}

/* ============================================================
   Pet reference photo zone (section 01) + caps note styling
============================================================ */
/* Last block in section 01 — the step's own bottom padding closes the
   section, so no extra field margin here. */
.tsg-ref-group {
    margin-bottom: 0;
}
.tsg-ref-optional {
    font-family: var(--tsg-font-body);
    font-style: normal;
    text-transform: none;
    letter-spacing: 0.01em;
    color: var(--tsg-text-muted);
    font-size: 0.72rem;
    font-weight: 400;
}
/* Our display:flex rules below would otherwise beat the UA's [hidden]
   default — keep JS-toggled visibility working. */
.tsg-ref-zone[hidden],
.tsg-ref-grid[hidden],
.tsg-ref-add[hidden],
.tsg-ref-count[hidden] {
    display: none !important;
}
.tsg-ref-labelrow {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}
.tsg-ref-count {
    color: var(--tsg-text-muted);
    font-family: var(--tsg-font-display);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
}
/* Empty state: big dashed drop zone, centered CTA */
.tsg-ref-zone {
    border: 1.5px dashed var(--tsg-text-muted);
    border-radius: var(--tsg-radius);
    padding: 2.1rem 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}
/* No focus ring on mouse/touch interaction — keyboard users still get one */
.tsg-ref-zone:focus:not(:focus-visible),
.tsg-ref-add:focus:not(:focus-visible) {
    outline: none;
}
.tsg-ref-zone:focus-visible,
.tsg-ref-add:focus-visible {
    outline: 2px solid var(--tsg-accent-hi);
    outline-offset: 2px;
}
.tsg-ref-zone:hover,
.tsg-ref-zone.is-drag,
.tsg-ref-grid.is-drag {
    border-color: var(--tsg-accent-hi);
    background: rgb(193 56 40 / 0.06);
}
.tsg-ref-zone.is-busy,
.tsg-ref-add.is-busy {
    opacity: 0.55;
    pointer-events: none;
}
.tsg-ref-plus {
    color: var(--tsg-accent-hi);
    font-size: 1.45rem;
    font-weight: 400;
    line-height: 1;
}
.tsg-ref-cta {
    font-family: var(--tsg-font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.92rem;
    color: var(--tsg-text);
}
.tsg-ref-sub {
    color: var(--tsg-text-muted);
    font-size: 0.88rem;
}
/* Filled state: thumbnail grid + "add angle" tile */
.tsg-ref-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    border-radius: var(--tsg-radius);
}
.tsg-ref-thumbwrap {
    position: relative;
    width: 108px;
    height: 108px;
    flex: 0 0 auto;
}
.tsg-ref-thumbwrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--tsg-border);
    display: block;
}
.tsg-ref-x {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: rgb(15 13 11 / 0.78);
    color: var(--tsg-text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.tsg-ref-x:hover {
    background: var(--tsg-error-hover);
    color: var(--tsg-on-primary);
}
.tsg-ref-primary {
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: var(--tsg-error-hover);
    color: var(--tsg-on-primary);
    font-family: var(--tsg-font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.58rem;
    padding: 0.35em 0.7em;
    border-radius: 5px;
}
.tsg-ref-add {
    width: 108px;
    height: 108px;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border: 1.5px dashed var(--tsg-text-muted);
    border-radius: 12px;
    background: transparent;
    color: var(--tsg-text);
    font-family: var(--tsg-font-display);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.72rem;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease;
}
.tsg-ref-add:hover {
    border-color: var(--tsg-accent-hi);
    background: rgb(193 56 40 / 0.06);
}
.tsg-ref-help {
    color: var(--tsg-text-muted);
    font-size: 0.72rem;
    line-height: 1.5;
    margin: 0.55rem 0 0;
}
.tsg-generate-note--limits {
    color: var(--tsg-accent-hi);
    margin-top: 0.25rem;
}
