/* App windows: small live views into Aquinas on the internal pages (js/app-windows.js).
   Same frame as the home page's Insight Tree card; the pieces inside use the app's own
   components and sizes (DockedInsightCards: 24–32 padding, 28–36 radius; dock pill 64 tall). */

.window {
  position: relative;
  width: 100%;
  height: 520px;
  overflow: hidden;
  background: var(--app-canvas);
  border: 2px solid var(--border);
  border-radius: 28px;
  font-family: var(--sans);
  color: var(--brown);
  user-select: none;
  -webkit-user-select: none;
}
.window * { margin: 0; }
.window button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.window [hidden] { display: none !important; }
.window--canvas {
  background-image: radial-gradient(rgba(74, 50, 28, 0.13) 1px, transparent 1.3px);
  background-size: 16px 16px;
}
.row__visual--stack { flex-direction: column; align-items: stretch; gap: 14px; }
.window-hint { font-size: 14px; color: var(--paragraph-dim); text-align: center; }
.window-hint button { margin-left: 6px; font: 700 14px var(--sans); color: var(--light-green); background: none; border: 0; cursor: pointer; }

/* ---------- Shared app components ---------- */

.w-dock {
  position: absolute;
  left: 50%;
  bottom: 20px;
  translate: -50% 0;
  z-index: 20;
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 22px;
  border-radius: 48px;
  background: var(--app-surface);
  border: 1px solid rgba(34, 15, 1, 0.1);
  box-shadow: 0 0 36px 12px rgba(243, 238, 226, 0.9), 0 10px 30px -12px rgba(34, 15, 1, 0.3);
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  color: var(--heading);
}
.w-dock__group { display: flex; align-items: center; gap: 22px; }
.w-dock__action { display: flex; align-items: center; gap: 8px; color: var(--paragraph); }
.window .w-dock__action:hover { color: var(--light-green); }
.w-dock img { width: 14px; height: 14px; }
.w-dock .w-spin { animation: spin 1.2s linear infinite; }
.w-thinking {
  background: linear-gradient(90deg, var(--light-green) 30%, #CFC690 50%, var(--light-green) 70%) 0 0 / 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: w-shimmer 1.4s linear infinite;
}
@keyframes w-shimmer { to { background-position: -200% 0; } }
.window .w-button {
  height: 44px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 40px;
  font-weight: 700;
  font-size: 14px;
  color: var(--paragraph);
}
.window .w-button--primary { background: var(--light-green); color: var(--cream); }
.w-dock--split { gap: 6px; padding: 0 10px; }

/* Docked card: sits above the dock, like the app's Insight card. */
.w-card {
  position: absolute;
  left: 50%;
  bottom: 96px;
  z-index: 15;
  width: min(460px, calc(100% - 40px));
  translate: -50% 0;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--app-surface);
  border: 1px solid rgba(34, 15, 1, 0.1);
  border-radius: 28px;
  box-shadow: 0 0 44px 16px rgba(243, 238, 226, 0.95), 0 20px 40px -20px rgba(34, 15, 1, 0.35);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s;
}
.w-card.is-closed { opacity: 0; transform: translateY(24px); pointer-events: none; }
.w-card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.w-card__title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; line-height: 1.4; color: var(--light-green); }
.w-card__title img { width: 14px; height: 14px; }
.w-card__heading { font-weight: 700; font-size: 18px; color: var(--heading); }
.w-card__context { font-weight: 700; font-size: 12px; color: var(--paragraph-dim); }
.w-card__body { font-size: 14px; line-height: 1.85; color: var(--paragraph); min-height: 52px; }
.w-card__body.is-loading {
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(74, 50, 28, 0.05) 25%, rgba(74, 50, 28, 0.13) 50%, rgba(74, 50, 28, 0.05) 75%) 0 0 / 200% 100%;
  animation: w-shimmer 1.1s linear infinite;
}
.w-save img { width: 64px; height: 16px; filter: grayscale(1) opacity(0.55); transition: filter 0.2s; }
.w-save[aria-pressed="true"] img { filter: none; }

/* Canvas chips (Insights) and Node Concepts */
.w-chip {
  position: absolute;
  z-index: 5;
  translate: -50% -50%;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 12px;
  background: var(--app-canvas);
  box-shadow: 0 0 24px 12px var(--app-canvas);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  color: var(--light-green);
  transition: left 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), top 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s, filter 0.4s;
}
.w-chip img { width: 14px; height: 14px; }
.w-chip.is-selected { box-shadow: 0 0 0 1.5px rgba(134, 128, 62, 0.45), 0 0 24px 12px var(--app-canvas); }
.w-chip.is-hidden { opacity: 0; filter: blur(8px); }
.w-node {
  position: absolute;
  z-index: 6;
  translate: -50% -50%;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-radius: 16px;
  background: var(--app-canvas);
  box-shadow: 0 0 36px 18px var(--app-canvas);
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  color: var(--brown);
  transition: opacity 0.4s, filter 0.4s, transform 0.4s;
}
.w-node img { width: 28px; height: 28px; }
.w-lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; overflow: visible; }
.w-lines line { stroke: rgba(74, 50, 28, 0.22); stroke-width: 1.2; stroke-linecap: round; }
.w-lines line.is-hidden { opacity: 0; }
.w-lines line.is-dashed { stroke-dasharray: 4 5; }
.w-lines line.is-strong { stroke: rgba(134, 128, 62, 0.65); stroke-width: 2; }
.w-top {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 20;
  padding: 9px 16px;
  border-radius: 48px;
  background: var(--app-surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  color: var(--paragraph);
}

/* ---------- Conversation ---------- */

.w-read {
  position: absolute;
  inset: 0;
  padding: 30px 48px 0;
  text-align: center;
}
.w-read__eyebrow { font-weight: 700; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--light-green); }
.w-read__title { margin-top: 6px !important; font-family: var(--serif); font-weight: 400; font-size: 28px; line-height: 1.3; color: var(--heading); }
.w-read__question { margin-top: 10px !important; font-weight: 500; font-size: 15px; line-height: 1.5; color: var(--brown); }
.w-read__rule { width: 72px; margin: 16px auto 0 !important; border: 0; border-top: 1px solid rgba(34, 15, 1, 0.14); }
.w-read__thinking { margin-top: 14px !important; font-weight: 700; font-size: 14px; color: var(--brown); }
.w-read__thinking span { margin-left: 6px; }
.w-read__answer {
  max-width: 460px;
  margin: 12px auto 0 !important;
  font-size: 15px;
  line-height: 1.75;
  text-align: justify;
  hyphens: auto;
  color: var(--paragraph);
  -webkit-mask-image: linear-gradient(#000 50%, transparent 92%);
  mask-image: linear-gradient(#000 50%, transparent 92%);
}
.window .w-term {
  font-weight: 700;
  color: var(--light-green);
  border-bottom: 2px solid rgba(134, 128, 62, 0.55);
  line-height: 1.2;
  border-radius: 3px;
  transition: background 0.2s;
}
.window .w-term.is-active { background: rgba(134, 128, 62, 0.14); }
.window .w-cite {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 10px;
  border-radius: 20px;
  background: rgba(134, 128, 62, 0.12);
  font-weight: 700;
  font-size: 12px;
  line-height: 1.8;
  color: var(--light-green);
  vertical-align: 1px;
}
.window .w-cite.is-active { background: var(--light-green); color: var(--cream); }

/* Passage reader card (Model Details) */
.w-card--reader { gap: 8px; }
.w-card--reader blockquote { font-family: var(--serif); font-style: italic; font-size: 17px; line-height: 1.55; color: var(--heading); }
.w-card__ref { font-weight: 700; font-size: 13px; color: var(--heading); }

/* ---------- Branches ---------- */

.w-branches { position: absolute; inset: 0; display: flex; transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1); }
.w-branches.is-branch { transform: translateX(-100%); }
.w-branch { flex: 0 0 100%; position: relative; padding: 40px 48px 0; text-align: center; }
.w-branch__bar { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 18px !important; }
.w-branch__bar i { width: 7px; height: 7px; border-radius: 50%; background: rgba(74, 50, 28, 0.2); }
.w-branch__bar i.is-on { width: 18px; border-radius: 4px; background: var(--light-green); }
.w-quote {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px !important;
  padding: 10px 16px;
  border-radius: 14px;
  background: rgba(134, 128, 62, 0.1);
  font-weight: 700;
  font-size: 14px;
  color: var(--light-green);
}
.w-quote img { width: 14px; height: 14px; }
.window .w-back { position: absolute; top: 22px; left: 22px; padding: 9px 16px; border-radius: 48px; border: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--paragraph); }

/* ---------- Insight Library ---------- */

.w-lib { position: absolute; inset: 0; padding: 36px 40px 0; }
.w-lib__title { font-family: var(--serif); font-weight: 400; font-size: 32px; color: var(--heading); }
.w-lib__title em { font-style: italic; }
.w-lib__sub { margin-top: 6px !important; font-size: 14px; color: var(--paragraph); }
.w-list { margin-top: 18px !important; display: flex; flex-wrap: wrap; gap: 8px; }
.w-branch .w-read__answer { -webkit-mask-image: none; mask-image: none; }
.window .w-list__item {
  width: auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 16px;
  background: var(--canvas);
  font-weight: 700;
  font-size: 15px;
  text-align: left;
  color: var(--light-green);
  transition: background 0.2s, outline-color 0.2s;
  outline: 2px solid transparent;
}
.window .w-list__item.is-active { outline-color: rgba(134, 128, 62, 0.5); }
.w-list__item img { width: 14px; height: 14px; }
.w-list__item small { margin-left: 4px; font-weight: 600; font-size: 12px; color: var(--paragraph-dim); }
.window[data-window="library-insights"] .w-card { bottom: 24px; }
.w-contexts { display: flex; flex-direction: column; gap: 12px; }
.w-contexts > div { padding-left: 14px; border-left: 2px solid rgba(134, 128, 62, 0.35); }

/* ---------- Home ---------- */

.w-home { position: absolute; inset: 0; padding: 40px 44px 0; }
.w-home__card { transition: opacity 0.35s, transform 0.35s; }
.w-home__card.is-out { opacity: 0; transform: translateY(10px); }
.w-home__eyebrow { font-weight: 700; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--light-green); }
.w-home__title { margin-top: 10px !important; font-family: var(--serif); font-weight: 400; font-size: 38px; line-height: 1.2; color: var(--heading); }
.w-home__title--quote { font-style: italic; font-size: 28px; line-height: 1.4; }
.w-home__body { margin-top: 14px !important; max-width: 460px; font-size: 15px; line-height: 1.8; color: var(--paragraph); }
.w-home__action {
  margin-top: 20px !important;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 22px;
  border-radius: 48px;
  background: var(--light-green);
  font-weight: 700;
  font-size: 15px;
  color: var(--cream);
}
.w-pager { position: absolute; left: 44px; bottom: 112px; display: flex; gap: 8px; z-index: 20; }
.window .w-pager button { width: 8px; height: 8px; border-radius: 4px; background: rgba(74, 50, 28, 0.2); transition: width 0.3s, background 0.3s; }
.window .w-pager button.is-on { width: 22px; background: var(--light-green); }

/* ---------- Model tasks ---------- */

.w-tasks {
  position: absolute;
  left: 50%;
  bottom: 96px;
  width: min(345px, calc(100% - 40px));
  translate: -50% 0;
  padding: 22px 24px;
  border-radius: 28px;
  background: var(--app-surface);
  border: 1px solid rgba(34, 15, 1, 0.1);
  box-shadow: 0 20px 40px -20px rgba(34, 15, 1, 0.35);
}
.w-tasks__head { font-weight: 700; font-size: 16px; color: var(--heading); margin-bottom: 8px !important; }
.w-task {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  color: var(--heading);
  transition: opacity 0.3s;
}
.w-task:last-child { border-bottom: 0; }
.w-task__state { width: 16px; height: 16px; flex-shrink: 0; border-radius: 50%; border: 2px dotted rgba(74, 50, 28, 0.35); }
.w-task.is-done { color: var(--paragraph-dim); }
.w-task.is-done .w-task__state { border: 0; background: var(--light-green) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 8.2l2.3 2.3 4.7-5' fill='none' stroke='%23FFFAF0' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat; }
.w-task.is-active { color: var(--light-green); }
.w-task.is-active .w-task__state { border: 2px solid rgba(134, 128, 62, 0.25); border-top-color: var(--light-green); animation: spin 0.9s linear infinite; }
.window .w-task__remove { margin-left: auto; width: 26px; height: 26px; border-radius: 50%; font-size: 16px; color: var(--paragraph-dim); }
.window .w-task__remove:hover { background: var(--canvas); color: var(--accent-red, #AF4949); }

/* ---------- Library ---------- */

.w-search {
  margin-top: 18px !important;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  height: 52px;
  border-radius: 16px;
  border: 1px solid rgba(34, 15, 1, 0.14);
  background: var(--canvas);
}
.w-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: 400 15px var(--sans); color: var(--ink); outline: none; }
.w-search span { font-size: 15px; color: var(--light-green); }
.w-passage { margin-top: 16px !important; padding: 22px 24px; border-radius: 24px; border: 1px solid rgba(34, 15, 1, 0.08); display: flex; flex-direction: column; gap: 10px; }
.w-passage blockquote { font-family: var(--serif); font-style: italic; font-size: 18px; line-height: 1.5; color: var(--heading); }
.w-passage p { font-weight: 700; font-size: 13px; color: var(--heading); }
.w-results { margin-top: 12px !important; display: flex; flex-direction: column; max-height: 300px; overflow: auto; }
.w-result { padding: 12px 4px; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); font-size: 15px; color: var(--heading); }
.w-result small { font-weight: 700; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--light-green); white-space: nowrap; }
.w-empty { padding: 20px 4px; font-size: 14px; color: var(--paragraph-dim); }

/* ---------- Make Node ---------- */

.w-rise { animation: w-rise 0.55s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes w-rise { from { opacity: 0; filter: blur(8px); translate: -50% -10%; } }
.w-flash { animation: w-flash 0.7s ease-in-out infinite; }
@keyframes w-flash { 50% { opacity: 0.35; } }

@media (max-width: 560px) {
  .window { height: 460px; }
  .w-chip { padding: 9px 11px; gap: 6px; font-size: 12.5px; }
  .w-node { font-size: 15px; }
  .w-read, .w-branch { padding: 32px 22px 0; }
  .w-read__title { font-size: 26px; }
  .w-lib, .w-home { padding: 30px 22px 0; }
  .w-home__title { font-size: 30px; }
  .w-pager { left: 22px; }
  .w-dock { padding: 0 20px; gap: 14px; font-size: 14px; }
  .w-dock__group { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .w-dock .w-spin, .w-thinking, .w-card__body.is-loading, .w-task.is-active .w-task__state, .w-flash { animation: none; }
  .w-card, .w-branches, .w-chip, .w-home__card { transition: none; }
  .w-rise { animation: none; }
}
