/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #fef9f0;
    --bg-card: #ffffff;
    --bg-card-hover: #fff7ed;
    --border: #f0e0c8;
    --text: #3d2c1e;
    --text-dim: #9a8570;
    --pink: #ff6b9d;
    --pink-light: #fff0f5;
    --purple: #a855f7;
    --purple-light: #faf0ff;
    --blue: #60a5fa;
    --blue-light: #eff6ff;
    --orange: #fb923c;
    --orange-light: #fff7ed;
    --green: #34d399;
    --green-light: #ecfdf5;
    --yellow: #fbbf24;
    --danger: #f87171;
    --radius: 20px;
    --radius-sm: 12px;
    --shadow: 0 2px 12px rgba(180, 140, 100, 0.1);
    --shadow-hover: 0 6px 24px rgba(180, 140, 100, 0.18);
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 90% 80%, rgba(255, 107, 157, 0.04) 0%, transparent 50%);
}

/* ── Header ────────────────────────────────────────────── */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: #ffffff;
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 8px rgba(200, 160, 100, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 800;
    color: var(--purple);
}

.logo-icon { font-size: 28px; }

.nav-tabs {
    display: flex;
    gap: 6px;
    background: var(--orange-light);
    padding: 5px;
    border-radius: 16px;
}

.nav-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.25s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.6); }

.nav-tab.active {
    background: var(--orange);
    color: #fff;
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.35);
}

.tab-icon { font-size: 16px; }

.credit-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background: var(--yellow);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    color: #78350f;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

/* ── Main Layout ───────────────────────────────────────── */
.main {
    max-width: 1360px;
    margin: 0 auto;
    padding: 24px;
}

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

.panel-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    align-items: start;
}

.panel-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── Card ──────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.card-emoji { font-size: 40px; }

.card-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
}

.card-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 2px;
}

/* ── Form ──────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group textarea,
.form-group input[type="text"],
.form-group input[type="url"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: #fefcf8;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    resize: vertical;
}

.form-group textarea:focus,
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.form-group select { cursor: pointer; }

.form-group input[type="range"] {
    width: 100%;
    accent-color: var(--purple);
    height: 8px;
}

.form-group input[type="checkbox"] {
    accent-color: var(--purple);
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

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

.range-hint {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ── Buttons ───────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-cute {
    background: var(--purple-light);
    border-color: rgba(168, 85, 247, 0.25);
    color: var(--purple);
}

.btn-cute:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--purple);
}

.btn-dl-glb {
    background: var(--blue-light);
    border: 2px solid rgba(96, 165, 250, 0.3);
    color: #1d4ed8;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-dl-glb:hover {
    background: rgba(96, 165, 250, 0.2);
    border-color: var(--blue);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(96, 165, 250, 0.25);
}

.btn-dl-obj {
    background: var(--green-light);
    border: 2px solid rgba(52, 211, 153, 0.3);
    color: #065f46;
    font-weight: 700;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-dl-obj:hover {
    background: rgba(52, 211, 153, 0.2);
    border-color: var(--green);
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(52, 211, 153, 0.25);
}

.btn-magic {
    background: linear-gradient(135deg, var(--pink), var(--purple));
    border: none;
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    padding: 14px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.btn-magic:hover {
    box-shadow: 0 6px 24px rgba(168, 85, 247, 0.45);
    transform: translateY(-2px);
}

.btn-magic:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-full { width: 100%; justify-content: center; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ── Upload Area ───────────────────────────────────────── */
.upload-area {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #fefcf8;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--purple);
    background: var(--purple-light);
}

.upload-icon { font-size: 40px; display: block; margin-bottom: 8px; }
.upload-placeholder p { font-size: 14px; color: var(--text-dim); line-height: 1.5; }
.upload-hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; display: block; }

.upload-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* ── 3D Viewer ─────────────────────────────────────────── */
.viewer-card { padding: 0; overflow: hidden; }

.viewer-container {
    width: 100%;
    height: 480px;
    position: relative;
    background: linear-gradient(135deg, #f8f0ff 0%, #fff0f5 50%, #eff6ff 100%);
}

.viewer-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

.viewer-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-dim);
}

.placeholder-icon { font-size: 56px; display: block; margin-bottom: 8px; }
.viewer-placeholder p { font-size: 15px; }

.viewer-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 2px solid var(--border);
    background: var(--orange-light);
}

/* ── Progress Card ─────────────────────────────────────── */
.progress-card {
    padding: 16px 20px;
    background: var(--purple-light);
    border-color: rgba(168, 85, 247, 0.2);
}

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

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-dim);
}

.status-badge.pending { background: rgba(251, 191, 36, 0.2); color: #92400e; }
.status-badge.in-progress { background: rgba(168, 85, 247, 0.15); color: var(--purple); }
.status-badge.succeeded { background: rgba(52, 211, 153, 0.2); color: #065f46; }
.status-badge.failed { background: rgba(248, 113, 113, 0.2); color: #991b1b; }

.progress-percent { font-size: 15px; font-weight: 800; color: var(--purple); }

.progress-track {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pink), var(--purple));
    border-radius: 5px;
    transition: width 0.5s ease;
}

.progress-text {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 8px;
}

/* ── My Models Grid ────────────────────────────────────── */
.models-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.models-header h2 { font-size: 22px; font-weight: 800; }

.models-filter { display: flex; gap: 8px; align-items: center; }

.models-filter select {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
}

.models-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 0;
    color: var(--text-dim);
}

.empty-icon { font-size: 56px; display: block; margin-bottom: 12px; }
.models-empty p { font-size: 15px; line-height: 1.6; }

.model-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s;
    box-shadow: var(--shadow);
}

.model-card:hover {
    border-color: var(--purple);
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.model-card-thumb {
    width: 100%;
    height: 190px;
    background: linear-gradient(135deg, #f8f0ff, #fff0f5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.model-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.model-card-thumb .no-thumb {
    color: var(--text-dim);
    font-size: 13px;
}

.model-card-body { padding: 14px; }

.model-card-body h4 {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
}

.model-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-card-meta span {
    font-size: 12px;
    color: var(--text-dim);
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    width: 90vw;
    max-width: 860px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    color: #fff;
    font-size: 22px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-viewer {
    width: 100%;
    height: 460px;
    background: linear-gradient(135deg, #f8f0ff 0%, #fff0f5 50%, #eff6ff 100%);
}

.modal-info {
    padding: 16px 20px;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.modal-info h3 {
    font-size: 16px;
    font-weight: 700;
}

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

/* ── Spinner ──────────────────────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
    .panel-layout { grid-template-columns: 1fr; }
    .viewer-container { height: 320px; }
    .nav-tab { padding: 6px 10px; font-size: 12px; }
    .nav-tab .tab-icon { display: none; }
    .logo span { display: none; }
}

@media (max-width: 600px) {
    .main { padding: 12px; }
    .header { padding: 0 12px; }
    .models-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
}
