:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --dark: #0f172a;
    --light: #f8fafc;
    --gray: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --radius: 16px;
    --font-main: 'Inter', sans-serif;
}

body {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    /* Используем локальное изображение или CSS градиент как фолбэк */
    background: radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    background-color: #0f172a;
    /* Fallback */
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
    color: var(--dark);
    font-family: var(--font-main);
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    /* Fix horizontal scroll */
}

/* Glassmorphism Classes */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    /* Critical layout fix */
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    /* Ensure responsiveness */
}

/* Header */
.main-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.nav-link {
    color: var(--gray);
    text-decoration: none;
    /* margin-left: 2rem; Removed in favor of gap */
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Cards & Feed */
.card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.card:not(.no-hover):hover {
    transform: translateY(-2px);
}

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
}

.star {
    color: #cbd5e1;
    /* Darker gray for better visibility */
    font-size: 1.2rem;
    transition: color 0.2s ease, transform 0.2s ease;
    /* Smooth transition */
}

.star.filled {
    color: #f59e0b;
}

.author {
    font-weight: 600;
    color: var(--primary);
}

.date {
    color: var(--gray);
    font-size: 0.85rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Rating Buttons Hover Effect */
.rating-label:hover .rating-btn {
    background-color: rgba(99, 102, 241, 0.1);
}

/* Photo Upload Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-window {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.modal-close {
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--gray);
    line-height: 1;
}

.photo-preview-box {
    width: 100%;
    height: 200px;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
    background: #f8fafc;
}

.photo-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Visual Editor */
.editor-content {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    resize: vertical;
}

.editor-content:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
}

.editor-image-wrapper {
    position: relative;
    display: block;
    /* Always on new line */
    clear: both;
    margin: 15px 0;
    /* More spacing */
    max-width: 50%;
    /* Limit size to half editor width */
    vertical-align: top;
    user-select: none;
    cursor: grab;
    /* Show grab cursor */
    transition: transform 0.2s;
}

.editor-image-wrapper img {
    width: 100%;
    /* Fill the wrapper */
    height: auto;
    border-radius: 12px;
    display: block;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.editor-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.0);
    border-radius: 12px;
    transition: background 0.2s;
    pointer-events: none;
    /* Let clicks pass through to controls */
}

/* Controls */
.image-control-btn {
    position: absolute;
    width: 32px;
    height: 32px;
    background: rgba(15, 23, 42, 0.8);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s;
    z-index: 10;
    pointer-events: auto;
}

.image-control-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.btn-delete-img {
    top: 10px;
    right: 10px;
}

.btn-move-img {
    top: 10px;
    left: 10px;
    cursor: grab;
}

.editor-image-wrapper:hover .editor-image-overlay {
    background: rgba(0, 0, 0, 0.02);
    border: 2px solid var(--primary);
}

/* HTML Content Styling (from Editor) */
.content-html {
    font-size: 1rem;
    line-height: 1.6;
    color: #334155;
    word-break: break-word;
    /* Prevent overflow */
}

.content-html p {
    margin-bottom: 0.8rem;
}

.content-html img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: block;
}

.content-html ul,
.content-html ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.content-html blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    margin-left: 0;
    font-style: italic;
    color: var(--gray);
    background: #f8fafc;
    padding: 0.5rem 1rem;
    border-radius: 0 8px 8px 0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        padding: 0.8rem;
    }

    .main-nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .nav-link {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .container {
        padding: 1rem 0.5rem;
    }

    .card {
        padding: 1.25rem !important;
        border-radius: 12px !important;
    }

    h1 {
        font-size: 1.4rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.3 !important;
    }

    h2 {
        font-size: 1.25rem !important;
    }

    /* Form specifics */
    .form-group label {
        font-size: 0.95rem !important;
        white-space: normal;
        /* wrap long labels */
        line-height: 1.4;
    }

    /* FIX STARS OVERFLOW */
    .star-rating-input {
        font-size: 2rem !important;
        /* Smaller stars */
        display: flex;
        justify-content: space-between;
        /* Distribute evenly or center */
        gap: 2px;
        flex-wrap: nowrap;
        /* Keep in one line */
        width: 100%;
        /* Full width */
        overflow: hidden;
        /* Safety */
    }

    .star-rating-input span {
        flex: 1;
        /* Distribute space */
        text-align: center;
    }

    /* Editor Images on mobile */
    .editor-image-wrapper {
        max-width: 100% !important;
        /* Full width for better visibility */
        margin: 15px 0;
    }

    /* Make touch controls bigger */
    .image-control-btn {
        width: 42px;
        height: 42px;
        font-size: 1.4rem;
    }

    .btn-delete-img {
        top: 10px;
        right: 10px;
    }

    .btn-move-img {
        top: 10px;
        left: 10px;
    }

    /* Stack form inputs better if needed */
    .form-control {
        font-size: 16px !important;
        /* Prevent iOS zoom on focus */
    }

    /* Grid adjustments if any */
    .companies-grid,
    .reviews-grid {
        grid-template-columns: 1fr;
    }
}