:root {
  --bg: #f2efe9;
  --panel: #ffffff;
  --ink: #2b2a28;
  --muted: #6b6861;
  --accent: #3a5f6f;
  --accent-2: #b36b4b;
  --danger: #a6342d;
  --shadow: 0 12px 30px rgba(34, 30, 24, 0.12);
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  color: var(--ink);
  background:
    radial-gradient(1000px 400px at 10% -10%, rgba(179, 107, 75, 0.2), transparent),
    radial-gradient(800px 500px at 90% 0%, rgba(58, 95, 111, 0.2), transparent),
    var(--bg);
  min-height: 100vh;
}

.app-header {
  padding: 20px 20px 8px;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(242, 239, 233, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  flex-shrink: 0;
}

.brand-title {
  font-size: 22px;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.nav-bar {
  display: flex;
  position: relative;
  gap: 2px;
  background: rgba(58, 95, 111, 0.08);
  border-radius: 12px;
  padding: 3px;
  flex-shrink: 0;
}

.nav-tab {
  position: relative;
  z-index: 2;
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.nav-tab.active {
  color: #fff;
}

.nav-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  background: var(--accent);
  border-radius: 10px;
  z-index: 1;
  transition: left 0.3s ease, width 0.3s ease;
}

.app-main {
  padding: 12px 16px 40px;
  max-width: 720px;
  margin: 0 auto;
}

.view {
  display: none;
  animation: fadeUp 0.4s ease;
}

.view.active {
  display: block;
}

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.notice {
  background: rgba(58, 95, 111, 0.08);
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 14px;
  margin: 10px 0 18px;
}

.hint {
  background: rgba(58, 95, 111, 0.06);
  border-left: 4px solid rgba(58, 95, 111, 0.4);
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 12px;
}

.btn {
  border: 1px solid rgba(43, 42, 40, 0.15);
  background: transparent;
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(43, 42, 40, 0.12);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.btn.ghost {
  background: transparent;
  border: none;
  color: var(--muted);
  padding-left: 0;
}

.view-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-header h2 {
  margin: 0;
}

/* Индекс душевного здоровья */
.index-summary {
  background: rgba(58, 95, 111, 0.06);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-left: 4px solid rgba(58, 95, 111, 0.5);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.index-grid {
  display: grid;
  gap: 14px;
  margin-top: 6px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.index-block {
  border: 1px solid rgba(43, 42, 40, 0.1);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fffdf9;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.index-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(34, 30, 24, 0.08);
}

.index-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.index-pin {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.index-title {
  font-weight: 600;
  font-size: 16px;
}

.index-score {
  font-weight: 600;
  font-size: 15px;
  color: var(--accent);
}

.index-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  min-height: 46px;
}
.index-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  min-height: 40px;
}

.index-block[data-level="green"] {
  border-color: #3aa45c;
}

.index-block[data-level="yellow"] {
  border-color: #f7a400;
}

.index-block[data-level="orange"] {
  border-color: #d9691a;
}

.index-block[data-level="red"] {
  border-color: #a6342d;
}

.index-block[data-level="green"] .index-status {
  color: #3aa45c;
}

.index-block[data-level="yellow"] .index-status {
  color: #d18b1f;
}

.index-block[data-level="orange"] .index-status {
  color: #c15627;
}

.index-block[data-level="red"] .index-status {
  color: #a6342d;
}

.index-footer {
  margin-top: 18px;
  display: grid;
  gap: 6px;
}

.index-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.index-footer .index-note:first-child {
  font-weight: 600;
}

.index-quiz {
  margin-top: 18px;
}

.index-questions {
  display: grid;
  gap: 12px;
  margin-top: 4px;
}

.index-question {
  border: 1px solid rgba(43, 42, 40, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff;
}

.index-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.index-question-text {
  font-weight: 600;
  font-size: 15px;
  margin: 0;
}

.index-question-block {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(58, 95, 111, 0.08);
  color: var(--muted);
}

.index-option-group {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}

.index-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(58, 95, 111, 0.04);
  font-size: 13px;
  cursor: pointer;
  transition: border 0.2s ease, background 0.2s ease;
}

.index-option input {
  accent-color: var(--accent);
}

.index-option input:checked + span {
  font-weight: 600;
}

.index-option:hover {
  border-color: rgba(58, 95, 111, 0.4);
}

.index-option span {
  color: var(--muted);
}

.index-quiz-actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.index-history {
  margin-top: 24px;
}

.index-history-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
}

.index-history-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.index-history-card {
  border: 1px solid rgba(43, 42, 40, 0.08);
  border-radius: 14px;
  padding: 12px;
  background: #fffdf9;
}

.index-history-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.index-history-card strong {
  font-size: 14px;
}

.index-history-score {
  border-radius: 12px;
  background: rgba(58, 95, 111, 0.06);
  padding: 6px 10px;
  font-size: 13px;
  color: var(--muted);
}

.index-history-score strong {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}

.index-history-scores {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.index-history-scores span {
  font-weight: 600;
  color: var(--muted);
}

.index-progress-summary {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.index-progress-row {
  border: 1px solid rgba(43, 42, 40, 0.08);
  border-radius: 10px;
  padding: 10px;
  background: #fdfbf6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.index-progress-date {
  font-weight: 600;
  color: var(--muted);
  font-size: 13px;
}

.index-progress-chip {
  font-size: 12px;
  color: #fff;
  border-radius: 999px;
  padding: 6px 10px;
}

.index-progress-chip.level-green {
  background: #3aa45c;
}

.index-progress-chip.level-yellow {
  background: #d18b1f;
}

.index-progress-chip.level-orange {
  background: #c15627;
}

.index-progress-chip.level-red {
  background: #a6342d;
}

.status {
  color: var(--muted);
}

.empty {
  color: var(--muted);
  margin-top: 16px;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 520px) {
  .app-header {
    padding: 18px 16px 8px;
  }
}

/* Подвал */
.app-footer {
  text-align: center;
  padding: 20px;
  margin-top: 20px;
}

.app-footer a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.app-footer a:hover {
  border-color: var(--muted);
}

.footer-divider {
  margin: 0 8px;
  color: var(--muted);
}

/* Скрытие элементов */
.hidden {
  display: none !important;
}
