/* PC REM catalog — dark technical theme */
:root {
  --bg: #0b0c0e;
  --bg-2: #101215;
  --panel: #14171b;
  --panel-2: #1a1e23;
  --line: #262b32;
  --line-2: #333a43;
  --text: #e7e9ec;
  --muted: #8d95a1;
  --dim: #5d6570;
  --accent: #e3262f;
  --accent-2: #ff4a52;
  --ok: #38d39f;
  --radius: 4px;
  --header-h: 64px;
  --sidebar-w: 280px;
  --font: "Rajdhani", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); letter-spacing: .02em; }
.label { font-size: 11px; color: var(--muted); letter-spacing: .12em; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--panel-2); color: var(--text);
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .1em;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; color: var(--text);
}
.icon-btn:hover { border-color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* ---------- splash ---------- */
#splash {
  position: relative;
  height: 100vh; height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fefefe;
  overflow: hidden;
}
#splash::before { /* subtle tech grid on the white field */
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,0,0,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,.045) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, transparent 35%, #000 85%);
}
.splash-frame {
  position: relative;
  width: min(100vw, calc(100svh * 16 / 9));
  aspect-ratio: 16 / 9;
  display: grid; place-items: center;
}
.splash-banner { width: 100%; height: auto; }
.splash-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px clamp(16px, 4vw, 48px) max(18px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(11,12,14,.96), rgba(11,12,14,.85));
  color: var(--text);
  border-top: 2px solid var(--accent);
}
.splash-stats { font-size: 12px; color: #c9ced5; letter-spacing: .12em; }
.splash-stats b { color: #fff; }

/* ---------- header ---------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: rgba(11,12,14,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  height: 100%; display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(12px, 2.5vw, 28px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 46px; height: 46px; filter: drop-shadow(0 0 1px rgba(255,255,255,.55)) drop-shadow(0 0 6px rgba(255,255,255,.12)); }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-weight: 700; font-size: 22px; letter-spacing: .06em; }
.brand-sub { font-size: 10px; color: var(--muted); margin-top: 3px; letter-spacing: .14em; }
.search {
  flex: 1; min-width: 0; max-width: 640px; margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--muted);
}
.search:focus-within { border-color: var(--accent); color: var(--text); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent;
  font-family: var(--mono); font-size: 13px;
}
.search input::placeholder { color: var(--dim); }
.search kbd {
  font-size: 11px; padding: 1px 6px; border: 1px solid var(--line-2); border-radius: 3px; color: var(--dim);
}

/* ---------- layout ---------- */
#catalog {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--header-h));
}
#sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  padding: 16px 10px 40px;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 10px; }
#main { min-width: 0; padding: 18px clamp(12px, 2.5vw, 28px) 60px; }

/* ---------- tree ---------- */
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul ul { margin-left: 13px; padding-left: 8px; border-left: 1px dashed var(--line-2); }
.tree li { margin: 1px 0; }
.node {
  display: flex; align-items: center; gap: 4px;
  border-radius: var(--radius);
}
.node:hover { background: var(--panel); }
.node.active { background: rgba(227,38,47,.12); box-shadow: inset 2px 0 0 var(--accent); }
.node.active > a { color: #fff; }
.twisty {
  width: 22px; height: 26px; flex: none; display: grid; place-items: center;
  background: none; border: 0; cursor: pointer; color: var(--dim);
}
.twisty svg { transition: transform .15s; }
li.open > .node .twisty svg { transform: rotate(90deg); }
.twisty.leaf { visibility: hidden; }
.node a {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px 5px 0; text-decoration: none;
  font-size: 14px; font-weight: 600; letter-spacing: .03em; color: #c7ccd3;
}
.node a span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .n { font-family: var(--mono); font-size: 11px; color: var(--dim); font-weight: 400; }
.tree li > ul { display: none; }
.tree li.open > ul { display: block; }
.tree > ul > li > .node a { font-size: 15px; color: var(--text); }

/* ---------- main header ---------- */
.crumbs { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 18px; }
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--dim); }
.crumbs .cur { color: var(--accent-2); }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 6px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.view-head h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); font-weight: 700; letter-spacing: .04em; line-height: 1.05; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.count { font-size: 12px; color: var(--muted); }
.count b { color: var(--text); }
select {
  height: 34px; padding: 0 10px; font-size: 11px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-btn { width: 36px; height: 32px; display: grid; place-items: center; background: var(--panel); border: 0; color: var(--dim); cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { color: var(--text); background: var(--panel-2); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; font-weight: 600; font-size: 14px; letter-spacing: .03em; color: #cfd3d9;
}
.chip:hover { border-color: var(--accent); color: #fff; }
.chip .n { font-family: var(--mono); font-size: 11px; color: var(--dim); }

/* ---------- product grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.card {
  position: relative; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; text-align: left; padding: 0; text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card:hover .card-name { color: #fff; }
.card .thumb { position: relative; background: #000; aspect-ratio: 13 / 10; overflow: hidden; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .25s; }
.card .thumb img.loaded { opacity: 1; }
.card .tag {
  position: absolute; top: 8px; left: 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  padding: 2px 6px; background: rgba(11,12,14,.8); border: 1px solid var(--line-2); border-radius: 3px; color: var(--muted);
}
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-cat { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: .08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-name { font-weight: 600; font-size: 16px; line-height: 1.2; color: #dfe2e6; letter-spacing: .02em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* list layout */
.grid.list { grid-template-columns: 1fr; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.grid.list .card { flex-direction: row; align-items: center; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; transform: none; }
.grid.list .card:last-child { border-bottom: 0; }
.grid.list .card:hover { background: var(--panel-2); }
.grid.list .thumb { width: 104px; flex: none; }
.grid.list .tag { display: none; }
.grid.list .card-body { flex-direction: row; align-items: center; gap: 16px; padding: 8px 16px; }
.grid.list .card-name { flex: 1; -webkit-line-clamp: 1; }
.grid.list .card-cat { order: 2; width: 34%; text-align: right; }
.grid.list .card-id { order: 3; font-size: 11px; width: 90px; text-align: right; margin: 0; padding: 0; }
.card-id { font-family: var(--mono); font-size: 10px; color: var(--dim); letter-spacing: .08em; margin-top: auto; padding-top: 4px; }
.card .tag { display: none; }

.group-head {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 10px;
  margin: 14px 0 0; padding: 0 0 6px; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: 18px; letter-spacing: .05em;
}
.group-head:first-child { margin-top: 0; }
.group-head a { text-decoration: none; }
.group-head a:hover { color: var(--accent-2); }
.group-head .n { font-family: var(--mono); font-size: 11px; color: var(--dim); font-weight: 400; }
.grid.list .group-head { margin: 0; padding: 10px 16px; background: var(--bg-2); }

#sentinel { height: 1px; }
.empty { text-align: center; padding: 60px 16px; color: var(--muted); }
.empty .mono { color: var(--accent-2); margin-bottom: 8px; }
mark { background: rgba(227,38,47,.35); color: #fff; border-radius: 2px; padding: 0 1px; }

/* ---------- visit ---------- */
#visit { border-top: 1px solid var(--line); background: var(--bg-2); }
.visit-banner { width: 100%; height: auto; }
.visit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
  padding: 32px clamp(16px, 4vw, 48px);
  max-width: 1400px; margin: 0 auto;
}
.visit-card h2 { margin: 6px 0 10px; font-size: 30px; letter-spacing: .04em; }
.addr { font-size: 18px; color: #c9ced5; margin: 0 0 18px; }
.visit-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.visit-photo { width: 100%; height: 100%; max-height: 380px; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); }
.specs { margin: 0; font-size: 12px; border-top: 1px solid var(--line); }
.specs > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.specs dt { color: var(--dim); letter-spacing: .1em; }
.specs dd { margin: 0; text-align: right; }
footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px;
  padding: 18px clamp(16px, 4vw, 48px) max(18px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); font-size: 10px; color: var(--dim); letter-spacing: .1em;
}

/* ---------- lightbox ---------- */
#lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5,6,7,.97);
  display: flex; align-items: stretch; justify-content: center;
}
.lb-panel { display: grid; grid-template-columns: minmax(0, 1fr) 360px; width: 100%; height: 100%; min-width: 0; }
.lb-stage { position: relative; min-width: 0; min-height: 0; overflow: auto; display: grid; place-items: center; padding: 16px; cursor: zoom-in; }
.lb-stage img { max-width: 100%; max-height: calc(100vh - 32px); object-fit: contain; user-select: none; }
.lb-stage.zoomed { cursor: zoom-out; place-items: start; }
.lb-stage.zoomed img { max-width: none; max-height: none; width: 1800px; }
.lb-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 44px; height: 72px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: rgba(20,23,27,.85); color: var(--text); font-size: 32px; line-height: 1; cursor: pointer;
}
.lb-nav:hover { border-color: var(--accent); }
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 372px; }
.lb-info {
  position: relative; background: var(--panel); border-left: 1px solid var(--line);
  padding: 56px 22px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px;
}
.lb-close { position: absolute; top: 12px; right: 12px; }
.lb-info h2 { margin: 0; font-size: 26px; line-height: 1.15; letter-spacing: .03em; }
.lb-row { display: flex; gap: 10px; }
.lb-row .btn { flex: 1; }
.hint { margin: -6px 0 0; font-size: 13px; color: var(--muted); }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  padding: 10px 16px; background: var(--panel-2); border: 1px solid var(--ok); border-radius: var(--radius);
  font-size: 12px; color: var(--text); box-shadow: 0 8px 30px rgba(0,0,0,.5);
}

/* ---------- responsive ---------- */
.only-mobile { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 39; }

@media (max-width: 960px) {
  :root { --header-h: 58px; }
  .only-mobile { display: inline-grid; }
  .hide-mobile { display: none !important; }
  #catalog { grid-template-columns: 1fr; }
  #sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
    width: min(86vw, 340px); height: 100%;
    transform: translateX(-100%); transition: transform .22s ease;
    padding-top: 14px;
  }
  body.nav-open #sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  .brand-sub { display: none; }
  .brand-name { font-size: 19px; }
  .brand img { width: 38px; height: 38px; }
  .topbar-inner { gap: 10px; }
  .node a { padding: 8px 8px 8px 0; font-size: 15px; }
  .twisty { height: 34px; width: 28px; }

  .lb-panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .lb-stage { padding: 8px; }
  .lb-stage img { max-height: calc(100vh - 300px); }
  .lb-info { border-left: 0; border-top: 1px solid var(--line); padding: 16px; max-height: 50vh; }
  .lb-info h2 { font-size: 20px; padding-right: 44px; }
  .lb-close { top: 10px; right: 10px; }
  .lb-nav { top: 40%; width: 36px; height: 56px; font-size: 26px; }
  .lb-nav.prev { left: 6px; }
  .lb-nav.next { right: 6px; }
  .lb-info .specs { display: none; }

  .visit-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card-body { padding: 8px 9px 10px; }
  .card-name { font-size: 14px; }
  .card .tag { display: none; }
  .view-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .toolbar { width: 100%; }
  .toolbar .count { margin-right: auto; }
  .grid.list .card-cat, .grid.list .card-id { display: none; }
  .grid.list .thumb { width: 84px; }
  .grid.list .card-body { padding: 6px 12px; }
  .grid.list .card-name { -webkit-line-clamp: 2; }

  /* splash on phones: banner at full width, no forced 16:9 crop */
  #splash { height: auto; min-height: 0; padding: 0 0 92px; justify-content: flex-start; }
  .splash-frame { width: 100%; aspect-ratio: auto; padding: 28px 0 8px; }
  .splash-bar { flex-direction: column; align-items: stretch; text-align: center; gap: 12px; }
  .splash-bar .btn { width: 100%; }
  #splash { padding-bottom: 120px; }
  .addr { font-size: 16px; }
  .visit-card h2 { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
