<!-- SOLID CITY · part 74 -->
 var c = campusData(id); if (!c) return;
  var host = HOSTNAME(c.host);
  var h = '<p>' + esc(c.blurb) + '</p><p class="u-meta">Office hours: <b>' + esc(host) + '</b> \u00b7 ' + c.courses.length + ' courses</p>' +
    '<div class="u-tabs"><button type="button" class="on">\uD83D\uDCDA Courses</button><button type="button" id="u-lib">\uD83D\uDCD6 Library</button><button type="button" id="u-talk">\uD83D\uDCAC Talk to ' + esc(host) + '</button></div>' +
    '<div class="u-row"><button type="button" id="u-all2">\u2756 All that we can do</button><button type="button" id="u-beauty2">\uD83C\uDF39 Beauty Log</button></div>' +
    c.courses.map(function (k) { return '<button type="button" class="u-item" data-course="' + esc(k.id) + '"><b>' + esc(k.title) + '</b><small>' + esc(k.desc) + '</small><br><small>' + k.lessons.length + ' lessons \u00b7 professor ' + esc(HOSTNAME(k.host)) + '</small></button>'; }).join('');
  show('\uD83C\uDF93 ' + c.name, h);
  bind('[data-course]', function (b) { openCourse(id, b.getAttribute('data-course')); });
  bind('#u-lib', function () { openLibrary(id); });
  bind('#u-all2', function () { close(); if (window.CityPodium) CityPodium.open('courses'); });
  bind('#u-beauty2', function () { close(); if (window.CityPodium) CityPodium.open('beauty'); else window.open('/beauty', '_blank'); });
  bind('#u-talk', function () { close(); if (c.host === 'sable') A.openTalk(); else if (window.CityCitizens) CityCitizens.open(c.host); });
})(); }); }
function openCourse(cid, kid) { nav(function () {
  var c = campusData(cid), k = c && c.courses.filter(function (x) { return x.id === kid; })[0]; if (!k) return;
  show(k.title, '<p class="u-meta">' + esc(c.name) + ' \u00b7 professor ' + esc(HOSTNAME(k.host)) + '</p><p>' + esc(k.desc) + '</p><h4>Lessons</h4>' +
    k.lessons.map(function (l, i) { return '<button type="button" class="u-item" data-l="' + i + '"><b>' + (i + 1) + '. ' + esc(l) + '</b>' + (i === 0 ? '<small>Read the opening lesson</small>' : '<small>Outline \u00b7 ask the professor</small>') + '</button>'; }).join(''));
  bind('[data-l]', function (b) { openLesson(cid, kid, +b.getAttribute('data-l')); });
})(); }
function openLesson(cid, kid, li) { nav(function () {
  var c = campusData(cid), k = c && c.courses.filter(function (x) { return x.id === kid; })[0]; if (!k) return;
  var title = k.lessons[li], txt = li === 0 ? k.intro : 'This is lesson ' + (li + 1) + ' of ' + k.lessons.length + ' in ' + k.title + '. The full written lesson arrives in Stage 2; for now, ask the professor anything about it, or add your own notes to the ' + c.name + ' library.';
  var h = '<p class="u-meta">' + esc(k.title) + ' \u00b7 lesson ' + (li + 1) + ' of ' + k.lessons.length + '</p><h3>' + esc(title) + '</h3><p>' + esc(txt) + '</p>' +
    '<div class="u-row">' + (li > 0 ? '<button type="button" id="u-prev">\u2190 Previous</button>' : '') + (li < k.lessons.length - 1 ? '<button type="button" id="u-next">Next \u2192</button>' : '') + '</div>' +
    '<h4>\uD83C\uDF93 Ask the professor (' + esc(HOSTNAME(k.host)) + ')</h4><div id="u-ask"></div>' + (/^(medicine|social)$/.test(cid) ? '<p class="u-meta">Educational only: not medical, legal or financial advice.</p>' : '');
  show(title, h);
  bind('#u-prev', function () { openLesson(cid, kid, li - 1); }); bind('#u-next', function () { openLesson(cid, kid, li + 1); });
  me().then(function (m) {
    var box = $('u-ask'); if (!box) return;
    if (!m || !m.loggedIn) { box.innerHTML = '<p class="u-meta">Log in to ask the professor about this lesson.</p><a class="u-btn" href="/login?next=' + encodeURIComponent('/city/?to=' + cid) + '">Log in</a>'; return; }
    box.innerHTML = '<textarea id="u-q" maxlength="300" placeholder="Your question about \u201c' + esc(title) + '\u201d"></textarea><div class="u-row"><button type="button" class="gold" id="u-send">Ask</button></div><div id="u-out"></div>';
    var hist = [];
    $('u-send').addEventListener('click', function () {
      var q = $('u-q').value.trim(), out = $('u-out'); if (!q) return;
      var btn = $('u-send'); btn.disabled = true; out.insertAdjacentHTML('beforeend', '<div class="u-ans u-meta">You: ' + esc(q) + '</div><div class="u-ans u-meta" id="u-wait">' + esc(HOSTNAME(k.host)) + ' is thinking\u2026</div>');
      post('/api/city/citizen', { id: k.host, message: q, history: hist.slice(-6), where: c.name + ' campus, Solid City University', doing: 'holding office hours',
        lesson: { campus: c.name, course: k.title, lesson: title, intro: li === 0 ? k.intro : k.desc } }).then(function (j) {
        var w = $('u-wait'); if (w) w.remove();
        var reply = j && j.reply ? j.reply : (j && j._s === 429 ? 'Office hours are busy, give me a minute and ask again.' : 'I can\u2019t answer right now; try again in a minute.');
        if (j && j.reply) { hist.push({ role: 'user', text: q }); hist.push({ role: 'model', text: j.reply }); }
        out.insertAdjacentHTML('beforeend', '<div class