:root {
  --ink: #14110f;
  --ink-2: #45403a;
  --muted: #8a8378;
  --line: #e4ded4;
  --paper: #faf8f4;
  --card: #ffffff;
  --sand: #f4ecdf;
  --rose: #f8e9ea;
  --taupe: #ece5da;
  --gold: #9a7b3f;
  --hi: #b8873a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 17, 15, .06), 0 12px 32px -18px rgba(20, 17, 15, .35);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "kern" 1;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- шапка ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250, 248, 244, .92);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.top-in {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 10px; gap: 12px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: var(--ink); color: var(--sand);
  display: grid; place-items: center;
  font: 20px/1 Georgia, "Times New Roman", serif;
}

h1 {
  margin: 0;
  font: 400 22px/1.1 Georgia, "Times New Roman", serif;
  letter-spacing: .01em;
}

.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: lowercase; }

.count { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.count b { color: var(--ink); font-weight: 600; }

/* ---------- фильтры ---------- */
.controls {
  display: grid; gap: 8px;
  grid-template-columns: 1fr;
  padding-bottom: 12px;
}

.field {
  position: relative; display: flex; align-items: center;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: 0 10px; height: 40px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,17,15,.06); }

.field svg {
  width: 16px; height: 16px; flex: none; margin-right: 8px;
  fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round;
}

.field input, .field select {
  appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; outline: none;
  font: inherit; color: var(--ink); width: 100%; height: 100%;
  padding: 0; min-width: 0;
}
.field select { cursor: pointer; padding-right: 16px; }
.field::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 6px; height: 6px; margin-top: -4px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg); pointer-events: none;
}
.field.search::after { display: none; }

/* ---------- легенда ---------- */
.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 14px 2px 10px; font-size: 12px; color: var(--ink-2);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .hint { color: var(--muted); }
.sw { width: 14px; height: 9px; border-radius: 3px; display: inline-block; border: 1px solid rgba(20,17,15,.1); }
.sw.t { background: var(--sand); }
.sw.m { background: var(--rose); }
.sw.b { background: var(--taupe); }

/* ---------- таблица ---------- */
.table-head {
  display: none;
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
  padding: 8px 12px 10px; border-bottom: 1px solid var(--line);
}

.rows { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }

.row {
  display: grid; gap: 4px 14px;
  grid-template-columns: 44px 1fr;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  font: inherit; color: inherit;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.row:hover { border-color: #cfc6b8; box-shadow: var(--shadow); }
.row:active { transform: scale(.995); }
.row:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.thumb {
  width: 44px; height: 56px; border-radius: 9px; overflow: hidden; flex: none;
  background: #fff; border: 1px solid var(--line);
  display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }

.name { min-width: 0; }
.name b { display: block; font: 400 16.5px/1.2 Georgia, "Times New Roman", serif; }
.name .br { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.name .meta { display: block; font-size: 11.5px; color: var(--ink-2); margin-top: 3px; }

.tier { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.tier b { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.tier.t b { color: #9c8149; } .tier.m b { color: #a4636a; } .tier.b b { color: #7c6a52; }

/* мобильная раскладка: три ступени уходят под имя */
.row .tier { display: none; }
.row .name .meta { margin-top: 4px; }

.empty { padding: 40px 0; color: var(--muted); text-align: center; }

/* ---------- футер ---------- */
.foot { padding: 26px 2px 40px; font-size: 12px; color: var(--ink-2); }
.foot p { margin: 0 0 4px; }
.foot .muted { color: var(--muted); }

/* ---------- карточка аромата ---------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: grid; }
.sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20,17,15,.42); backdrop-filter: blur(3px); animation: fade .18s ease; }

.sheet-card {
  position: relative;
  background: var(--paper);
  width: 100%; height: 100%;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 0 40px;
  animation: rise .22s ease;
}
.sheet-close {
  position: sticky; top: 0; margin-left: auto; display: block;
  width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 26px; line-height: 1; color: var(--ink-2); cursor: pointer; z-index: 3;
}
.sheet-close:hover { color: var(--ink); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }

.hero {
  display: grid; grid-template-columns: 1fr; gap: 14px;
  padding: 0 18px 8px;
}
.hero-img {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden;
}
.hero-img img { max-width: 82%; max-height: 82%; object-fit: contain; }

.hero-t { min-width: 0; }
.hero-t h2 { margin: 6px 0 2px; font: 400 28px/1.12 Georgia, "Times New Roman", serif; }
.hero-t .b { color: var(--muted); font-size: 13px; }
.hero-t .m { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  font-size: 11.5px; padding: 4px 9px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
}
.pill.dir { background: var(--ink); color: var(--sand); border-color: var(--ink); }

.pyramid { padding: 16px 18px 0; display: grid; gap: 8px; }
.pyr-row {
  display: grid; grid-template-columns: 74px 1fr; gap: 10px; align-items: start;
  border-radius: 12px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--line);
}
.pyr-row .lab { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
.pyr-row.t { background: var(--sand); border-color: #e8dcc6; }
.pyr-row.m { background: var(--rose); border-color: #efd9db; }
.pyr-row.b { background: var(--taupe); border-color: #e0d6c7; }
.pyr-row .val { font-size: 14px; }

.sec { padding: 22px 18px 0; }
.sec h3 {
  margin: 0 0 10px; font: 400 17px/1.2 Georgia, "Times New Roman", serif;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.sec h3 span { font: 11.5px/1.2 -apple-system, sans-serif; color: var(--muted); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 7px 13px; font: 12.5px/1 inherit; cursor: pointer;
  transition: all .14s ease;
}
.tab:hover { border-color: #cfc6b8; color: var(--ink); }
.tab[aria-selected="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.cards { display: grid; gap: 10px; }
.sim {
  display: grid; grid-template-columns: 54px 1fr; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; cursor: pointer; text-align: left; font: inherit; color: inherit;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.sim:hover { border-color: #cfc6b8; box-shadow: var(--shadow); }
.sim .thumb { width: 54px; height: 70px; }
.sim .h { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sim .h b { font: 400 15.5px/1.2 Georgia, "Times New Roman", serif; }
.sim .h .pc { font-size: 12px; color: var(--gold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sim .b2 { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.sim .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.chip {
  font-size: 11px; padding: 3px 7px; border-radius: 6px;
  background: #f2f5ee; color: #3f5136; border: 1px solid #e0e7d9;
}
.chip.diff { background: #f6f2ee; color: #7a6f62; border-color: #e9e2d8; }
.chip.no { background: #fff; color: var(--muted); border-color: var(--line); }

.note-line { font-size: 12.5px; color: var(--ink-2); margin-top: 8px; }
.note-line b { color: var(--ink); font-weight: 600; }
.loading { color: var(--muted); font-size: 13px; padding: 14px 0; }

/* ---------- планшет и десктоп ---------- */
@media (min-width: 640px) {
  .controls { grid-template-columns: 1.6fr 1fr 1fr 1fr; }
  .legend { padding-top: 18px; }
}

@media (min-width: 900px) {
  body { font-size: 15px; }
  .table-head, .row { display: grid; grid-template-columns: 48px minmax(180px, 1.1fr) 1fr 1fr 1.15fr; }
  .table-head { padding: 8px 12px 10px; }
  .row { align-items: start; padding: 10px 12px; gap: 14px; }
  .row .thumb { width: 48px; height: 62px; margin-top: 2px; }
  .row .tier { display: block; }
  .row .name .meta { display: none; }
  .name b { font-size: 16px; }

  .hero { grid-template-columns: 320px 1fr; gap: 26px; padding: 0 34px 8px; align-items: start; }
  .hero-img { aspect-ratio: 4 / 5; position: sticky; top: 56px; }
  .hero-t h2 { font-size: 34px; }
  .pyramid { padding: 18px 34px 0; }
  .sec { padding: 26px 34px 0; }
  .cards { grid-template-columns: 1fr 1fr; }
  .sheet-close { position: absolute; right: 16px; top: 8px; }

  .sheet-card {
    position: absolute; inset: 24px; margin: auto;
    width: min(1060px, calc(100% - 48px));
    height: min(92vh, 980px);
    border-radius: 20px;
    box-shadow: 0 30px 90px -30px rgba(20,17,15,.5);
    padding-bottom: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
