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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #121212;
    color: #ffffff;
    line-height: 1.5;
}

.main-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 20px;
}

.app-container {
    max-width: 1400px;
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: stretch;
}

.app-header {
    background: #1f1f1f;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    margin-bottom: 20px;
}

.app-header h1 {
    font-size: 24px;
    margin-bottom: 15px;
    color: #ffffff;
}

.links {
    width: 250px;
    background: #1f1f1f;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    padding: 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.btn {
    padding: 8px 16px;
    border: 1px solid #333333;
    background: #2f2f2f;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    color: #ffffff;
}

.btn:hover {
    background: #3f3f3f;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: #fe2c55;
    color: white;
    border-color: #fe2c55;
}

.btn-primary:hover {
    background: #e02548;
}

.btn-danger {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
}

.btn-danger:hover {
    background: #e03d4d;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.main-content {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    justify-content: space-between;
}

.variables-panel {
    width: 280px;
    background: #1f1f1f;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    padding: 20px;
    flex-shrink: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.variables-panel h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #ffffff;
}

.variables-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #888888;
}

.form-group input,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid #333333;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #2f2f2f;
    color: #ffffff;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #fe2c55;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-direction: column;
}

.range-inputs input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #333333;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    background: #2f2f2f;
    color: #ffffff;
}

.range-inputs span {
    color: #888888;
}

.preview-canvas {
    width: 375px;
    background: #000000;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    overflow: hidden;
    position: relative;
}

.tiktok-profile {
    background: #000000;
    min-height: 100%;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 8px;
    text-align: center;
}

.profile-image-wrapper {
    flex-shrink: 0;
    width: 96px;
    height: 96px;
    position: relative;
}

.profile-image {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer;
    border: 2px solid #fe2c55;
}

.profile-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: #1f1f1f;
    border: 2px solid #333333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #888888;
    text-align: center;
    cursor: pointer;
}

.profile-info {
    flex: none;
    min-width: 0;
    width: 100%;
    text-align: center;
}

.username {
    font-size: 14px;
    color: #888888;
    margin-bottom: 4px;
    cursor: pointer;
}

.displayname {
    font-size: 16px;
    font-weight: 400;
    color: #fff;
    cursor: pointer;
}

.stats-section {
    display: flex;
    justify-content: space-around;
    padding-top: 10px;
    padding-right: 20px;
    padding-bottom: 6px;
    padding-left: 20px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 18px;
    font-weight: 300;
    color: #ffffff;
    cursor: pointer;
}

.stat-label {
    font-size: 12px;
    color: #888888;
}

.bio-section {
    padding: 6px 20px;
}

.bio {
    font-size: 14px;
    color: #ffffff;
    line-height: 1.4;
    cursor: pointer;
    word-wrap: break-word;
    text-align: center;
}

.icons-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 16px;
    gap: 12px;
}

.icons-row .icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: transparent;
}

.icons-row .icon svg {
    width: 20px;
    height: 20px;
}

.icons-row .icon:hover svg {
    opacity: 0.9;
}

/* Bottom navigation bar inside the preview canvas */
.tiktok-profile {
    position: relative;
}

.tiktok-bottom-bar {
    position: relative;
    left: 0;
    right: 0;
    bottom: 0;
    height: 58px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0,0,0,0.55);
    border-top: 1px solid rgba(255,255,255,0.04);
    padding: 6px 8px;
    gap: 6px;
}

.tiktok-bottom-bar .tb-item {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.tiktok-bottom-bar .tb-item svg {
    width: 22px;
    height: 22px;
    stroke: #ffffff;
}

.tiktok-bottom-bar .tb-plus {
    background: transparent;
}

.tiktok-bottom-bar .tb-profile .tb-profile-thumb {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tiktok-bottom-bar .tb-profile.active .tb-profile-thumb {
    border: 2px solid #fe2c55;
    box-sizing: border-box;
}

.tiktok-bottom-bar .tb-item:hover svg {
    opacity: 0.95;
}

.videos-section {
    padding: 12px 16px 20px 16px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.video-item {
    display: block;
}

.video-thumbnail-wrapper {
    width: 100%;
    height: 150px;
    position: relative;
    background: #1f1f1f;
    border-radius: 8px;
    overflow: hidden;
}

.video-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #888888;
    cursor: pointer;
}

.video-views {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    font-size: 13px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    background: linear-gradient(to top, rgba(0,0,0,0.6), rgba(0,0,0,0.12));
    padding: 6px 8px;
    border-radius: 6px;
    pointer-events: auto;
    cursor: text;
    display: inline-block;
    max-width: calc(100% - 16px);
}

.image-library-panel {
    width: 300px;
    background: #1f1f1f;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    padding: 20px;
    flex-shrink: 0;
}

.image-library-panel h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #ffffff;
}

.library-header-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.image-library-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

/* Limit library display to 10 images (5 rows x 2 cols) and make it scrollable */
.image-library-grid {
    --lib-item-size: 120px;
    --lib-gap: 10px;
    grid-auto-rows: var(--lib-item-size);
    gap: var(--lib-gap);
    max-height: calc((var(--lib-item-size) + var(--lib-gap)) * 5);
    overflow-y: auto;
    padding-right: 6px;
}

.library-image-item {
    aspect-ratio: auto;
    height: 100%;
}

.library-image-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.library-image-item:hover {
    border-color: #fe2c55;
}

.library-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-image-item .delete-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.library-image-item:hover .delete-btn {
    opacity: 1;
}

.library-image-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.drag-over {
    border: 2px dashed #fe2c55 !important;
    background: #2f1f1f !important;
}

.editable {
    outline: none;
    border: 1px dashed #fe2c55;
    background: #2f1f1f;
    padding: 2px 4px;
    border-radius: 2px;
}

.editable:focus {
    border: 1px solid #fe2c55;
    background: #1f1f1f;
}

img[src=""] {
    display: none;
}

.image-placeholder {
    display: flex;
}

img:not([src=""]) ~ .image-placeholder {
    display: none;
}

.website-link {
    color: #fe2c55;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    word-wrap: break-word;
}

.website-link:hover {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }
    
    .variables-panel {
        width: 100%;
        max-height: none;
    }
    
    .image-library-panel {
        width: 100%;
    }
    
    .preview-canvas {
        margin: 0 auto;
    }
}
