/* ============================================================
   EDUSION — workspace shell (/app)
   ============================================================ */

.ws {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  /* an almost invisible blue-grey fall from top to bottom */
  background: var(--canvas-2) var(--grad-canvas);
}

/* ─────────────────────────────────────────────  top bar (icon-led, ChatGPT-calm)  */
.ws-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 57px; /* 56 + hairline; other sticky offsets use 57px */
  box-sizing: border-box;
  padding: 0 clamp(10px, 2vw, 18px);
  border-bottom: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
}
.ws-top__session {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-left: 2px;
}
.ws-top__session strong {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.016em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-top__session span {
  flex: 0 0 auto;
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
}
.ws-top__right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* round icon buttons */
.ws-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--t-fast) linear, color var(--t-fast) linear;
}
.ws-icon-btn:hover:not(:disabled) {
  background: var(--hair);
  color: var(--ink);
}
.ws-icon-btn:active:not(:disabled) {
  background: var(--hair-2);
}
.ws-icon-btn:focus-visible {
  border-radius: 50%;
}
.ws-icon-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.ws-icon-btn[aria-expanded='true']:not(.ws-sidebar-toggle) {
  background: var(--hair);
  color: var(--ink);
}
.ws-icon-btn svg {
  flex-shrink: 0;
}
/* the sidebar toggle shows a panel icon on desktop and a menu icon in the drawer layout */
.ws-ic--mob {
  display: none;
}

/* tooltips: visible on hover and on keyboard focus (the aria-label stays the accessible name) */
[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  z-index: 60;
  padding: 5px 9px;
  border-radius: 7px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -2px);
  transition: opacity 120ms linear, transform 120ms var(--ease-out), visibility 0s linear 120ms;
}
[data-tip][data-tip-align='start']::after {
  left: 0;
  transform: translate(0, -2px);
}
[data-tip][data-tip-align='end']::after {
  left: auto;
  right: 0;
  transform: translate(0, -2px);
}
[data-tip][data-tip-pos='top']::after {
  top: auto;
  bottom: calc(100% + 6px);
}
[data-tip]:is(:hover, :focus-visible)::after {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 350ms, 350ms, 350ms;
}
[data-tip]:focus-visible::after {
  transition-delay: 0s;
}
[data-tip]:is([data-tip-align='start'], [data-tip-align='end']):is(:hover, :focus-visible)::after {
  transform: translate(0, 0);
}
/* no tooltip while the thing it names is open, or on touch-only screens */
[data-tip][aria-expanded='true']:not(.ws-sidebar-toggle)::after {
  display: none;
}
@media (hover: none) {
  [data-tip]:hover:not(:focus-visible)::after {
    opacity: 0;
    visibility: hidden;
  }
}
@media (prefers-reduced-motion: reduce) {
  [data-tip]::after {
    transition: none;
  }
}

/* ─────────────────────────────────────────────  layout  */
.ws-body {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 0;
  position: relative;
}

/* ─────────────────────────────────────────────  collapsed-sidebar rail (desktop only)  */
.ws-strip {
  display: none;
  flex: 0 0 60px;
  width: 60px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 12px;
  background: var(--canvas);
  border-right: 1px solid var(--hair);
  position: sticky;
  top: 57px;
  align-self: start;
  height: calc(100svh - 57px);
  z-index: 35;
}
.ws-strip__brand {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-bottom: 6px;
  border-radius: 50%;
  color: var(--ink);
}
.ws-strip__brand:hover {
  background: var(--hair);
}
.ws-strip__brand:focus-visible {
  border-radius: 50%;
}
.ws-strip__avatar {
  margin-top: auto;
}
/* Desktop open/close. The sidebar's width springs 264 <-> 0 while this rail grows 0 <-> 60 with the same curve,
   so the page slides over in one motion. Both keep their contents at a fixed width (no squash or re-wrap): the
   contents fade out faster than the panel closes and fade in once it has mostly opened. visibility flips only
   after a close has finished, so Tab never lands in the hidden one (app.js also sets inert).
   ".sb-rail *" is the collapsed state set by ws-layout.js before first paint, until app.js takes over. */
@media (min-width: 901px) {
  html:not(.a11y-w900) .ws-strip {
    display: flex;
    flex: none;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    border-right-color: transparent;
    transition: width var(--sb-dur) var(--sb-ease), border-color var(--sb-dur) linear, visibility 0s linear var(--sb-dur);
  }
  html:not(.a11y-w900) .ws-strip > * {
    flex: none;
    opacity: 0;
    transition: opacity var(--sb-fade-out) linear;
  }
  html:not(.a11y-w900) .ws-body:is(.sidebar-collapsed, .sb-rail *) .ws-strip {
    width: 60px;
    visibility: visible;
    border-right-color: var(--hair);
    transition: width var(--sb-dur) var(--sb-ease), border-color var(--sb-dur) linear, visibility 0s;
  }
  html:not(.a11y-w900) .ws-body:is(.sidebar-collapsed, .sb-rail *) .ws-strip > * {
    opacity: 1;
    transition: opacity var(--sb-fade-in) linear var(--sb-fade-delay);
  }
  /* the rail has its own expand button, so the top-bar toggle folds away (width and the 10px gap) in step,
     and the note title glides left instead of jumping */
  html:not(.a11y-w900) .ws-sidebar-toggle {
    transition: width var(--sb-dur) var(--sb-ease), margin var(--sb-dur) var(--sb-ease), opacity var(--sb-fade-in) linear var(--sb-fade-delay),
      background var(--t-fast) linear, color var(--t-fast) linear, visibility 0s;
  }
  html:not(.a11y-w900) .ws-top:has(~ .ws-body:is(.sidebar-collapsed, .sb-rail *)) .ws-sidebar-toggle {
    width: 0;
    margin-right: -10px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: width var(--sb-dur) var(--sb-ease), margin var(--sb-dur) var(--sb-ease), opacity var(--sb-fade-out) linear,
      visibility 0s linear var(--sb-dur);
  }
}
/* the first paint (and a resize across breakpoints) never animates: app.js drops .sb-still after boot */
html.sb-still :is(.ws-history, .ws-history > *, .ws-strip, .ws-strip > *, .ws-history-backdrop, .ws-sidebar-toggle) {
  transition: none !important;
}
/* reduced motion (OS setting; the a11y "Less motion" profile already makes every transition instant):
   no slide. The panel switches width at once and only its contents fade; the drawer fades in place. */
@media (prefers-reduced-motion: reduce) {
  .ws-history,
  .ws-strip {
    transition-property: visibility !important;
  }
}
@media (prefers-reduced-motion: reduce) and (max-width: 900px) {
  .ws-history {
    transform: none !important;
    transition-property: opacity, visibility !important;
  }
  .ws-body:not(.sidebar-open) .ws-history {
    opacity: 0 !important;
  }
}
/* tooltips that open to the right (rail) */
[data-tip][data-tip-pos='right']::after {
  top: 50%;
  left: calc(100% + 8px);
  right: auto;
  transform: translate(-2px, -50%);
}
[data-tip][data-tip-pos='right']:is(:hover, :focus-visible)::after {
  transform: translate(0, -50%);
}

/* ─────────────────────────────────────────────  notes sidebar (ChatGPT structure, Edusion tokens)  */
.ws-history {
  width: 264px;
  flex: none; /* width alone sizes it, so the width transition is the whole motion (flex-basis does not animate) */
  background: var(--canvas);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--hair);
  position: sticky;
  top: 57px;
  align-self: start;
  max-height: calc(100svh - 57px);
  height: calc(100svh - 57px);
  overflow: hidden;
  z-index: 30;
}
/* Desktop collapsed state (motion notes above .ws-strip) */
@media (min-width: 901px) {
  .ws-history {
    transition: width var(--sb-dur) var(--sb-ease), border-color var(--sb-dur) linear, visibility 0s;
  }
  .ws-history > * {
    flex-shrink: 0;
    width: calc(263px - var(--sb-mx, 0px)); /* the open width minus the border (and side margins): no reflow mid-motion */
    opacity: 1;
    transition: opacity var(--sb-fade-in) linear var(--sb-fade-delay);
  }
  .ws-history > :is(.ws-search, .ws-madeby) {
    --sb-mx: 24px;
  }
  .ws-history > .ws-history__scroll {
    flex: 1 1 auto;
    min-height: 0;
  }
  .ws-body:is(.sidebar-collapsed, .sb-rail *) .ws-history {
    width: 0;
    visibility: hidden;
    pointer-events: none;
    border-right-color: transparent;
    transition: width var(--sb-dur) var(--sb-ease), border-color var(--sb-dur) linear, visibility 0s linear var(--sb-dur);
  }
  .ws-body:is(.sidebar-collapsed, .sb-rail *) .ws-history > * {
    opacity: 0;
    transition: opacity var(--sb-fade-out) linear;
  }
}

.ws-history__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 6px 12px;
  flex-shrink: 0;
}
.ws-history__brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 8px 0 4px;
  border-radius: var(--r-sm);
  color: var(--ink);
}
.ws-history__brand .wordmark {
  font-size: 13px;
}

/* search */
.ws-search {
  position: relative;
  margin: 0 12px 6px;
  flex-shrink: 0;
}
.ws-search[hidden] {
  display: none;
}
.ws-search__ic {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.ws-search__input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.ws-search__input::placeholder {
  color: var(--ink-3);
}
.ws-search__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: var(--r-pill);
  border-color: transparent;
}

.ws-history__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ws-history__section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ws-history__section[hidden] {
  display: none;
}
.ws-history__heading {
  margin: 0;
  padding: 8px 10px 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--ink-3);
}
.ws-history__list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ws-history__empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink-3);
}
.ws-history__empty[hidden] {
  display: none;
}

/* History Item */
.ws-history-item {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 0 4px 0 10px;
  border-radius: var(--r-sm);
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  transition: background 0.14s ease, color 0.14s ease;
  user-select: none;
}
.ws-history-item[hidden] {
  display: none;
}
.ws-history-item:hover {
  background: var(--hair);
  color: var(--ink);
}
.ws-history-item.is-active {
  background: var(--accent-soft);
  color: var(--ink);
  font-weight: 500;
}
.ws-history-item__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
button.ws-history-item__title {
  align-self: stretch;
  border: 0;
  background: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
}
.ws-history-item__actions {
  display: inline-flex;
  align-items: center;
  gap: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
  margin-left: auto;
  flex-shrink: 0;
}
.ws-history-item:hover .ws-history-item__actions,
.ws-history-item:focus-within .ws-history-item__actions,
.ws-history-item.is-active .ws-history-item__actions {
  opacity: 1;
}
/* touch screens have no hover: keep row actions visible */
@media (hover: none) {
  .ws-history-item__actions {
    opacity: 1;
  }
}
.ws-history-item__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease;
}
.ws-history-item__btn:hover {
  background: var(--hair);
  color: var(--ink);
}
.ws-history-item__btn--delete:hover {
  color: var(--clay);
}
.ws-history-item__btn svg {
  width: 15px;
  height: 15px;
}

/* sidebar footer: avatar + New note pill */
.ws-history__foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--hair);
}
.ws-avatar {
  position: relative;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.ws-avatar:hover .ws-avatar__circle,
.ws-avatar[aria-expanded='true'] .ws-avatar__circle {
  box-shadow: 0 0 0 3px var(--accent-soft-2);
}
.ws-avatar:focus-visible {
  border-radius: 50%;
}
.ws-avatar__circle {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft-2);
  color: var(--accent-deep);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  transition: box-shadow var(--t-fast) linear;
}
.ws-avatar__circle--lg {
  width: 44px;
  height: 44px;
  font-size: 16px;
}
.ws-pill {
  flex: 1 1 auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-pill);
  /* paint: the .btn-primary recipe (base.css) */
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
}
.ws-pill:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* account menu: popover above the avatar (placed by app.js); a bottom sheet on phones */
.ws-account-scrim {
  position: fixed;
  inset: 0;
  z-index: 118;
  background: transparent;
}
.ws-account-scrim[hidden],
.ws-account[hidden] {
  display: none;
}
.ws-account {
  position: fixed;
  z-index: 120;
  width: 256px;
  padding: 6px;
  border: 1px solid var(--hair-2);
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--lift-4), var(--lift-2);
  animation: wsMenuIn 140ms var(--ease-out);
}
@keyframes wsMenuIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}
.ws-account__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--hair);
}
.ws-account__who {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-account__who strong {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-account__who span {
  font-size: 12.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-account__menu {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ws-account__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.ws-account__item svg {
  color: var(--ink-2);
  flex-shrink: 0;
}
.ws-account__item:hover,
.ws-account__item:focus {
  background: var(--hair);
}
.ws-account__item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 10px;
}
.ws-account__item:disabled {
  opacity: 0.6;
  cursor: wait;
}
.ws-account__sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--hair);
}
@media (prefers-reduced-motion: reduce) {
  .ws-account {
    animation: none;
  }
}

.ws-history-backdrop {
  display: none;
}

/* ─────────────────────────────────────────────  sources list (the Sources panel itself: ios.css, workspace panels)  */
.ws-sources {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ws-src {
  display: grid;
  grid-template-columns: 15px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hair);
  background: #fff;
  transition: border-color var(--t-fast) linear, box-shadow var(--t-mid) var(--ease-out);
  animation: srcIn 420ms var(--ease-out);
}
@keyframes srcIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.ws-src:hover {
  border-color: var(--hair-2);
  box-shadow: var(--lift-1);
}
.ws-src--error {
  border-color: rgba(173, 95, 74, 0.35);
  background: rgba(173, 95, 74, 0.04);
}
.ws-src__icon {
  width: 15px;
  height: 15px;
  color: var(--ink-4);
}
.ws-src__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ws-src__name {
  font-size: 12.5px;
  letter-spacing: -0.012em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ws-src__status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ws-src--error .ws-src__status {
  color: var(--clay);
}
.ws-src__bar {
  height: 2px;
  border-radius: 99px;
  background: var(--hair);
  overflow: hidden;
  margin-top: 5px;
}
.ws-src__bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  width: 0%;
  transition: width 400ms var(--ease-out);
}
.ws-src__bar--indet i {
  width: 40%;
  animation: indet 1.4s var(--ease-io) infinite;
}
@keyframes indet {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(260%);
  }
}
.ws-src__x {
  width: 22px;
  height: 22px;
  border-radius: 99px;
  border: 0;
  background: none;
  color: var(--ink-3);
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-fast) linear, background var(--t-fast) linear, color var(--t-fast) linear;
}
.ws-src:hover .ws-src__x,
.ws-src__x:focus-visible {
  opacity: 1;
}
@media (hover: none) {
  .ws-src__x {
    opacity: 1;
  }
}
.ws-src__x:hover {
  background: rgba(173, 95, 74, 0.1);
  color: var(--clay);
}
.ws-src__x svg {
  width: 11px;
  height: 11px;
}

.ws-empty-note {
  padding: 14px 12px;
  border-radius: var(--r-sm);
  border: 1px dashed var(--hair-2);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-3);
  text-align: center;
}

/* add source */
.ws-add {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
}
.seg {
  display: flex;
  padding: 3px;
  border-radius: var(--r-pill);
  background: rgba(11, 13, 18, 0.045);
  border: 1px solid var(--hair);
}
.seg button {
  flex: 1;
  padding: 6px 4px;
  border: 0;
  border-radius: var(--r-pill);
  background: none;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out), color var(--t-fast) linear, box-shadow var(--t-fast) linear;
  white-space: nowrap;
}
.seg button[aria-selected='true'] {
  background: #fff;
  color: var(--ink);
  box-shadow: var(--lift-1);
}
.seg-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
}
.seg-panel[data-on] {
  display: flex;
  animation: fadeIn 220ms linear;
}
.mini-drop {
  border: 1px dashed var(--hair-2);
  border-radius: var(--r-sm);
  padding: 18px 12px;
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
  cursor: pointer;
  background: none;
  width: 100%;
  transition: border-color var(--t-fast) linear, background var(--t-fast) linear, color var(--t-fast) linear;
}
.mini-drop:hover,
.mini-drop.is-over {
  border-color: var(--accent-hair);
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.ws-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--r-xs);
  border: 1px solid var(--hair-2);
  background: #fff;
  font-size: 12.5px;
  outline: none;
  transition: border-color var(--t-fast) linear, box-shadow var(--t-fast) linear;
}
.ws-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* script-focused landing spots (skip link target, headings) need no ring */
.ws-main:focus,
h1[tabindex='-1']:focus,
h2[tabindex='-1']:focus,
h3[tabindex='-1']:focus {
  outline: none;
}
.ws-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.ws-input::placeholder {
  color: var(--ink-3);
}
textarea.ws-input {
  resize: vertical;
  min-height: 74px;
  line-height: 1.5;
  font-family: inherit;
}
.ws-add__submit {
  width: 100%;
  justify-content: center;
  padding: 10px;
  font-size: 12.5px;
}
.field-err {
  font-size: 10.5px;
  color: var(--clay);
  min-height: 14px;
}

.ws-generate {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--hair);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ws-generate .btn {
  width: 100%;
  justify-content: center;
}
.ws-generate small {
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.45;
}
/* pulse on the mark while generating */
.gen-mark {
  width: 15px;
  height: 15px;
  color: currentColor;
}
.btn.is-busy .gen-mark {
  animation: markPulse 1.5s var(--ease-io) infinite;
}
@keyframes markPulse {
  0%,
  100% {
    opacity: 0.4;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
}

/* ─────────────────────────────────────────────  main  */
.ws-main {
  flex: 1 1 0%;
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - 57px);
}

.ws-panels {
  flex: 1;
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.ws-panel {
  display: none;
  padding: clamp(20px, 3vw, 40px) clamp(16px, 2.5vw, 36px) 72px;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}
.ws-panel[data-on] {
  display: flex;
  flex-direction: column;
  animation: panelIn 220ms var(--ease-out);
}
.ws-panel--map {
  padding: 14px clamp(14px, 2vw, 24px) 20px;
}
.ws-panel--map[data-on] {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: calc(100svh - 110px);
  min-height: 540px;
  padding: 14px clamp(14px, 2vw, 24px) 20px;
  box-sizing: border-box;
}
#panel-chat[data-on],
.ws-panel:has(.ch-wrap)[data-on] {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: calc(100svh - 110px);
  min-height: 520px;
  padding: 14px clamp(14px, 2vw, 24px) 20px;
  box-sizing: border-box;
}
@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* ── empty state */
.ws-zero {
  min-height: calc(100svh - 210px);
  display: grid;
  place-items: center;
  padding: 40px 0;
}
.ws-zero__inner {
  position: relative;
  width: min(100%, 620px);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.bigdrop {
  width: 100%;
  padding: clamp(40px, 7vw, 76px) clamp(20px, 4vw, 44px);
  border-radius: 22px;
  border: 1px dashed var(--hair-2);
  background: rgba(255, 255, 255, 0.55);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  transition: border-color var(--t-mid) linear, background var(--t-mid) linear, transform var(--t-mid) var(--ease-out);
}
.bigdrop.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.008);
}
.bigdrop .mark {
  width: 46px;
  height: 46px;
  opacity: 0.9;
}
.bigdrop h3 {
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  font-weight: 500;
  letter-spacing: -0.03em;
}
.bigdrop p {
  font-size: var(--fs-sm);
  color: var(--ink-3);
  max-width: 40ch;
}
.bigdrop__acts {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
.ws-zero__hint {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

/* ── empty session: greeting, quick starts, recent notes */
#ws-zero .ws-zero {
  padding: 4px 0 24px;
}
#ws-zero .ws-zero__inner {
  gap: 18px;
}
.ws-greet {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  max-width: 100%;
  margin-bottom: 4px;
}
.ws-greet__mark {
  flex: none;
  width: 34px;
  height: 34px;
}
.ws-greet__h {
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(2rem, 3.4vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: anywhere;
  /* greet.js sets the line before first paint; without it the server's line shows after a moment */
  visibility: hidden;
  animation: wsGreetShow 0s linear 1.2s forwards;
}
.ws-greet__h:is(:lang(hi), :lang(mr)) {
  line-height: 1.35;
  font-weight: 500;
}
.ws-greet__h.is-greeted {
  visibility: visible;
  animation: wsGreetIn 620ms var(--ease-out) both;
}
@keyframes wsGreetShow {
  to {
    visibility: visible;
  }
}
@keyframes wsGreetIn {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ws-greet__h.is-greeted {
    animation: none;
  }
}
html.lite .ws-greet__h.is-greeted {
  animation: none;
}
/* phones only: the session status under the greeting (desktop shows it in the top bar) */
.ws-greet__sub {
  display: none;
}
#ws-zero .bigdrop {
  padding: clamp(26px, 3.6vw, 40px) clamp(20px, 4vw, 44px);
  gap: 12px;
}
.bigdrop__ic {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.ws-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.ws-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--hair-2);
  background: var(--paper);
  color: var(--ink-2);
  font: 500 var(--fs-sm) / 1.25 var(--font-sans);
  cursor: pointer;
  transition: border-color var(--t-mid) linear, color var(--t-mid) linear, background var(--t-mid) linear;
}
.ws-chip .ic {
  flex: none;
  color: var(--ink-3);
}
.ws-chip:hover {
  border-color: var(--hair-3);
  background: var(--canvas-2);
  color: var(--ink);
}
.ws-resume {
  width: 100%;
  text-align: start;
}
.ws-resume__h {
  margin: 0 0 8px 4px;
  font: 600 13px / 18px var(--font-sans);
  letter-spacing: 0;
  color: var(--ink-3);
}
.ws-resume__list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--hair);
  border-radius: 16px;
  background: var(--paper);
  overflow: hidden;
}
.ws-resume__list li + li {
  border-top: 1px solid var(--hair);
}
.ws-resume__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: start;
  cursor: pointer;
  transition: background var(--t-mid) linear;
}
.ws-resume__item:hover {
  background: var(--canvas-2);
}
.ws-resume__item:focus-visible {
  outline-offset: -3px;
}
.ws-resume__t {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.ws-resume__when {
  flex: none;
  color: var(--ink-3);
}
.ws-resume__ic,
.ws-resume__chev {
  flex: none;
  color: var(--ink-3);
}

/* ── processing state */
.ws-working {
  width: min(100%, 620px);
  margin: clamp(30px, 6vw, 70px) auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.ws-working .mark {
  width: 44px;
  height: 44px;
}
.ws-working .mark .ring {
  transform-origin: 16px 16px;
  animation: spin 3.4s linear infinite;
}
.ws-working h3 {
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.028em;
}
.ws-working p {
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.ws-working .track {
  width: 100%;
  max-width: 380px;
  height: 1px;
  background: var(--hair-2);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.ws-working .track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: translateX(-100%);
  animation: travel 1.9s var(--ease-io) infinite;
}
.ws-log {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  min-height: 16px;
  text-transform: uppercase;
}

/* brief job progress + failure (with Retry) */
.ws-progress {
  width: 100%;
  max-width: 380px;
  height: 4px;
  appearance: none;
  border: 0;
  border-radius: 99px;
  background: var(--hair-2);
  overflow: hidden;
}
.ws-progress::-webkit-progress-bar { background: var(--hair-2); border-radius: 99px; }
.ws-progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; transition: width .4s var(--ease-io); }
.ws-progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.ws-progress[hidden], .ws-fail[hidden] { display: none; }
.ws-fail { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.ws-working .ws-fail__msg { color: var(--ink); font-size: var(--fs-body); }
.ws-fail__acts { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#ws-working.is-failed .track, #ws-working.is-failed .mark .ring { display: none; }

/* ── brief doc in workspace */
.doc-layout {
  display: grid;
  grid-template-columns: 1fr minmax(0, 210px);
  gap: clamp(24px, 3.2vw, 48px);
  align-items: start;
  max-width: min(100%, 1260px);
  margin-inline: auto;
  width: 100%;
}
.doc-toc {
  position: sticky;
  top: 128px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-left: 14px;
  border-left: 1px solid var(--hair);
}
.doc-toc h3 {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
  margin-bottom: 7px;
}
.doc-toc a {
  font-size: 11.5px;
  color: var(--ink-3);
  padding: 4px 0;
  transition: color var(--t-fast) linear, transform var(--t-fast) var(--ease-out);
  line-height: 1.35;
}
.doc-toc a:hover {
  color: var(--ink);
  transform: translateX(2px);
}
.doc-toc a.on {
  color: var(--accent-deep);
}
@media (max-width: 900px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }
  .doc-toc {
    position: static;
    order: -1;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    border-left: 0;
    padding-left: 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--hair);
  }
  .doc-toc h3 {
    width: 100%;
    margin: 0;
  }
}

/* ── generated asset controls */
.asset-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 2px;
}
.asset-head--end {
  margin-bottom: 18px;
}
.qz-done__h {
  font-size: clamp(1.7rem, 3vw, 2.2rem);
  line-height: 1.1;
  color: var(--ink);
}
.asset-label {
  color: var(--ink-3);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.regen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  background: rgba(255,255,255,.72);
  color: var(--ink-3);
  padding: 7px 12px;
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.regen-btn:hover:not(:disabled) {
  color: var(--accent-deep);
  border-color: var(--accent-hair);
  background: var(--accent-soft);
}
.regen-btn:disabled {
  opacity: .5;
  cursor: wait;
}

/* ── flashcards panel */
.fc-wrap {
  max-width: min(100%, 860px);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}
.fc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fc-progress {
  height: 2px;
  background: var(--hair);
  border-radius: 99px;
  overflow: hidden;
}
.fc-progress i {
  display: block;
  height: 100%;
  background: var(--ink);
  border-radius: 99px;
  transition: width 380ms var(--ease-out);
}
.fc-stage {
  perspective: 1600px;
  height: clamp(300px, 42vh, 460px);
  width: 100%;
}
.fc-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.34, 1.4, 0.5, 1);
  cursor: pointer;
  border: 0;
  padding: 0;
  background: none;
  display: block;
  border-radius: var(--r-lg);
}
.fc-card[data-flipped='true'] {
  transform: rotateY(180deg);
}
.fc-face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--hair-2);
  background: #fff;
  box-shadow: var(--lift-3);
  padding: clamp(22px, 3vw, 34px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
  gap: 16px;
}
.fc-face--back {
  transform: rotateY(180deg);
  background: var(--dark);
  border-color: #000;
  color: #fff;
}
.fc-face p {
  font-size: clamp(1rem, 1.7vw, 1.3rem);
  line-height: 1.4;
  letter-spacing: -0.024em;
  font-weight: 500;
}
.fc-face--back p {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.92);
  font-size: clamp(0.95rem, 1.5vw, 1.125rem);
  line-height: 1.55;
}
.fc-face__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.fc-face--back .fc-face__foot {
  color: rgba(255, 255, 255, 0.4);
}
.fc-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hair-2);
  background: rgba(255, 255, 255, 0.6);
  font-size: var(--fs-sm);
  color: var(--ink-2);
  cursor: pointer;
  transition: color var(--t-fast) linear, border-color var(--t-fast) linear, background var(--t-fast) linear,
    transform var(--t-fast) var(--ease-out);
}
.ghost-btn:hover:not([disabled]) {
  color: var(--ink);
  border-color: var(--hair-3);
  background: #fff;
  transform: translateY(-1px);
}
.ghost-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}
.ghost-btn svg {
  width: 13px;
  height: 13px;
}
.hint-row {
  text-align: center;
  font-size: 11.5px;
  color: var(--ink-3);
}
kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  padding: 2px 5px;
  border: 1px solid var(--hair-2);
  border-radius: 5px;
  background: #fff;
  color: var(--ink-3);
}

/* ── quiz panel */
.qz-wrap {
  max-width: min(100%, 860px);
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}
.qz-card {
  border-radius: var(--r-lg);
  border: 1px solid var(--hair-2);
  background: #fff;
  box-shadow: var(--lift-3);
  padding: clamp(22px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.qz-card h3 {
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  font-weight: 500;
  letter-spacing: -0.024em;
  line-height: 1.35;
}
.qz-opts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qz-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 15px;
  border-radius: var(--r-sm);
  border: 1px solid var(--hair);
  background: rgba(250, 251, 253, 0.8);
  font-size: var(--fs-body);
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast) linear, background var(--t-fast) linear, color var(--t-fast) linear,
    transform var(--t-fast) var(--ease-out);
}
.qz-opt:hover:not([disabled]):not([aria-disabled='true']) {
  border-color: var(--hair-3);
  background: #fff;
  transform: translateX(3px);
}
.qz-opt i {
  width: 20px;
  height: 20px;
  border-radius: 99px;
  border: 1px solid var(--hair-2);
  display: grid;
  place-items: center;
  font-style: normal;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  flex: none;
}
.qz-opt[data-state='right'] {
  border-color: rgba(94, 122, 99, 0.5);
  background: rgba(94, 122, 99, 0.08);
  color: #4f6a54;
}
.qz-opt[data-state='right'] i {
  border-color: rgba(94, 122, 99, 0.5);
  color: #4f6a54;
}
.qz-opt[data-state='wrong'] {
  border-color: rgba(173, 95, 74, 0.45);
  background: rgba(173, 95, 74, 0.07);
  color: #9a4f3b;
}
.qz-opt[data-state='wrong'] i {
  border-color: rgba(173, 95, 74, 0.5);
  color: #9a4f3b;
}
.qz-opt[disabled],
.qz-opt[aria-disabled='true'] {
  cursor: default;
}
/* right / wrong is spelled out in text, not only colour */
.qz-mark {
  margin-left: auto;
  flex: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
}
.qz-fb {
  font-size: var(--fs-sm);
  color: var(--ink-2);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: rgba(11, 13, 18, 0.035);
  border: 1px solid var(--hair);
  display: none;
}
.qz-fb.on {
  display: block;
  animation: fadeIn 240ms linear;
}
.qz-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.qz-score {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.qz-done {
  text-align: center;
  padding: 30px 20px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.qz-done.on {
  display: flex;
}
.qz-done .mark {
  width: 34px;
  height: 34px;
}

/* ── report panel */
.rp-wrap {
  max-width: min(100%, 1080px);
  margin-inline: auto;
  width: 100%;
}
.rp-doc {
  background: #fff;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-lg);
  box-shadow: var(--lift-3);
  padding: clamp(26px, 4vw, 56px);
}
.rp-doc header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hair);
  margin-bottom: 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.rp-doc h2 {
  font-size: clamp(1.35rem, 2.6vw, 1.9rem);
  font-weight: 500;
  letter-spacing: -0.032em;
  line-height: 1.12;
  max-width: 26ch;
}
.rp-doc h2 em {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
}
.rp-body {
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.rp-body h3 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-bottom: 9px;
}
.rp-body p {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--ink-2);
}
.rp-body p + p {
  margin-top: 12px;
}
.rp-body strong {
  color: var(--ink);
  font-weight: 500;
}
.rp-body ul {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 10px;
}
.rp-body li {
  display: flex;
  gap: 11px;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-2);
}
.rp-body li::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 99px;
  background: var(--ink-4);
  margin-top: 10px;
  flex: none;
}
.rp-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 10px;
}
.rp-body th,
.rp-body td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--hair);
  color: var(--ink-2);
}
.rp-body th {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 400;
}
.rp-body td:first-child {
  color: var(--ink);
  font-weight: 500;
}

/* ── mind map panel */
.mm-wrap {
  width: 100%;
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  margin: 0;
}
.mm-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.mm-frame {
  position: relative;
  border-radius: var(--r-lg);
  border: 1px solid var(--hair-2);
  background: linear-gradient(to bottom right, #fff, rgba(240, 243, 248, 0.7));
  box-shadow: var(--lift-3);
  /* a pan/zoom canvas (app.js mapWire): no scrollbars; touch gestures belong to the map only here */
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: clamp(420px, 68vh, 880px);
  max-height: none;
  cursor: grab;
}
.mm-frame.is-drag,
.mm-frame.is-drag .map-card {
  cursor: grabbing;
}
.mm-frame:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* the dots move and scale with the map (app.js sets the vars) */
.mm-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(11, 13, 18, 0.075) 1px, transparent 1px);
  background-size: var(--mm-g, 22px) var(--mm-g, 22px);
  background-position: var(--mm-gx, 0) var(--mm-gy, 0);
  pointer-events: none;
}
.mm-canvas {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
}
.mm-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 1;
  margin: 0;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  background: rgba(11, 13, 18, 0.78);
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
.mm-hint.is-on {
  opacity: 1;
  transform: translate(-50%, 0);
}
.mm-actions > .mm-pct {
  min-width: 54px;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.mm-actions > button[disabled] {
  opacity: 0.45;
  cursor: default;
}
.mm-frame svg {
  display: block;
  overflow: visible;
}
.mm-legend {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ink-3);
}
.mm-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mm-actions > button:not(.regen-btn) {
  min-width: 32px;
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--ink-2);
  cursor: pointer;
}
.map-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 8px 12px;
  border: 1px solid var(--hair-2);
  border-radius: 11px;
  background: #fff;
  /* no outer shadow: the foreignObject would clip it into a hard white edge */
  box-shadow: none;
  color: var(--ink-2);
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast), background-color var(--t-fast);
}
/* long titles wrap to 2 lines instead of cutting off after a few words */
.map-card strong {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  line-height: 1.25;
  font-size: 12px;
  font-weight: 500;
  color: inherit;
}
.map-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  color: var(--ink-3);
}
.map-card--root {
  border-color: var(--dark);
  background: var(--dark);
  color: #fff;
}
/* Each card fills its SVG foreignObject exactly, and Chrome clips anything drawn outside it
   (outer shadows, rings, lifts). So hover/focus stays inside the box. */
.map-card:hover,
.map-card.is-pinned,
.map-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 45%, #fff);
}
.map-card--root:hover,
.map-card--root.is-pinned,
.map-card--root:focus-visible {
  background: var(--dark);
  box-shadow: inset 0 0 0 2px var(--accent);
}
/* other branches step back but stay readable */
.map-card.dim {
  opacity: .6;
  box-shadow: none;
}
.mm-frame .map-edge {
  stroke-dasharray: none;
  stroke-dashoffset: 0;
}
/* the key fact under the title: two lines, the rest shows when the node is pinned */
.map-card .map-card__note {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  white-space: normal;
  line-height: 1.3;
  font-size: 10px;
}
.map-card--root .map-card__note {
  color: rgba(255, 255, 255, 0.72);
}
.map-card.is-linked {
  border-color: var(--accent-hair);
}
/* relationship words on the lines and cross-link labels: small, quiet, with a halo so crossing lines don't cut them */
.mm-frame {
  --mm-halo: #fbfcfd;
}
.map-rel,
.map-xl__t {
  font-size: 10.5px;
  fill: var(--ink-3);
  paint-order: stroke;
  stroke: var(--mm-halo);
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: fill var(--t-fast) linear, opacity var(--t-fast) linear;
}
.map-rel.hot,
.map-xl__t.hot {
  fill: var(--accent-deep);
}
.map-xl {
  fill: none;
  stroke: var(--hair-3);
  stroke-width: 1.1;
  stroke-dasharray: 4 4;
  transition: stroke var(--t-fast) linear, opacity var(--t-fast) linear;
}
.map-xl.hot {
  stroke: var(--accent);
  stroke-width: 1.4;
  marker-end: url(#mm-arr-hot);
}
.map-arr {
  fill: var(--hair-3);
}
.map-arr--hot {
  fill: var(--accent);
}
/* a cross-link label that would sit on a card shows only while its link is lit */
.map-xl__t.is-tucked:not(.hot) {
  opacity: 0;
}
.mm-frame.has-on :is(.map-xl, .map-xl__t):not(.hot) {
  opacity: 0.3;
}
.mm-frame.has-on .map-rel:not(.hot) {
  opacity: 0.5;
}
.mm-frame.is-far :is(.map-rel, .map-xl__t) {
  opacity: 0;
}
/* the pinned node's detail card, over the canvas */
.mm-detail {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 2;
  box-sizing: border-box;
  width: min(340px, calc(100% - 24px));
  max-height: min(62%, 380px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 44px 14px 16px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-card);
  background: var(--paper);
  box-shadow: var(--lift-3);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
  cursor: auto;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}
.mm-detail[hidden] {
  display: none;
}
.mm-detail__kick {
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--ink-3);
}
.mm-detail__t {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
}
.mm-detail__t + .mm-detail__kick {
  margin: 2px 0 0;
}
.mm-detail__note {
  margin: 8px 0 0;
}
.mm-detail__src {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-3);
}
.mm-detail__src .cite-mks {
  margin-left: 2px;
}
.mm-detail__h {
  margin: 12px 0 4px;
  font-size: 12px;
  color: var(--ink-3);
}
.mm-detail__links {
  list-style: none;
  margin: 0 -8px;
  padding: 0;
}
.mm-detail__links button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 5px 8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}
.mm-detail__links button:hover,
.mm-detail__links button:focus-visible {
  background: var(--accent-soft);
  outline: none;
}
.mm-detail__links strong {
  font-weight: 500;
  color: var(--ink);
}
.mm-detail__go {
  flex: none;
  color: var(--ink-4);
}
.mm-detail__links button:hover .mm-detail__go {
  color: var(--accent);
}
@media (pointer: coarse) {
  .mm-detail .mm-detail__links button {
    min-height: 40px;
  }
  .mm-detail .mm-detail__x {
    width: 36px;
    height: 36px;
    top: 4px;
    right: 4px;
  }
}
.mm-detail__x {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
}
.mm-detail__x:hover {
  background: var(--accent-soft);
  color: var(--ink);
}
.mm-detail__x:focus-visible,
.mm-detail__links button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
@media (max-width: 560px) {
  .mm-detail {
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 55%;
  }
}

/* ── chat panel */
.ch-wrap {
  max-width: min(100%, 880px);
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  flex: 1;
  min-height: 0;
}
.ch-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 8px;
  overflow-y: auto;
  min-height: 0;
}
.ch-msg {
  max-width: 86%;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: var(--fs-body);
  line-height: 1.6;
  animation: msgIn 320ms var(--ease-out);
  word-break: break-word;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}
.ch-msg--me {
  align-self: flex-end;
  background: var(--dark);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.ch-msg--ai {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--hair);
  color: var(--ink-2);
  border-bottom-left-radius: 6px;
  box-shadow: var(--lift-1);
}
.ch-msg--ai b,
.ch-msg--ai strong {
  color: var(--ink);
  font-weight: 500;
}
.ch-msg--ai p {
  margin: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ch-msg--ai p + p {
  margin-top: 10px;
}
.ch-cites {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
/* chips that follow the last paragraph inline; a long source name may wrap */
.ch-cites .cite-chip {
  margin-left: 0;
  line-height: 1.5;
}
.ch-msg .cite-chip {
  white-space: normal;
  overflow-wrap: anywhere;
}
.ch-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--hair);
  background: #fff;
}
.ch-typing i {
  width: 5px;
  height: 5px;
  border-radius: 99px;
  background: var(--ink-4);
  animation: typing 1.1s var(--ease-io) infinite;
}
.ch-typing i:nth-child(2) {
  animation-delay: 150ms;
}
.ch-typing i:nth-child(3) {
  animation-delay: 300ms;
}
@keyframes typing {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-2px);
  }
}
.ch-form {
  position: sticky;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 7px 7px 17px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hair-2);
  background: rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: var(--lift-3);
}
.ch-form:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ch-form input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font-size: var(--fs-body);
  min-width: 0;
}
.ch-form input::placeholder {
  color: var(--ink-3);
}
.ch-form .icon-btn {
  width: 34px;
  height: 34px;
}
.ch-sug {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.ch-sug button {
  padding: 7px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--hair);
  background: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color var(--t-fast) linear, color var(--t-fast) linear, background var(--t-fast) linear;
}
.ch-sug button:hover {
  border-color: var(--accent-hair);
  color: var(--accent-deep);
  background: var(--accent-soft);
}

/* ─────────────────────────────────────────────  toast  */
.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: min(92vw, 440px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-card);
  background: rgba(11, 13, 18, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #fff;
  font-size: var(--fs-sm);
  line-height: 1.45;
  box-shadow: var(--lift-4);
  animation: toastIn 320ms var(--ease-out);
  max-width: 100%;
}
.toast.out {
  animation: toastOut 260ms var(--ease-in) forwards;
}
.toast svg {
  width: 14px;
  height: 14px;
  flex: none;
  margin-top: 2px;
}
.toast--warn svg {
  color: var(--amber);
}
.toast--err svg {
  color: #e0866c;
}
.toast--ok svg {
  color: #8fb396;
}
@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
}
@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

/* ─────────────────────────────────────────────  responsive  */
@media (max-width: 900px) {
  .ws-body {
    overflow: visible;
  }
  .ws-history {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    height: 100svh;
    max-height: 100svh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.28);
    border-right: 0;
    margin-left: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }
  .ws-body.sidebar-open .ws-history {
    transform: translateX(0);
  }
  .ws-history-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 95;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .ws-body.sidebar-open .ws-history-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  /* drawer layout: menu icon, title only (status line hidden) */
  .ws-ic--desk {
    display: none;
  }
  .ws-ic--mob {
    display: block;
  }
  .ws-top__session span {
    display: none;
  }
  .asset-head,
  .mm-bar {
    align-items: flex-start;
  }
}
@media (max-width: 560px) {
  .asset-head,
  .mm-bar {
    flex-direction: column;
  }
  .mm-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .mm-actions .regen-btn {
    margin-left: auto;
  }
}

/* ─────────────────────────────────────────────  404  */
.nf {
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px;
  position: relative;
  overflow: hidden;
}
.nf__inner {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.nf .mark {
  width: 52px;
  height: 52px;
}
.nf h1 {
  font-size: clamp(1.4rem, 3.4vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -0.032em;
}
.nf p {
  color: var(--ink-2);
  max-width: 34ch;
}
.nf code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
}

/* ─────────────────────────────────────────────  accessibility entry + listen buttons  */
.asset-acts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--accent-hair);
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) linear, border-color var(--t-fast) linear;
}
.listen-btn:hover {
  background: var(--accent-soft-2);
  border-color: var(--accent);
}
.listen-btn svg {
  width: 14px;
  height: 14px;
  flex: none;
}
.listen-btn[aria-pressed='true'] {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  color: #fff;
}
.brief-doc__meta .listen-btn {
  margin-left: auto;
}
/* no speech engine in this browser: hide the buttons (a11y.js sets the class) */
html:not(.a11y-tts) .listen-btn {
  display: none;
}

/* ─────────────────────────────────────────────  mind map view toggle + outline  */
.map-card {
  cursor: pointer;
}
.mm-view {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-pill);
  background: var(--paper);
  margin-right: 4px;
}
.mm-actions > .mm-view > button {
  height: 26px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  cursor: pointer;
}
.mm-view > button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--paper);
}
.mm-outline {
  flex: 1;
  overflow: auto;
  padding: 20px 24px;
  border: 1px solid var(--hair-2);
  border-radius: var(--r-lg);
  background: var(--paper);
  box-shadow: var(--lift-3);
}
.mm-ol,
.mm-ol ul {
  list-style: disc;
  padding-left: 1.3em;
}
.mm-ol ul {
  list-style: circle;
  margin-top: 4px;
}
.mm-ol li {
  margin: 4px 0;
  line-height: 1.5;
}
.mm-ol > li > strong {
  font-size: 1.05em;
}
.mm-ol strong {
  font-weight: 500;
  color: var(--ink);
}
.mm-ol__rel {
  color: var(--ink-3);
  font-size: 0.92em;
}
.mm-ol__line {
  margin: 0;
}
.mm-ol__note {
  margin: 1px 0 0;
  max-width: 68ch;
  font-size: 0.92em;
  color: var(--ink-2);
}
.mm-ol__h {
  margin: 22px 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.mm-ol__links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mm-ol__links li {
  margin: 4px 0;
  line-height: 1.5;
}
.mm-ol__links strong {
  font-weight: 500;
  color: var(--ink);
}

/* narrow phones: tighter top bar */
@media (max-width: 480px) {
  .ws-top {
    gap: 6px;
    padding: 0 6px;
  }
  .ws-top__right {
    gap: 0;
  }
}
/* the closed history drawer's shadow peeked in at the left edge */
@media (max-width: 900px) {
  .ws-body:not(.sidebar-open) .ws-history {
    box-shadow: none;
  }
}

/* phones: the account menu becomes a bottom sheet */
@media (max-width: 599px) {
  .ws-account-scrim {
    background: rgba(11, 13, 18, 0.42);
  }
  .ws-account {
    left: 0 !important;
    right: 0;
    bottom: 0 !important;
    top: auto !important;
    width: auto;
    max-height: 88svh;
    overflow-y: auto;
    padding: 10px 12px calc(16px + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: 22px 22px 0 0;
    animation-name: wsSheetIn;
    animation-duration: 220ms;
  }
  .ws-account::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto 10px;
    border-radius: 2px;
    background: var(--hair-2);
  }
  .ws-account__head {
    flex-direction: column;
    text-align: center;
    gap: 10px;
    padding: 8px 8px 16px;
    margin-bottom: 8px;
  }
  .ws-account__who {
    align-items: center;
    max-width: 100%;
  }
  .ws-account__who strong {
    font-size: 17px;
  }
  .ws-account__who span {
    font-size: 14px;
  }
  .ws-account__head .ws-avatar__circle--lg {
    width: 64px;
    height: 64px;
    font-size: 22px;
  }
  .ws-account__item {
    min-height: 52px;
    font-size: 15px;
    border-radius: 12px;
  }
}
@keyframes wsSheetIn {
  from {
    transform: translateY(100%);
  }
}

/* account menu: language item + its list */
.ws-account__item--lang .ws-account__val {
  margin-left: auto;
  color: var(--ink-2);
  font-size: 13px;
}
.ws-account__chev {
  transition: transform 160ms ease;
}
.ws-account__item--lang[aria-expanded='true'] .ws-account__chev {
  transform: rotate(180deg);
}
.ws-account__langs {
  margin: 0 0 4px 30px;
  padding-left: 8px;
  border-left: 1px solid var(--hair-2);
}
.ws-account__langs[hidden] {
  display: none;
}
.ws-account__langs .lang-opt {
  min-height: 38px;
}
@media (max-width: 599px) {
  .ws-account__langs .lang-opt {
    min-height: 48px;
    font-size: 15px;
  }
}
/* "This brief is in English · Regenerate in हिन्दी" */
.brief-lang {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 14px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--accent-hair);
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.5;
}
.brief-lang__btn {
  min-height: 34px;
}

/* ── Generation progress ("thinking" card): app.js genStart(). Header, steps, preview skeleton, tip.
   Continuous motion (shimmer, spin, fan, sweep) only runs when motion is allowed: see the block
   near the end, scoped to prefers-reduced-motion: no-preference and not the a11y "Pause animations"
   or focus mode. Entrance animations are one-shot; the global reduced-motion rules flatten them. */
.gen-host {
  width: 100%;
}
.gen {
  width: min(100%, 560px);
  margin: clamp(20px, 5vw, 56px) auto;
  padding: 22px 22px 18px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: start;
  border: 1px solid var(--hair);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--lift-3);
  animation: genIn 0.45s var(--ease-out) both;
}
.gen.is-out {
  opacity: 0;
  transform: translateY(-4px) scale(0.99);
  transition: opacity 0.2s var(--ease-in), transform 0.2s var(--ease-in);
}
.gen__top {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.gen__emo {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 15px;
  background: var(--canvas-2);
}
.gen__emo .emo {
  width: 32px;
  height: 32px;
}
.gen__hd {
  min-width: 0;
}
.gen__h {
  margin: 0;
  font: var(--ios-headline);
  letter-spacing: var(--track-title);
  color: var(--ink);
}
.gen__h:focus {
  outline: none;
}
.gen__h:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.gen__status,
.gen-inline {
  display: flex;
  align-items: center;
  gap: 7px;
  font: 500 13px/18px var(--font-sans);
  color: var(--ink-2);
}
.gen__status {
  margin: 3px 0 0;
}
.gen__mark .mark {
  width: 18px;
  height: 18px;
}
.gen__mark .mark .ring {
  transform-origin: 16px 16px;
}
.gen__time {
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.gen[data-state='done'] .gen__label {
  color: var(--ink);
  font-weight: 600;
}
.gen[data-state='failed'] .gen__label {
  color: var(--clay);
  font-weight: 600;
}

/* steps: todo (ring) → active (spinning arc) → done (✓, small spring); fail (!) */
.gen__steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.gen-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 6px 0;
  font: 400 15px/21px var(--font-sans);
  letter-spacing: var(--track-body);
  color: var(--ink-3);
  transition: color 0.25s linear;
}
.gen-step__ic {
  position: relative;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1.5px;
  box-sizing: border-box;
  border: 1.5px solid var(--hair-3);
  border-radius: 50%;
}
.gen-step__b {
  flex: 1;
  min-width: 0;
}
.gen-step__d {
  display: block;
  overflow: hidden;
  margin-top: 1px;
  font: 400 13px/18px var(--font-sans);
  color: var(--ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.gen-step__d:empty {
  display: none;
}
.gen-step[data-s='active'] {
  color: var(--ink);
  font-weight: 500;
}
.gen-step[data-s='active'] .gen-step__ic {
  border-color: var(--accent-soft-2);
  border-top-color: var(--accent);
}
.gen-step[data-s='done'] {
  color: var(--ink-2);
}
.gen-step[data-s='done'] .gen-step__ic {
  border-color: transparent;
  background: var(--accent-deep) var(--grad-accent);
  box-shadow: var(--hi-inset), 0 1px 2px rgba(26, 52, 170, 0.25);
  animation: genPop 0.45s var(--spring-bouncy) both;
}
.gen-step[data-s='done'] .gen-step__ic::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2.5px;
  width: 4px;
  height: 7.5px;
  border: solid #fff;
  border-width: 0 1.75px 1.75px 0;
  transform: rotate(45deg);
}
.gen-step[data-s='fail'] {
  color: var(--ink);
}
.gen-step[data-s='fail'] .gen-step__ic {
  border-color: var(--clay);
  background: var(--clay);
}
.gen-step[data-s='fail'] .gen-step__ic::after {
  content: '!';
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 700 11px/1 var(--font-sans);
  color: #fff;
}

.gen__slow {
  margin: -4px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--canvas-2);
  font: 400 13px/18px var(--font-sans);
  color: var(--ink-2);
  animation: genIn 0.35s var(--ease-out) both;
}
.gen__slow[hidden],
.gen__fail[hidden] {
  display: none;
}
.gen__fail {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gen__fail-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  font: 400 15px/21px var(--font-sans);
  color: var(--ink);
}
.gen__fail-msg .ic {
  flex: none;
  margin-top: 1.5px;
  color: var(--clay);
}
.gen__note {
  margin: 0;
  font: 400 13px/18px var(--font-sans);
  color: var(--ink-3);
}
.gen__acts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.gen__acts .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.gen[data-state='failed'] :is(.gen__pv, .gen__tip) {
  display: none;
}

/* the tip: one line or two; the height is kept so a change never moves the card */
.gen__tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  font: 400 13px/18px var(--font-sans);
  color: var(--ink-2);
}
.gen__tip-k {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--ink);
}
.gen__tip-t {
  transition: opacity 0.3s linear;
}
.gen__tip-t.is-out {
  opacity: 0;
}

/* preview skeleton, shaped like the result */
.gen__pv {
  position: relative;
  display: grid;
  place-items: center;
  height: 120px;
  padding: 12px 16px;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--hair);
  border-radius: 14px;
  background: color-mix(in srgb, var(--canvas) 55%, var(--paper));
}
.gen__pv::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--paper) 65%, transparent) 50%, transparent 70%);
  transform: translateX(-100%);
  pointer-events: none;
}
.gsk {
  width: 100%;
}
/* :where() keeps this at element specificity so .gsk-pill / .gsk-sec can set flex */
:where(.gsk) i,
:where(.gsk) b {
  display: block;
}
.gsk-l,
.gsk-sec b,
.gsk-pill b,
.gsk-card b {
  height: 7px;
  border-radius: 99px;
  background: var(--hair-2);
}
.gsk .gsk-h {
  height: 10px;
  width: 55%;
  background: var(--hair-3);
}
.gsk--brief {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gsk--brief .gsk-l {
  transform-origin: left center;
  animation: genGrow 0.6s var(--ease-out) both;
  animation-delay: calc(var(--i) * 140ms);
}
.gsk--brief .gsk-l:nth-child(2) { width: 94%; }
.gsk--brief .gsk-l:nth-child(3) { width: 80%; }
.gsk--brief .gsk-sub { width: 36%; margin-top: 4px; background: var(--hair-3); }
.gsk--brief .gsk-l:nth-child(5) { width: 88%; }
.gsk--brief .gsk-l:nth-child(6) { width: 62%; }
.gsk--flash {
  position: relative;
  width: 150px;
  height: 88px;
}
.gsk-card {
  position: absolute;
  inset: 0;
  padding: 18px 16px;
  box-sizing: border-box;
  border: 1px solid var(--hair-2);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--lift-2);
  transform-origin: 50% 110%;
  animation: genIn 0.4s var(--ease-out) both;
  animation-delay: calc(var(--i) * 120ms);
}
.gsk-card:nth-child(1) { --fan: -1; }
.gsk-card:nth-child(2) { --fan: 1; }
.gsk-card:nth-child(3) { --fan: 0; }
.gsk-card b + b {
  width: 64%;
  margin-top: 8px;
}
.gsk--quiz {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.gsk--quiz .gsk-h {
  grid-column: 1 / -1;
  width: 72%;
  margin-bottom: 4px;
  transform-origin: left center;
  animation: genGrow 0.5s var(--ease-out) both;
}
.gsk-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px 0 9px;
  box-sizing: border-box;
  border: 1px solid var(--hair-2);
  border-radius: 99px;
  background: var(--paper);
  animation: genIn 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i) * 110ms);
}
/* radio dot, so the shape reads as an answer choice */
.gsk-pill::before {
  content: '';
  flex: none;
  width: 12px;
  height: 12px;
  box-sizing: border-box;
  border: 1.5px solid var(--hair-3);
  border-radius: 50%;
}
.gsk-pill b {
  width: 58%;
  height: 6px;
}
.gsk--report {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.gsk-sec {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 10px;
  border-left: 2px solid var(--hair-2);
  animation: genIn 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i) * 160ms);
}
.gsk-sec b {
  height: 5px;
}
.gsk-sec .gsk-h {
  width: 38%;
  height: 7px;
}
.gsk-sec b:nth-child(2) { width: 92%; }
.gsk-sec b:nth-child(3) { width: 70%; }
.gsk--map {
  width: 100%;
  max-width: 280px;
  height: 96px;
}
.gsk--map path {
  fill: none;
  stroke: var(--hair-3);
  stroke-width: 1.5;
  stroke-linecap: round;
}
.gsk-node {
  fill: var(--paper);
  stroke: var(--hair-3);
  stroke-width: 1.25;
  transform-box: fill-box;
  transform-origin: center;
}
.gsk-root {
  fill: var(--accent-soft-2);
  stroke: var(--accent);
  stroke-width: 1.5;
  transform-box: fill-box;
  transform-origin: center;
}

/* the real result fades in as the card fades out */
.gen-reveal > * {
  animation: genReveal 0.45s var(--ease-out) both;
}

/* chat: the light, inline form */
.ch-typing.gen-inline {
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
}
.gen-inline .gen__mark .mark {
  width: 16px;
  height: 16px;
}

/* study tools panel: a tool being written */
/* the words sit to the right of the emoji (up to two lines); the ring is a small badge on the emoji's corner */
.ws-tile__gen {
  position: absolute;
  top: 15px;
  right: 10px;
  left: 64px;
  display: flex;
  justify-content: flex-end;
  font: 500 11px/13px var(--font-sans);
  color: var(--ink-2);
  text-align: end;
}
.ws-tile__gen > span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}
.ws-tile__ring {
  position: absolute;
  top: -8px;
  left: -19px;
  width: 13px;
  height: 13px;
  box-sizing: border-box;
  border: 2px solid rgba(var(--tone), 0.25);
  border-top-color: rgb(var(--tone));
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 0 2px var(--paper);
}
.ws-tile.is-gen {
  border-color: rgba(var(--tone), 0.35);
}
.ws-tile.is-gen::before {
  display: none;
}
.ws[data-tools='rail'] .ws-tile__gen {
  top: 3px;
  right: 3px;
  left: auto;
}
.ws[data-tools='rail'] .ws-tile__ring {
  position: static;
}
.ws[data-tools='rail'] .ws-tile__gen > span {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}
.ws-tools__hint.is-gen {
  color: var(--ink-2);
}

@keyframes genIn {
  from { opacity: 0; transform: translateY(6px); }
}
@keyframes genReveal {
  from { opacity: 0; transform: translateY(6px); }
}
@keyframes genGrow {
  from { opacity: 0; transform: scaleX(0.2); }
}
@keyframes genPop {
  0% { transform: scale(0.4); }
  100% { transform: scale(1); }
}
@keyframes genSpin {
  to { transform: rotate(360deg); }
}
@keyframes genShimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}
@keyframes genSweep {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}
@keyframes genBreath {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}
@keyframes genFan {
  0%, 15% { transform: none; }
  55%, 100% { transform: translateX(calc(var(--fan) * 26px)) rotate(calc(var(--fan) * 9deg)); }
}
@keyframes genDraw {
  0% { stroke-dashoffset: 100; opacity: 1; }
  35%, 86% { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes genNode {
  0%, 18% { opacity: 0; transform: scale(0.4); }
  38%, 86% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}
@keyframes genPick {
  0%, 55%, 100% { border-color: var(--hair-2); background: var(--paper); }
  25%, 40% { border-color: var(--accent); background: var(--accent-soft); }
}

/* continuous motion: only when motion is allowed (not reduced, not "Pause animations", not focus mode) */
@media (prefers-reduced-motion: no-preference) {
  html:not(.a11y-motion):not(.a11y-focusmode) :is(.gen[data-state='run'] .gen__label, .gen[data-state='run'] .gen-step[data-s='active'] .gen-step__t, .gen-inline .gen__label) {
    background: linear-gradient(90deg, currentColor 0%, currentColor 38%, var(--accent) 50%, currentColor 62%, currentColor 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: genShimmer 2.2s linear infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) :is(.gen[data-state='run'], .gen-inline) .gen__mark .ring {
    animation: genSpin 2.6s linear infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) :is(.gen[data-state='run'], .gen-inline) .gen__mark .spark {
    transform-box: fill-box;
    transform-origin: center;
    animation: genBreath 1.6s ease-in-out infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen-step[data-s='active'] .gen-step__ic,
  html:not(.a11y-motion):not(.a11y-focusmode) .ws-tile__ring {
    animation: genSpin 0.9s linear infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gen__pv::after {
    animation: genSweep 2.8s ease-in-out infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gsk-card:nth-child(-n + 2) {
    animation: genIn 0.4s var(--ease-out) both, genFan 3.6s var(--ease-io) 0.5s infinite alternate;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gsk--map path {
    stroke-dasharray: 100;
    animation: genDraw 6s var(--ease-out) infinite;
    animation-delay: calc(var(--i) * 0.15s);
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gsk-node {
    animation: genNode 6s var(--ease-out) infinite;
    animation-delay: calc(var(--i) * 0.15s);
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gsk-root {
    animation: genBreath 2.4s ease-in-out infinite;
  }
  html:not(.a11y-motion):not(.a11y-focusmode) .gen[data-state='run'] .gsk-pill:nth-child(4) {
    animation: genIn 0.45s var(--ease-out) both, genPick 4s ease-in-out 1.2s infinite;
  }
}
/* focus mode ("Fewer distractions"): no tips, no preview */
html.a11y-focusmode .gen :is(.gen__tip, .gen__pv) {
  display: none;
}
/* reduced motion: the ✓ just appears */
@media (prefers-reduced-motion: reduce) {
  .gen-step[data-s='done'] .gen-step__ic {
    animation: none;
  }
}
html:is(.a11y-motion, .a11y-focusmode) .gen-step[data-s='done'] .gen-step__ic {
  animation: none;
}
@media (max-width: 599px) {
  .gen {
    margin: 12px auto 20px;
    padding: 18px 16px 14px;
    border-radius: 18px;
    gap: 14px;
  }
  .gen__emo {
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }
  .gen__emo .emo {
    width: 28px;
    height: 28px;
  }
}

/* ── credit in the notes sidebar, above the account row (links to the About section) */
.ws-madeby {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0 12px 2px;
  padding: 6px 8px;
  border-radius: 8px;
  font: 500 11.5px/16px var(--font-sans);
  color: var(--ink-3);
  text-align: center;
  text-decoration: none;
  transition: color 0.18s linear, background-color 0.18s linear;
}
.ws-madeby:hover {
  color: var(--ink-2);
  background: var(--hair);
}
.ws-madeby:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.ws-madeby__heart {
  width: 13px;
  height: 13px;
}
.ws-madeby__flag {
  flex: none;
  border-radius: 2px;
  box-shadow: 0 0 0 0.5px var(--hair-3);
}
html.a11y-focusmode .ws-madeby__heart {
  filter: grayscale(1);
}

/* ── AI text formatting (public/static/md.js): `code` pills, nested lists, paragraphs in AI output.
   Colours come from currentColor, so they follow dark mode, the a11y contrast profiles and the flashcard's coloured back. */
.md-code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  font-weight: 450;
  padding: 0.06em 0.3em;
  border-radius: 6px;
  background: rgba(11, 13, 18, 0.06);
  background: color-mix(in srgb, currentColor 9%, transparent);
  color: inherit;
  overflow-wrap: anywhere;
  word-break: normal;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.md-pre {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(11, 13, 18, 0.05);
  background: color-mix(in srgb, currentColor 7%, transparent);
  font: 400 0.86em/1.55 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: start;
}
.md-pre code {
  font: inherit;
}
/* list items with formatting: one flex child, so <strong>/<code> stay inline next to the bullet */
.li-body,
.md-lb {
  flex: 1;
  min-width: 0;
}
.md-p + .md-p,
.li-body > .md-p,
.md-lb > .md-p {
  margin-top: 6px;
}
.md-h {
  color: var(--ink);
}
/* nested list inside a brief / report bullet: indented, tighter, hollow lighter bullet */
:is(.brief-body, .rp-body) .md-ul {
  margin-top: 7px;
  gap: 6px;
  padding-left: 2px;
}
:is(.brief-body, .rp-body) .md-ul > li::before {
  background: transparent;
  box-shadow: inset 0 0 0 1.25px var(--ink-4);
  width: 5px;
  height: 5px;
  margin-top: 9px;
}
.md-ol {
  counter-reset: md-ol;
}
.md-ol > li {
  counter-increment: md-ol;
}
:is(.brief-body, .rp-body) .md-ol > li::before {
  content: counter(md-ol) '.';
  box-shadow: none;
  width: auto;
  height: auto;
  margin-top: 0;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
/* chat replies: ordinary lists */
.ch-msg--ai .md-ul {
  margin: 6px 0 0;
  padding-left: 1.3em;
  list-style: disc;
}
.ch-msg--ai .md-ol {
  list-style: decimal;
}
.ch-msg--ai .md-ul .md-ul {
  list-style: circle;
}
.ch-msg--ai li + li {
  margin-top: 3px;
}
.ch-msg--ai li::marker {
  color: var(--ink-4);
}
.ch-msg--ai :is(.md-ul, .md-pre) + .md-p {
  margin-top: 10px;
}
/* span-only output (inside <p>, <button>, <h3>): flashcards, quiz, the brief summary */
span.md-p,
span.md-ul,
span.md-li,
span.md-pre {
  display: block;
}
span.md-ul {
  margin-top: 0.35em;
  text-align: start;
}
span.md-li {
  position: relative;
  padding-left: 1em;
}
span.md-li + span.md-li {
  margin-top: 0.2em;
}
span.md-li::before {
  content: '';
  position: absolute;
  left: 0.15em;
  top: 0.62em;
  width: 0.3em;
  height: 0.3em;
  border-radius: 99px;
  background: currentColor;
  opacity: 0.45;
}
span.md-li span.md-li::before {
  background: transparent;
  box-shadow: inset 0 0 0 1px currentColor;
}
/* a list on a centred flashcard: the block stays centred, its lines read left to right */
.fc-face span.md-ul {
  display: table;
  margin: 0.45em auto 0;
}
/* phones: the top bar + Sources|Learn bar stack to 109px, 1px more than the page's scroll-padding (108px), so a
   contents-chip jump left the section heading tucked under the blurred bar. Land it with some air instead. */
.ws[data-layout='phone'] :is(.brief-body > section, .rp-body > section) {
  scroll-margin-top: 14px;
}
/* text that follows a list or code block inside one AI string */
:is(.md-ul, .md-pre) + .md-p {
  margin-top: 10px;
}
