:root {
  color-scheme: light;
  --page: #f5f7ee;
  --surface: #ffffff;
  --surface-muted: #e8ecdb;
  --surface-sunken: #f5f7ee;
  --ink: #232b18;
  --muted: #4b5932;
  --line: #d2dbbb;
  --line-strong: #b5c492;
  --accent: #60723e;
  --accent-hover: #4b5932;
  --accent-soft: #e8ecdb;
  --hero-start: #4b5932;
  --hero-end: #60723e;
  --shadow: 0 10px 30px rgba(75, 89, 50, .1);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --page: #232b18;
  --surface: #363f28;
  --surface-muted: #3e482c;
  --surface-sunken: #2b341d;
  --ink: #f5f7ee;
  --muted: #b5c492;
  --line: #4b5932;
  --line-strong: #60723e;
  --accent: #99ad6e;
  --accent-hover: #b5c492;
  --accent-soft: #3e482c;
  --hero-start: #3e482c;
  --hero-end: #232b18;
  --shadow: 0 16px 36px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { min-width: 320px; color: var(--ink); background: var(--page); line-height: 1.6; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 42%, transparent); outline-offset: 2px; }
::selection { color: #232b18; background: #b5c492; }

.container { width: min(1200px, 100%); margin: 0 auto; padding: 0 2rem; }

.navbar { position: sticky; z-index: 100; top: 0; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--page) 88%, transparent); box-shadow: 0 3px 16px rgba(35, 43, 24, .07); backdrop-filter: blur(14px); }
.navbar .container { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; min-height: 84px; }
.nav-brand { display: grid; gap: .2rem; }
.nav-brand h1 { color: var(--ink); font-size: clamp(1.2rem, 2.2vw, 1.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.nav-brand span { color: var(--accent); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .65rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav-links { display: flex; align-items: center; gap: .35rem; }
.nav-links a, .theme-toggle { border: 1px solid transparent; border-radius: 999px; padding: .55rem .8rem; color: var(--muted); background: transparent; font-size: .92rem; font-weight: 700; text-decoration: none; transition: background .18s, color .18s, border-color .18s; }
.nav-links a:hover { border-color: var(--line); color: var(--ink); background: var(--surface-muted); }
.theme-toggle { display: inline-flex; align-items: center; gap: .45rem; border-color: var(--line-strong); color: var(--ink); background: var(--accent-soft); }
.theme-toggle:hover { background: var(--line); }

.hero { padding: clamp(4.25rem, 10vw, 7.5rem) 1rem; color: #fff; background: linear-gradient(135deg, var(--hero-start), var(--hero-end)); text-align: center; }
.hero-content { width: min(780px, 100%); margin: 0 auto; }
.hero-content h2 { font-size: clamp(2rem, 5vw, 3.35rem); font-weight: 800; letter-spacing: -.055em; line-height: 1.14; }

.catalog-section { padding: clamp(3.5rem, 7vw, 5.5rem) 0; background: var(--page); }
.catalog-section h2 { margin-bottom: 2rem; color: var(--ink); font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -.04em; text-align: center; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: end; gap: 1rem; padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.filter-group, .tag-filter-container { display: flex; flex-direction: column; gap: .5rem; }
.filter-group label { color: var(--muted); font-size: .9rem; font-weight: 700; }
.filter-group select, .filter-group input, .tag-combobox-toggle, .tag-combobox-panel input { width: 100%; border: 1px solid var(--line-strong); border-radius: 12px; padding: .75rem; color: var(--ink); background: var(--surface); font-size: .92rem; }
.filter-group select:focus, .filter-group input:focus, .tag-combobox-toggle:focus, .tag-combobox-panel input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }

.tag-combobox { position: relative; }
.tag-combobox-toggle { cursor: pointer; text-align: left; }
.tag-combobox-toggle::after { float: right; content: "⌄"; }
.tag-combobox-panel { position: absolute; z-index: 10; top: calc(100% + .35rem); right: 0; left: 0; padding: .55rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 16px 34px rgba(35, 43, 24, .16); }
.tag-combobox-options { max-height: 12rem; margin-top: .5rem; overflow-y: auto; }
.tag-combobox-option { display: block; width: 100%; border: 0; border-radius: 8px; padding: .55rem .65rem; color: var(--ink); background: transparent; text-align: left; }
.tag-combobox-option:hover, .tag-combobox-option:focus { background: var(--surface-muted); outline: none; }
.tag-combobox-empty { margin: .5rem; color: var(--muted); font-size: .9rem; }
.selected-tags { display: flex; flex-wrap: wrap; gap: .45rem; min-height: 2.8rem; padding: .45rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-sunken); }
.selected-tags:empty::before { align-self: center; padding-left: .25rem; color: var(--muted); font-size: .9rem; font-style: italic; content: "Теги не обрано"; }
.selected-tag { display: inline-flex; align-items: center; gap: .3rem; border-radius: 999px; padding: .28rem .45rem .28rem .65rem; color: #fff; background: #60723e; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .72rem; font-weight: 600; }
.remove-tag { display: grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .18); cursor: pointer; }
.remove-tag:hover { background: rgba(255, 255, 255, .35); }
.results-info { margin-bottom: 1.3rem; color: var(--muted); font-weight: 700; }

.category-section { overflow: hidden; margin-bottom: 2rem; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 24px rgba(75, 89, 50, .08); }
.category-section.empty { opacity: .72; }
.category-header { display: flex; align-items: center; gap: .8rem; padding: 1.2rem 1.6rem; color: #fff; background: linear-gradient(135deg, #4b5932, #60723e); font-size: clamp(1.15rem, 2vw, 1.45rem); font-weight: 700; }
.category-section.empty .category-header { color: var(--ink); background: var(--surface-muted); }
.category-icon { font-size: 1.8rem; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .15)); }
.category-count { color: inherit; opacity: .8; }
.category-models { padding: 1.6rem; }
.empty-category-message { padding: 1rem; color: var(--muted); font-style: italic; text-align: center; }
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.5rem; }
.model-card { display: flex; flex-direction: column; overflow: hidden; min-width: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.model-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.model-image { display: flex; height: 220px; align-items: center; justify-content: center; overflow: hidden; padding: .65rem; color: var(--muted); background: var(--surface-sunken); font-size: 3rem; }
.model-image img { width: 100%; height: 100%; object-fit: contain; object-position: center; }
.model-info { display: flex; flex: 1; flex-direction: column; padding: 1.25rem; }
.model-title { margin-bottom: .65rem; color: var(--ink); font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.model-tags, .modal-tags { display: flex; flex-wrap: wrap; gap: .45rem; margin-bottom: 1rem; }
.tag { border-radius: 999px; padding: .28rem .58rem; color: var(--muted); background: var(--surface-muted); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .7rem; font-weight: 600; }
.model-description { display: -webkit-box; overflow: hidden; margin-top: auto; color: var(--muted); font-size: .9rem; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }

.btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; padding: .7rem 1rem; font-size: .9rem; font-weight: 700; text-align: center; text-decoration: none; transition: transform .18s, background .18s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: #fff; background: #60723e; }
.btn-primary:hover { background: #4b5932; }
.btn-secondary { color: var(--ink); background: var(--surface-muted); }
.btn-secondary:hover { background: var(--line); }

.modal { position: fixed; z-index: 1000; inset: 0; display: none; overflow-y: auto; padding: 2rem 1rem; background: rgba(20, 26, 13, .72); backdrop-filter: blur(6px); }
.modal-content { position: relative; width: min(1000px, 100%); max-height: 90vh; margin: 0 auto; overflow-y: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 28px 70px rgba(0, 0, 0, .35); }
.close { position: absolute; z-index: 1; top: 1rem; right: 1rem; display: grid; width: 40px; height: 40px; place-items: center; border-radius: 50%; color: var(--muted); background: var(--surface-muted); cursor: pointer; font-size: 28px; font-weight: 700; line-height: 1; }
.close:hover { color: var(--ink); background: var(--line); }
.modal-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; padding: 2rem; }
.modal-gallery { display: flex; flex-direction: column; gap: 1rem; }
.main-image { display: flex; height: 400px; align-items: center; justify-content: center; overflow: hidden; padding: .7rem; border-radius: 12px; background: var(--surface-sunken); }
.main-image img { max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; border-radius: 8px; }
.thumbnail-strip { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .45rem; }
.thumbnail { flex: 0 0 60px; width: 60px; height: 60px; overflow: hidden; border: 2px solid transparent; border-radius: 8px; cursor: pointer; transition: border-color .18s; }
.thumbnail.active { border-color: var(--accent); }
.thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.modal-info h2 { margin-bottom: 1rem; color: var(--ink); font-size: 1.65rem; line-height: 1.25; }
.modal-category { margin-bottom: 1.3rem; }
.model-category { display: inline-block; border-radius: 999px; padding: .3rem .7rem; color: #fff; background: #60723e; font-size: .75rem; font-weight: 700; }
.modal-description { margin-bottom: 2rem; color: var(--muted); line-height: 1.65; }
.modal-description h1, .modal-description h2, .modal-description h3, .modal-description strong, .modal-description b { color: var(--ink); }
.modal-description h1, .modal-description h2, .modal-description h3 { margin: 1.4rem 0 .9rem; font-weight: 700; line-height: 1.25; }
.modal-description h1 { font-size: 1.7rem; }
.modal-description h2 { font-size: 1.4rem; }
.modal-description h3 { font-size: 1.15rem; }
.modal-description p { margin: .9rem 0; }
.modal-description img { max-width: 100%; height: auto; margin: 1rem 0; border-radius: 10px; }
.modal-description ul, .modal-description ol { margin: 1rem 0; padding-left: 1.6rem; }
.modal-description li { margin: .4rem 0; }
.modal-description li a, .some-link { color: var(--accent); font-weight: 700; }
.modal-description li a:hover, .some-link:hover { color: var(--accent-hover); }
.modal-actions { display: flex; gap: 1rem; }

.about-section { padding: 4.5rem 0; color: #fff; background: linear-gradient(135deg, var(--hero-start), var(--hero-end)); }
.about-section h2 { margin-bottom: 1.8rem; font-size: 2rem; text-align: center; }
.about-content { max-width: 800px; margin: 0 auto; text-align: center; }
.about-content p { margin-bottom: 1.25rem; font-size: 1.05rem; }
.about-content .some-link { color: #fff; }
.how-to-add { padding: 1.5rem; margin: 2rem 0; border-radius: 12px; background: rgba(255, 255, 255, .12); text-align: left; }
.how-to-add h3 { margin-bottom: 1rem; }
.how-to-add ol { padding-left: 1.5rem; }
.how-to-add li { margin-bottom: .5rem; }
.how-to-add code { border-radius: 4px; padding: .2rem .45rem; background: rgba(0, 0, 0, .18); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .9rem; }

footer { padding: 2rem 0; color: #d2dbbb; background: #232b18; text-align: center; }
.footer-social-links { display: flex; justify-content: center; gap: .5rem; margin-top: .8rem; }
.footer-social-links a { display: inline-flex; width: 34px; height: 34px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 10px; color: #d2dbbb; font-size: 18px; text-decoration: none; transition: color .18s, border-color .18s, background .18s; }
.footer-social-links a:hover { border-color: #60723e; color: #fff; background: #3e482c; }
.empty-state { grid-column: 1 / -1; padding: 3rem; color: var(--muted); text-align: center; }
.empty-state-icon { margin-bottom: 1rem; font-size: 4rem; }
.empty-state h3 { margin-bottom: .5rem; color: var(--ink); font-size: 1.5rem; }

@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .navbar .container { flex-direction: column; justify-content: center; padding-top: .9rem; padding-bottom: .9rem; }
  .nav-brand { text-align: center; }
  .nav-links { justify-content: center; flex-wrap: wrap; }
  .nav-links a, .theme-toggle { padding: .45rem .65rem; font-size: .85rem; }
  .filters { grid-template-columns: 1fr; }
  .category-header { padding: 1rem 1.15rem; }
  .category-models { padding: 1rem; }
  .models-grid { grid-template-columns: 1fr; gap: 1rem; }
  .model-image { height: 190px; }
  .modal { padding: 1rem .5rem; }
  .modal-content { max-height: 94vh; }
  .modal-body { grid-template-columns: 1fr; gap: 1.2rem; padding: 1.2rem; }
  .main-image { height: 300px; }
  .modal-description ul, .modal-description ol { padding-left: 1.35rem; }
}
