:root {
    --header-height-mobile: 52px;
    --header-height-desktop: 56px;
    /* Telegram iOS aesthetic: SF Pro on iOS/Telegram, graceful fallback elsewhere */
    --font-primary: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro', 'Inter', system-ui, 'Segoe UI', sans-serif;
    --color-accent: #008BFF;          /* Telegram blue */
    --color-accent-hover: #3aa3ff;
    --color-ton: #0098EA;
    --color-error: #ff453a;
    /* Telegram dark palette */
    --bg: #17212B;                    /* page (Telegram night) */
    --bg-elevated: #232E3C;           /* grouped sections / cells / inputs */
    --bg-elevated-hover: #2b3848;
    --separator: rgba(255, 255, 255, 0.08);
    --label-primary: #ffffff;
    --label-secondary: rgba(255, 255, 255, 0.5);
    --label-tertiary: rgba(255, 255, 255, 0.3);
    --radius-section: 12px;
}

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

body {
    background: var(--bg);
    min-height: 100vh;
    font-family: var(--font-primary);
    padding-top: var(--header-height-mobile);
    color: var(--label-primary);
    -webkit-font-smoothing: antialiased;
}

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: rgba(23, 33, 43, 0.82);
    backdrop-filter: saturate(180%) blur(20px);
    height: var(--header-height-mobile);
    z-index: 1000;
    transition: all 0.3s ease;
    border-bottom: 1px solid transparent;
    margin-bottom: 0;
}

.header.scrolled {
    background-color: rgba(23, 33, 43, 0.92);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
}

/* TON Connect button size */
#ton-connect button {
    padding: 8px 16px !important;
    font-size: 15px !important;
    height: auto !important;
}

/* Tabs — now inline inside the single header bar */
.header-tabs {
    display: flex;
    align-items: stretch;
    gap: 0;
    height: 100%;
    flex: 1;
    justify-content: center;
}

main {
    padding-top: 16px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    padding: 0 14px;
    display: flex;
    align-items: center;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-family: var(--font-primary);
    white-space: nowrap;
}

.tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--color-accent);
    border-bottom-color: var(--color-accent);
}

/* Tab content */
.tab-content {
    display: none;
}

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

.brand-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.brand-logo svg {
    width: 100%;
    height: 100%;
}

/* Desktop Styles */
@media (min-width: 768px) {
    body {
        padding-top: var(--header-height-desktop);
    }

    .header {
        height: var(--header-height-desktop);
    }

    .header-container {
        padding: 0 24px;
    }

    .header-brand {
        font-size: 18px;
    }

    .brand-logo {
        width: 32px;
        height: 32px;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
    }

    .header-brand {
        font-size: 15px;
        gap: 8px;
    }

    .brand-logo {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    :root { --header-height-mobile: 48px; }

    .header {
        height: var(--header-height-mobile);
    }

    body {
        padding-top: var(--header-height-mobile);
    }

    .header-brand {
        font-size: 14px;
        gap: 6px;
    }

    .brand-logo {
        width: 22px;
        height: 22px;
    }

    /* Single-header: free up room on tiny screens */
    .header-brand span {
        display: none;
    }

    .tab-btn {
        padding: 0 10px;
        font-size: 13px;
    }

    footer {
        padding: 20px 0;
        margin-top: 30px;
    }

    .footer-content {
        justify-content: space-between;
        gap: 16px;
    }
}

/* Footer */
footer {
    padding: 24px 0;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 32px;
    flex-wrap: wrap;
}

.footer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    text-decoration: none;
}

.footer-logo {
    width: 20px;
    height: 20px;
}

.footer-logo svg {
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .footer-content {
        gap: 20px;
        font-size: 13px;
    }

    .footer-logo {
        width: 18px;
        height: 18px;
    }
}

/* Upload Section */
.upload-section {
    padding: 12px 0 20px 0;
    max-width: 700px;
    margin: 0 auto;
}

.section-header {
    text-align: center;
    margin-bottom: 14px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
}

.section-title-ton {
    color: var(--color-ton);
}

.subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
}

.upload-form {
    background: var(--bg-elevated);
    border: none;
    border-radius: var(--radius-section);
    padding: 16px;
}

.wallet-required {
    text-align: center;
    padding: 30px 16px;
}

.wallet-required h3 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 6px;
}

.wallet-required p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #fff;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 11px 12px;
    font-size: 17px;
    letter-spacing: -0.4px;
    color: var(--label-primary);
    font-family: var(--font-primary);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    background: rgba(255, 255, 255, 0.09);
}

.form-group small {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.form-group small span {
    color: var(--color-accent);
    font-weight: 500;
}

/* Tags Input */
.tags-input-container {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    min-height: 40px;
    transition: all 0.2s;
}

.tags-input-container:focus-within {
    border-color: var(--color-accent);
    background: rgba(255, 255, 255, 0.08);
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tag-badge {
    background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
    color: #ffffff;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    animation: tagSlideIn 0.2s ease;
}

@keyframes tagSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tag-badge .tag-remove {
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tag-badge .tag-remove:hover {
    opacity: 1;
}

#tagsInput {
    flex: 1;
    min-width: 120px;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 15px;
    font-family: var(--font-primary);
    padding: 4px;
}

#tagsInput::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Upload Area */
.upload-area {
    border: 1.5px dashed rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 22px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--color-accent);
    background: rgba(0, 139, 255, 0.06);
}

.upload-area svg {
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 10px;
    width: 32px;
    height: 32px;
}

.upload-area p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
}

/* File List */
.file-list {
    margin-top: 10px;
}

.file-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-item span {
    font-size: 14px;
    color: #fff;
}

.file-item button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 18px;
}

.file-item button:hover {
    color: #ff4444;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 590;
    letter-spacing: -0.4px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 16px;
}

.submit-btn:hover {
    opacity: 0.9;
}

.submit-btn:active {
    transform: scale(0.99);
}

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

/* Projects List */
.projects-list {
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.projects-list h3 {
    font-size: 22px;
    margin-bottom: 24px;
    color: #fff;
}

/* Explore — Telegram grouped list of project cells */
.projects-grid {
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
    border-radius: var(--radius-section);
    overflow: hidden;
    max-width: 680px;
    margin: 0 auto;
}

.project-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    position: relative;
    cursor: pointer;
    transition: background 0.12s ease;
}

/* hairline separator between cells, inset past the avatar (iOS style) */
.project-card:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 70px;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--separator);
}

.project-card:hover,
.project-card:active {
    background: var(--bg-elevated-hover);
}

.project-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    text-transform: uppercase;
    user-select: none;
}

.project-main {
    flex: 1;
    min-width: 0;
}

.project-card h4 {
    font-size: 17px;
    font-weight: 590;
    letter-spacing: -0.43px;
    color: var(--label-primary);
    margin: 0 0 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.project-card p {
    font-size: 15px;
    letter-spacing: -0.23px;
    color: var(--label-secondary);
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.tag-display {
    background: rgba(0, 139, 255, 0.15);
    color: var(--color-accent);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.project-chevron {
    flex-shrink: 0;
    width: 7px;
    height: 13px;
    color: var(--label-tertiary);
}

@media (max-width: 768px) {
    .upload-section {
        padding: 40px 0;
    }

    .upload-area {
        padding: 32px 16px;
    }

    .tabs-container {
        padding: 0 16px;
    }

    .tab-btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .tabs-nav {
        top: var(--header-height-mobile);
    }
}

@media (max-width: 480px) {
    .tabs-nav {
        top: var(--header-height-mobile);
    }

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