:root {
    --bg-color: #000;
    --text-color: #fff;
    --accent-color: #007aff;
    --card-bg: rgba(255, 255, 255, 0.1);
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
}

body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow-x: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* --- Header --- */
header {
    padding-top: max(20px, var(--safe-area-top));
    padding-bottom: 10px;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky; top: 0; z-index: 100;
    border-bottom: 0.5px solid rgba(255,255,255,0.1);
}

h1 {
    font-size: 24px; font-weight: 800; margin: 0;
    background: linear-gradient(90deg, #007aff, #af52de, #ff2d55, #ff9500, #ffcc00, #34c759, #007aff);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shine 5s linear infinite;
}
@keyframes shine { to { background-position: 200% center; } }

/* --- Layout --- */
.container { padding: 20px; padding-bottom: 120px; max-width: 600px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- Preview Card --- */
.preview-card {
    position: relative; background: #111; border-radius: 32px; overflow: hidden;
    height: 500px; width: 230px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin: 0 auto 20px; display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.preview-image { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.5s ease; }
.preview-image.loaded { opacity: 1; }
#firefly-canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity 0.5s; }
#firefly-canvas.active { opacity: 1; }

/* --- Overlays --- */
.overlay-label {
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
    background: rgba(255,255,255,0.2); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    padding: 8px 16px; border-radius: 20px; font-weight: bold; font-size: 14px; white-space: nowrap;
}
.overlay-info {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}

/* --- Forms & Settings --- */
.group { background: #1c1c1e; border-radius: 12px; overflow: hidden; margin-bottom: 20px; }
.row { padding: 12px 16px; border-bottom: 0.5px solid #38383a; display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.row:last-child { border-bottom: none; }
.label { font-size: 15px; }
select, input, textarea { background: transparent; color: var(--accent-color); border: none; font-size: 15px; text-align: right; outline: none; font-family: inherit; }
textarea { text-align: left; width: 100%; height: 150px; resize: none; color: #fff; font-size: 13px; margin-top: 10px; padding: 10px; }

.section-title { font-size: 13px; color: #888; text-transform: uppercase; margin: 0 0 8px 16px; font-weight: 600; }

/* --- Prompt Builder --- */
.chip-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; }
.chip { background: rgba(0,122,255,0.15); color: var(--accent-color); padding: 6px 12px; border-radius: 8px; font-size: 12px; font-family: monospace; white-space: nowrap; border: 0.5px solid rgba(0,122,255,0.3); cursor: pointer; }

/* --- Buttons --- */
.btn { width: 100%; padding: 16px; border-radius: 18px; border: none; background: var(--accent-color); color: white; font-size: 17px; font-weight: 600; margin-bottom: 10px; cursor: pointer; transition: transform 0.1s; }
.btn:active { transform: scale(0.98); }
.btn-secondary { background: #333; }
.btn-danger { background: #ff3b30; }
.btn-home { width: 80%; max-width: 260px; display: block; margin: 0 auto 10px; padding: 14px; font-size: 15px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Tab Bar --- */
.tab-bar {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(28, 28, 30, 0.9); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    padding-bottom: max(5px, var(--safe-area-bottom)); display: flex; border-top: 0.5px solid rgba(255,255,255,0.1);
}
.tab-btn { background: none; border: none; color: #888; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 10px; flex: 1; }
.tab-btn.active { color: var(--accent-color); }
.tab-icon { font-size: 20px; }

.list-item { padding: 12px 16px; border-bottom: 0.5px solid #38383a; display: flex; justify-content: space-between; align-items: center; }
.list-item-title { font-weight: 600; font-size: 15px; }
.list-item-sub { font-size: 12px; color: #888; }

/* --- Global Overlay (Import) --- */
#import-modal {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.95); z-index: 2000; flex-direction: column; align-items: center; justify-content: center; padding: 20px; box-sizing: border-box;
}
#import-modal.active { display: flex; }
#import-text { width: 100%; max-width: 600px; height: 400px; background: #1c1c1e; color: #fff; border: 1px solid #333; border-radius: 12px; padding: 15px; font-family: monospace; font-size: 12px; }
