/* Акцент фиолетовый, только зелёный и фиолетовый, без заливки фона */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-inactive: #F2F2F7;
  --accent: #8B5CF6;
  --accent-gradient: linear-gradient(90deg, #7C3AED 0%, #8B5CF6 50%, #A78BFA 100%);
  --accent-soft: rgba(139, 92, 246, 0.12);
  --text: #1C1C1E;
  --text-secondary: #3A3A3C;
  --text-muted: #8E8E93;
  --border: rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.08);
  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;
  --success: #34C759;
  --warning: #A78BFA;
  --danger: #7C3AED;
  --max-width: 430px;
  --max-width-tablet: 640px;
  --max-width-desktop: 880px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: var(--max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 0 12px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.app {
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Один экран за раз, как в мобильном приложении */
.view {
  display: none;
}
.view.active {
  display: block;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.view.active .card-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

/* Карточки — белые, сильное скругление, мягкая тень (как на скринах) */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow-card);
}
.card--welcome {
  margin: 24px;
  text-align: center;
}
.card-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card-screen .card {
  width: 100%;
  max-width: 360px;
}

.title {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: var(--text);
}
.subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 24px 0;
  line-height: 1.5;
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 24px;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  width: 100%;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-sm);
}
.btn--primary:hover:not(:disabled) {
  opacity: 0.95;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.35);
}

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius-sm);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--surface-inactive);
  border-color: rgba(0, 0, 0, 0.1);
}

.btn--outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}
.btn--outline:hover:not(:disabled) {
  background: var(--accent-soft);
}

/* Выбор типа кожи */
.skin-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}
.option {
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: none;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}
.option:hover {
  background: var(--surface-inactive);
}
.option.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

/* Шапка — без тени, отступ от верха экрана */
.header--gradient {
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 28px 20px 24px;
  margin-top: 12px;
}
.header {
  padding: 20px;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 12px;
}
.logo {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 6px 0;
  letter-spacing: -0.02em;
}
.header__subtitle, .header__desc {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.header__title {
  font-size: 1.35rem;
  margin: 0 0 4px 0;
  font-weight: 600;
  color: var(--text);
}
.back {
  display: inline-block;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 8px;
  text-decoration: none;
  font-weight: 500;
}
.back:hover { opacity: 0.85; }

.main {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  margin-top: -1px;
  min-height: 60vh;
}

/* Карточки-действия — белые с сильным скруглением */
.card--action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 22px 24px;
  margin-bottom: 16px;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card--action:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1);
}
.card__icon {
  font-size: 1.75rem;
}
.card__title {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text);
}
.card__desc {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Блоки секций */
.block {
  margin-top: 28px;
}
.block__title {
  font-size: 1.15rem;
  margin-bottom: 12px;
  color: var(--text);
}
.block__meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* Бейджи проблем */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* Бейджи — pill-форма, пастельные фоны */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 500;
}
.badge__name { font-weight: 600; }
.badge__level { font-size: 0.8rem; color: var(--text-muted); }
.badge--low { background: #E8F8EE; color: var(--success); }
.badge--moderate, .badge--medium { background: #EDE9FE; color: var(--accent); }
.badge--high { background: #EDE9FE; color: var(--danger); }

.empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.routine-list {
  margin: 0 0 16px 0;
  padding-left: 20px;
  line-height: 1.6;
  font-size: 0.95rem;
}
.routine-list li { margin-bottom: 6px; }

.link-more {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.95rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.link-more:hover { opacity: 0.85; }

/* Сканирование */
.scan-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.preview-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-inactive);
  margin-bottom: 20px;
  aspect-ratio: 3/4;
  max-height: 60vh;
  box-shadow: var(--shadow-card);
}
.preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
}
.hidden { display: none !important; }

/* INCI */
.textarea {
  width: 100%;
  padding: 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
  min-height: 120px;
  margin-bottom: 16px;
  background: var(--surface-inactive);
}
.textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.results-block { margin-top: 24px; }
.inci-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.inci-summary span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
}
.inci-summary .sum-danger { background: #EDE9FE; color: var(--danger); border-radius: var(--radius-pill); }
.inci-summary .sum-warning { background: #EDE9FE; color: var(--accent); border-radius: var(--radius-pill); }
.inci-summary .sum-safe { background: #E8F8EE; color: var(--success); border-radius: var(--radius-pill); }

.inci-tag {
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 4px solid transparent;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.inci-tag .name { font-weight: 600; display: block; }
.inci-tag .comment { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }
.inci-tag--safe { background: #F0FDF4; border-left-color: var(--success); }
.inci-tag--warning { background: #F5F3FF; border-left-color: var(--accent); }
.inci-tag--danger { background: #F5F3FF; border-left-color: var(--danger); }

/* История сканов */
.history-item {
  padding: 20px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}
.history-item__date {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  display: block;
}

/* Routine cards */
.intro {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}
.routine-cards { list-style: none; margin: 0 0 24px 0; padding: 0; }
.routine-cards li { margin-bottom: 12px; }
.routine-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}
.routine-card__category {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.routine-card__text { margin: 0; font-size: 1rem; line-height: 1.55; color: var(--text); }

/* ——— Веб-адаптив: планшет и десктоп ——— */
@media (min-width: 600px) {
  body {
    max-width: var(--max-width-tablet);
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
  .main {
    padding: 24px;
  }
  .header {
    padding: 24px;
  }
  .header--gradient {
    padding: 28px 24px 24px;
  }
  /* Две карточки-действия в ряд на дашборде */
  .view#view-dashboard .main {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
  }
  .view#view-dashboard .main > a.card--action {
    flex: 1 1 260px;
    max-width: 100%;
    margin-bottom: 0;
  }
  .view#view-dashboard .main > section.block {
    flex: 1 1 100%;
  }
  .scan-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
  }
  .scan-actions .btn {
    width: auto;
    min-width: 160px;
  }
  .preview-wrap {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (min-width: 900px) {
  body {
    max-width: var(--max-width-desktop);
    padding-left: 32px;
    padding-right: 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
  .main {
    padding: 32px;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
  }
  .header {
    padding: 24px 32px;
  }
  .header--gradient {
    padding: 32px 32px 28px;
  }
  .view.active {
    min-height: 100vh;
  }
  .card--action {
    padding: 24px;
  }
  .card__icon {
    font-size: 1.75rem;
  }
  .card__title {
    font-size: 1.2rem;
  }
  .title {
    font-size: 1.9rem;
  }
  .block__title {
    font-size: 1.25rem;
  }
  .preview-wrap {
    max-width: 480px;
    max-height: 70vh;
  }
}
