* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: #fafafa;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    background: white;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid #dbdbdb;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(45deg, #405de6, #5851db, #833ab4, #c13584);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.header-icons {
    display: flex;
    gap: 20px;
}

.header-icon {
    font-size: 24px;
    cursor: pointer;
}

/* Story Bar */
.story-bar {
    background: white;
    padding: 12px 16px;
    border-bottom: 1px solid #efefef;
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.story-bar::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    min-width: 64px;
}

.story-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #405de6, #5851db, #833ab4, #c13584, #e1306c, #fd1d1d);
    padding: 2px;
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.story-name {
    font-size: 11px;
    color: #262626;
}

.my-story .story-avatar {
    background: #dbdbdb;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 0;
    scroll-behavior: smooth;
}

/* Feed Section */
.feed-section, .reels-section, .search-section, .profile-section, .channel-section {
    display: block;
    height: 100%;
    overflow-y: auto;
}

.reel-item {
    background: white;
    border-bottom: 1px solid #efefef;
    margin-bottom: 12px;
}

.reel-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.reel-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, #405de6, #5851db, #833ab4, #c13584, #e1306c, #fd1d1d);
    padding: 2px;
}

.reel-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid white;
    object-fit: cover;
}

.reel-user-info {
    flex: 1;
}

.reel-username {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

.reel-location {
    font-size: 12px;
    color: #8e8e8e;
}

.reel-options {
    color: #262626;
    cursor: pointer;
    font-size: 20px;
}

.reel-image {
    width: 100%;
    aspect-ratio: 1/1;
    background: #fafafa;
    position: relative;
    cursor: pointer;
}

.reel-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reel-actions {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    gap: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 28px;
}

.action-btn span {
    font-size: 14px;
    color: #262626;
    font-weight: 500;
}

.action-btn.liked {
    color: #ed4956;
}

.reel-caption {
    padding: 4px 16px 8px;
    font-size: 14px;
}

.caption-username {
    font-weight: 600;
    margin-right: 8px;
}

.view-comments {
    padding: 4px 16px;
    color: #8e8e8e;
    font-size: 14px;
    cursor: pointer;
}

.reel-time {
    padding: 4px 16px 12px;
    color: #8e8e8e;
    font-size: 10px;
    text-transform: uppercase;
}

/* Reels Section */
.reels-section {
    background: black;
}

.reels-video {
    height: 100vh;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.reels-video img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reels-info {
    position: absolute;
    bottom: 80px;
    left: 16px;
    color: white;
}

.reels-actions {
    position: absolute;
    right: 16px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    color: white;
}

.reels-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 28px;
    cursor: pointer;
}

.reels-action span {
    font-size: 14px;
}

/* Channel Section */
.channel-section {
    background: white;
    padding: 20px 16px;
}

.channel-header {
    text-align: center;
    margin-bottom: 24px;
}

.channel-header h2 {
    font-size: 24px;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #405de6, #833ab4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.channel-header p {
    color: #8e8e8e;
    font-size: 14px;
}

.channel-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.channel-stat-card {
    flex: 1;
    background: #fafafa;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid #efefef;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: #262626;
}

.stat-label {
    font-size: 12px;
    color: #8e8e8e;
    margin-top: 4px;
}

.channel-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.channel-action-card {
    background: #fafafa;
    padding: 16px 8px;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid #efefef;
}

.channel-action-card:hover {
    transform: translateY(-2px);
    background: white;
}

.action-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.action-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.action-desc {
    font-size: 10px;
    color: #8e8e8e;
}

.my-channels h3 {
    margin-bottom: 16px;
    font-size: 18px;
}

.channel-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #fafafa;
    border-radius: 12px;
}

.channel-thumb {
    width: 50px;
    height: 50px;
    background: linear-gradient(45deg, #405de6, #833ab4);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.channel-details {
    flex: 1;
}

.channel-name {
    font-weight: 600;
    margin-bottom: 4px;
}

.channel-stats-mini {
    font-size: 11px;
    color: #8e8e8e;
}

.channel-btn {
    padding: 6px 12px;
    background: #0095f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
}

/* Search Section */
.search-section {
    background: white;
}

.search-header {
    padding: 12px 16px;
    border-bottom: 1px solid #efefef;
    position: sticky;
    top: 0;
    background: white;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    background: #efefef;
    border: none;
    border-radius: 10px;
    font-size: 16px;
}

.search-categories {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #efefef;
    overflow-x: auto;
}

.category-btn {
    padding: 6px 16px;
    background: #efefef;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.category-btn.active {
    background: #262626;
    color: white;
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
}

.search-item {
    aspect-ratio: 1/1;
    background: #fafafa;
    cursor: pointer;
    position: relative;
}

.search-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-item-overlay {
    position: absolute;
    bottom: 8px;
    left: 8px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Profile Section */
.profile-section {
    background: white;
}

.profile-header {
    padding: 20px 16px;
    display: flex;
    gap: 20px;
    align-items: center;
}

.profile-avatar {
    width: 86px;
    height: 86px;
    border-radius: 50%;
    background: linear-gradient(45deg, #405de6, #5851db, #833ab4, #c13584, #e1306c, #fd1d1d);
    padding: 3px;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.profile-stats {
    flex: 1;
    display: flex;
    justify-content: space-around;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-weight: 600;
    font-size: 18px;
}

.stat-label {
    color: #8e8e8e;
    font-size: 12px;
}

.profile-bio {
    padding: 0 16px 20px;
}

.profile-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

.profile-bio-text {
    color: #262626;
    font-size: 14px;
    line-height: 1.4;
}

.profile-actions {
    padding: 0 16px 20px;
    display: flex;
    gap: 8px;
}

.profile-btn {
    flex: 1;
    padding: 8px;
    background: #efefef;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.profile-btn.primary {
    background: #0095f6;
    color: white;
}

.profile-tabs {
    display: flex;
    border-top: 1px solid #efefef;
    border-bottom: 1px solid #efefef;
}

.profile-tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    font-size: 20px;
    color: #8e8e8e;
}

.profile-tab.active {
    color: #262626;
    border-bottom: 2px solid #262626;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px 0;
}

.profile-grid-item {
    aspect-ratio: 1/1;
    background: #fafafa;
    cursor: pointer;
    position: relative;
}

.profile-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.grid-item-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    color: white;
    font-size: 18px;
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* Bottom Navigation */
.bottom-nav {
    background: white;
    border-top: 1px solid #dbdbdb;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
    flex: 1;
    color: #8e8e8e;
    transition: color 0.2s;
}

.nav-item.active {
    color: #262626;
}

.nav-icon {
    font-size: 26px;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

.nav-item.profile .nav-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    overflow: hidden;
}

.nav-item.profile .nav-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modals */
.story-modal, .channel-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 1000;
}

.story-modal.active, .channel-modal.active {
    display: block;
}

.channel-modal {
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
}

.channel-modal.active {
    display: flex;
}

.channel-modal-content {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    overflow: hidden;
}

.channel-modal-header {
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid #efefef;
    font-weight: 700;
    font-size: 18px;
}

.channel-modal-body {
    padding: 20px;
}

.channel-modal-footer {
    padding: 12px 16px;
    border-top: 1px solid #efefef;
    display: flex;
    gap: 12px;
}

.modal-save-btn, .modal-close-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.modal-save-btn {
    background: #0095f6;
    color: white;
}

.modal-close-btn {
    background: #efefef;
    color: #262626;
}

.edit-input, .edit-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #dbdbdb;
    border-radius: 8px;
    margin-bottom: 16px;
    font-family: inherit;
    font-size: 14px;
}

.edit-textarea {
    resize: none;
}

.story-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    z-index: 1001;
}

.story-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.story-info {
    flex: 1;
}

.story-username {
    font-weight: 600;
    font-size: 14px;
}

.story-time {
    font-size: 12px;
    opacity: 0.8;
}

.story-close {
    font-size: 30px;
    cursor: pointer;
}

.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-progress {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
}

.progress-bar {
    height: 2px;
    background: rgba(255,255,255,0.3);
    flex: 1;
    border-radius: 2px;
}

.progress-bar.active {
    background: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 14px;
    display: none;
    z-index: 2000;
    white-space: nowrap;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; }
}