* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #0a0a0a;
    color: #fafafa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    text-align: center;
    padding: 2.5rem 1rem 1.5rem;
}
header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
header h1 span {
    color: #6366f1;
}
header .tagline {
    color: #888;
    font-size: 1rem;
    margin-top: 0.35rem;
}

/* ── Main ── */
main {
    flex: 1;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
    padding: 0 1rem 2rem;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-radius: 0.6rem;
    overflow: hidden;
    border: 1px solid #222;
}
.tab-btn {
    flex: 1;
    padding: 0.7rem;
    background: transparent;
    color: #888;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.tab-btn.active {
    background: #6366f1;
    color: #fff;
}
.tab-btn:not(.active):hover {
    background: #161616;
    color: #ccc;
}

/* ── Tab Panels ── */
.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
}

/* ── Text Input ── */
.prompt-wrap {
    position: relative;
}
.prompt-wrap textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    background: #111;
    border: 1px solid #222;
    border-radius: 0.6rem;
    color: #fafafa;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}
.prompt-wrap textarea::placeholder {
    color: #555;
}
.prompt-wrap textarea:focus {
    outline: none;
    border-color: #6366f1;
}
.char-counter {
    position: absolute;
    bottom: 0.6rem;
    right: 0.75rem;
    font-size: 0.75rem;
    color: #555;
    pointer-events: none;
}
.char-counter.warn {
    color: #f59e0b;
}
.char-counter.over {
    color: #ef4444;
}

/* ── Image Upload ── */
.upload-area {
    border: 2px dashed #222;
    border-radius: 0.6rem;
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.05);
}
.upload-area input[type="file"] {
    display: none;
}
.upload-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #444;
}
.upload-label {
    color: #888;
    font-size: 0.9rem;
}
.upload-label strong {
    color: #6366f1;
}
.upload-hint {
    color: #555;
    font-size: 0.75rem;
    margin-top: 0.4rem;
}
.upload-preview {
    display: none;
    margin-top: 1rem;
    text-align: center;
}
.upload-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 0.5rem;
    border: 1px solid #222;
}
.upload-preview .file-name {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.4rem;
}
.upload-preview .remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 0.3rem;
    padding: 0.2rem 0.5rem;
}
.upload-preview .remove-btn:hover {
    text-decoration: underline;
}

/* ── Generate Button ── */
.generate-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.85rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.generate-btn:hover:not(:disabled) {
    background: #5558e6;
}
.generate-btn:active:not(:disabled) {
    transform: scale(0.98);
}
.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Spinner */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner.visible { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mockup Area ── */
#mockup-area {
    position: relative;
    margin-top: 2rem;
    min-height: 320px;
    border: 1px solid #1a1a1a;
    border-radius: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f0f0f;
    overflow: hidden;
    transition: border-color 0.3s;
}
#mockup-area.has-result {
    border-color: #6366f1;
}

/* Mockup canvas fills the area */
#mockup-area canvas {
    max-width: 100%;
    height: auto;
}

#mockup-wrap {
    margin-bottom: 1rem;
}

/* ── Mockup Overlay Actions ── */
.mockup-overlay-actions {
    display: none;
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 20;
}
.mockup-overlay-actions.visible {
    display: flex;
}
.mockup-overlay-actions button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #6366f1;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}
.mockup-overlay-actions button:hover {
    background: #5558e6;
    transform: scale(1.1);
}

/* ── Mockup Progress Indicator ── */
.mockup-progress {
    display: none;
    position: absolute;
    bottom: 0.6rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: #ccc;
    font-size: 0.7rem;
    padding: 0.3rem 0.8rem;
    border-radius: 1rem;
    align-items: center;
    gap: 0.4rem;
    z-index: 15;
    white-space: nowrap;
}
.mockup-progress.visible {
    display: flex;
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 1.5rem 1rem;
    border-top: 1px solid #151515;
}
.session-counter {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 0.4rem;
}
.session-counter strong {
    color: #6366f1;
}
.footer-text {
    font-size: 0.7rem;
    color: #333;
}

/* ── Zoom Lens ── */
#zoom-lens {
    position: absolute;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    border: 3px solid #6366f1;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
    pointer-events: none;
    z-index: 100;
    display: none;
    background-repeat: no-repeat;
}
#zoom-fullscreen {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}
#zoom-fullscreen.active {
    display: flex;
}
#zoom-fullscreen .close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}
#zoom-fullscreen .zoom-container {
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pinch-zoom;
    display: flex;
    align-items: center;
    justify-content: center;
}
#zoom-fullscreen .zoom-container img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
}
.tap-hint {
    position: absolute;
    bottom: 0.8rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: #888;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.25rem 0.6rem;
    border-radius: 0.4rem;
    pointer-events: none;
}

/* ── Color Selector ── */
#color-selector {
    display: block;
    margin-bottom: 1rem;
    text-align: center;
}
.color-swatches {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
    position: relative;
}
.color-swatch:hover {
    transform: scale(1.1);
}
.color-swatch.active {
    border-color: #6366f1;
}
.color-swatch[data-color="White"] {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}
.color-name {
    font-size: 0.75rem;
    color: #888;
    margin-top: 0.4rem;
}

/* ── Share Popover ── */
.share-popover {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 1rem;
    background: #111;
    border: 1px solid #333;
    border-radius: 0.6rem;
}
.share-popover.visible {
    display: flex;
}
.share-popover-label {
    font-size: 0.8rem;
    color: #888;
}
.share-popover-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: #0a0a0a;
    border: 1px solid #333;
    border-radius: 0.4rem;
    color: #fafafa;
    font-size: 0.9rem;
    font-family: inherit;
}
.share-popover-input:focus {
    outline: none;
    border-color: #6366f1;
}
.share-popover-copy {
    padding: 0.55rem 1rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background 0.2s;
}
.share-popover-copy:hover {
    background: #5558e6;
}

/* ── Copy Toast (fixed slide-up) ── */
.copy-toast {
    position: fixed;
    bottom: -3rem;
    left: 50%;
    transform: translateX(-50%);
    background: #16a34a;
    color: #fff;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    z-index: 2000;
    transition: bottom 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.copy-toast.visible {
    bottom: 2rem;
}
/* ── Lifestyle Image ── */
#lifestyle-container {
    display: none;
    margin-top: 1.5rem;
    text-align: center;
}
#lifestyle-container.visible {
    display: block;
}
#lifestyle-area {
    position: relative;
}
#lifestyle-area canvas {
    max-width: 100%;
    height: auto;
    border-radius: 0.8rem;
    border: 1px solid #6366f1;
}
.ai-lifestyle-img {
    display: none;
    max-width: 100%;
    height: auto;
    border-radius: 0.8rem;
    border: 1px solid #6366f1;
}
.ai-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    z-index: 10;
    pointer-events: none;
}
.ai-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.ai-loading-overlay span {
    color: #fff;
    font-size: 0.8rem;
    font-weight: 500;
}
.vto-error-hint {
    position: absolute;
    bottom: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.85);
    color: #fff;
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    pointer-events: none;
    white-space: nowrap;
}
.lifestyle-disclaimer {
    font-size: 0.7rem;
    color: #555;
    margin-top: 0.4rem;
}
.view-toggle {
    display: none;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    margin-bottom: 1rem;
}
.view-toggle.visible {
    display: flex;
}
.view-toggle button {
    padding: 0.4rem 1rem;
    background: transparent;
    border: 1px solid #333;
    border-radius: 0.4rem;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.view-toggle button.active {
    border-color: #6366f1;
    color: #fff;
}

/* ── Color Mode Toggle ── */
.color-mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 1rem;
    border-radius: 0.4rem;
    overflow: hidden;
    border: 1px solid #333;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}
.color-mode-toggle button {
    padding: 0.4rem 1.2rem;
    background: transparent;
    border: none;
    color: #888;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.color-mode-toggle button.active {
    background: #6366f1;
    color: #fff;
}
.color-mode-toggle button:not(.active):hover {
    background: #161616;
    color: #ccc;
}

/* ── Style Selector ── */
.style-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.style-card {
    position: relative;
    padding: 0.7rem 0.4rem;
    background: #111;
    border: 1.5px solid #222;
    border-radius: 0.6rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.style-card:hover {
    border-color: #444;
    background: #161616;
}
.style-card.active {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}
.style-card .style-icon {
    font-size: 1.3rem;
    margin-bottom: 0.3rem;
}
.style-card .style-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #ccc;
    line-height: 1.2;
}
.style-card .style-desc {
    font-size: 0.6rem;
    color: #666;
    margin-top: 0.15rem;
    line-height: 1.2;
}
#custom-style-input:focus {
    outline: none;
    border-color: #6366f1;
}

/* ── Order Section ── */
#order-section {
    display: none;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #1a1a1a;
}
#order-section.visible {
    display: block;
}
/* ── Size + Quantity Row ── */
.size-qty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.size-selector {
    display: flex;
    gap: 0.4rem;
}
.size-btn {
    padding: 0.5rem 1rem;
    background: #111;
    border: 1.5px solid #222;
    border-radius: 0.5rem;
    color: #888;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.size-btn:hover {
    border-color: #444;
    color: #ccc;
}
.size-btn.active {
    border-color: #6366f1;
    color: #fff;
    background: rgba(99, 102, 241, 0.15);
}
.order-btn {
    width: 100%;
    padding: 0.9rem;
    background: #22c55e;
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.order-btn:hover:not(:disabled) {
    background: #16a34a;
}
.order-btn:active:not(:disabled) {
    transform: scale(0.98);
}
.order-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
/* ── Quantity Selector ── */
.quantity-selector {
    display: flex;
    align-items: center;
    gap: 0;
    background: #111;
    border: 1.5px solid #222;
    border-radius: 0.5rem;
    overflow: hidden;
    flex-shrink: 0;
}
.qty-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #111;
    color: #ccc;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.qty-btn:hover:not(:disabled) {
    background: #1a1a1a;
    color: #fff;
}
.qty-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.qty-value {
    font-size: 1rem;
    font-weight: 600;
    min-width: 2.2rem;
    text-align: center;
    padding: 0 0.3rem;
    border-left: 1px solid #222;
    border-right: 1px solid #222;
    height: 36px;
    line-height: 36px;
}

/* ── HD Confirmation Section ── */
.hd-confirm {
    display: none;
    margin-top: 1.25rem;
    padding: 1rem;
    background: #111;
    border: 1px solid #222;
    border-radius: 0.8rem;
}
.hd-confirm.visible {
    display: block;
}
.hd-confirm-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ccc;
    text-align: center;
    margin-bottom: 0.75rem;
}
.hd-confirm-header i {
    color: #6366f1;
    margin-right: 0.3rem;
}
.hd-confirm-image {
    text-align: center;
    margin-bottom: 0.75rem;
}
.hd-confirm-image img {
    max-width: 100%;
    max-height: 280px;
    border-radius: 0.6rem;
    border: 1px solid #333;
}
.hd-confirm-summary {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}
.hd-confirm-cancel {
    display: block;
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.55rem;
    background: transparent;
    color: #888;
    border: 1px solid #333;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}
.hd-confirm-cancel:hover {
    border-color: #555;
    color: #ccc;
}

.order-error {
    color: #ef4444;
    font-size: 0.8rem;
    text-align: center;
    margin-top: 0.5rem;
    display: none;
}
/* ── Order Hints Row (savings + free shipping) ── */
.order-hints-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    min-height: 1.25rem;
}
.savings-hint {
    font-size: 0.8rem;
    color: #22c55e;
    visibility: hidden;
}
.savings-hint.visible {
    visibility: visible;
}
.free-shipping-note {
    font-size: 0.75rem;
    color: #666;
    margin-left: auto;
}
.free-shipping-note i {
    color: #22c55e;
    margin-right: 0.25rem;
}

/* ── Responsive — Small phones ── */
@media (max-width: 479px) {
    header { padding: 1.5rem 0.75rem 1rem; }
    header h1 { font-size: 1.8rem; }
    header .tagline { font-size: 0.85rem; }
    main { padding: 0 0.75rem 1.5rem; }
    .tab-btn { font-size: 0.8rem; padding: 0.6rem; }
    .prompt-wrap textarea { min-height: 100px; font-size: 0.9rem; }
    .generate-btn { font-size: 0.9rem; padding: 0.75rem; }
    #mockup-area { min-height: 260px; }
    .size-btn { padding: 0.35rem 0.5rem; font-size: 0.75rem; }
    .size-qty-row { gap: 0.5rem; }
    .qty-btn { width: 32px; height: 32px; }
    .qty-value { height: 32px; line-height: 32px; font-size: 0.9rem; min-width: 1.8rem; }
    .style-card { padding: 0.5rem 0.3rem; }
    .style-card .style-icon { font-size: 1.1rem; }
    .style-card .style-name { font-size: 0.65rem; }
    .style-card .style-desc { font-size: 0.55rem; }
    .color-swatch { width: 28px; height: 28px; }
}

/* ── Responsive — Tablet ── */
@media (min-width: 480px) and (max-width: 767px) {
    header { padding: 2rem 1rem 1.25rem; }
    header h1 { font-size: 2.2rem; }
    main { max-width: 540px; }
    #mockup-area { min-height: 320px; }
}

/* ── Responsive — Tablet landscape / small desktop ── */
@media (min-width: 768px) and (max-width: 1023px) {
    header { padding-top: 3rem; }
    header h1 { font-size: 2.8rem; }
    main { max-width: 580px; }
    #mockup-area { min-height: 380px; }
}

/* ── Responsive — Desktop ── */
@media (min-width: 1024px) {
    header { padding-top: 4rem; }
    header h1 { font-size: 3.2rem; }
    main { max-width: 620px; }
    #mockup-area { min-height: 420px; }
    .generate-btn { font-size: 1.05rem; }
    .style-selector { gap: 0.75rem; }
}
