:root {
  --navy: #0e1622;
  --navy-2: #14202f;
  --slate: #1c2c3a;
  --amber: #ff9e2c;
  --cyan: #3fd0e0;
  --ink: #e8eef4;
  --muted: #8ba0b4;
  --glass: rgba(18, 30, 44, 0.68);
  --glass-brd: rgba(120, 160, 200, 0.22);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--navy);
  color: var(--ink);
  font-family: 'Archivo', sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

#scene-container { position: fixed; inset: 0; }
#scene-container canvas { display: block; }

/* ---------- Header ---------- */
#app-header {
  position: fixed;
  top: 18px; left: 22px;
  z-index: 10;
  pointer-events: none;
  animation: fadeDown 0.9s ease both;
}
#app-title {
  font-weight: 900;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  letter-spacing: -0.04em;
  line-height: 0.9;
  cursor: pointer;
  pointer-events: auto;
  text-shadow: 0 2px 20px rgba(0,0,0,0.6);
  user-select: none;
}
#app-title span { color: var(--amber); }
#app-title:active { transform: scale(0.96); }
.tagline {
  font-weight: 300;
  font-size: clamp(0.7rem, 1.6vw, 0.9rem);
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

/* ---------- Selector sidebar ---------- */
#selector {
  position: fixed;
  top: 130px; left: 22px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
  animation: fadeLeft 0.9s 0.15s ease both;
}
.sel-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-brd);
  border-radius: 12px;
  padding: 9px 13px;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  min-width: 190px;
  text-align: left;
}
.sel-item:hover { border-color: var(--amber); transform: translateX(4px); }
.sel-item.active {
  border-color: var(--amber);
  background: rgba(255, 158, 44, 0.14);
  box-shadow: 0 0 0 1px var(--amber), 0 8px 24px rgba(0,0,0,0.4);
}
.sel-icon { font-size: 1.25rem; filter: saturate(1.1); }
.sel-name { line-height: 1.1; }

/* ---------- Info panel ---------- */
#info-panel {
  position: fixed;
  top: 22px; right: 22px;
  z-index: 10;
  width: 290px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-brd);
  border-radius: 16px;
  padding: 18px;
  animation: fadeRight 0.9s 0.2s ease both;
}
#info-panel.flash { animation: flashIn 0.4s ease; }
.ip-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.badge {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--slate);
  color: var(--cyan);
}
.cat-bridge { background: rgba(63,208,224,0.16); color: var(--cyan); }
.cat-hydraulics { background: rgba(47,111,143,0.28); color: #7fd0ee; }
.cat-structure { background: rgba(255,158,44,0.16); color: var(--amber); }
.cat-transport { background: rgba(140,120,255,0.18); color: #b3a6ff; }
#ip-name {
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: -0.03em;
  line-height: 1;
}
#ip-specs { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.spec {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px dashed rgba(139,160,180,0.18);
  padding-bottom: 5px;
}
.spec-k { font-size: 0.74rem; color: var(--muted); }
.spec-v { font-family: 'JetBrains Mono', monospace; font-size: 0.74rem; color: var(--ink); font-weight: 700; }
.ip-note {
  background: rgba(255,158,44,0.08);
  border-left: 3px solid var(--amber);
  border-radius: 6px;
  padding: 10px 12px;
}
.note-label {
  font-size: 0.58rem; font-weight: 700; letter-spacing: 0.16em;
  color: var(--amber); display: block; margin-bottom: 4px;
}
#ip-note-text { font-size: 0.8rem; line-height: 1.4; color: #d6e0e9; font-weight: 300; font-style: italic; }

/* ---------- Control bar ---------- */
#control-bar {
  position: fixed;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex; gap: 8px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-brd);
  border-radius: 16px;
  padding: 8px;
  animation: fadeUp 0.9s 0.25s ease both;
}
.ctrl {
  width: 46px; height: 46px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 1.3rem;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex; align-items: center; justify-content: center;
}
.ctrl:hover { color: var(--ink); background: rgba(255,255,255,0.1); }
.ctrl.active {
  color: var(--navy);
  background: var(--amber);
  box-shadow: 0 4px 16px rgba(255,158,44,0.4);
}
.ctrl:active { transform: scale(0.92); }

/* ---------- Loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  font-weight: 300; letter-spacing: 0.1em; color: var(--muted);
  font-size: 1.1rem;
}

/* ---------- Footer ---------- */
#app-footer {
  position: fixed;
  bottom: 8px; right: 14px;
  z-index: 10;
  font-size: 0.68rem;
}
#app-footer a {
  color: var(--muted);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.2s, color 0.2s;
}
#app-footer a:hover { opacity: 1; color: var(--amber); }

/* ---------- Animations ---------- */
@keyframes fadeDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fadeLeft { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes fadeRight { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes flashIn { from { box-shadow: 0 0 0 2px var(--amber); } to { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Mobile: selector becomes bottom carousel ---------- */
@media (max-width: 768px) {
  #app-header { top: 12px; left: 14px; }
  #info-panel {
    top: auto; bottom: 86px; right: 10px; left: 10px;
    width: auto;
    padding: 12px 14px;
  }
  #ip-specs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
  .spec { border-bottom: none; }
  .ip-note { display: none; }
  #selector {
    top: auto; bottom: 148px; left: 0; right: 0;
    flex-direction: row;
    max-height: none;
    overflow-x: auto; overflow-y: hidden;
    padding: 0 12px 6px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .sel-item {
    flex-direction: column;
    min-width: 92px;
    gap: 4px;
    padding: 10px 8px;
    text-align: center;
    font-size: 0.68rem;
  }
  .sel-item:hover { transform: none; }
  .sel-name { line-height: 1.1; }
  #control-bar { bottom: 14px; gap: 6px; padding: 6px; }
  .ctrl { width: 42px; height: 42px; font-size: 1.15rem; }
  #app-footer { bottom: 2px; right: 8px; }
}

/* thin scrollbars */
#selector::-webkit-scrollbar { width: 5px; height: 5px; }
#selector::-webkit-scrollbar-thumb { background: rgba(139,160,180,0.3); border-radius: 3px; }