:root {
    --bg-color: #f9f6f0;
    --card-bg-glass: rgba(255, 255, 255, 0.70);
    --card-bg-solid: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: rgba(230, 224, 216, 0.8);
    --accent-color: #d4a373;
    --accent-hover: #c28e5c;
    --btn-bg: #ffffff;
    --btn-hover-bg: #fffaf5;
    --progress-bg: #eeeeee;
    --shadow: rgba(0, 0, 0, 0.12);
    --header-bg: #fdfbf7;
}

[data-theme="dark"] {
    --bg-color: #121212;
    --card-bg-glass: rgba(22, 22, 22, 0.65);
    --card-bg-solid: #1e1e1e;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.15);
    --accent-color: #e0a96d;
    --accent-hover: #f0b87c;
    --btn-bg: #2a2a2a;
    --btn-hover-bg: #333333;
    --progress-bg: #333333;
    --shadow: rgba(0, 0, 0, 0.5);
    --header-bg: #252525;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    transition: background-color 0.3s, color 0.3s; 
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-color); 
    display: flex; 
    justify-content: center; 
    align-items: flex-start; 
    min-height: 100vh; 
    padding: 15px 10px; 
}

.main-container {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Кнопка смены темы */
.theme-toggle { 
    position: fixed; 
    top: 15px; 
    right: 15px; 
    background: var(--card-bg-solid); 
    border: 1px solid var(--border-color); 
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem; 
    cursor: pointer; 
    z-index: 90; 
    box-shadow: 0 4px 12px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Шапка с кадрированием по ромбу --- */
.site-header {
    display: flex;
    justify-content: center;
    padding: 0;
    position: relative;
    z-index: 1; /* Логотип под карточкой мастера */
    margin-bottom: -70px; /* Нахлест карточки на нижнюю часть логотипа */
    overflow: hidden;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 10px 30px var(--shadow);
}

.logo-wrapper {
    width: 100%;
    aspect-ratio: 1024 / 400;
    height: auto;
    position: relative;
    overflow: hidden;
}

.site-logo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    transition: opacity 0.3s ease;
}

/* Раздельные настройки кадрирования для светлой и темной версий логотипа */
.logo-light {
    display: block;
}

.logo-dark {
    display: none;
}

/* Логика показа логотипа в зависимости от темы сайта */
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

/* --- Карточка мастера с полупрозрачным стеклом --- */
.hero-card {
    background: var(--card-bg-glass); /* Прозрачный фон для просвечивания */
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: 20px;
    padding: 24px 20px 20px 20px;
    box-shadow: 0 10px 30px var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
    position: relative;
    z-index: 2; /* Карточка поверх логотипа */
}

.master-avatar-wrapper {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--accent-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.master-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.master-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.master-name {
    font-size: 1.3rem;
    font-weight: 700;
}

.master-badge {
    background: var(--accent-color);
    color: #fff;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
}

.master-desc {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.master-phone {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-color);
    text-decoration: none;
    margin-top: 2px;
}

.header-messengers { 
    display: flex; 
    gap: 8px; 
    width: 100%;
    margin-top: 6px; 
}

.btn-mini-msg { 
    flex: 1; 
    padding: 8px 10px; 
    border-radius: 10px; 
    font-size: 0.82rem; 
    font-weight: bold; 
    border: none; 
    color: #fff; 
    cursor: pointer; 
    text-align: center; 
    text-decoration: none; 
}

.btn-wa { background-color: #25D366; }
.btn-tg { background-color: #0088cc; }
.btn-max { background-color: #ff5e00; }



/* Баннер Квиза */
.quiz-banner {
    background: linear-gradient(135deg, var(--header-bg), var(--card-bg-solid));
    border: 2px solid var(--accent-color);
    border-radius: 20px;
    padding: 22px;
    text-align: center;
    box-shadow: 0 8px 25px var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.quiz-banner-badge {
    background: var(--accent-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
}

.quiz-banner h2 {
    font-size: 1.2rem;
    color: var(--text-color);
}

.quiz-banner p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.btn-primary-quiz {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(212, 163, 115, 0.4);
    margin-top: 5px;
}

.btn-primary-quiz:hover {
    background: var(--accent-hover);
}

/* Карточка Квиза */
.quiz-card { 
    background: var(--card-bg-solid); 
    border-radius: 20px; 
    padding: 22px; 
    box-shadow: 0 10px 30px var(--shadow); 
    border: 1px solid var(--border-color);
}

.quiz-card.hidden-quiz {
    display: none;
}

.progress-bar { 
    width: 100%; 
    height: 6px; 
    background: var(--progress-bg); 
    border-radius: 3px; 
    margin-bottom: 20px; 
    overflow: hidden; 
}

.progress-fill { 
    height: 100%; 
    background: var(--accent-color); 
    width: 25%; 
    transition: width 0.3s ease; 
}

.options { 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    margin-bottom: 20px; 
}

.option-btn { 
    background: var(--btn-bg); 
    border: 1.5px solid var(--border-color); 
    border-radius: 12px; 
    padding: 12px 14px; 
    font-size: 0.95rem; 
    cursor: pointer; 
    color: var(--text-color); 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    text-align: left; 
}

.option-btn:hover { 
    border-color: var(--accent-color); 
    background: var(--btn-hover-bg); 
}

.option-text { 
    flex: 1; 
    padding-right: 10px; 
    line-height: 1.3; 
}

.info-btn { 
    background: var(--progress-bg); 
    color: var(--text-secondary); 
    border: none; 
    border-radius: 50%; 
    width: 26px; 
    height: 26px; 
    min-width: 26px; 
    font-size: 0.85rem; 
    font-weight: bold; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer; 
}

.hidden { display: none !important; }

/* Информационные блоки (Прайс / Контакты) */
.content-section {
    background: var(--card-bg-solid);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 30px var(--shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color);
}

.price-card-wrapper {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.price-img-preview {
    width: 100%;
    height: auto;
    display: block;
}

.price-overlay {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.65);
    color: #fff;
    padding: 10px;
    text-align: center;
    font-size: 0.82rem;
    font-weight: bold;
    backdrop-filter: blur(2px);
}

.contact-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.contact-item strong {
    font-size: 0.9rem;
    color: var(--text-color);
}

.contact-item p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Контейнер интерактивной Яндекс Карты */
.map-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid var(--border-color);
    background: var(--progress-bg);
}

#map {
    width: 100%;
    height: 240px;
    display: block;
    transition: filter 0.3s ease;
}

.site-footer {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    padding: 10px 0 20px 0;
}

/* Картинка и сетка характеристик в результате квиза */
.result-img-wrapper { 
    width: 100%; 
    max-width: 511px; 
    height: auto; 
    margin: 0 auto 16px auto; 
    border-radius: 14px; 
    overflow: hidden; 
    background: var(--progress-bg); 
    border: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}

.result-img { 
    width: 100%; 
    height: auto; 
    max-height: 341px; 
    object-fit: contain; 
    display: block; 
}

.specs-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
    margin: 15px 0; 
    background: var(--header-bg); 
    padding: 12px; 
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
}

.spec-item { font-size: 0.85rem; color: var(--text-secondary); }
.spec-item strong { color: var(--text-color); }
.result-title { font-size: 1.25rem; color: var(--accent-color); margin-bottom: 8px; font-weight: 700; }
.result-desc { font-size: 0.9rem; line-height: 1.5; color: var(--text-secondary); margin-bottom: 15px; }

.messenger-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 10px; }
.messenger-buttons { display: flex; flex-direction: column; gap: 10px; }
.btn-messenger { width: 100%; padding: 13px; border-radius: 12px; font-weight: bold; font-size: 0.95rem; cursor: pointer; border: none; color: white; display: flex; align-items: center; justify-content: center; gap: 8px; }

/* Экран загрузки */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 10px; text-align: center; }
.spinner { width: 45px; height: 45px; border: 4px solid var(--progress-bg); border-top: 4px solid var(--accent-color); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 20px; }
.loading-text { font-size: 1rem; font-weight: 600; color: var(--text-color); min-height: 48px; display: flex; align-items: center; justify-content: center; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Модальные окна */
.modal-overlay { 
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background: rgba(0,0,0,0.65); 
    backdrop-filter: blur(4px); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 20px; 
    z-index: 100; 
    opacity: 0; 
    pointer-events: none; 
    transition: opacity 0.2s ease; 
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content { 
    background: var(--card-bg-solid); 
    border-radius: 16px; 
    padding: 20px; 
    max-width: 400px; 
    width: 100%; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.3); 
    border: 1px solid var(--border-color); 
    max-height: 90vh; 
    overflow-y: auto; 
}

.modal-img-wrapper { 
    width: 100%; 
    max-height: 280px; 
    background: var(--progress-bg); 
    border-radius: 12px; 
    margin-bottom: 14px; 
    overflow: hidden; 
    border: 1px solid var(--border-color); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    padding: 10px; 
}

.modal-img { max-width: 100%; max-height: 260px; width: auto; height: auto; object-fit: contain; border-radius: 8px; display: block; }
.modal-title { font-weight: bold; font-size: 1.1rem; margin-bottom: 8px; color: var(--accent-color); }
.modal-text { font-size: 0.9rem; color: var(--text-color); line-height: 1.4; margin-bottom: 16px; }
.modal-close { width: 100%; padding: 12px; background: var(--accent-color); color: #fff; border: none; border-radius: 10px; font-weight: bold; font-size: 0.95rem; cursor: pointer; }

/* Окно просмотра прайс-листа */
.modal-price-content {
    max-width: 500px;
}

.modal-price-img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}
/* --- Сетка портфолио 3x2 --- */
.portfolio-section {
    width: 100%;
    margin: 20px 0;
}

.portfolio-grid-3x2 {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important; /* Ровно 3 колонки */
    grid-template-rows: repeat(2, 1fr) !important;     /* Ровно 2 ряда */
    gap: 8px !important;
    width: 100% !important;
}

.portfolio-item-box {
    width: 100%;
    aspect-ratio: 1 / 1 !important; /* Делает элементы идеально квадратными */
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: var(--progress-bg, #222);
    border: 1px solid var(--border-color, #333);
    position: relative;
}

.portfolio-img-el {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Заполняет квадрат без искажения пропорций */
    display: block !important;
    transition: transform 0.3s ease;
}

.portfolio-item-box:hover .portfolio-img-el {
    transform: scale(1.05); /* Легкое увеличение при наведении */
}

/* --- Стили модального окна для просмотра фото --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: #1a1a1a;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.modal-price-img {
    width: 100%;
    height: auto;
    max-height: 80vh;
    display: block;
    border-radius: 8px;
    object-fit: contain;
}

.modal-close {
    position: absolute;
    top: -15px;
    right: -15px;
    background: #fff;
    color: #000;
    border: none;
    font-size: 24px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 1001;
}


/* Fix: modal close control stays inside the visible modal on narrow/mobile browsers. */
.modal-content {
    overflow: visible;
}
.modal-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    margin: 0;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: 50%;
}

@media (max-width: 520px) {
    .logo-wrapper { height: auto; aspect-ratio: 1024 / 400; }
}


/* Modal button fixes: the help dialog needs its visible "Понятно" action;
   the price dialog uses a full-width styled close button below the image. */
#helpModal .modal-content,
#priceModal .modal-content {
    position: relative;
}
#helpModal .modal-close,
#priceModal .modal-close {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    padding: 12px 16px;
    margin: 12px 0 0;
    display: block;
    background: var(--accent-color);
    color: #fff;
    border: 0;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    box-shadow: none;
    cursor: pointer;
}
#helpModal .modal-close:hover,
#priceModal .modal-close:hover {
    background: var(--accent-hover);
}
/* The portfolio lightbox alone uses a floating round X. */
#portfolioModal .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    background: #fff;
    color: #111;
    font-size: 24px;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

/* Финальные настройки шапки, портфолио и модальных окон */
.site-header { margin-bottom: -34px; }
.portfolio-item-box { position: relative; }
.portfolio-caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 9px 6px;
  color: #fff; text-align: center; font-size: .82rem; font-weight: 600;
  background: linear-gradient(transparent, rgba(0,0,0,.78));
}
#portfolioModal .modal-content { max-width: min(92vw, 760px); max-height: 92vh; overflow: auto; }
#portfolioModal .modal-price-img { max-height: 72vh; width: auto; max-width: 100%; margin: 0 auto; }
#portfolioModal .modal-title, #portfolioModal .modal-text { color: #fff; text-align: center; margin-top: 8px; }
.modal-x {
  position: absolute; top: 8px; right: 8px; z-index: 1002;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; color: #111; font-size: 25px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
#helpModal .modal-content, #priceModal .modal-content { padding-top: 54px; }
#priceModal .modal-price-content { padding-top: 54px; }

/* Корректировки портфолио, расстояний и адаптивных модальных окон */
.portfolio-section { margin: 0 !important; }
.portfolio-caption {
  white-space: nowrap;
  font-size: clamp(10px, 2.9vw, 15px);
  line-height: 1.15;
  padding: 8px 3px;
  letter-spacing: -0.02em;
}
/* Модальные окна наследуют палитру выбранной темы */
.modal-content {
  background: var(--card-bg-solid) !important;
  color: var(--text-color) !important;
  border-color: var(--border-color) !important;
}
#helpModal .modal-title,
#helpModal .modal-text,
#priceModal .modal-title,
#priceModal .modal-text { color: var(--text-color) !important; }
#portfolioModal .modal-content { background: var(--card-bg-solid) !important; }
#portfolioModal .modal-title,
#portfolioModal .modal-text { color: var(--text-color) !important; }
