/* Chart container */
.chart {
  width: 80%;
  height: calc(80% * 0.75);
  resize: both;
  margin: 10px auto;
}

/* Inline math variable highlight (works in viewer too) */
.math-var {
  cursor: pointer;
  /* visually neutral by default (no "link" feel); only show affordance on hover */
  border-bottom: none;
}
.math-var:hover {
  background: rgba(0, 120, 255, 0.08);
  color: #0b66c3;
  border-bottom: 1px dotted rgba(0, 120, 255, 0.6);
}

/* Chart title */
.chart h3 {
  text-align: center;
  margin: 10px 0;
  outline: none;
}

/* Map container */
.map-container {
  width: 100%;
  height: 60vh;
  min-height: 360px;
  /* Keep vertical breathing room without overflowing horizontally:
     width:100% + left/right margins will exceed the parent width and "stick out" to the right. */
  margin: 10px 0;
  padding: 10px;
  border: 1px solid lightblue;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  position: relative; /* allow overlay controls (swiper buttons/pagination) */
}

/* Swiper nav buttons (map slider mode)
   Keep Swiper's built-in arrow icons (via ::after), just restyle the button chrome. */
.map-container .swiper-button-prev,
.map-container .swiper-button-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: transparent;
  border: 0;
  color: rgba(0, 0, 0, 0.65);
  line-height: 1;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}
.map-container .swiper-button-prev { left: 8px; }
.map-container .swiper-button-next { right: 8px; }
.map-container .swiper-button-prev:hover,
.map-container .swiper-button-next:hover {
  background: rgba(255, 255, 255, 0.6);
  color: rgba(0, 0, 0, 0.85);
}

/* Map title */
.map-title {
  flex: 0 0 auto;
  height: auto;
  text-align: center;
  margin: 0;
  padding: 5px 0;
}

/* Map element */
.map-element {
  flex: 1 1 auto;
  width: 100%;
  min-height: 260px;
  margin: 0 auto;
}

/* -----------------------------------------------------------------------------
 * Rich embeds (pasted content)
 * ---------------------------------------------------------------------------*/
.embed-youtube {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 10px 0;
  padding-top: 56.25%; /* 16:9 */
}
.embed-youtube__iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Article / post link cards (LinkedIn, Medium, Substack, etc.) */
.embed-article {
  display: block;
  width: 100%;
  max-width: 900px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.12);
  border-left-width: 4px;
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
}
.embed-article a {
  color: inherit;
  text-decoration: none;
}
.embed-article a:hover .embed-article__title {
  text-decoration: underline;
}
.embed-article__kicker {
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.embed-article__title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.25;
}
.embed-article__url {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.embed-article--linkedin { border-left-color: #0a66c2; }
.embed-article--medium   { border-left-color: #111111; }
.embed-article--substack { border-left-color: #ff6719; }

/* Swiper sizing inside map container (slider mode) */
.map-swiper {
  flex: 1 1 auto;
  width: 100%;
  min-height: 260px;
}
.map-swiper .swiper-wrapper {
  width: 100%;
  height: 100%;
}
.map-swiper .swiper-slide {
  width: 100%;
  height: 100%;
}

/* Map list container */
.map-list-container {
  display: flex;
  flex-wrap: wrap;
  width: 50%;
  padding: 10px;
  margin: 10px auto;
}

/* Map list item */
.map-list-item {
  width: 100%;
  height: 50vh;
  padding: 10px;
  border: 1px solid lightblue;
  border-radius: 5px;
  margin: 0 auto 20px auto;
}

/* Legend popup */
#legend-popup {
  position: absolute;
  background-color: white;
  border: 1px solid black;
  padding: 5px;
  z-index: 10000;
}

/* Analysis item */
.analysis-item {
  margin-bottom: 20px;
}

/* Source note (under charts) — not doc-body paragraphs; avoid #doc-body p margins */
.source-note {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.35em;
  margin-top: 10px;
  font-size: 0.8em;
  line-height: 1.4;
  color: #666;
}

.source-note__label,
.source-note__name,
.source-note p,
.source-note a,
.source-note span {
  margin: 0;
  padding: 0;
  font-size: inherit;
  line-height: inherit;
}

#doc-body .source-note p,
.doc-body .source-note p,
#feed-doc-overlay-body .source-note p {
  margin: 0;
}

.source-note a {
  color: #0b66c3;
  text-decoration: underline;
}

/* Analysis text sections */
.analysis-text {
  text-align: left;
  margin-bottom: 10px;
  font-size: 14px;
}

.analysis-title {
  text-align: center;
  margin-bottom: 10px;
  font-size: 14px;
}

/* Canvas sizing */
canvas {
  resize: both;
  width: 100%;
  height: 300px;
}




/* ----------------------------
   Shared document reading surface (feed overlay, /docs/ view, editor body)
   Typography and layout only — no editor chrome (dashed frames).
---------------------------- */
.doc-body,
#doc-body,
#feed-doc-overlay-body {
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: #2f3347;
  overflow-wrap: anywhere;
  word-break: break-word;
  box-sizing: border-box;
  outline: none;
  border: none;
  background: transparent;
}

.doc-body p,
#doc-body p,
#feed-doc-overlay-body p {
  margin: 0 0 0.85em 0;
}

.doc-body p:last-child,
#doc-body p:last-child,
#feed-doc-overlay-body p:last-child {
  margin-bottom: 0;
}

body.dark-mode .doc-body,
body.dark-mode #doc-body,
body.dark-mode #feed-doc-overlay-body,
html.dark-mode .doc-body,
html.dark-mode #doc-body,
html.dark-mode #feed-doc-overlay-body {
  color: #eaeaf2;
}

/* View mode in main shell: no title/body editor frames */
#doc-page.doc-shell--view #doctitle,
#doc-page.doc-shell--view #docsubtitle,
#doc-page.doc-shell--view #doc-body {
  border: none !important;
  box-shadow: none;
}

#doc-page.doc-shell--view #doc-body {
  /* Do not use min-height: 0 here — #doc-page is a flex column (main.css) and that
     lets the body shrink so the grade footer overlaps article text. */
  flex: 0 0 auto;
  min-height: auto;
  padding: 10px;
  padding-top: 0;
}

#doc-page.doc-shell--view #doctitle:focus,
#doc-page.doc-shell--view #docsubtitle:focus,
#doc-page.doc-shell--view #doc-body:focus {
  border: none !important;
  outline: none;
  box-shadow: none;
}

#doc-page.doc-shell--edit .doc-public-only {
  display: none !important;
}

/* Public /docs/ reader chrome — desktop signature + footer */
#doc-page.doc-shell--view #doctitle {
  margin-bottom: 4px;
}

#doc-page.doc-shell--view .doc-public-profile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin: 0 0 10px;
  /* Match #doc-body horizontal inset (10px) so signature text aligns with article */
  padding: 7px 10px;
  box-sizing: border-box;
  background-color: #ecf2f4;
  border-radius: 5px;
}

#doc-page.doc-shell--view .doc-public-stamp {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-width: 0;
  font-size: small;
  font-weight: bold;
  color: rgb(78, 78, 78);
  gap: 0;
}

#doc-page.doc-shell--view .doc-public-stamp-row {
  display: contents;
}

#doc-page.doc-shell--view .doc-public-by {
  margin-right: 4px;
}

#doc-page.doc-shell--view .doc-public-stamp a {
  color: inherit;
  margin-right: 0;
}

#doc-page.doc-shell--view .doc-public-stamp-sep {
  margin-right: 4px;
}

#doc-page.doc-shell--view .doc-public-date {
  font-weight: normal;
  color: rgb(120, 120, 120);
  margin-right: 10px;
}

#doc-page.doc-shell--view .doc-public-stamp .doc-views,
#doc-page.doc-shell--view .doc-public-stamp .doc-geotag {
  margin-left: 10px;
  font-size: 0.9em;
  font-weight: normal;
  color: #666;
}

#doc-page.doc-shell--view .doc-public-stamp .doc-views:first-child,
#doc-page.doc-shell--view .doc-public-stamp .doc-geotag:first-child {
  margin-left: 0;
}

#doc-page.doc-shell--view .doc-public-share--desktop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-shrink: 0;
  margin-left: 10px;
}

#doc-page.doc-shell--view .doc-public-share--desktop .share-icon {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

#doc-page.doc-shell--view .doc-public-share--phone {
  display: none !important;
}

.doc-public-hr {
  border: none;
  border-top: 1px solid #ccc;
  margin: 16px 0;
}

/* Public footer: normal flow below #doc-body (not pinned over the article) */
#doc-page.doc-shell--view .doc-public-footer {
  flex: 0 0 auto;
  width: 100%;
  position: static;
}

/* Grade buttons (comments + doc footer) — main.html loads this sheet, not reader.html inline CSS */
.grade-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.grade-bar > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  height: 35px;
}

.grade-bar button {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 25px;
  width: auto;
}

.grade-bar button img,
.comment-action button img {
  width: 20px;
  height: 20px;
  max-width: 20px;
  max-height: 20px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.grade-bar .grade-score {
  font-size: 9px;
  line-height: 1;
  color: #666;
  min-height: 10px;
}

#doc-grade-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 15px;
  width: 100%;
  margin: 8px 0 16px;
  flex: 0 0 auto;
  position: static;
  clear: both;
}

#doc-grade-bar .grade-bar {
  border-left: none;
  padding-left: 0;
  margin-top: 10px;
}

#doc-grade-bar .grade-bar > div {
  height: 45px;
}

#doc-grade-bar .grade-bar button {
  height: 30px;
  padding: 4px;
}

#doc-grade-bar .grade-bar button img {
  width: 26px;
  height: 26px;
  max-width: 26px;
  max-height: 26px;
}

#doc-grade-bar .grade-bar .grade-score {
  font-size: 0.85em;
  color: #666;
}

#comments-section {
  margin-top: 8px;
  margin-bottom: 24px;
}

#comments-section h3 {
  margin: 0 0 12px;
  font-size: 1.1em;
}

#comment-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

#comment-text {
  flex: 1;
  min-height: 2.5em;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  font-family: inherit;
  font-size: 14px;
}

#post-comment {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid #cfd6ea;
  border-radius: 6px;
  background: #fff;
  color: #3a4db3;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 16px/1 Arial, sans-serif;
  padding: 0;
  box-sizing: border-box;
}

#post-comment:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

body.dark-mode #post-comment,
html.dark-mode #post-comment {
  background: #2a2a2a !important;
  border-color: #5a5a5a !important;
  color: #8ab4f8 !important;
}

#comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Comment cards (reader.html inline styles are not loaded on main.html) */
.comment-div {
  position: relative;
  background-color: #fff;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 0;
}

.comment-div.reply {
  background-color: #fafafa;
}

.comment-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.75em;
}

.comment-action {
  display: flex;
  align-items: center;
  gap: 4px;
}

.comment-action button {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  height: 35px;
  width: auto;
}

.comment-author {
  font-size: 0.85em;
  font-weight: bold;
  color: #555;
  margin-bottom: 4px;
}

.comment-date {
  font-size: 0.7em;
  color: #999;
  margin-left: 8px;
}

.comment-text {
  font-size: 0.8em;
  color: #333;
  line-height: 1.4;
}

.owner-controls {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

body.dark-mode .comment-div,
html.dark-mode .comment-div {
  background-color: #2a2a2a !important;
  border-color: #5a5a5a !important;
}

body.dark-mode .comment-div.reply,
html.dark-mode .comment-div.reply {
  background-color: #242424 !important;
}

body.dark-mode .comment-author,
html.dark-mode .comment-author {
  color: #d0d0d8 !important;
}

body.dark-mode .comment-text,
html.dark-mode .comment-text {
  color: #e8e8e8 !important;
}

body.dark-mode #doc-page.doc-shell--view .doc-public-profile,
html.dark-mode #doc-page.doc-shell--view .doc-public-profile {
  background-color: #2a3238 !important;
}

body.dark-mode #doc-page.doc-shell--view .doc-public-stamp,
html.dark-mode #doc-page.doc-shell--view .doc-public-stamp {
  color: #d0d0d8 !important;
}

body.dark-mode #doc-page.doc-shell--view .doc-public-date,
html.dark-mode #doc-page.doc-shell--view .doc-public-date {
  color: #a8a8b8 !important;
}

body.dark-mode #doc-page.doc-shell--view .doc-public-stamp .doc-views,
body.dark-mode #doc-page.doc-shell--view .doc-public-stamp .doc-geotag,
html.dark-mode #doc-page.doc-shell--view .doc-public-stamp .doc-views,
html.dark-mode #doc-page.doc-shell--view .doc-public-stamp .doc-geotag {
  color: #a8a8b8 !important;
}

body.dark-mode .doc-public-hr,
html.dark-mode .doc-public-hr {
  border-top-color: #5a5a5a !important;
}

body.dark-mode #comment-text,
html.dark-mode #comment-text {
  background: #2a2a2a !important;
  color: #fff !important;
  border-color: #5a5a5a !important;
}

body.dark-mode .grade-bar .grade-score,
html.dark-mode .grade-bar .grade-score,
body.dark-mode #doc-grade-bar .grade-bar .grade-score,
html.dark-mode #doc-grade-bar .grade-bar .grade-score {
  color: #a8a8b8 !important;
}

body.dark-mode .grade-bar button:hover,
html.dark-mode .grade-bar button:hover {
  background-color: #333 !important;
}

/* Prevent stray list markers inside editable doc body */
.doc-body ul,
.doc-body li {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-body li::marker {
  content: none;
}

