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

:root {
    --bg-primary: #191a1e;
    --bg-secondary: #191a1e;
    --bg-card: #2c2f33;
    --bg-input: #23252a;
    --border: #545861;
    --border-focus: #ca4b44;
    --text-primary: #e5e7eb;
    --text-secondary: #a6a9ad;
    --text-muted: #6b6e73;
    --accent: #ca4b44;
    --accent-hover: #d45b55;
    --accent-glow: rgba(202, 75, 68, 0.15);
    --danger: #ff4a6e;
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── NAV ─── */
.nav {
    position: sticky; top: 0; z-index: 100;
    background: #2c2f33;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
}
.nav-inner {
    max-width: 1050px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between;
    height: 64px;
}
.nav-brand {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: var(--text-primary);
    font-weight: 600; font-size: 17px;
}
.nav-brand img { height: 32px; width: 32px; border-radius: 6px; }
.nav-tag {
    color: var(--accent); font-size: 14px; font-weight: 500;
    text-decoration: none; transition: color 0.2s;
}
.nav-tag:hover { color: var(--accent-hover); }

/* ─── HERO ─── */
.hero {
    text-align: center;
    padding: 24px 24px 40px;
}
.hero h1 {
    font-size: clamp(28px, 4vw, 42px);
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 0px;
}
.hero p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 520px;
    margin: 0 auto;
}

/* ─── LAYOUT ─── */
.app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px 80px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}

/* ─── CARDS ─── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    user-select: none;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title .icon { font-size: 14px; opacity: 0.6; }
.card-body {
    padding: 0 24px 24px;
}

/* ─── FORM ─── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
input[type="text"], input[type="url"], textarea, select {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.field-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ─── COLORS ─── */
.color-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.color-field { min-width: 0; }
.color-field label {
    display: block; font-size: 12px; font-weight: 500;
    color: var(--text-secondary); margin-bottom: 5px;
    text-transform: uppercase; letter-spacing: 0.04em;
}
.color-input-wrap {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 8px 3px 3px;
    transition: border-color 0.2s;
}
.color-input-wrap:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.color-input-wrap input[type="color"] {
    -webkit-appearance: none; appearance: none;
    width: 32px; height: 32px;
    border: none; background: none;
    cursor: pointer; border-radius: 6px; padding: 0;
}
.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-input-wrap input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.color-hex {
    flex: 1; background: none; border: none;
    color: var(--text-primary);
    font-family: 'DM Sans', monospace;
    font-size: 12px; outline: none;
    text-transform: uppercase;
    width: 70px;
}

/* ─── GRAPHIC SECTIONS ─── */
.graphic-section:not(.active) { display: none; }

/* ─── UPLOAD ─── */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}
.upload-zone input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-zone p { font-size: 13px; color: var(--text-secondary); }
.upload-zone p span { color: var(--accent); font-weight: 600; }
.photo-preview-wrap {
    display: flex; align-items: center; gap: 12px; margin-top: 10px;
}
.photo-preview-wrap img {
    width: 44px; height: 44px; object-fit: cover; border-radius: 50%;
    border: 2px solid var(--border);
}
.remove-photo {
    font-size: 12px; color: var(--danger); cursor: pointer;
    background: none; border: none; font-family: inherit; font-weight: 500;
}
.remove-photo:hover { text-decoration: underline; }

/* ─── BUTTONS ─── */
.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.action-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}
.action-btn svg { width: 16px; height: 16px; }
.secondary-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
}
.secondary-btn:hover {
    border-color: var(--text-muted);
    background: var(--bg-card);
}
.generate-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    flex: 1;
    padding: 13px 20px;
    background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
}
.generate-btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.generate-btn:active { transform: scale(0.98); }
.generate-btn svg { width: 18px; height: 18px; }

.action-btn:disabled, .generate-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

/* ─── STATUS ─── */
.status-bar {
    font-size: 12px;
    color: var(--text-muted);
    padding: 10px 0;
}

/* ─── PREVIEW PANEL ─── */
.preview-panel {
    position: sticky;
    top: 88px;
}
.preview-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}
.preview-label {
    font-size: 13px; font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pill {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: none;
    letter-spacing: 0;
}

.canvas-wrap {
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
    background-color: #111;
    background-image:
        linear-gradient(45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,0.04) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.04) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.04) 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0px;
}
canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
}

.tips {
    margin-top: 14px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.55;
}
.tips strong { color: var(--text-secondary); }

/* ─── FULLSCREEN ─── */
.fullscreen-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 6px; cursor: pointer;
    color: var(--text-muted); transition: all 0.2s;
}
.fullscreen-btn svg { width: 14px; height: 14px; }
.fullscreen-btn:hover { color: var(--text-primary); border-color: var(--text-muted); }

.fullscreen-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    padding: 40px;
}
.fullscreen-close {
    position: absolute; top: 20px; right: 24px;
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
    border-radius: 10px; cursor: pointer;
    color: #fff; transition: all 0.2s; z-index: 1;
}
.fullscreen-close svg { width: 22px; height: 22px; }
.fullscreen-close:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.3); }

.fullscreen-canvas-wrap {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
}
.fullscreen-canvas-wrap canvas {
    max-width: 100%; max-height: 100%;
    width: auto; height: auto;
    border-radius: var(--radius);
    aspect-ratio: 16 / 9;
}

/* ─── FOOTER ─── */
.footer {
    text-align: center; padding: 28px 24px;
    border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px;
}
.footer a { color: var(--text-secondary); text-decoration: none; }
.footer a:hover { color: var(--text-primary); }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .preview-panel { position: static; order: -1; }
}
@media (max-width: 500px) {
    .action-buttons { flex-direction: column; }
    .field-row { grid-template-columns: 1fr; }
}
