/* The StudyBuddy website's layout. Colours, buttons, cards, chat and tool screens come from the
   extension's stylesheet (styles/studybuddy.css, shared); this file only lays them out as a website:
   a top bar, the start page, and the workspace (menu | tool | chat). */

body.app {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ---------------------------------------------------------------- password */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  place-items: center;
  padding: 16px;
  background: linear-gradient(135deg, #eaf4ff, #f4ecfb);
}

body[data-screen="gate"] .gate {
  display: grid;
}

body[data-screen="gate"] .app-bar,
body[data-screen="gate"] .landing,
body[data-screen="gate"] .lp-start,
body[data-screen="gate"] .workspace {
  visibility: hidden;
}

.gate-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  width: 100%;
  max-width: 380px;
  padding: 28px 24px 22px;
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 18px 40px rgba(31, 42, 55, 0.14);
  text-align: center;
}

.gate-title {
  margin: 0;
  font-size: 24px;
}

.gate-sub {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #5a6f86;
}

.gate-label {
  justify-self: start;
  font-size: 13px;
  font-weight: 700;
  color: #2e4057;
}

.gate-input {
  width: 100%;
}

.gate-card .transform-btn,
.gate-card .file-notice {
  width: 100%;
}

.gate-lang {
  margin-top: 4px;
}

/* ---------------------------------------------------------------- top bar */

.app-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 58px;
  padding: 0 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  z-index: 30;
}

.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: none;
  padding: 4px 6px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.app-brand img {
  width: 34px;
  height: 34px;
}

.app-brand:hover {
  background: #f0f6ff;
}

.app-bar-space {
  flex: 1;
}

.app-bar-btn {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.app-bar-btn:hover {
  background: #f0f6ff;
}

/* 💬 is for narrow screens; ☰ hides or shows the menu (on narrow screens it slides it in). */
.chat-toggle,
.chat-close {
  display: none;
}

body:not([data-screen="workspace"]) .nav-toggle {
  display: none;
}

/* ---------------------------------------------------------------- start page */

.landing {
  flex: 1;
  overflow-y: auto;
}

/* ---------------------------------------------------------------- workspace */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  position: relative;
}

.workspace.has-chat {
  grid-template-columns: 250px minmax(0, 1fr) var(--chat-width, minmax(320px, 400px));
}

.workspace:not(.has-chat) .app-chat {
  display: none;
}

/* Menu hidden with ☰ (wide screens): the tool takes its room. */
@media (min-width: 901px) {
  .workspace.nav-hidden {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace.nav-hidden.has-chat {
    grid-template-columns: minmax(0, 1fr) var(--chat-width, minmax(320px, 400px));
  }

  .workspace.nav-hidden .app-nav {
    display: none;
  }
}

/* The document every tool uses, above the tool */
.doc-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px max(16px, calc((100% - 760px) / 2));
  background: #f6f9fe;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: #2e4057;
}

.doc-bar[hidden] {
  display: none;
}

.doc-bar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-bar-label {
  color: #5a6f86;
}

.doc-bar-change {
  border: 1px solid var(--line);
  background: #ffffff;
  color: #2e4057;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.doc-bar-change:hover {
  background: #f0f6ff;
  border-color: #b6d2ee;
}

.doc-bar-error {
  flex-basis: 100%;
  color: #a33b3b;
  font-weight: 700;
}

/* With the Reader in the middle, the bar spans it edge to edge. */
.workspace-main[data-view="reader"] .doc-bar {
  padding-inline: 16px;
}

/* Menu */
.app-nav {
  overflow-y: auto;
  padding: 14px 10px 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: grid;
  align-content: start;
  gap: 14px;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group-title {
  margin: 0 8px 4px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #5a6f86;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.nav-item:hover:not(:disabled) {
  background: #f0f6ff;
}

.nav-item.is-current {
  background: #e3f0ff;
  font-weight: 700;
}

.nav-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.nav-icon {
  flex: 0 0 22px;
  text-align: center;
}

.nav-label {
  flex: 1;
}

.nav-arrow:empty {
  display: none;
}

.nav-item .home-option-soon {
  font-size: 10px;
  padding: 2px 7px;
}

.nav-home {
  font-weight: 700;
}

/* The middle and the chat use the extension's panel styles, but fill their column. */
.workspace .panel {
  height: auto;
  min-height: 0;
  min-width: 0;
}

.workspace-main {
  background: #ffffff;
  padding: 0;
}

.workspace-main .panel-body {
  padding: 18px max(16px, calc((100% - 760px) / 2)) 32px;
}

.workspace-main .reformat {
  max-width: 760px;
}

.panel.right[data-view="reader"] .reader-view {
  display: block;
}

.workspace-main .reader-view {
  padding: 0;
  overflow: hidden;
  height: 100%;
}

.reader-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg);
}

/* Chat */
.app-chat {
  border-left: 1px solid var(--line);
}

.chat-panel-title {
  font-weight: 800;
  font-size: 15px;
  color: #2e4057;
}

.app-chat .panel-top {
  padding-right: 0;
}

/* Before a document is open, "Ask me anything" waits for it. */
.app-chat.chat-waiting .ask-pill,
.app-chat.chat-waiting .quick-actions {
  display: none;
}

.panel.right[data-view="tutor"] .now-reading {
  display: flex;
}

/* 🐞 over the whole page */
.app-overlay {
  position: fixed;
  z-index: 200;
}

/* ---------------------------------------------------------------- narrow screens */

@media (max-width: 1180px) {
  .workspace.has-chat {
    grid-template-columns: 220px minmax(0, 1fr) var(--chat-width, minmax(300px, 340px));
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .workspace.nav-hidden.has-chat {
    grid-template-columns: minmax(0, 1fr) var(--chat-width, minmax(300px, 340px));
  }
}

/* Below 900px: the menu (☰) and the chat (💬) slide in over the tool. */
@media (max-width: 900px) {
  .workspace,
  .workspace.has-chat {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-nav,
  .app-chat {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 20;
    width: min(320px, 88vw);
    box-shadow: 0 10px 30px rgba(31, 42, 55, 0.18);
    transition: transform 0.2s ease;
  }

  .app-nav {
    left: 0;
    transform: translateX(-105%);
  }

  .app-chat {
    right: 0;
    width: min(420px, 100vw);
    transform: translateX(105%);
  }

  .workspace.nav-open .app-nav,
  .workspace.chat-open .app-chat {
    transform: none;
  }

  .workspace.has-chat .chat-close {
    display: grid;
  }

}

body.chat-available .chat-toggle {
  display: none;
}

@media (max-width: 900px) {
  body.chat-available .chat-toggle {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-nav,
  .app-chat {
    transition: none;
  }
}

/* » hides the chat on a wide screen; the « 💬 tab on the right edge brings it back. */




@media (min-width: 901px) {
  .workspace.has-chat.chat-hidden {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  .workspace.nav-hidden.has-chat.chat-hidden {
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace.chat-hidden .app-chat {
    display: none;
  }

  .workspace.has-chat.chat-hidden .chat-show {
    display: flex;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .workspace.has-chat.chat-hidden {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}


/* ---------------------------------------------------------------- first-time tour (web/tour.js) */

.tour {
  position: fixed;
  inset: 0;
  z-index: 400;
  font-family: "Nunito", system-ui, sans-serif;
}

/* Clicks outside the card don't reach the page while the tour is on. */
.tour-block {
  position: absolute;
  inset: 0;
}

/* The lit-up part: everything around it is darker. */
.tour-hole {
  position: fixed;
  border-radius: 14px;
  box-shadow: 0 0 0 200vmax rgba(18, 24, 38, 0.58), 0 0 0 4px #d39be0, 0 0 22px 6px rgba(211, 155, 224, 0.55);
  pointer-events: none;
  transition: left 0.3s ease, top 0.3s ease, width 0.3s ease, height 0.3s ease;
}

.tour-card {
  position: fixed;
  width: min(340px, calc(100vw - 24px));
  padding: 16px 18px 14px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(18, 24, 38, 0.28);
  color: #1f2a37;
  transition: left 0.3s ease, top 0.3s ease;
}

.tour-card.is-in {
  animation: tour-in 0.3s ease;
}

@keyframes tour-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
}

.tour-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.tour-count {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #a774d2;
}

.tour-close {
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #5a6f86;
  cursor: pointer;
  padding: 0 2px;
}

.tour-close:hover {
  color: #1f2a37;
}

.tour-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.tour-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #44566c;
}

.tour-text mark {
  background: var(--tour-mark, #e2abe280);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.tour-text u {
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  text-decoration-color: #000000;
}

.tour-text strong {
  font-weight: 800;
  color: #000000;
}

.tour-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.tour-space {
  flex: 1;
}

.tour-skip {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #5a6f86;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.tour-back,
.tour-next {
  border-radius: 12px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.tour-back {
  border: 1px solid #d6e0ea;
  background: #ffffff;
  color: #1f2a37;
}

.tour-next {
  border: none;
  color: #ffffff;
  background: linear-gradient(90deg, #5aa6e8, #b07cd8);
  box-shadow: 0 6px 14px rgba(122, 130, 220, 0.3);
}

.tour-back:hover,
.tour-next:hover {
  transform: translateY(-1px);
}

@media (prefers-reduced-motion: reduce) {
  .tour-hole,
  .tour-card {
    transition: none;
  }

  .tour-card.is-in {
    animation: none;
  }
}

/* Exam practice quiz → only some chapters */
.quiz-parts {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}

.quiz-parts[hidden] {
  display: none;
}

.quiz-part {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  cursor: pointer;
  font-size: 14px;
}

.quiz-part:hover {
  border-color: #b6d2ee;
}

.quiz-part input {
  width: 18px;
  height: 18px;
  accent-color: #a774d2;
  flex: 0 0 auto;
}

.quiz-part-title {
  flex: 1;
  min-width: 0;
}

.quiz-part small {
  color: #7c8794;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- what's new (after an update) */

.news-overlay {
  position: fixed;
  z-index: 250;
}

.news-dialog {
  max-width: 860px;
  max-height: calc(100vh - 32px);
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 24px 24px 20px;
}

.news-dialog .owl-medium {
  justify-self: center;
  width: 56px;
  height: auto;
}

.news-dialog .reformat-title {
  justify-self: stretch;
  text-align: center;
}

.news-dialog .reformat-sub {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #2e4057;
}

.news-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

/* A wide screen: the changes in two columns, so the popup isn't a long phone-like strip. */
@media (min-width: 760px) {
  .news-list {
    grid-template-columns: 1fr 1fr;
  }
}

/* A big screen: three columns, in a wider popup. */
@media (min-width: 1150px) {
  .news-dialog {
    max-width: 1080px;
  }

  .news-list {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.news-list li {
  padding: 8px 12px;
  border-radius: 12px;
  background: #f4f8fd;
  line-height: 1.45;
}

.news-thanks {
  margin: 4px 0 0;
  line-height: 1.5;
}

.news-actions {
  justify-self: stretch;
  display: grid;
  gap: 6px;
  justify-items: center;
}

.news-actions .transform-btn {
  width: 100%;
}

.news-ext {
  justify-self: stretch;
  font-size: 14px;
  display: grid;
  gap: 8px;
  line-height: 1.45;
}

.news-ext p {
  margin: 0;
}

.news-ext-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}

.news-ext-links a {
  font-weight: 800;
  color: #2e4057;
}

/* ---------------------------------------------------------------- flashcards in sets (long documents) */

.fc-sets {
  display: grid;
  gap: 8px;
  margin: 4px 0 6px;
}

.fc-set-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fc-set-tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: #ffffff;
  color: #2e4057;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.fc-set-tab[aria-pressed="true"] {
  background: #eaf4ff;
  border-color: #5aa6e8;
}

.fc-set-now {
  font-weight: 800;
  color: #2e4057;
}

.fc-next {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f4f0fb;
  border: 1px solid #e2d6f3;
}

.fc-next-text {
  margin: 0;
  line-height: 1.45;
}

#fcLoadingText {
  white-space: pre-line;
}

/* The extension on an iPad, a phone, Safari or Firefox (lib/device.js) */
.ext-device-note {
  margin: 10px 0 0;
  max-width: 560px;
  line-height: 1.45;
}

/* ---------------------------------------------------------------- exam practice quiz: extras */

/* Chips that can be ticked together (question types, maths questions) */
.option-chip--check[aria-pressed="true"]::before {
  content: "✓ ";
}

.drop-zone--small {
  padding: 14px;
  min-height: 0;
}

.quiz-fresh-hint {
  margin: 8px 0 0;
  text-align: center;
}

/* Read aloud, text size, font, highlights: above a question and above the results */
.quiz-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}

.quiz-tool {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  background: #ffffff;
  color: #2e4057;
  font: 700 13px/1.2 "Nunito", system-ui, sans-serif;
  cursor: pointer;
}

.quiz-tool:hover:not(:disabled) {
  background: #f0f6ff;
}

.quiz-tool:disabled {
  opacity: 0.45;
  cursor: default;
}

.quiz-tool.is-on,
.quiz-tool-larf[aria-pressed="true"] {
  background: #eaf4ff;
  border-color: #5aa6e8;
}

/* The chosen text size and font, on the question and the answers (not on the buttons above) */
.quiz-styled .quiz-question,
.quiz-styled .quiz-options,
.quiz-styled .quiz-written,
.quiz-styled .quiz-feedback,
.quiz-styled .quiz-score-card,
.quiz-styled .quiz-review {
  zoom: var(--quiz-scale, 1);
}

.quiz-own-font .quiz-question,
.quiz-own-font .quiz-options,
.quiz-own-font .quiz-options *,
.quiz-own-font .quiz-answer,
.quiz-own-font .quiz-feedback,
.quiz-own-font .quiz-feedback *,
.quiz-own-font .quiz-review,
.quiz-own-font .quiz-review * {
  font-family: var(--quiz-font) !important;
}

/* Smart highlights in the questions and answers (switch: .quiz-plain hides them) */
.quiz-styled mark {
  background-color: var(--quiz-mark, #e2abe24d) !important;
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.quiz-styled strong {
  font-weight: 800;
  color: #000000;
}

.quiz-styled u {
  text-decoration: underline;
  text-decoration-color: #000000;
  text-underline-offset: 3px;
}

.quiz-plain mark {
  background: none !important;
  padding: 0;
}

.quiz-plain strong {
  font-weight: inherit;
  color: inherit;
}

.quiz-plain u {
  text-decoration: none;
}

.quiz-feedback-title {
  display: block;
}

/* 🤔 Why? and 📖 Define the concepts under a wrong answer */
.quiz-help {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.quiz-help-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quiz-help-btn {
  border: 1px solid #cfe3fb;
  border-radius: 999px;
  padding: 6px 14px;
  background: #ffffff;
  color: #2e4057;
  font: 800 14px/1.2 "Nunito", system-ui, sans-serif;
  cursor: pointer;
}

.quiz-help-btn:hover:not(:disabled) {
  background: #eaf4ff;
}

.quiz-help-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.quiz-help-out {
  display: grid;
  gap: 8px;
}

.quiz-help-answer {
  padding: 10px 14px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #e3eaf3;
  line-height: 1.5;
  color: #1f2a37;
}

.quiz-help-answer p,
.quiz-help-answer ul {
  margin: 0 0 6px;
}

.quiz-help-answer ul {
  padding-left: 20px;
}

.quiz-help-answer--define {
  background: #fbf8ff;
  border-color: #e2d6f3;
}

.quiz-help-later {
  margin: 0;
  font-size: 13px;
  color: #5b6b7d;
}

/* Read aloud on the quiz: the word being said (as in the Reader) */
::highlight(studybuddy-tts-word) {
  background-color: var(--tts-word, #ffd84d);
}

::highlight(studybuddy-tts-sentence) {
  background-color: var(--tts-sentence, rgba(90, 166, 232, 0.18));
}

::highlight(studybuddy-tts-sentence-only) {
  background-color: var(--tts-sentence-only, rgba(255, 216, 77, 0.75));
}

/* The chat's left edge: drag it (or use the arrow keys) to make the chat wider or narrower. (Only on
   wide screens: on a phone the chat slides in over the tool, positioned by the rules above.) */
@media (min-width: 901px) {
  .app-chat {
    position: relative;
  }
}

.chat-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -5px;
  width: 10px;
  z-index: 5;
  cursor: col-resize;
  touch-action: none;
}

.chat-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 4px;
  height: 44px;
  margin-top: -22px;
  border-radius: 4px;
  background: #c9d6e6;
  opacity: 0;
  transition: opacity 0.15s;
}

.app-chat:hover .chat-resizer::after,
.chat-resizer:focus-visible::after,
body.chat-resizing .chat-resizer::after {
  opacity: 1;
  background: #5aa6e8;
}

/* While dragging, the Reader frame mustn't catch the mouse */
body.chat-resizing {
  cursor: col-resize;
  user-select: none;
}

body.chat-resizing iframe {
  pointer-events: none;
}

@media (max-width: 900px) {
  .chat-resizer {
    display: none;
  }
}

/* "What's new", compact: short lines, small owl */
.news-dialog {
  max-width: 760px;
  gap: 8px;
  padding: 18px 22px 16px;
}

.news-dialog .owl-medium {
  width: 40px;
}

.news-dialog .reformat-title {
  margin: 0;
  font-size: 19px;
}

.news-list {
  gap: 6px;
}

.news-list li {
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.4;
}

@media (min-width: 760px) {
  .news-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1150px) {
  .news-dialog {
    max-width: 920px;
  }

  .news-list {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.news-ext {
  padding: 8px 12px;
  font-size: 13px;
}

.news-thanks {
  margin: 0;
  font-size: 14px;
}

.news-actions .transform-btn {
  padding-top: 10px;
  padding-bottom: 10px;
}

/* Exam practice quiz: the number of questions, typed */
.quiz-count-own {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 14px;
  color: #2e4057;
}

.quiz-count-own input {
  width: 80px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
}

.quiz-count-own input:focus {
  outline: 2px solid #5aa6e8;
  outline-offset: 1px;
}

.quiz-tool-voice {
  max-width: 220px;
}

/* The chat's hide / show tab: on the line between the tool and the chat, at mid-height; when the chat
   is hidden, the same tab sits at the right edge, at the same height. */
.chat-edge-tab {
  position: absolute;
  top: 50%;
  z-index: 16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 28px;
  height: 64px;
  margin: 0;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  color: #2e4057;
  font: 800 16px/1 "Nunito", system-ui, sans-serif;
  writing-mode: horizontal-tb;
  box-shadow: 0 4px 14px rgba(31, 42, 55, 0.12);
  cursor: pointer;
}

.chat-edge-tab:hover {
  background: #f0f6ff;
}

.chat-edge-tab.chat-hide {
  display: none;
  right: calc(var(--chat-now, 400px) - 14px);
}

@media (min-width: 901px) {
  .workspace.has-chat:not(.chat-hidden) .chat-edge-tab.chat-hide {
    display: flex;
  }
}

.chat-edge-tab.chat-show {
  display: none; /* only while the chat is hidden (see .chat-hidden above) */
  right: 6px;
}

.chat-edge-tab.chat-show span {
  writing-mode: horizontal-tb;
  font-size: 14px;
}

@media (max-width: 900px) {
  .chat-edge-tab.chat-hide {
    display: none;
  }
}

/* The update popup: small, one message */
.news-dialog.news-dialog--small {
  max-width: 440px;
  justify-items: stretch;
  text-align: center;
}

.news-dialog--small .news-ext {
  text-align: left;
}

.news-date {
  margin: -4px 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: #5b6b7d;
}

.news-see {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* The chapter or part a quiz question tests ("📍 From: Chapter 3") */
.quiz-kind-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.quiz-kind-row .quiz-kind {
  margin-bottom: 0;
}

.quiz-part-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef6ee;
  border: 1px solid #cfe6cf;
  color: #2f5d34;
  font-size: 12px;
  font-weight: 800;
}

.quiz-kind-row + .quiz-question {
  margin-top: 10px;
}

/* A maths question of the results: ask the chat, or solve it step by step */
.quiz-math-row {
  margin-top: 8px;
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 480px) {
  .app-bar {
    gap: 6px;
    padding: 0 10px;
  }

  /* The owl stays; the name goes, so every button fits */
  body[data-screen="workspace"] .app-brand span {
    display: none;
  }

  .app-brand {
    font-size: 16px;
    gap: 6px;
  }

  /* The quiz's reading tools: smaller, the voice menu narrower */
  .quiz-tool {
    padding: 5px 10px;
    font-size: 12px;
  }

  .quiz-tool-voice {
    max-width: 150px;
  }
}

/* Phones: the menu and the chat wait outside the screen until they slide in; the page must not scroll
   sideways to them. */
@media (max-width: 900px) {
  .workspace {
    overflow: clip;
  }
}

/* ---------------------------------------------------------------- Make a diagram */

.panel.right[data-view="diagram"] .diagram-view {
  display: block;
}

/* The diagram above, the document underneath (when a box is clicked) */
.panel.right[data-view="diagram-result"] .diagram-result-view {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.doc-bar-back {
  border: 1px solid #c07bdc;
  background: #f7ecfb;
  color: #6b2f8a;
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.doc-bar-back:hover {
  background: #f2d8f3;
}

/* Step 1: the kinds, as big cards with a small example */
.dg-types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.dg-type {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 4px;
  padding: 10px 10px 12px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dg-type:hover {
  border-color: #b6d2ee;
  box-shadow: var(--shadow);
}

.dg-type[aria-checked="true"] {
  border-color: #c07bdc;
  background: #fcf6fe;
  box-shadow: 0 0 0 3px #f2d8f3;
}

.dg-type-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 112px;
  overflow: hidden;
  border-radius: 12px;
  background: #f6f9fc;
  font-size: 6.5px;
  pointer-events: none;
}

.dg-type-name {
  margin-top: 4px;
  font-weight: 800;
  font-size: 15px;
}

.dg-type-icon {
  display: inline-block;
  min-width: 1.4em;
  color: #a774d2;
  font-weight: 900;
}

.dg-type-hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

/* Step 1: the parts, chapters with their sections */
.dg-parts {
  max-height: 340px;
}

.dg-chapter {
  display: grid;
  gap: 6px;
}

.dg-chapter-toggle {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #f6f9fc;
  border-radius: 999px;
  padding: 2px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #35618f;
  cursor: pointer;
}

.dg-chapter-toggle::after {
  content: " ▾";
}

.dg-chapter-toggle[aria-expanded="true"]::after {
  content: " ▴";
}

.dg-sections {
  display: grid;
  gap: 6px;
  margin-left: 26px;
}

.dg-part--section {
  font-size: 13.5px;
  padding-block: 6px;
}

.dg-part input:disabled + .quiz-part-title {
  color: var(--muted);
}

.dg-hint-warn {
  color: #a5641b;
  font-weight: 700;
}

/* Step 2 */
.dg-result {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px max(16px, calc((100% - 1100px) / 2)) 32px;
}

.dg-head {
  margin: 10px 0 8px;
}

.dg-title {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
}

.dg-from {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13.5px;
}

.dg-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 10px 0;
}

.dg-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.dg-zoom {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.dg-zoom button {
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: none;
  border-radius: 999px;
  background: #f0f6ff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.dg-zoom button:hover {
  background: #d6ecff;
}

.dg-zoom span {
  min-width: 44px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.dg-click-hint {
  margin: 4px 0 8px;
}

.dg-stage {
  display: flex;
  justify-content: safe center;
  align-items: flex-start;
  overflow: auto;
  min-height: 260px;
  padding: 24px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fbfdff;
}

/* The drawing (lib/diagramDraw.js): sizes in em, so the zoom is the font size */
.dg-canvas {
  position: relative;
  flex: 0 0 auto;
  font-family: "Nunito", system-ui, sans-serif;
  font-size: 1em;
  line-height: 1.3;
}

.dg-canvas--outline,
.dg-canvas--timeline {
  flex: 1 1 auto;
  max-width: 50em;
}

.dg-lines {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}

.dg-line {
  fill: none;
  stroke: #9db7d3;
  stroke-width: var(--dg-stroke, 2px);
}

.dg-line--cross {
  stroke: #a774d2;
  stroke-dasharray: 6 5;
}

.dg-brace {
  stroke: #5aa6e8;
  stroke-width: calc(var(--dg-stroke, 2px) * 1.25);
  stroke-linecap: round;
}

.dg-head {
  fill: #8aa6c4;
}

.dg-node {
  position: relative;
  z-index: 1;
  max-width: 15em;
  padding: 0.45em 0.8em;
  border: 2px solid #9db7d3;
  border-radius: 0.8em;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 1em;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(44, 62, 80, 0.06);
  transition: transform 0.12s, box-shadow 0.12s;
}

.dg-node:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.14);
}

.dg-node:focus-visible {
  outline: 3px solid #5aa6e8;
  outline-offset: 2px;
}

.dg-node.is-picked {
  outline: 3px solid #ffcf3f;
  outline-offset: 2px;
}

.dg-depth-0 {
  border-color: #3d8fd6;
  background: #5aa6e8;
  color: #ffffff;
  font-weight: 900;
  font-size: 1.15em;
}

.dg-depth-1 {
  border-color: #5aa6e8;
  background: #e8f2fd;
  font-weight: 800;
}

.dg-depth-2 {
  border-color: #c07bdc;
  background: #f7ecfb;
}

.dg-depth-3 {
  border-color: #5fb47f;
  background: #ecf7f0;
}

.dg-depth-4 {
  border-color: #dba54a;
  background: #fdf5e6;
}

/* Boxes inside a list or table: just the words */
.dg-node--plain {
  max-width: none;
  padding: 0.15em 0.35em;
  border: none;
  border-radius: 0.4em;
  background: transparent;
  color: inherit;
  font-weight: inherit;
  font-size: 1em;
  text-align: left;
  box-shadow: none;
}

.dg-node--plain:hover {
  transform: none;
  background: #eef5fd;
  box-shadow: none;
}

.dg-link {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 11em;
  margin-bottom: 0.35em;
  padding: 0 0.3em;
  background: #fbfdff;
  color: #6b7785;
  font-size: 0.8em;
  font-style: italic;
  text-align: center;
}

.dg-cross-label {
  position: absolute;
  z-index: 2;
  margin: 0;
  color: #8a4fb3;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

/* Concept map: from the top down */
.dg-v-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dg-v-kids {
  display: flex;
  align-items: flex-start;
  gap: 1.3em;
  margin-top: 2.4em;
}

/* The last ideas of a branch, one under the other, with the line down their left side */
.dg-v-kids--stack {
  flex-direction: column;
  gap: 0.6em;
  margin-top: 1.6em;
  padding-left: 1.3em;
}

.dg-v-kids--stack > .dg-v-branch {
  flex-direction: row;
  align-items: center;
  gap: 0.4em;
}

.dg-v-kids--stack > .dg-v-branch > .dg-link {
  margin: 0;
  text-align: left;
}

.dg-v-kids--stack .dg-node {
  max-width: 12em;
  text-align: left;
}

/* Braces and arrows: from left to right */
.dg-h-branch {
  display: flex;
  align-items: center;
}

.dg-h-branch > .dg-node {
  flex: 0 0 auto;
  text-align: left;
}

.dg-h-join {
  flex: 0 0 auto;
  align-self: stretch;
  width: 2em;
}

.dg-canvas--arrows .dg-h-join {
  width: 3.2em;
}

.dg-h-kids {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55em;
  padding: 0.3em 0;
}

/* Numbered outline */
.dg-outline-title {
  margin-bottom: 0.6em;
}

.dg-outline-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.dg-outline-list .dg-outline-list {
  padding-left: 1.8em;
}

.dg-outline-row {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  padding: 0.12em 0;
}

.dg-outline-num {
  flex: 0 0 auto;
  min-width: 2.2em;
  color: #3d8fd6;
  font-weight: 900;
}

.dg-outline-1 > .dg-outline-item > .dg-outline-row {
  margin-top: 0.5em;
  font-size: 1.08em;
  font-weight: 800;
}

.dg-outline-1 > .dg-outline-item > .dg-outline-row .dg-outline-num {
  color: #a774d2;
}

/* Comparison table */
.dg-table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #d5e2ef;
  border-radius: 0.8em;
  overflow: hidden;
  background: #ffffff;
}

.dg-table th,
.dg-table td {
  min-width: 8em;
  max-width: 18em;
  padding: 0.45em 0.6em;
  border-bottom: 1px solid #e3e9f0;
  border-right: 1px solid #e3e9f0;
  text-align: left;
  vertical-align: top;
}

.dg-table thead th {
  background: #5aa6e8;
  color: #ffffff;
  font-weight: 900;
}

.dg-table tbody th {
  background: #f7ecfb;
  font-weight: 800;
}

.dg-table tr > :last-child {
  border-right: none;
}

.dg-table tbody tr:last-child > * {
  border-bottom: none;
}

/* Timeline: one under the other */
.dg-timeline {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dg-timeline::before {
  content: "";
  position: absolute;
  top: 0.4em;
  bottom: 0.4em;
  left: 7.15em;
  width: 3px;
  border-radius: 3px;
  background: #d6ecff;
}

.dg-event {
  position: relative;
  display: grid;
  grid-template-columns: 6.4em minmax(0, 1fr);
  align-items: center;
  gap: 1.6em;
  margin: 0.55em 0;
}

.dg-event::before {
  content: "";
  position: absolute;
  left: 6.85em;
  top: 50%;
  width: 0.8em;
  height: 0.8em;
  margin-top: -0.4em;
  border: 3px solid #5aa6e8;
  border-radius: 50%;
  background: #ffffff;
  z-index: 1;
}

.dg-event-date {
  color: #8a4fb3;
  font-weight: 900;
  text-align: right;
  overflow-wrap: anywhere;
}

.dg-event .dg-node {
  justify-self: start;
  max-width: 28em;
  text-align: left;
}

/* The document, in the chat's column (over the chat: one or the other) */
.dg-peek {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  flex-direction: column;
  min-height: 0;
  background: #ffffff;
}

.workspace.dg-doc-open .dg-peek {
  display: flex;
}

/* With the chat hidden (»), the column still opens for the document */
@media (min-width: 901px) {
  .workspace.has-chat.chat-hidden.dg-doc-open {
    grid-template-columns: 250px minmax(0, 1fr) var(--chat-width, minmax(320px, 400px));
  }

  .workspace.nav-hidden.has-chat.chat-hidden.dg-doc-open {
    grid-template-columns: minmax(0, 1fr) var(--chat-width, minmax(320px, 400px));
  }

  .workspace.chat-hidden.dg-doc-open .app-chat {
    display: flex;
  }

  .workspace.dg-doc-open .chat-edge-tab {
    display: none !important;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  .workspace.has-chat.chat-hidden.dg-doc-open {
    grid-template-columns: 220px minmax(0, 1fr) var(--chat-width, minmax(300px, 340px));
  }
}

.dg-peek-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #f6f9fc;
  font-size: 14px;
}

.dg-peek-title {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dg-peek-note {
  flex-basis: 100%;
  order: 3;
  color: #a5641b;
  font-weight: 700;
  font-size: 13px;
}

.dg-peek-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.dg-peek-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 999px;
  padding: 4px 11px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #2e4057;
  cursor: pointer;
}

.dg-peek-btn:hover {
  background: #f0f6ff;
  border-color: #b6d2ee;
}

.dg-peek-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #e3e9f0;
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.dg-peek-close:hover {
  background: #d3dce6;
}


/* ⛶ Full screen: the diagram over everything */
.dg-full-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  border-radius: 999px;
  padding: 6px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  color: #2e4057;
  cursor: pointer;
}

.dg-full-btn:hover {
  background: #f0f6ff;
  border-color: #b6d2ee;
}

/* 📝 Explanations: On / Off */
.dg-onoff {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.dg-onoff-label {
  margin-right: 2px;
  font-size: 14px;
  font-weight: 800;
  color: #2e4057;
  white-space: nowrap;
}

.dg-onoff .option-chip {
  margin: 0;
  padding: 4px 12px;
}

/* A box: its words, then (with the explanations shown) its explanation in small letters */
.dg-node-text {
  display: block;
}

.dg-key {
  font-size: 0.85em;
}

.dg-note {
  display: block;
  margin-top: 0.3em;
  padding-top: 0.3em;
  border-top: 1px dashed rgba(44, 62, 80, 0.18);
  color: #3f4b58;
  font-size: 0.9em;
  font-weight: 500;
  line-height: 1.35;
}

.dg-depth-0 .dg-note {
  color: #eef6ff;
  border-top-color: rgba(255, 255, 255, 0.45);
}

.dg-node--plain .dg-note {
  margin-top: 0.1em;
  padding-top: 0;
  border-top: none;
}

/* With explanations, the boxes are a little wider */
.dg-canvas--notes .dg-node {
  max-width: 18em;
}

.dg-canvas--notes .dg-v-kids--stack .dg-node {
  max-width: 15em;
}

.dg-peek-explain {
  flex-basis: 100%;
  order: 4;
  padding: 8px 12px;
  border-radius: 12px;
  background: #fff8db;
  border: 1px solid #f3e1a0;
  font-size: 14px;
  line-height: 1.4;
}

.dg-full {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  background: #fbfdff;
}

.dg-full[hidden] {
  display: none;
}

.dg-full-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.dg-full-title {
  flex: 1 1 160px;
  min-width: 0;
  overflow: hidden;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.dg-full-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #e3e9f0;
  font: inherit;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.dg-full-close:hover {
  background: #d3dce6;
}

.dg-full-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

.dg-full-body .dg-stage {
  flex: 1 1 auto;
  min-height: 0;
  border: none;
  border-radius: 0;
}

body.dg-full-open {
  overflow: hidden;
}

.dg-peek-body {
  flex: 1 1 auto;
  min-height: 0;
}

@media (max-width: 560px) {
  .dg-types {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .dg-type {
    padding: 8px;
  }

  .dg-type-preview {
    height: 84px;
    font-size: 4.8px;
  }

  .dg-type-name {
    font-size: 14px;
  }

  .dg-type-hint {
    font-size: 12px;
  }

  .dg-title {
    font-size: 20px;
  }

  .dg-stage {
    padding: 16px 10px;
  }

  .dg-peek-btn {
    padding: 4px 9px;
    font-size: 12.5px;
  }
}

/* 🖨️ Print or save as PDF: only the diagram */
@media screen {
  #dgPrint {
    display: none;
  }
}

@media print {
  html,
  body {
    height: auto !important;
    overflow: visible !important;
    background: #ffffff !important;
  }

  body > *:not(#dgPrint) {
    display: none !important;
  }

  #dgPrint {
    display: block;
    font-family: "Nunito", system-ui, sans-serif;
    color: #1f2a37;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  #dgPrint h1 {
    margin: 0 0 2px;
    font-size: 22px;
  }

  #dgPrint p {
    margin: 0 0 14px;
    color: #7c8794;
    font-size: 12px;
  }

  #dgPrint .dg-node {
    box-shadow: none;
  }
}
