:root {
  color: #1c1c1c;
  background: #f4f6f8;
  font-family: "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
}

button, .linkish {
  font: inherit;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #e8eef5;
  color: #16324f;
  cursor: pointer;
}

button.primary, button.on {
  background: #1565c0;
  color: white;
}

button:hover { filter: brightness(0.97); }

#app { min-height: 100vh; }

.home {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 20px;
}

.home h1 { margin: 0 0 4px; font-size: 32px; }

.home-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 12px 0 16px;
}

.home-tools .visits { font-size: 18px; font-weight: 600; }
.home-tools .share-note { font-size: 16px; }

.home .name { margin: 0; font-size: 22px; font-weight: 600; }
.home .credentials { margin: 8px 0 4px; font-size: 16px; line-height: 1.4; }

.course-btn {
  display: block;
  margin-top: 16px;
  padding: 16px 18px;
  background: #1565c0;
  color: white;
  border: 1px solid #0d47a1;
  border-radius: 12px;
  text-decoration: none;
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 4px 0 #0a3a86;
}

.course-btn:hover { filter: brightness(1.08); }

.course-btn:active {
  transform: translateY(4px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 0 #0a3a86;
}

.course-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.course-row .course-btn { flex: 1; margin-top: 0; }

.suggest-btn,
.home-tools button,
.home .suggest-box button {
  border: 1px solid #c5d2e0;
  box-shadow:
    inset 0 1px 0 #fff,
    0 4px 0 #b3c2d4;
}

.suggest-btn:active,
.home-tools button:active,
.home .suggest-box button:active {
  transform: translateY(4px);
  box-shadow: inset 0 1px 0 #fff, 0 0 0 #b3c2d4;
}

.home .suggest-box button.primary {
  border-color: #0d47a1;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 4px 0 #0a3a86;
}

.home .suggest-box button.primary:active {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 0 0 #0a3a86;
}

.course-btn:focus-visible,
.suggest-btn:focus-visible,
.home-tools button:focus-visible,
.home .suggest-box button:focus-visible {
  outline: 3px solid #0d47a1;
  outline-offset: 3px;
}

.suggest-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 16px 18px;
  background: #e8eef5;
  color: #16324f;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 600;
}

.suggest-box { margin-top: 12px; }

.suggest-box textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px;
  font: inherit;
  border: 1px solid #d5dee8;
  border-radius: 12px;
}

.suggest-box button { margin-top: 10px; }

.welcome {
  display: block;
  width: 100%;
  margin-top: 20px;
  border-radius: 12px;
  background: #111;
  aspect-ratio: 16 / 9;
}

.notice {
  margin-top: 18px;
  padding: 14px 16px;
  background: white;
  border: 1px solid #d5dee8;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.45;
}
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin: 0; }
.shell > .notice {
  margin: 0;
  border: 0;
  border-top: 1px solid #dde3ea;
  border-radius: 0;
  font-size: 14px;
}

.shell { height: 100vh; display: flex; flex-direction: column; background: white; }
.head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 4;
  background: white;
}
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.head img { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; }
.head h1 { margin: 0; font-size: 20px; }
.head p { margin: 2px 0 0; color: #667; font-size: 13px; }
.grow { flex: 1; }
.langs { display: flex; gap: 8px; }
.head-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.panes { flex: 1; display: flex; min-height: 0; border-top: 1px solid #dde3ea; }
.nav {
  width: 460px;
  overflow: auto;
  padding: 8px 8px 24px;
}
.detail {
  flex: 1;
  overflow: auto;
  padding: 16px 20px 32px;
  border-left: 1px solid #dde3ea;
}

.nav button.row {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: 8px;
  background: transparent;
  color: black;
  padding: 4px 8px;
}
.nav button.row.here { color: #1565c0; font-weight: 700; }
.nav button.row.keep { font-weight: 700; }

.wait {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin: 0 0 14px;
  padding: 16px 18px;
  background: #fff6d8;
  border: 2px solid #a36b00;
  border-radius: 12px;
}
.wait strong { display: block; font-size: 22px; margin-bottom: 4px; }
.wait p { margin: 0 0 6px; font-size: 18px; line-height: 1.4; }
.wait p:last-child { margin-bottom: 0; }
.wait-mark {
  width: 16px;
  height: 16px;
  margin-top: 6px;
  border-radius: 50%;
  background: #a36b00;
  flex: none;
  animation: wait-pulse 1.2s ease-in-out infinite;
}
@keyframes wait-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
@media (prefers-reduced-motion: reduce) {
  .wait-mark { animation: none; }
}
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.speed { display: flex; align-items: center; gap: 8px; margin: 8px 0 14px; }
.speed input { flex: 1; }
.ask { display: flex; flex-wrap: wrap; gap: 8px; }
.ask input {
  flex: 1 1 12rem;
  min-width: 0;
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #c5d0dc;
  border-radius: 8px;
}
.passage { font-size: 16px; line-height: 1.45; white-space: pre-wrap; }
.passage p { margin: 0 0 0.75em; }
.passage ol, .passage ul { margin: 0 0 0.75em; padding-left: 1.4em; white-space: normal; }
.passage li { margin: 0.25em 0; white-space: pre-wrap; }
.passage .katex-display { margin: 0.4em 0; overflow-x: auto; overflow-y: hidden; }
.katex .katex-mathml {
  position: absolute;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  width: 1px;
  overflow: hidden;
  white-space: nowrap;
  border: 0;
  padding: 0;
}
.head a.home-link {
  color: #1565c0;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.nav-toggle { display: none; }
.muted { color: #667; font-size: 14px; }
.note { white-space: pre-wrap; line-height: 1.45; }
a.aux { display: block; margin: 4px 0; color: #1565c0; }

@media (max-width: 900px) {
  #app, .shell { width: 100%; max-width: 100%; overflow-x: hidden; }
  .shell { height: 100vh; height: 100dvh; }
  .panes, .detail, .head { min-width: 0; max-width: 100%; }
  .head { width: 100%; align-items: center; padding: 8px 10px; gap: 8px; }
  .who { flex-direction: column; align-items: center; gap: 2px; width: 5.6rem; flex: none; }
  .head-tools { flex: 1; min-width: 0; flex-wrap: wrap; justify-content: flex-start; gap: 6px; margin-left: 0; padding-right: 5.1rem; }
  .head .nav-toggle { order: 1; }
  .head .langs { order: 2; }
  .head .home-link {
    order: 3;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }
  .head img { width: 44px; height: 44px; }
  .head h1 { font-size: 12px; line-height: 1.15; text-align: center; }
  .head button { padding: 6px 8px; font-size: 14px; }
  .head .home-link { font-size: 13px; }
  .head .langs { gap: 4px; flex: none; }
  .speed { flex-wrap: nowrap; gap: 6px; font-size: 14px; }
  .speed input { min-width: 0; flex: 1 1 2.5rem; width: 2.5rem; }
  .panes { flex-direction: column; }
  .nav-toggle { display: inline-block; }
  .nav {
    display: none;
    width: auto;
    flex: none;
    max-height: none;
    padding: 4px 8px 8px;
  }
  .nav.open {
    display: block;
    max-height: 50vh;
  }
  .detail {
    flex: 1 1 auto;
    min-height: 0;
    border-left: 0;
    border-top: 1px solid #dde3ea;
    padding: 12px 14px 28px;
  }
}
