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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #ffffff;
    color: #000000;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

main {
    max-width: 600px;
    width: 100%;
    padding: 40px 24px;
}

h1 {
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 14px;
    color: #666;
    margin-bottom: 32px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.header-row h1 {
    margin-bottom: 0;
}

.site-logo {
    display: block;
    height: 34px;
    width: auto;
}

.site-logo-lg {
    height: 52px;
    margin-bottom: 12px;
}

/* GPU Status */
.status-dot {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
}

.status-dot .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.online .dot {
    background: #22c55e;
}

.status-dot.offline .dot {
    background: #ef4444;
}

/* Auth / Input */
.input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

input[type="password"] {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.15s;
}

input[type="password"]:focus {
    border-color: #000;
}

input::placeholder {
    color: #aaa;
}

button {
    padding: 12px 24px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
}

button:hover {
    opacity: 0.8;
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Upload Area */
.upload-area {
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s;
    margin-bottom: 16px;
    position: relative;
}

.upload-area:hover {
    border-color: #999;
}

.upload-area.dragover {
    border-color: #000;
    background: #fafafa;
}

.upload-area p {
    font-size: 14px;
    color: #999;
}

.upload-preview {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    margin-top: 12px;
}

.upload-tips {
    font-size: 12px;
    color: #999;
    margin-bottom: 16px;
    text-align: center;
}

#generate-btn {
    width: 100%;
    margin-bottom: 24px;
}

/* While a generation is active, pin the progress bar to the top of the viewport
   so it stays visible while scrolling down to browse history or edit an item. */
#progress-section.sticky-progress {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #fff;
    padding-top: 12px;
    border-bottom: 1px solid #f0f0f0;
}

/* Progress */
.progress-bar {
    height: 4px;
    background: #f0f0f0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: #000;
    border-radius: 2px;
    width: 0%;
    /* Glide across the ~2s poll interval instead of snapping every update */
    transition: width 1.8s linear;
}

.progress-fill.pulsing {
    transition: none;
    width: 100% !important;
    opacity: 0.15;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.08; }
    50% { opacity: 0.2; }
}

.status-text {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
}

.error-text {
    font-size: 13px;
    color: #cc0000;
    line-height: 1.5;
}

/* Preview Tabs */
.preview-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.tab {
    background: none;
    color: #999;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: #000;
    opacity: 1;
}

.tab.active {
    color: #000;
    border-bottom-color: #000;
    font-weight: 500;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Model Viewer */
model-viewer {
    width: 100%;
    height: 400px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fafafa;
    margin-bottom: 16px;
}

#viewer-untextured {
    background: #e0e0e0;
}

.texture-image {
    width: 100%;
    height: 400px;
    object-fit: contain;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 16px;
    display: block;
}

/* Download */
.download-btn {
    display: block;
    text-align: center;
    padding: 12px 32px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    background: #000;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    transition: opacity 0.15s;
    cursor: pointer;
}

.download-btn:hover {
    opacity: 0.8;
}

/* "Uploaded to Roblox" toggle — shared across all friends */
.uploaded-btn {
    width: 100%;
    margin-top: 10px;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.uploaded-btn:hover:not(:disabled) {
    border-color: #999;
}

.uploaded-btn.is-uploaded {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.uploaded-btn.is-uploaded:hover:not(:disabled) {
    border-color: #16a34a;
    opacity: 0.85;
}

/* Green "✓ uploaded" pill shown next to an item's name in history */
.history-uploaded {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 500;
    color: #16a34a;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    vertical-align: middle;
}

.history-item.uploaded {
    background: #fafffb;
}

.model-stats {
    text-align: center;
    font-size: 12px;
    color: #888;
    /* viewer above already has 16px bottom margin; this spaces it from the
       download button below so it never crowds into it */
    margin: 0 0 16px;
}

.name-section {
    margin-bottom: 16px;
}

#name-btn {
    width: 100%;
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    color: #000;
    border: 1px solid #000;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

#name-btn:hover:not(:disabled) {
    background: #000;
    color: #fff;
}

#name-btn:disabled {
    color: #999;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

#name-result {
    margin-top: 12px;
}

/* Editable item name / description */
.meta-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.meta-field .ph-label {
    font-size: 12px;
    color: #999;
}

.meta-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

#item-name-input,
#item-desc-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    color: #000;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}

#item-desc-input {
    resize: vertical;
    line-height: 1.4;
}

#item-name-input:focus,
#item-desc-input:focus {
    border-color: #000;
}

.name-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.name-actions button {
    flex: 1;
}

#meta-save-btn {
    padding: 10px 16px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
}

.retry-btn {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 24px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    transition: opacity 0.15s;
    cursor: pointer;
}

.retry-btn:hover {
    opacity: 0.8;
}

/* History Icon */
.subtitle {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* What's New — fixed in the top-left corner, out of the content flow */
.whatsnew-fab {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    color: #888;
    font-family: inherit;
    font-size: 12px;
    padding: 6px 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.whatsnew-fab:hover {
    color: #000;
    border-color: #999;
}

/* How-to / requirements — mirrors the what's-new FAB, top-right corner */
.howto-fab {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    color: #888;
    font-family: inherit;
    font-size: 12px;
    padding: 6px 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.howto-fab:hover {
    color: #000;
    border-color: #999;
}

.howto-section {
    margin-bottom: 18px;
}

.modal-body .howto-section:last-child {
    margin-bottom: 0;
}

.howto-title {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    margin-bottom: 6px;
}

.howto-note {
    font-size: 12px;
    color: #888;
    line-height: 1.5;
    margin-bottom: 10px;
}

.howto-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
}

.howto-links a {
    display: block;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    color: #000;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}

.howto-links a:hover {
    border-color: #999;
    background: #fafafa;
}

.howto-tutorial {
    display: inline-block;
    padding: 10px 16px;
    background: #000;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: opacity 0.15s;
}

.howto-tutorial:hover {
    opacity: 0.8;
}

/* Shared modal — fixed, on top of everything, never shifts page layout */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: modal-fade 0.15s ease;
}

@keyframes modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-popup {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 460px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modal-popup.wide {
    max-width: 560px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    font-weight: 600;
    color: #000;
}

.modal-head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-icon-btn {
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}

.modal-icon-btn:hover,
.modal-icon-btn.active {
    color: #000;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.modal-close:hover {
    color: #000;
}

.modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.whatsnew-entry {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
}

.modal-body .whatsnew-entry:last-child {
    margin-bottom: 0;
}

.whatsnew-date {
    font-size: 12px;
    font-weight: 500;
    color: #999;
    text-transform: lowercase;
    margin-bottom: 6px;
}

.whatsnew-entry ul {
    margin: 0;
    padding-left: 18px;
}

.whatsnew-entry li {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 3px;
}

.whatsnew-entry li:last-child {
    margin-bottom: 0;
}

.history-icon {
    background: none;
    border: none;
    color: #ccc;
    padding: 2px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}

.history-icon:hover {
    color: #666;
    opacity: 1;
}

.history-list {
    margin-top: 16px;
    margin-bottom: 16px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.history-item:hover {
    border-color: #999;
}

.history-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    object-fit: cover;
    background: #fafafa;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    font-size: 12px;
    color: #999;
}

.history-delete {
    background: none;
    border: none;
    color: #ccc;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s;
}

.history-delete:hover {
    color: #cc0000;
    opacity: 1;
}

.history-empty {
    font-size: 13px;
    color: #999;
    text-align: center;
    padding: 16px;
}

/* Triangle Presets */
.triangle-presets {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.presets-label {
    font-size: 12px;
    color: #999;
    margin-right: 4px;
}

.preset-chip {
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.preset-chip:hover {
    border-color: #999;
    color: #000;
    opacity: 1;
}

.preset-chip.active {
    background: #000;
    color: #fff;
    border-color: #000;
    font-weight: 500;
}

.history-tris {
    font-size: 11px;
    color: #999;
    margin-left: 6px;
}

/* Prompt Helper */
.prompt-helper-trigger {
    width: 100%;
    margin-bottom: 16px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    color: #666;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.prompt-helper-trigger:hover {
    color: #000;
    border-color: #999;
}

.prompt-helper-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ph-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ph-research {
    padding-top: 14px;
    border-top: 1px solid #e0e0e0;
}

.ph-label {
    font-size: 12px;
    color: #999;
}

#ph-idea {
    padding: 10px 12px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    resize: none;
    background: #fff;
    width: 100%;
    height: 56px;
}

#ph-refine-btn, #ph-research-btn {
    align-self: flex-start;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 500;
    background: #fff;
    color: #000;
    border: 1px solid #000;
    border-radius: 6px;
    min-width: 140px;
}

#ph-refine-btn:hover, #ph-research-btn:hover {
    background: #000;
    color: #fff;
    opacity: 1;
}

#ph-refine-btn:disabled, #ph-research-btn:disabled {
    background: #fff;
    color: #999;
    border-color: #e0e0e0;
    cursor: not-allowed;
}

#ph-idea:focus {
    outline: none;
    border-color: #000;
}

.ph-result {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.ph-card {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 8px;
    align-items: start;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
}

.ph-card label {
    color: #999;
    padding-top: 2px;
}

.ph-value {
    color: #000;
    word-break: break-word;
}

.ph-multiline {
    white-space: pre-wrap;
    line-height: 1.5;
}

.ph-copy {
    padding: 4px 10px;
    font-size: 11px;
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    min-width: 60px;
    text-align: center;
    white-space: nowrap;
}

.ph-copy:hover {
    border-color: #999;
    color: #000;
    opacity: 1;
}

.ph-error {
    font-size: 12px;
    color: #cc0000;
    margin-top: 4px;
}

.ph-hint {
    font-size: 11px;
    color: #999;
}

/* Prompt-help history */
.ph-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ph-hist-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.ph-hist-item:hover {
    border-color: #999;
}

.ph-hist-info {
    flex: 1;
    min-width: 0;
}

.ph-hist-name {
    font-size: 13px;
    font-weight: 500;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ph-hist-idea {
    font-size: 12px;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.ph-hist-date {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
}

.ph-hist-del {
    background: none;
    border: none;
    color: #ccc;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    transition: color 0.15s;
}

.ph-hist-del:hover {
    color: #cc0000;
}

.ph-hist-empty {
    font-size: 13px;
    color: #999;
    text-align: center;
    padding: 24px 0;
}

/* Mobile */
@media (max-width: 640px) {
    /* Tall content (the preview, long history) gets clipped at the top when a
       flex parent centers it vertically — pin to the top on small screens. */
    body {
        align-items: flex-start;
    }
    main {
        /* extra top padding clears the fixed corner FABs (what's new / how to)
           so they never overlap the logo or GPU status on narrow screens */
        padding: 52px 16px 28px;
    }
    .site-logo { height: 30px; }
    .site-logo-lg { height: 44px; }
    .subtitle { margin-bottom: 24px; }
    model-viewer, .texture-image { height: 300px; }
    .whatsnew-fab {
        top: 10px;
        left: 10px;
        padding: 5px 11px;
        font-size: 11px;
    }
    .howto-fab {
        top: 10px;
        right: 10px;
        padding: 5px 11px;
        font-size: 11px;
    }
    .modal-overlay { padding: 12px; }
    .modal-popup { max-height: 88vh; }
    /* The 80px label column crowds the value on narrow screens — stack it. */
    .ph-card {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .ph-copy { justify-self: start; }
    .triangle-presets { gap: 6px; }
    .preset-chip { padding: 5px 12px; }
}

/* Utility */
.hidden {
    display: none !important;
}
